diff --git a/common/pom.xml b/common/pom.xml index 05e0527..38add34 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -17,6 +17,15 @@ + + cn.bunny + dao + 0.0.1-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-web + com.fasterxml.jackson.datatype jackson-datatype-jsr310 @@ -30,12 +39,7 @@ cn.hutool hutool-all - - - com.alibaba.fastjson2 - fastjson2 - - + mysql mysql-connector-java diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml index 6cf708f..23a0cf0 100644 --- a/common/service-utils/pom.xml +++ b/common/service-utils/pom.xml @@ -17,15 +17,6 @@ - - cn.bunny - dao - 0.0.1-SNAPSHOT - - - org.springframework.boot - spring-boot-starter-web - javax.xml.bind diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java index 6eff47b..8792352 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/Knife4jConfig.java @@ -20,7 +20,7 @@ public class Knife4jConfig { // 使用协议 License license = new License().name("MIT").url("http://MUT.com"); // 相关信息 - Info info = new Info().title("Bunny-Java-Template").description("Bunny的Java模板").version("v1.0.0").contact(contact).license(license).termsOfService("记得给我start"); + Info info = new Info().title("Bunny-Java-Template").description("Bunny的Java模板").version("v1.0.0").contact(contact).license(license).termsOfService("维护不易~求个start"); return new OpenAPI().info(info).externalDocs(new ExternalDocumentation()); } diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java index abfaafc..160e058 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java @@ -30,9 +30,11 @@ public class WebMvcConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); + // log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); - String[] excludeList = {"/api/checkCode", "/api/sendEmailCode", "/api/register", "/api/login",}; + // TODO Spring Security 和这个拦截器任选一个 + String[] excludeList = {"/", "/test/**", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", + "/swagger-resources/**", "/swagger-ui.html/**", "/admin/login", "/v3/**", "/api/**"}; registry.addInterceptor(userTokenInterceptor).excludePathPatterns(excludeList); // TODO 如果想使用普通JWT可以使用这个,不使用 SpringSecurity6 diff --git a/dao/pom.xml b/dao/pom.xml index dfcd89a..a5efe1d 100644 --- a/dao/pom.xml +++ b/dao/pom.xml @@ -33,6 +33,11 @@ com.github.xiaoymin knife4j-openapi3-jakarta-spring-boot-starter + + + com.alibaba.fastjson2 + fastjson2 + io.swagger diff --git a/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java b/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java index 1dfde60..29a8c62 100644 --- a/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java +++ b/module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java @@ -88,8 +88,8 @@ public class WebSecurityConfig { // 排出鉴定路径 @Bean public WebSecurityCustomizer webSecurityCustomizer() { - String[] annotations = {"/", "/test/**", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/swagger-ui.html/**", - "/api/**" + String[] annotations = {"/", "/test/**", "/admin/login", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", + "/swagger-resources/**", "/swagger-ui.html/**", "/v3/**", "/api/**" }; return web -> web.ignoring().requestMatchers(annotations); } diff --git a/service/src/main/java/cn/bunny/service/service/impl/UserServiceImpl.java b/service/src/main/java/cn/bunny/service/service/impl/UserServiceImpl.java index 84d347d..fa4b983 100644 --- a/service/src/main/java/cn/bunny/service/service/impl/UserServiceImpl.java +++ b/service/src/main/java/cn/bunny/service/service/impl/UserServiceImpl.java @@ -1,5 +1,6 @@ package cn.bunny.service.service.impl; +import cn.bunny.common.service.exception.BunnyException; import cn.bunny.common.service.utils.EmptyUtil; import cn.bunny.common.service.utils.JwtHelper; import cn.bunny.dto.user.LoginDto; @@ -23,6 +24,7 @@ import cn.hutool.captcha.CaptchaUtil; import cn.hutool.captcha.CircleCaptcha; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springdoc.core.service.OperationService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; @@ -51,6 +53,8 @@ public class UserServiceImpl extends ServiceImpl implements Us private EmailUsersMapper emailUsersMapper; @Autowired private RedisTemplate redisTemplate; + @Autowired + private OperationService operationBuilder; /** * 前台用户登录接口 @@ -68,6 +72,11 @@ public class UserServiceImpl extends ServiceImpl implements Us String password = DigestUtils.md5DigestAsHex(loginDto.getPassword().getBytes()); // 查询数据库,用户对应的角色、权限 User user = baseMapper.login(username, password); + + if (user == null) { + throw new BunnyException(ExceptionConstant.USER_NOT_FOUND_Exception); + } + Long userId = user.getId(); // 查询用户所有的角色信息 diff --git a/service/src/main/resources/application-dev.yml b/service/src/main/resources/application-dev.yml index f2147b4..bd3361d 100644 --- a/service/src/main/resources/application-dev.yml +++ b/service/src/main/resources/application-dev.yml @@ -7,9 +7,9 @@ bunny: password: "02120212" redis: - host: 1192.168.3.100 + host: 192.168.3.100 port: 6379 - database: 3 + database: 0 password: "123456" minio: diff --git a/service/src/main/resources/application-prod.yml b/service/src/main/resources/application-prod.yml index 035261d..59d1992 100644 --- a/service/src/main/resources/application-prod.yml +++ b/service/src/main/resources/application-prod.yml @@ -1,15 +1,15 @@ bunny: datasource: - host: 192.168.1.4 + host: 192.168.3.100 port: 3306 sqlData: bunny_docs username: root password: "02120212" redis: - host: 192.168.1.4 + host: 192.168.3.100 port: 6379 - database: 3 + database: 0 password: "123456" minio: diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml index 35e44de..4ef693f 100644 --- a/service/src/main/resources/application.yml +++ b/service/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 8800 + port: 8080 spring: profiles: @@ -8,28 +8,24 @@ spring: name: bunny-service datasource: - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true - username: ${bunny.datasource.username} - password: ${bunny.datasource.password} - # dynamic: - # primary: master #设置默认的数据源或者数据源组,默认值即为master - # strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 - # grace-destroy: false #是否优雅关闭数据源,默认为false,设置为true时,关闭数据源时如果数据源中还存在活跃连接,至多等待10s后强制关闭 - # datasource: - # master: - # driver-class-name: com.zaxxer.hikari.HikariDataSource - # url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true - # username: ${bunny.datasource.username} - # password: ${bunny.datasource.password} - # i18n: - # url: jdbc:mysql://${bunny.datasource2.host}:${bunny.datasource2.port}/${bunny.datasource2.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true - # username: ${bunny.datasource2.username} - # password: ${bunny.datasource2.password} - # driver-class-name: com.zaxxer.hikari.HikariDataSource - # aop: - # enabled: true + # type: com.zaxxer.hikari.HikariDataSource + # driver-class-name: com.mysql.cj.jdbc.Driver + # url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true + # username: ${bunny.datasource.username} + # password: ${bunny.datasource.password} + dynamic: + primary: master #设置默认的数据源或者数据源组,默认值即为master + strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 + grace-destroy: false #是否优雅关闭数据源,默认为false,设置为true时,关闭数据源时如果数据源中还存在活跃连接,至多等待10s后强制关闭 + datasource: + master: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true + username: ${bunny.datasource.username} + password: ${bunny.datasource.password} + aop: + enabled: true data: redis: