commit
eeac34f266
@ -0,0 +1,2 @@ |
||||
/mvnw text eol=lf |
||||
*.cmd text eol=crlf |
@ -0,0 +1,33 @@ |
||||
HELP.md |
||||
target/ |
||||
!.mvn/wrapper/maven-wrapper.jar |
||||
!**/src/main/**/target/ |
||||
!**/src/test/**/target/ |
||||
|
||||
### STS ### |
||||
.apt_generated |
||||
.classpath |
||||
.factorypath |
||||
.project |
||||
.settings |
||||
.springBeans |
||||
.sts4-cache |
||||
|
||||
### IntelliJ IDEA ### |
||||
.idea |
||||
*.iws |
||||
*.iml |
||||
*.ipr |
||||
|
||||
### NetBeans ### |
||||
/nbproject/private/ |
||||
/nbbuild/ |
||||
/dist/ |
||||
/nbdist/ |
||||
/.nb-gradle/ |
||||
build/ |
||||
!**/src/main/**/build/ |
||||
!**/src/test/**/build/ |
||||
|
||||
### VS Code ### |
||||
.vscode/ |
@ -0,0 +1,140 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-parent</artifactId> |
||||
<version>2.1.3.RELEASE</version> |
||||
<relativePath/> <!-- lookup parent from repository --> |
||||
</parent> |
||||
<groupId>com.keyware</groupId> |
||||
<artifactId>HTEY</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<name>HTEY</name> |
||||
<description>HTEY</description> |
||||
<url/> |
||||
<licenses> |
||||
<license/> |
||||
</licenses> |
||||
<developers> |
||||
<developer/> |
||||
</developers> |
||||
<scm> |
||||
<connection/> |
||||
<developerConnection/> |
||||
<tag/> |
||||
<url/> |
||||
</scm> |
||||
<properties> |
||||
<java.version>8</java.version> |
||||
</properties> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web-services</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.session</groupId> |
||||
<artifactId>spring-session-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-devtools</artifactId> |
||||
<scope>runtime</scope> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-actuator</artifactId> |
||||
</dependency> |
||||
<!-- Mybatis-plus--> |
||||
<dependency> |
||||
<groupId>com.baomidou</groupId> |
||||
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||
<version>3.5.3.1</version> |
||||
</dependency> |
||||
<!--Swagger--> |
||||
<dependency> |
||||
<groupId>org.springdoc</groupId> |
||||
<artifactId>springdoc-openapi-ui</artifactId> |
||||
<version>1.6.14</version> |
||||
</dependency> |
||||
<!-- 神通数据库--> |
||||
<!-- <dependency> |
||||
<groupId>com.stdb</groupId> |
||||
<artifactId>oscar-jdbc</artifactId> |
||||
<version>1.0</version> |
||||
</dependency>--> |
||||
<!-- oracle数据库--> |
||||
<dependency> |
||||
<groupId>com.oracle.database.jdbc</groupId> |
||||
<artifactId>ojdbc8</artifactId> |
||||
<version>19.8.0.0</version> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<configuration> |
||||
<annotationProcessorPaths> |
||||
<path> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
</path> |
||||
</annotationProcessorPaths> |
||||
</configuration> |
||||
</plugin> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<configuration> |
||||
<excludes> |
||||
<exclude> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
</exclude> |
||||
</excludes> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
<repositories> |
||||
<repository> |
||||
<id>spring-snapshots</id> |
||||
<name>Spring Snapshots</name> |
||||
<url>https://repo.spring.io/snapshot</url> |
||||
<releases> |
||||
<enabled>false</enabled> |
||||
</releases> |
||||
</repository> |
||||
</repositories> |
||||
<pluginRepositories> |
||||
<pluginRepository> |
||||
<id>spring-snapshots</id> |
||||
<name>Spring Snapshots</name> |
||||
<url>https://repo.spring.io/snapshot</url> |
||||
<releases> |
||||
<enabled>false</enabled> |
||||
</releases> |
||||
</pluginRepository> |
||||
</pluginRepositories> |
||||
|
||||
</project> |
@ -0,0 +1,13 @@ |
||||
package com.keyware.htey; |
||||
|
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
||||
@SpringBootApplication |
||||
public class HteyApplication { |
||||
|
||||
public static void main(String[] args) { |
||||
SpringApplication.run(HteyApplication.class, args); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package com.keyware.htey.config; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType; |
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Configuration |
||||
public class MybatisPlusConfig { |
||||
|
||||
@Bean |
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() { |
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.ORACLE)); // 数据库类型
|
||||
return interceptor; |
||||
} |
||||
} |
@ -0,0 +1,97 @@ |
||||
package com.keyware.htey.controller.user; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.keyware.htey.entity.User; |
||||
import com.keyware.htey.service.itf.UserService; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 用户接口 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping("/user") |
||||
@Tag(name = "User API", description = "用户管理接口") |
||||
public class UserController { |
||||
@Autowired |
||||
private UserService userService; |
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 分页获取所有用户 |
||||
*/ |
||||
@GetMapping("/selectAll") |
||||
@ResponseBody |
||||
@Operation(summary = "分页查询用户", description = "返回查询用户信息") |
||||
@ApiResponse(responseCode = "200", description = "成功获取用户信息") |
||||
public Page<User> selectAll(@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "10") int pageSize){ |
||||
// 创建分页对象
|
||||
Page<User> pageParam = new Page<>(pageNum, pageSize); |
||||
|
||||
// 创建查询条件
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.notLike("USER_NAME","安全保密员") |
||||
.notLike("USER_NAME","系统管理员") |
||||
.notLike("USER_NAME","安全审计员") |
||||
.notLike("USER_NAME","超级管理员"); // 模糊查询
|
||||
// 执行分页查询
|
||||
return userService.page(pageParam, queryWrapper); |
||||
} |
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 根据id获取用户信息 |
||||
*/ |
||||
@GetMapping("/selectById") |
||||
@ResponseBody |
||||
@Operation(summary = "根据id查询用户", description = "返回查询用户信息") |
||||
@ApiResponse(responseCode = "200", description = "成功获取用户信息") |
||||
public User selectById(@RequestParam String id){ |
||||
return userService.getById(id); |
||||
} |
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 新增用户 |
||||
*/ |
||||
@GetMapping("/addUser") |
||||
@ResponseBody |
||||
@Operation(summary = "新增用户", description = "返回新增用户信息") |
||||
@ApiResponse(responseCode = "200", description = "成功新增用户信息") |
||||
public boolean addUser(@RequestParam User user){ |
||||
return userService.save(user); |
||||
} |
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 修改用户 |
||||
*/ |
||||
@GetMapping("/updateUser") |
||||
@ResponseBody |
||||
@Operation(summary = "修改用户", description = "返回修改用户信息") |
||||
@ApiResponse(responseCode = "200", description = "成功修改用户信息") |
||||
public boolean updateUser(@RequestParam User user){ |
||||
return userService.updateById(user); |
||||
} |
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 根据id进行删除 |
||||
*/ |
||||
@GetMapping("/deleteUser") |
||||
@ResponseBody |
||||
@Operation(summary = "根据id删除用户", description = "返回删除用户信息") |
||||
@ApiResponse(responseCode = "200", description = "成功删除用户信息") |
||||
public boolean deleteUser(@RequestParam String id){ |
||||
return userService.removeById(id); |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.keyware.htey.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
@Data |
||||
@TableName("K_USER") |
||||
public class User implements Serializable { |
||||
private String id; |
||||
private String userId; |
||||
private String userName; |
||||
private String password; |
||||
private String departId; |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.keyware.htey.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.keyware.htey.entity.User; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* @author yangmengchuan |
||||
* @date 2025/1/7 |
||||
* @description 用户与数据库交互 |
||||
*/ |
||||
@Mapper |
||||
public interface UserMapper extends BaseMapper<User> { |
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.keyware.htey.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.keyware.htey.entity.User; |
||||
import com.keyware.htey.mapper.UserMapper; |
||||
import com.keyware.htey.service.itf.UserService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service("userService") |
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{ |
||||
@Autowired |
||||
private UserMapper userMapper; |
||||
|
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.keyware.htey.service.itf; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.keyware.htey.entity.User; |
||||
|
||||
public interface UserService extends IService<User> { |
||||
} |
@ -0,0 +1,30 @@ |
||||
spring: |
||||
application: |
||||
name: HTEY |
||||
datasource: |
||||
url: jdbc:oracle:thin:@172.16.36.140:1521:orcl |
||||
username: kdhtey |
||||
password: 123456 |
||||
driver-class-name: oracle.jdbc.OracleDriver |
||||
# secondary: |
||||
# url: jdbc:oscar://172.16.36.232:2003/OSRDB |
||||
# username: tykd |
||||
# password: 123456 |
||||
# driver-class-name: com.oscar.Driver |
||||
#mybatis日志打印 |
||||
mybatis: |
||||
configuration: |
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl |
||||
#日志级别及打印 |
||||
logging: |
||||
level: |
||||
com.baomidou.mybatisplus: DEBUG |
||||
com.keyware.htey.mapper: DEBUG # 替换为您的 Mapper 接口所在的包名 |
||||
#swagger |
||||
springdoc: |
||||
swagger-ui: |
||||
path: /swagger-ui.html # Swagger UI 的访问路径 |
||||
enabled: true # 是否启用 Swagger UI |
||||
api-docs: |
||||
path: /v3/api-docs # OpenAPI JSON 的访问路径 |
||||
enabled: true # 是否启用 OpenAPI JSON |
Loading…
Reference in new issue