diff --git a/heritage-web/pom.xml b/heritage-web/pom.xml new file mode 100644 index 0000000..8c7a789 --- /dev/null +++ b/heritage-web/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + org.leocoder.heritage + heritage-backend + ${revision} + + + + heritage-web + heritage-web + 入口项目,负责打包 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.leocoder.heritage + heritage-system + ${revision} + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + + + + org.leocoder.heritage + heritage-oss + ${revision} + + + + org.leocoder.heritage + heritage-dict + ${revision} + + + + org.leocoder.heritage + heritage-job + ${revision} + + + + + + + + + + org.leocoder.heritage + heritage-monitor + ${revision} + + + + + + + + + + + + coder-admin + + + org.springframework.boot + spring-boot-maven-plugin + ${springboot.version} + + + + repackage + + + + + + + + src/main/java + + **/*.xml + + + + src/main/resources + + **/* + + + + + + \ No newline at end of file diff --git a/heritage-web/src/main/java/org/leocoder/heritage/web/HeritageApplication.java b/heritage-web/src/main/java/org/leocoder/heritage/web/HeritageApplication.java new file mode 100644 index 0000000..2210675 --- /dev/null +++ b/heritage-web/src/main/java/org/leocoder/heritage/web/HeritageApplication.java @@ -0,0 +1,56 @@ +package org.leocoder.heritage.web; + +import lombok.extern.slf4j.Slf4j; +import org.leocoder.heritage.desensitize.anno.EnableCoderDesensitize; +import org.leocoder.heritage.easyexcel.anno.EnableCoderEasyExcel; +import org.leocoder.heritage.limit.anno.EnableCoderLimit; +import org.leocoder.heritage.mybatisplus.anno.EnableMybatisPlus; +import org.leocoder.heritage.operlog.annotation.EnableOperLog; +import org.leocoder.heritage.oss.annotation.EnableCoderOss; +import org.leocoder.heritage.repect.anno.EnableCoderRepeatSubmit; +import org.leocoder.heritage.resultex.anno.EnableResultEx; +import org.leocoder.heritage.satoken.anno.EnableCoderSaToken; +import org.leocoder.heritage.dict.anno.EnableCoderDict; +import org.leocoder.heritage.job.anno.EnableCoderJob; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * @author : Leocoder + * @version 1.0 + * @date 2025-06-28 14:05 + * @description : 开头的注解是一个插件插入的开关,如果不是相同目录级别的可以使用这个进行跨包! + */ +@EnableCoderSaToken +@EnableCoderEasyExcel +@EnableCoderDesensitize +@EnableCoderRepeatSubmit +@EnableCoderLimit +@EnableMybatisPlus +@EnableResultEx +@EnableOperLog +@EnableCoderOss +@EnableCoderDict +@EnableCoderJob +@EnableScheduling +@Slf4j +@SpringBootApplication(scanBasePackages = "org.leocoder.heritage") +public class HeritageApplication { + public static void main(String[] args) { + // 注意:注入依赖三种选择:@Autowired(required = false) OR @Resource[推荐] OR @RequiredArgsConstructor[推荐] + SpringApplication.run(HeritageApplication.class, args); + log.info( + "\n" + + "Coder-Admin管理平台starter =>ヽ(✿゚▽゚)ノ \n" + + "超级无敌宇宙最强最帅最可爱系统启动成功(๑‾ ꇴ ‾๑) \n" + + " ____ __. .__ _____ ________ _____ .___ _______ \n" + + "| |/ _|____ |__| / _ \\ \\______ \\ / \\ | |\\ \\ \n" + + "| < / _ \\| | ______ / /_\\ \\ | | \\ / \\ / \\| |/ | \\ \n" + + "| | ( <_> ) | /_____/ / | \\| ` \\/ Y \\ / | \\ \n" + + "|____|__ \\____/|__| \\____|__ /_______ /\\____|__ /___\\____|__ / \n" + + " \\/ \\/ \\/ \\/ \\/ \n" + + "CoderApplication[18099] => 闪亮登场(๑•̀ㅂ•́) ✧" + ); + } +} diff --git a/heritage-web/src/main/java/org/leocoder/heritage/web/config/OpenApiConfig.java b/heritage-web/src/main/java/org/leocoder/heritage/web/config/OpenApiConfig.java new file mode 100644 index 0000000..19f04ea --- /dev/null +++ b/heritage-web/src/main/java/org/leocoder/heritage/web/config/OpenApiConfig.java @@ -0,0 +1,32 @@ +package org.leocoder.heritage.web.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author Leocoder + * @description OpenAPI 3.0 配置类 + */ +@Configuration +public class OpenApiConfig { + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("Coder-Admin 后台管理系统 API 文档") + .description("基于 Spring Boot 3.5.0 的企业级后台管理系统 API 接口文档") + .version("1.0.0") + .contact(new Contact() + .name("Leocoder") + .email("admin@leocoder.org") + .url("https://www.leocoder.org")) + .license(new License() + .name("Apache 2.0") + .url("https://www.apache.org/licenses/LICENSE-2.0.html"))); + } +} \ No newline at end of file diff --git a/heritage-web/src/main/resources/application-dev.yml b/heritage-web/src/main/resources/application-dev.yml new file mode 100755 index 0000000..86d9470 --- /dev/null +++ b/heritage-web/src/main/resources/application-dev.yml @@ -0,0 +1,128 @@ +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + hikari: + # 连接池名字 + pool-name: HERITAGE-HIKARI-DEV + # 最大连接池数量 + maximum-pool-size: 20 + # 最小空闲线程数量 + minimum-idle: 10 + # 配置获取连接等待超时的时间 + connectionTimeout: 30000 + # 校验超时时间 + validationTimeout: 5000 + # 空闲连接存活最大时间,默认10分钟 + idleTimeout: 600000 + # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟 + maxLifetime: 1800000 + # 连接测试query[配置检测连接是否有效] + connectionTestQuery: SELECT 1 + # 多久检查一次连接的活性 + keepaliveTime: 30000 + dynamic: + # 性能分析插件[有性能损耗,不建议生产环境使用] + p6spy: true + # 默认数据源[master] + primary: master + # 严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 + strict: false + datasource: + # 主库数据源 + master: # 没有@DS,默认数据源 + type: ${spring.datasource.type} + url: jdbc:mysql://localhost:3306/xxxxxxxx?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: coder + # 从库数据源 + slave: # @DS("dsName"),dsName可以为组名也可以为具体某个库的名称,使用多数据源遵循格式,注解都在mapper层使用。 + lazy: true + type: ${spring.datasource.type} + url: jdbc:mysql://localhost:3306/xxxxxxxx?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: coder + # redis配置 + data: + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 16379 + # 数据库索引 + database: 4 + # 密码[若没有密码请注释掉,若有账号密码:则 账号:密码] + password: coder + # 连接超时时间 + timeout: 10s + # 是否开启ssl + ssl.enabled: false + +# SpringDoc OpenAPI 3.0 配置 +springdoc: + api-docs: + # 是否开启 OpenAPI 接口文档 + enabled: true + # OpenAPI 接口文档路径 + path: /v3/api-docs + swagger-ui: + # 是否开启 Swagger UI + enabled: true + # Swagger UI 访问路径 + path: /swagger-ui.html + # 显示 Extensions + display-extensions: true + # 显示 Common Extensions + display-common-extensions: true + # 需要扫描的包路径 + packages-to-scan: org.leocoder.heritage + # 接口排序方式[method: 按方法名排序, alpha: 按字母排序] + swagger-ui.operations-sorter: method + # 标签排序方式[alpha: 按字母排序] + swagger-ui.tags-sorter: alpha + +# 项目配置 +coder: + # 名称 + projectName: HERITAGE-ADMIN + # 版本 + projectVersion: 1.0.0 + # 文件路径 示例[Windows配置D:/CoderFile,Linux配置 /usr/local/CoderFile] + filePath: + # 存储服务配置 + storage: + # 存储类型:local(本地存储) | oss(阿里云OSS) + type: oss + # 阿里云OSS配置 + oss: + # 是否启用OSS存储 + enabled: true + # OSS服务端点 + endpoint: xxxxxxxx + # 访问密钥ID + access-key-id: xxxxxxxx + # 访问密钥Secret + access-key-secret: xxxxxxxx + # 存储桶名称 + bucket-name: xxxxxxxx + # 自定义域名(可选) + domain: xxxxxxxx + # 路径前缀 + path-prefix: xxxxxxxx + # 是否使用HTTPS + https: true + # 连接超时时间(毫秒) + connect-timeout: 10000 + # 读取超时时间(毫秒) + read-timeout: 10000 + # 全局限流 + globalLimit: + # 是否开启全局限流 + enabled: false + # 默认限流时间[秒] + time: 1 + # 默认限流次数 + count: 12 + # 是否封禁IP + ban: false diff --git a/heritage-web/src/main/resources/application.yml b/heritage-web/src/main/resources/application.yml new file mode 100755 index 0000000..7d95777 --- /dev/null +++ b/heritage-web/src/main/resources/application.yml @@ -0,0 +1,177 @@ +server: + port: ${port:18099} + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # Tomcat默认限制文件上传的大小是2MB ,超过就不会被捕获,需要调整大一点或者-1不限制 + max-swallow-size: -1 + # 不限制POST提交请求的数据大小,默认是2MB + max-http-form-post-size: -1 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + # 开启GZIP压缩,利于你静态资源传输,提升网站请求响应速度 + compression: + enabled: true + min-response-size: 1024 + # 默认是8k + max-http-request-header-size: 80KB +spring: + messages: + encoding: UTF-8 + basename: i18n/messages + profiles: + active: local + +# 操作日志配置 +coder: + oper-log: + # 异步线程池配置 + async: + core-pool-size: 2 + max-pool-size: 5 + queue-capacity: 1000 + keep-alive-seconds: 60 + # 日志清理配置 + clean: + enabled: true + days: 90 + cron: "0 0 2 * * ?" + # 参数记录配置 + param: + max-length: 2000 + exclude-fields: + - password + - pwd + - oldPassword + - newPassword + - confirmPassword + # 结果记录配置 + result: + max-length: 2000 + exclude-large-result: true + + # 解决时间的保存及显示错误问题[实体中就无需再额外注解] + jackson: + date-format: yyyy-MM-dd HH:mm:ss + locale: zh_CN + # 解决java中时间是对的,序列化后到前端差8小时 + time-zone: GMT+8 + default-property-inclusion: non_null + mvc: + # 解决时间的保存及显示错误问题[实体中就无需再额外注解] + format: + date: yyyy-MM-dd HH:mm:ss + main: # SpringBootv2.6.3中,做了循环应用的检查,默认情况下,如果类中存在有循环引用的情况,就会报上面的错误 + allow-circular-references: true + application: + name: heritage-web + servlet: + multipart: + enabled: true + # 是单个文件大小 默认1M + max-file-size: 2MB + # 是设置总上传的数据大小 + max-request-size: 10MB + freemarker: + # 指定HttpServletRequest的属性是否可以覆盖controller的model的同名项 + allow-request-override: false + # req访问request + request-context-attribute: request + # 后缀名freemarker默认后缀为.ftl,当然你也可以改成自己习惯的.html + suffix: .html + # 设置响应的内容类型 + content-type: text/html;charset=utf-8 + # 是否允许mvc使用freemarker + enabled: true + # 是否开启template caching + cache: false + # 检查模板位置是否存在 + check-template-location: true + # 设定模板的加载路径,多个以逗号分隔,默认: [“classpath:/templates/”] + template-loader-path: classpath:/templates/,classpath:/templates/**/ + # 设定Template的编码 + charset: UTF-8 + settings: + template_update_delay: 0 # 检查模板更新延迟时间,设置为0表示立即检查,如果时间大于0会有缓存不方便进行模板测试 + tag_syntax: auto_detect + default_encoding: UTF-8 + output_encoding: UTF-8 + locale: zh_CN + date_format: yyyy-MM-dd + time_format: HH:mm:ss + boolean_format: true,false + whitespace_stripping: true + url_escaping_charset: UTF-8 + datetime_format: yyyy/MM/dd HH:mm:ss + number_format: 0.## + classic_compatible: true + # ignore,debug,html_debug,rethrow + template_exception_handler: rethrow + prefer-file-system-access: false + +# mybatis-plus配置 +mybatis-plus: + mapper-locations: classpath*:mapper/**/*.xml,mapper/*.xml + configuration: + # MybatisPlus配置中设置将sql日志和结果集输出到控制台,会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl + # 关闭日志记录[单纯使用 p6spy 分析] org.apache.ibatis.logging.nologging.NoLoggingImpl + # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl + log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + global-config: + # 是否打印 Logo banner + banner: true + dbConfig: + # 主键类型 + # AUTO[自增] NONE[空] INPUT[用户输入] ASSIGN_ID[雪花] ASSIGN_UUID[唯一] UUID[UUID] + idType: ASSIGN_ID + # 逻辑已删除值[框架表均使用此值 禁止随意修改] + logicDeleteValue: 0 + # 逻辑未删除值 + logicNotDeleteValue: 1 + insertStrategy: NOT_NULL + updateStrategy: NOT_NULL + whereStrategy: NOT_NULL +############## Sa-Token 配置 [文档: https://sa-token.cc] ############## +# 1、被顶下线旧的token为何还存在? 如果还是用旧token来请求,就会返回你已被顶下线 +# 2、前后端分离模式记录的sa-session存在哪个地方? 会存在Redis中 +# 3、前后端分离模式,退出时,前后端模式获取到token的值只从前端传递过来headers中拿(yml中进行配置的,如下方所示) +# 然后StpUtil.logout();自动根据Headers的Authorization获取值,进行从redis中删除token +# 是否尝试从header里读取token,Header用来获取客户端使用的操作系统和浏览器名称和版本和token,前端将token怎么存储的需要跟yml下方中配置的保持一致 +# is-read-header: true +# 是否尝试从cookie里读取token +# is-read-cookie: false +# 是否尝试从请求体里读取token +# is-read-body: false +# StpUtil.getLoginIdAsString() 使用这种Sa-Token封装的方法必须携带token +sa-token: + # token名称 [同时也是cookie名称,推荐使用] + token-name: Authorization + # token 前缀 + token-prefix: Bearer + # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik) + token-style: tik + # token有效期,单位s 默认30天, -1代表永不过期(10800[3小时]后端生成的 token,即使用户一直操作,在 30 天后一定会过期,要求用户重新登录) + timeout: -1 + # token 最低活跃频率[单位:秒],如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 3600 + active-timeout: -1 + # 自动续签,指定时间内有操作,则会自动续签 + auto-renew: true + # 是否尝试从cookie里读取token + is-read-cookie: false + # 是否尝试从header里读取token + is-read-header: true + # 是否允许同一账号多地同时登录[为 true 时允许一起登录, 为 false 时新登录挤掉旧登录] + is-concurrent: true + # 在多人登录同一账号时,是否共用一个 token[为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token] + is-share: false + # 是否在初始化配置时打印版本字符画 + is-print: true + # 是否输出操作日志 + is-log: true + + diff --git a/heritage-web/src/main/resources/logback-spring-hour.xml b/heritage-web/src/main/resources/logback-spring-hour.xml new file mode 100755 index 0000000..8dc2def --- /dev/null +++ b/heritage-web/src/main/resources/logback-spring-hour.xml @@ -0,0 +1,67 @@ + + + + heritage-logback + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + + INFO + + + ERROR + + + WARN + + + + ${HERITAGE_ADMIN_LOGS}/%d{yyyy-MM-dd_HH}.log + 30 + + + + + + UTF-8 + [[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/heritage-web/src/main/resources/logback-spring-part.xml b/heritage-web/src/main/resources/logback-spring-part.xml new file mode 100755 index 0000000..60365ac --- /dev/null +++ b/heritage-web/src/main/resources/logback-spring-part.xml @@ -0,0 +1,109 @@ + + + + + + heritage-logback + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + INFO + + + ${HERITAGE_ADMIN_LOGS}/info/%d{yyyy-MM-dd}/%d{HH}.log + + + 100MB + + 30 + + 10GB + + + UTF-8 + [[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n + + + + + + + + + ERROR + + + ${HERITAGE_ADMIN_LOGS}/error/%d{yyyy-MM-dd}/%d{HH}.log + + + 100MB + + 30 + + 10GB + + + UTF-8 + [[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/heritage-web/src/main/resources/logback-spring.xml b/heritage-web/src/main/resources/logback-spring.xml new file mode 100755 index 0000000..8366e90 --- /dev/null +++ b/heritage-web/src/main/resources/logback-spring.xml @@ -0,0 +1,71 @@ + + + + heritage-logback + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + UTF-8 + + + + + + INFO + + + ERROR + + + WARN + + + + ${HERITAGE_ADMIN_LOGS}/%d{yyyy-MM-dd}.log + 30 + + + + + + + + + + UTF-8 + [[TraceId: %X{traceId}]%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %-5level %logger{36} : %msg%n + + + + + + + + + + + + + + + + + + + + + + + +