diff --git a/.gitignore b/.gitignore index dae2bf8..c89952b 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ MANIFEST .idea/ .DS_Store +log/ \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6b2417e..83e3924 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,29 @@ 5.8.22 + + + + dev + + + dev + debug + + + + true + + + + pro + + pro + info + + + + org.springframework.boot @@ -35,12 +58,6 @@ spring-boot-starter-web - - - - - - org.springframework.boot spring-boot-starter-data-jdbc @@ -161,21 +178,11 @@ log4j-api 2.23.1 - - io.springfox - springfox-swagger2 - 2.7.0 - - - io.springfox - springfox-swagger-ui - 2.7.0 - com.github.xiaoymin knife4j-spring-boot-starter - 2.0.8 + 3.0.3 org.springframework.boot @@ -185,6 +192,19 @@ + + + src/main/resources + true + + **/*.xml + application.yml + application-${profiles.active}.yml + *.xml + *.json + + + org.springframework.boot diff --git a/src/main/java/com/jiagutech/common/Knife4jConfig.java b/src/main/java/com/jiagutech/common/Knife4jConfig.java index f0f6341..7f0a686 100644 --- a/src/main/java/com/jiagutech/common/Knife4jConfig.java +++ b/src/main/java/com/jiagutech/common/Knife4jConfig.java @@ -11,14 +11,14 @@ import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; +import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; /** * 自定义 Knife4j 接口文档的配置 */ @Configuration -@EnableSwagger2 @EnableKnife4j +@Profile({"dev","pro"}) public class Knife4jConfig { @Bean(value = "defaultApi2") diff --git a/src/main/java/com/jiagutech/controller/UserController.java b/src/main/java/com/jiagutech/controller/UserController.java index 7b72729..5199cc4 100644 --- a/src/main/java/com/jiagutech/controller/UserController.java +++ b/src/main/java/com/jiagutech/controller/UserController.java @@ -7,6 +7,7 @@ import com.jiagutech.dto.request.LoginRequest; import com.jiagutech.dto.request.UserRequest; import com.jiagutech.dto.response.LoginResponse; import com.jiagutech.dto.response.UserItem; +import com.jiagutech.entity.UserEntity; import com.jiagutech.service.UserService; import com.jiagutech.utils.LoginUtil; import io.swagger.annotations.Api; @@ -75,4 +76,10 @@ public class UserController { public R> approvalUserList() { return R.ok(userService.approvalUserList()); } + + @ApiOperation(value = "修改用户密码/信息") + @PutMapping(value = "/update", consumes = "application/json") + public R update(@RequestBody UserEntity userEntity) { + return userService.update(userEntity) ? R.ok() : R.fail(); + } } diff --git a/src/main/java/com/jiagutech/entity/UserEntity.java b/src/main/java/com/jiagutech/entity/UserEntity.java index a910707..4e2bad4 100644 --- a/src/main/java/com/jiagutech/entity/UserEntity.java +++ b/src/main/java/com/jiagutech/entity/UserEntity.java @@ -15,14 +15,16 @@ public class UserEntity { private long id; private String phone; + private String password; + private String realName; private String unitName; private LocalDateTime createTime; - private int status; + private Integer status; private Integer role; diff --git a/src/main/java/com/jiagutech/service/UserService.java b/src/main/java/com/jiagutech/service/UserService.java index 59cc7d7..3bb42f2 100644 --- a/src/main/java/com/jiagutech/service/UserService.java +++ b/src/main/java/com/jiagutech/service/UserService.java @@ -4,6 +4,7 @@ import com.jiagutech.dto.request.LoginRequest; import com.jiagutech.dto.response.LoginResponse; import com.jiagutech.dto.response.UserItem; import com.jiagutech.dto.request.UserRequest; +import com.jiagutech.entity.UserEntity; import java.util.List; @@ -15,4 +16,6 @@ public interface UserService { void approval(Long userId); List approvalUserList(); + + Boolean update(UserEntity userEntity); } diff --git a/src/main/java/com/jiagutech/service/UserServiceImpl.java b/src/main/java/com/jiagutech/service/UserServiceImpl.java index b9a2ae3..f7e671d 100644 --- a/src/main/java/com/jiagutech/service/UserServiceImpl.java +++ b/src/main/java/com/jiagutech/service/UserServiceImpl.java @@ -3,6 +3,7 @@ package com.jiagutech.service; import cn.dev33.satoken.secure.BCrypt; import cn.dev33.satoken.stp.StpUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.jiagutech.common.UserConstants; import com.jiagutech.common.exception.BizCode; @@ -82,4 +83,17 @@ public class UserServiceImpl implements UserService { List userEntities = userMapper.selectList(wrapper); return UserMapping.INSTANCE.convertToUserItems(userEntities); } + + @Override + public Boolean update(UserEntity userEntity) { + if (userEntity != null && StringUtils.isNotBlank(userEntity.getPassword())) { + userEntity.setPassword(BCrypt.hashpw(userEntity.getPassword())); + } + int res = userMapper.updateById(userEntity); + if (res > 0) { + assert userEntity != null; + StpUtil.logout(); + } + return res > 0; + } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..c9ea209 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,18 @@ +spring: + datasource: + url: jdbc:mysql://101.34.243.138:7306/siliqua_recognition?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true + username: ams + password: ams@1234 + + + redis: + host: 192.168.10.111 + port: 6379 +email: + to: yeguangzhang@126.com + +recognition: + model: + url: http://api.camacloud.org.cn/recognition + + diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml new file mode 100644 index 0000000..1fed607 --- /dev/null +++ b/src/main/resources/application-pro.yml @@ -0,0 +1,19 @@ +spring: + datasource: + url: jdbc:mysql://192.168.1.232:3306/siliqua_recognition?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true + username: root + password: Njsszxs1! + + + redis: + host: 192.168.1.182 + port: 6379 + password: guwei2018 +email: + to: 120059323@qq.com + +recognition: + model: + url: http://localhost:9199 + + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 73e165e..afb554e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,14 +1,14 @@ server: port: 9196 spring: + profiles: + active: @profiles.active@ + application: name: siliqua_recognition datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://101.34.243.138:7306/siliqua_recognition?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true - username: ams - password: ams@1234 type: com.zaxxer.hikari.HikariDataSource hikari: maximum-pool-size: 10 @@ -18,6 +18,11 @@ spring: max-lifetime: 1800000 pool-name: siliqua-recognition + redis: + database: 8 + # host: 192.168.10.111 + # port: 6379 + jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 @@ -27,10 +32,6 @@ spring: enabled: true max-file-size: 20MB max-request-size: 500MB - redis: - host: 192.168.10.111 - port: 6379 - database: 8 mail: host: smtpdm.aliyun.com port: 465 @@ -43,8 +44,7 @@ spring: auth: true ssl: enable: true -email: - to: yeguangzhang@126.com + mybatis-plus: mapper-locations: classpath*:mapper/*.xml type-aliases-package: com.jiagutech.entity @@ -55,9 +55,6 @@ mybatis-plus: db-config: update-strategy: not_null -recognition: - model: - url: http://api.camacloud.org.cn/recognition sa-token: # token名称 (同时也是cookie名称) @@ -81,6 +78,7 @@ huawei: path-prefix: recognition + thread: enabled: true pool: @@ -100,7 +98,14 @@ http: read-timeout: 20000 logging: level: - com.jiagutech.mapper: debug + com.jiagutech.mapper: @logging.level@ root: info tmp: - path: /tmp/ \ No newline at end of file + path: /tmp/ + +knife4j: + basic: + enable: true + username: admin + password: admin123 + enable: true \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..600f48c --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + DEBUG + + + ${LOG_PATTERN} + utf8 + + + + + + + ${LOG_FILE}/${springAppName}-info.log + + true + + + ${LOG_FILE}/${springAppName}-info.%d{yyyy-MM-dd}.%i.log.gz + + 20 + + 100MB + + + ${LOG_PATTERN} + utf8 + + + + + 0 + + 256 + + + + + + + + ERROR + ACCEPT + DENY + + + ${LOG_FILE}/${springAppName}-error.log + true + + + + ${LOG_FILE}/${springAppName}-error.%d{yyyy-MM-dd}.%i.log.gz + + 20 + + 100MB + + + ${LOG_PATTERN} + utf8 + + + + + 0 + + 256 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file