diff --git a/common/common-generator/pom.xml b/common/common-generator/pom.xml index c99ab7e..8a81ce5 100644 --- a/common/common-generator/pom.xml +++ b/common/common-generator/pom.xml @@ -18,31 +18,11 @@ - - org.projectlombok - lombok - javax.xml.bind jaxb-api 2.1 - - - mysql - mysql-connector-java - - - - com.zaxxer - HikariCP - 5.1.0 - - - - com.baomidou - mybatis-plus-spring-boot3-starter - com.baomidou diff --git a/common/pom.xml b/common/pom.xml index f82ae99..05e0527 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -25,5 +25,25 @@ io.jsonwebtoken jjwt + + + cn.hutool + hutool-all + + + + com.alibaba.fastjson2 + fastjson2 + + + + mysql + mysql-connector-java + + + + com.zaxxer + HikariCP + diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml index 32bafae..6cf708f 100644 --- a/common/service-utils/pom.xml +++ b/common/service-utils/pom.xml @@ -22,6 +22,10 @@ dao 0.0.1-SNAPSHOT + + org.springframework.boot + spring-boot-starter-web + javax.xml.bind @@ -34,15 +38,6 @@ httpclient 4.5.14 - - - com.github.xiaoymin - knife4j-openapi3-jakarta-spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - org.springframework.boot @@ -54,11 +49,6 @@ redisson 3.26.1 - - - com.github.pagehelper - pagehelper - org.lionsoul 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 5abefce..6eff47b 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 @@ -15,13 +15,12 @@ import org.springframework.context.annotation.Configuration; public class Knife4jConfig { @Bean public OpenAPI openAPI() { - log.info("Knife4jConfig===>配置knife4j"); // 作者等信息 Contact contact = new Contact().name("Bunny").email("1319900154@qq.com").url("http://z-bunny.com"); // 使用协议 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); + 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()); } @@ -29,18 +28,12 @@ public class Knife4jConfig { // 前台相关分类接口 @Bean public GroupedOpenApi groupedOpenApi() { - return GroupedOpenApi.builder().group("前台接口管理").pathsToMatch("/api/**").build(); + return GroupedOpenApi.builder().group("web前台接口管理").pathsToMatch("/api/**").build(); } // 管理员相关分类接口 @Bean public GroupedOpenApi groupedOpenAdminApi() { - return GroupedOpenApi.builder().group("管理员接口请求").pathsToMatch("/admin/**").build(); - } - - // 测试相关分类接口 - @Bean - public GroupedOpenApi testGroupedOpenApi() { - return GroupedOpenApi.builder().group("测试相关分类接口").pathsToMatch("/test/**").build(); + return GroupedOpenApi.builder().group("admin管理员接口请求").pathsToMatch("/admin/**").build(); } } diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java index 013c778..519a465 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; -import com.github.pagehelper.PageInterceptor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -34,9 +33,4 @@ public class MybatisPlusConfig { return interceptor; } - - @Bean// pagehelper分页插件需要配的拦截器 - public PageInterceptor pageInterceptor() { - return new PageInterceptor(); - } } 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 34dd3b5..abfaafc 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,8 +30,11 @@ public class WebMvcConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - String[] excludeList = {"/api/checkCode", "/api/sendEmailCode", "/api/register", "/api/login", "/api/article/loadArticle/**"}; log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); + + String[] excludeList = {"/api/checkCode", "/api/sendEmailCode", "/api/register", "/api/login",}; + registry.addInterceptor(userTokenInterceptor).excludePathPatterns(excludeList); + // TODO 如果想使用普通JWT可以使用这个,不使用 SpringSecurity6 // registry.addInterceptor(userTokenInterceptor).addPathPatterns("/api/**").excludePathPatterns(excludeList); } diff --git a/dao/pom.xml b/dao/pom.xml index ac62f0e..dfcd89a 100644 --- a/dao/pom.xml +++ b/dao/pom.xml @@ -23,28 +23,6 @@ org.projectlombok lombok - - - - cn.hutool - hutool-all - - - - com.alibaba.fastjson2 - fastjson2 - - - - mysql - mysql-connector-java - - - - com.zaxxer - HikariCP - 5.1.0 - com.baomidou @@ -55,21 +33,6 @@ com.github.xiaoymin knife4j-openapi3-jakarta-spring-boot-starter - - - org.springframework.boot - spring-boot-starter-security - - - - org.springframework.security - spring-security-test - - - - org.springframework.boot - spring-boot-starter-web - io.swagger diff --git a/module/pom.xml b/module/pom.xml index 4ea3077..cc81d26 100644 --- a/module/pom.xml +++ b/module/pom.xml @@ -31,5 +31,14 @@ service-utils 0.0.1-SNAPSHOT + + com.google.protobuf + protobuf-java + 4.27.2 + + + org.springframework.boot + spring-boot-starter-web + 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 5899405..1dfde60 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,9 @@ public class WebSecurityConfig { // 排出鉴定路径 @Bean public WebSecurityCustomizer webSecurityCustomizer() { - String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html", - "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"}; + String[] annotations = {"/", "/test/**", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/swagger-ui.html/**", + "/api/**" + }; return web -> web.ignoring().requestMatchers(annotations); } } diff --git a/pom.xml b/pom.xml index 1937036..db56230 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,8 @@ 6.1.0 2.2 3.1 + 5.1.0 + 4.3.1 @@ -72,6 +74,18 @@ mysql-connector-java ${mysql.version} + + + com.zaxxer + HikariCP + ${HikariCP.version} + + + + com.baomidou + dynamic-datasource-spring-boot3-starter + ${dynamic.datasource.version} + com.github.xiaoymin @@ -96,7 +110,7 @@ lombok ${lombok.version} - + cn.hutool hutool-all @@ -131,17 +145,12 @@ joda-time ${jodatime.version} - + com.fasterxml.jackson.datatype jackson-datatype-jsr310 2.12.3 - - com.github.pagehelper - pagehelper - ${pagehelper.version} - diff --git a/service/pom.xml b/service/pom.xml index f738218..60266e8 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -20,21 +20,36 @@ + + cn.bunny + service-utils + 0.0.1-SNAPSHOT + cn.bunny spring-security 0.0.1-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-test + + + + org.springframework.boot + spring-boot-starter-web + + cn.bunny module-mail 0.0.1-SNAPSHOT - - cn.bunny - module-minio - 0.0.1-SNAPSHOT - junit @@ -46,11 +61,6 @@ org.springframework.boot spring-boot-starter-test - - - org.springframework.boot - spring-boot-starter-websocket - org.aspectj @@ -60,6 +70,11 @@ org.aspectj aspectjweaver + + + com.baomidou + dynamic-datasource-spring-boot3-starter + diff --git a/service/src/main/java/cn/bunny/service/ServiceApplication.java b/service/src/main/java/cn/bunny/service/ServiceApplication.java index 559b8c6..c9022ce 100644 --- a/service/src/main/java/cn/bunny/service/ServiceApplication.java +++ b/service/src/main/java/cn/bunny/service/ServiceApplication.java @@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Slf4j public class ServiceApplication { public static void main(String[] args) { - log.info("ServiceApplication启动..."); SpringApplication.run(ServiceApplication.class, args); } } diff --git a/service/src/main/java/cn/bunny/service/controller/WebController.java b/service/src/main/java/cn/bunny/service/controller/WebController.java new file mode 100644 index 0000000..88e4fb6 --- /dev/null +++ b/service/src/main/java/cn/bunny/service/controller/WebController.java @@ -0,0 +1,31 @@ +package cn.bunny.service.controller; + +import cn.bunny.service.service.LoginService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "web相关接口") +@RestController +@RequestMapping("/api") +public class WebController { + @Autowired + private LoginService loginService; + + @Operation(summary = "生成验证码", description = "生成验证码") + @GetMapping("checkCode") + public ResponseEntity checkCode() { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.IMAGE_JPEG); + + byte[] image = loginService.checkCode(); + return new ResponseEntity(image, headers, HttpStatus.OK); + } +} diff --git a/service/src/main/java/cn/bunny/service/service/LoginService.java b/service/src/main/java/cn/bunny/service/service/LoginService.java new file mode 100644 index 0000000..6a2dd06 --- /dev/null +++ b/service/src/main/java/cn/bunny/service/service/LoginService.java @@ -0,0 +1,10 @@ +package cn.bunny.service.service; + +public interface LoginService { + /** + * * 生成验证码 + * + * @return 验证码图片数组 + */ + byte[] checkCode(); +} diff --git a/service/src/main/java/cn/bunny/service/service/impl/LoginServiceImpl.java b/service/src/main/java/cn/bunny/service/service/impl/LoginServiceImpl.java new file mode 100644 index 0000000..36023b1 --- /dev/null +++ b/service/src/main/java/cn/bunny/service/service/impl/LoginServiceImpl.java @@ -0,0 +1,21 @@ +package cn.bunny.service.service.impl; + +import cn.bunny.service.service.LoginService; +import cn.hutool.captcha.CaptchaUtil; +import cn.hutool.captcha.CircleCaptcha; +import org.springframework.stereotype.Service; + +@Service +public class LoginServiceImpl implements LoginService { + /** + * * 生成验证码 + * + * @return 验证码图片数组 + */ + @Override + public byte[] checkCode() { + // 生成验证码 + CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(150, 48, 4, 2); + return captcha.getImageBytes(); + } +} diff --git a/service/src/main/resources/application-dev.yml b/service/src/main/resources/application-dev.yml index 0eae702..f2147b4 100644 --- a/service/src/main/resources/application-dev.yml +++ b/service/src/main/resources/application-dev.yml @@ -1,19 +1,19 @@ bunny: datasource: - host: 192.168.1.4 + host: 192.168.3.100 port: 3305 sqlData: bunny_docs username: root password: "02120212" redis: - host: 192.168.1.4 + host: 1192.168.3.100 port: 6379 database: 3 password: "123456" minio: - endpointUrl: "http://192.168.1.4:9000" + endpointUrl: "http://192.168.3.100:9000" bucket-name: test accessKey: bunny secretKey: "02120212" \ No newline at end of file diff --git a/service/src/main/resources/application-prod.yml b/service/src/main/resources/application-prod.yml index de30295..035261d 100644 --- a/service/src/main/resources/application-prod.yml +++ b/service/src/main/resources/application-prod.yml @@ -13,7 +13,7 @@ bunny: password: "123456" minio: - endpointUrl: "http://192.168.1.4:9000" + endpointUrl: "http://192.168.3.100:9000" bucket-name: test accessKey: bunny secretKey: "02120212" \ No newline at end of file diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml index 60bc9fa..35e44de 100644 --- a/service/src/main/resources/application.yml +++ b/service/src/main/resources/application.yml @@ -13,6 +13,23 @@ spring: 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 data: redis: