commit 72ff5d0d8d910fc03ba578087f71828ba6f97e2b Author: Bunny <1319900154@qq.com> Date: Thu May 2 22:25:29 2024 +0800 :sparkles: init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/common/common-utils/pom.xml b/common/common-utils/pom.xml new file mode 100644 index 0000000..d8dcd25 --- /dev/null +++ b/common/common-utils/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + cn.bunny + common + 0.0.1-SNAPSHOT + + + common-utils + jar + + common-utils + https://maven.apache.org + + + UTF-8 + + + + + junit + junit + 3.8.1 + test + + + diff --git a/common/pom.xml b/common/pom.xml new file mode 100644 index 0000000..50db59f --- /dev/null +++ b/common/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + cn.bunny + java-template + 0.0.1-SNAPSHOT + + common + pom + common Maven Webapp + https://maven.apache.org + + service-utils + common-utils + spring-security + + + + + diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml new file mode 100644 index 0000000..da561e3 --- /dev/null +++ b/common/service-utils/pom.xml @@ -0,0 +1,55 @@ + + 4.0.0 + + cn.bunny + common + 0.0.1-SNAPSHOT + + + service-utils + jar + + service-utils + https://maven.apache.org + + + UTF-8 + + + + + cn.bunny + model + 0.0.1-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.redisson + redisson + 3.26.1 + + + + mysql + mysql-connector-java + + + + com.baomidou + mybatis-plus-boot-starter + provided + + + + com.zaxxer + HikariCP + 5.1.0 + + + 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 new file mode 100644 index 0000000..11a0871 --- /dev/null +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java @@ -0,0 +1,33 @@ +package cn.bunny.common.service.config; + +import com.baomidou.mybatisplus.annotation.DbType; +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 lombok.extern.slf4j.Slf4j; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@EnableTransactionManagement +@MapperScan("cn.bunny.service.mapper") +@Configuration +@Slf4j +public class MybatisPlusConfig { + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + log.info("注入Mybatis-Plus配置..."); + + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 分页插件 + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + // 乐观锁 + interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); + // 防止全表删除 + interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); + + return interceptor; + } +} diff --git a/common/spring-security/pom.xml b/common/spring-security/pom.xml new file mode 100644 index 0000000..48c5390 --- /dev/null +++ b/common/spring-security/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + cn.bunny + common + 0.0.1-SNAPSHOT + + + spring-security + jar + + spring-security + https://maven.apache.org + + + UTF-8 + + + + + + diff --git a/logs/bunny-service/spring.log b/logs/bunny-service/spring.log new file mode 100644 index 0000000..873183a --- /dev/null +++ b/logs/bunny-service/spring.log @@ -0,0 +1,19 @@ +22:13:48:146 INFO 6108 --- [bunny-service] [main] cn.bunny.service.ServiceApplication : Starting ServiceApplication using Java 21.0.2 with PID 6108 (G:\web项目\Bunny-Cli\Java\java-template\service\target\classes started by 13199 in G:\web项目\Bunny-Cli\Java\java-template) +22:13:48:146 INFO 6108 --- [bunny-service] [main] cn.bunny.service.ServiceApplication : The following 1 profile is active: "dev" +22:13:48:409 INFO 6108 --- [bunny-service] [main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode +22:13:48:410 INFO 6108 --- [bunny-service] [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. +22:13:48:423 INFO 6108 --- [bunny-service] [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 Redis repository interfaces. +22:13:48:630 INFO 6108 --- [bunny-service] [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8800 (http) +22:13:48:635 INFO 6108 --- [bunny-service] [main] o.apache.catalina.core.StandardService : Starting service [Tomcat] +22:13:48:635 INFO 6108 --- [bunny-service] [main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.20] +22:13:48:664 INFO 6108 --- [bunny-service] [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +22:13:48:664 INFO 6108 --- [bunny-service] [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 497 ms +22:13:49:073 WARN 6108 --- [bunny-service] [main] .s.s.UserDetailsServiceAutoConfiguration : + +Using generated security password: 8d911c70-0398-4b8f-b5e7-b50ff6bc614e + +This generated password is for development use only. Your security configuration must be updated before running your application in production. + +22:13:49:116 INFO 6108 --- [bunny-service] [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@2acb1264, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@30a01dd8, org.springframework.security.web.context.SecurityContextHolderFilter@1c8e8fed, org.springframework.security.web.header.HeaderWriterFilter@17df689e, org.springframework.web.filter.CorsFilter@1f68e4e8, org.springframework.security.web.csrf.CsrfFilter@78f5cbc5, org.springframework.security.web.authentication.logout.LogoutFilter@3cad24ae, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@2f6e92ca, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@1e8bccfb, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@47b4ac83, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@56299b0e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@713e7d9a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@681d704e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@351ede23, org.springframework.security.web.access.ExceptionTranslationFilter@5d58dc61, org.springframework.security.web.access.intercept.AuthorizationFilter@6b7c4734] +22:13:49:145 INFO 6108 --- [bunny-service] [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8800 (http) with context path '' +22:13:49:149 INFO 6108 --- [bunny-service] [main] cn.bunny.service.ServiceApplication : Started ServiceApplication in 1.229 seconds (process running for 1.545) diff --git a/model/pom.xml b/model/pom.xml new file mode 100644 index 0000000..b15e61e --- /dev/null +++ b/model/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + + cn.bunny + java-template + 0.0.1-SNAPSHOT + + + model + jar + + model + https://maven.apache.org + + + UTF-8 + + + + + org.projectlombok + lombok + + + com.alibaba.fastjson2 + fastjson2 + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.security + spring-security-test + + + + org.springframework.boot + spring-boot-starter-web + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ed4c03e --- /dev/null +++ b/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.5 + + + cn.bunny + java-template + 0.0.1-SNAPSHOT + pom + java-template + java-template + + + common + model + service + + + 21 + 3.5.6 + 8.0.33 + 3.0.3 + 2.0.47 + 8.4.3 + 1.18.32 + 3.3.3 + 2.10.1 + + + + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + + + + mysql + mysql-connector-java + ${mysql.version} + + + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + + + com.alibaba.fastjson2 + fastjson2 + ${fastjson2.version} + + + + io.minio + minio + ${minio.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + com.alibaba + easyexcel + ${easyexcel.version} + + + joda-time + joda-time + ${jodatime.version} + + + + diff --git a/service/Dockerfile b/service/Dockerfile new file mode 100644 index 0000000..447a2bc --- /dev/null +++ b/service/Dockerfile @@ -0,0 +1,21 @@ +FROM openjdk:21 +MAINTAINER bunny + +#系统编码 +ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 + +# 设置时区,构建镜像时执行的命令 +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo "Asia/Shanghai" > /etc/timezone + +# 设定工作目录 +WORKDIR /home/bunny + +# 复制jar包 +COPY target/*.jar /home/bunny/app.jar + +#启动容器时的进程 +ENTRYPOINT ["java","-jar","/home/bunny/app.jar"] + +#暴露 8800 端口 +EXPOSE 8800 \ No newline at end of file diff --git a/service/pom.xml b/service/pom.xml new file mode 100644 index 0000000..793c56c --- /dev/null +++ b/service/pom.xml @@ -0,0 +1,102 @@ + + 4.0.0 + + cn.bunny + java-template + 0.0.1-SNAPSHOT + + + service + jar + + service + https://maven.apache.org + + + UTF-8 + 192.168.3.98:1100 + 192.168.3.98:2375 + bunny-service + UTF-8 + + + + + + cn.bunny + model + 0.0.1-SNAPSHOT + + + + cn.bunny + service-utils + 0.0.1-SNAPSHOT + + + + + junit + junit + 3.8.1 + + + + org.springframework.boot + spring-boot-starter-test + + + + com.github.xiaoymin + knife4j-spring-boot-starter + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + com.spotify + docker-maven-plugin + 1.2.2 + + + + build-image + + package + + build + push + + + + + harbor + http://${docker.repostory} + + http://${docker.host} + + + ${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version} + + + ${project.basedir} + + false + + + + + diff --git a/service/src/main/java/cn/bunny/service/ServiceApplication.java b/service/src/main/java/cn/bunny/service/ServiceApplication.java new file mode 100644 index 0000000..620679a --- /dev/null +++ b/service/src/main/java/cn/bunny/service/ServiceApplication.java @@ -0,0 +1,11 @@ +package cn.bunny.service; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ServiceApplication { + public static void main(String[] args) { + SpringApplication.run(ServiceApplication.class, args); + } +} diff --git a/service/src/main/resources/application-dev.yml b/service/src/main/resources/application-dev.yml new file mode 100644 index 0000000..3e12aa6 --- /dev/null +++ b/service/src/main/resources/application-dev.yml @@ -0,0 +1,13 @@ +bunny: + datasource: + host: 106.15.251.123 + port: 3305 + sqlData: guigu-oa + username: root + password: "02120212" + + redis: + host: 47.120.65.66 + port: 6379 + database: 3 + password: "02120212" \ No newline at end of file diff --git a/service/src/main/resources/application.yml b/service/src/main/resources/application.yml new file mode 100644 index 0000000..f9290a2 --- /dev/null +++ b/service/src/main/resources/application.yml @@ -0,0 +1,42 @@ +server: + port: 8800 + +spring: + profiles: + active: dev + application: + 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} + + data: + redis: + host: ${bunny.redis.host} + port: ${bunny.redis.port} + database: ${bunny.redis.database} + password: ${bunny.redis.password} + lettuce: + pool: + max-active: 20 #最大连接数 + max-wait: -1 #最大阻塞等待时间(负数表示没限制) + max-idle: 5 #最大空闲 + min-idle: 0 #最小空闲 + + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + +logging: + level: + cn.bunny.service.mapper: debug + cn.bunny.service.controller: info + cn.bunny.service.service: info + pattern: + dateformat: HH:mm:ss:SSS + file: + path: "logs/${spring.application.name}" \ No newline at end of file diff --git a/service/src/main/resources/banner.txt b/service/src/main/resources/banner.txt new file mode 100644 index 0000000..cc77fc2 --- /dev/null +++ b/service/src/main/resources/banner.txt @@ -0,0 +1,16 @@ +-----------------▄██-█▄--------- +-----------------███▄██▄-------- +-----------------███████-------- +-----------------▀███████------- +-------------------██████▄▄----- +-------------------█████████▄--- +-------------------██████▄████-- +-------▄███████████████████████- +-----▄███████████████████████▀-- +---▄██████████████████████------ +---███████████████████████------ +---███████████████████████------ +-▄▄██████████████████████▀------ +-█████████████████▀█████-------- +-▀██████████████▀▀-▀█████▄------ +-------▀▀▀▀▀▀▀▀▀------▀▀▀▀------ \ No newline at end of file diff --git a/service/src/main/resources/favicon.ico b/service/src/main/resources/favicon.ico new file mode 100644 index 0000000..1ba397c Binary files /dev/null and b/service/src/main/resources/favicon.ico differ diff --git a/service/src/test/java/cn/bunny/AppTest.java b/service/src/test/java/cn/bunny/AppTest.java new file mode 100644 index 0000000..34b54ff --- /dev/null +++ b/service/src/test/java/cn/bunny/AppTest.java @@ -0,0 +1,38 @@ +package cn.bunny; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +}