diff --git a/doc/lms-application-config.md b/doc/lms-application-config.md new file mode 100644 index 00000000..f2dd278c --- /dev/null +++ b/doc/lms-application-config.md @@ -0,0 +1,208 @@ +# LMS 模块 application.yaml 配置说明 + +## 一、Spring 基础配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `spring.application.name` | `lms-server` | 服务名称,用于 Nacos 注册中心和日志文件命名 | +| `spring.profiles.active` | `dev` | 激活的 profile,决定加载 `application-dev.yaml` | +| `spring.main.allow-circular-references` | `true` | 允许 Bean 循环依赖,三层架构中难以完全避免 | +| `spring.main.allow-bean-definition-overriding` | `true` | 允许 Bean 覆盖,Feign 等组件可能存在重复定义 | +| `server.port` | `48081` | 服务端口号 | + +### 配置导入 + +```yaml +spring.config.import: + - optional:classpath:application-${spring.profiles.active}.yaml + - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml +``` + +- **第一行**:加载本地环境配置文件(如 `application-dev.yaml`),`optional:` 表示文件不存在也不报错 +- **第二行**:从 Nacos 配置中心加载 `${spring.application.name}-${spring.profiles.active}.yaml`,即 `lms-server-dev.yaml`,支持运行时动态刷新配置 + +--- + +## 二、Jackson 序列化配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `spring.jackson.serialization.write-dates-as-timestamps` | `true` | LocalDateTime 序列化为时间戳(毫秒数),而非字符串 | +| `spring.jackson.serialization.write-date-timestamps-as-nanoseconds` | `false` | 不使用纳秒精度,输出 `1611460870401` 而非 `1611460870.401` | +| `spring.jackson.serialization.write-durations-as-timestamps` | `true` | Duration 类型序列化为时间戳 | +| `spring.jackson.serialization.fail-on-empty-beans` | `false` | 允许序列化无属性 Bean,避免空对象报错 | + +--- + +## 三、缓存配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `spring.cache.type` | `REDIS` | 缓存类型为 Redis | +| `spring.cache.redis.time-to-live` | `1h` | 缓存默认过期时间为 1 小时 | + +--- + +## 四、日志配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `logging.file.name` | `${user.home}/logs/${spring.application.name}.log` | 日志文件输出到用户目录下的 `logs/lms-server.log` | + +--- + +## 五、接口文档配置 (SpringDoc + Knife4j) + +Knife4j 是 Swagger 的增强实现,用于生成和展示 API 文档。 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `springdoc.api-docs.enabled` | `true` | 启用 OpenAPI 元数据接口 `/v3/api-docs` | +| `springdoc.swagger-ui.enabled` | `true` | 启用 Swagger UI 界面 `/swagger-ui` | +| `springdoc.default-flat-param-object` | `true` | GET 请求的复杂参数展开为平铺字段 | +| `knife4j.enable` | `true` | 启用 Knife4j 增强 | +| `knife4j.setting.language` | `zh_cn` | UI 界面语言为简体中文 | + +--- + +## 六、MyBatis-Plus 配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `mybatis-plus.configuration.map-underscore-to-camel-case` | `true` | 数据库下划线字段自动映射到 Java 驼峰属性(如 `create_time` → `createTime`) | +| `mybatis-plus.global-config.db-config.id-type` | `NONE` | ID 生成策略由 `IdTypeEnvironmentPostProcessor` 根据数据源类型自动适配(MySQL → AUTO,Oracle → INPUT) | +| `mybatis-plus.global-config.db-config.logic-delete-value` | `1` | 逻辑删除标记值:已删除 | +| `mybatis-plus.global-config.db-config.logic-not-delete-value` | `0` | 逻辑删除标记值:未删除 | +| `mybatis-plus.global-config.banner` | `false` | 关闭 MyBatis-Plus 启动 Banner | +| `mybatis-plus.type-aliases-package` | `${nl.info.base-package}.dal.dataobject` | 类型别名扫描包,实际为 `cn.code.nl.module.lms.dal.dataobject` | +| `mybatis-plus.encryptor.password` | `XDV71a+xqStEA3WH` | 数据库字段加解密密钥(用于加密敏感字段) | +| `mybatis-plus-join.banner` | `false` | 关闭 MyBatis-Plus-Join 启动 Banner | + +--- + +## 七、Redis 配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `spring.data.redis.repositories.enabled` | `false` | 禁用 Spring Data Redis 的 Repository 功能,项目未使用该特性,禁用可加快启动速度 | + +--- + +## 八、Easy-Trans 数据翻译配置 + +Easy-Trans 是一个 VO 数据翻译框架,用于自动将 ID 转换为对应的名称等(如 `deptId` → `部门名称`)。 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `easy-trans.is-enable-global` | `false` | 禁用全局翻译拦截器(对所有 SpringMVC 响应自动翻译),因为全局拦截对性能有影响。需要翻译时通过 `@Trans` 注解手动指定 | + +--- + +## 九、RocketMQ 消息队列配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `rocketmq.producer.group` | `${spring.application.name}_PRODUCER` | 生产者分组名,实际为 `lms-server_PRODUCER` | + +> 实际连接地址在 `application-dev.yaml` 中指定为 `127.0.0.1:9876` + +--- + +## 十、XXL-JOB 定时任务配置 + +XXL-JOB 是分布式任务调度平台。 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `xxl.job.executor.appname` | `${spring.application.name}` | 执行器名称,用于调度中心识别 | +| `xxl.job.executor.logpath` | `${user.home}/logs/xxl-job/${spring.application.name}` | 任务执行日志存储路径 | +| `xxl.job.accessToken` | `123456` | 执行器与调度中心的通信 Token | + +--- + +## 十一、芋道 (nl) 自定义配置 + +### 11.1 基础信息 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.info.version` | `1.0.0` | 应用版本号 | +| `nl.info.base-package` | `cn.code.nl.module.lms` | **核心配置**,用于 `@MapperScan` 扫描 Mapper、MyBatis 类型别名等 | + +### 11.2 Admin UI + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.web.admin-ui.url` | `http://dashboard.nl.iocoder.cn` | 前端管理后台地址,用于跨域配置和 Cookie 域名设置 | + +### 11.3 XSS 防护 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.xss.enable` | `false` | 关闭 XSS 过滤器 | +| `nl.xss.exclude-urls` | `${management.endpoints.web.base-path}/**` | 排除 Actuator 端点,不进行 XSS 过滤 | + +### 11.4 API 加解密 + +通过 AES 算法对请求体和响应体进行加解密,防止明文传输。 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.api-encrypt.enable` | `true` | 开启 API 加解密 | +| `nl.api-encrypt.algorithm` | `AES` | 加密算法 | +| `nl.api-encrypt.request-key` | `52549111389893486934626385991395` | 请求解密密钥(AES 需要 16/24/32 位) | +| `nl.api-encrypt.response-key` | `96103715984234343991809655248883` | 响应加密密钥(AES 需要 16/24/32 位) | + +> 注释中的长字符串是 RSA 模式的示例密钥,当前未使用 + +### 11.5 Swagger 文档信息 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.swagger.title` | `管理后台` | API 文档标题 | +| `nl.swagger.description` | `提供管理员管理的所有功能` | API 文档描述 | +| `nl.swagger.version` | `${nl.info.version}` | API 文档版本号 | + +### 11.6 多租户配置 + +多租户用于 SaaS 场景,数据按租户隔离。 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.tenant.enable` | `true` | 开启多租户功能 | +| `nl.tenant.ignore-urls` | (空) | 不进行租户过滤的 URL | +| `nl.tenant.ignore-visit-urls` | `/admin-api/system/user/profile/**`, `/admin-api/system/auth/**` | 登录和个人信息接口跳过租户校验 | +| `nl.tenant.ignore-tables` | (空) | 不进行租户隔离的表 | +| `nl.tenant.ignore-caches` | `user_role_ids`, `permission_menu_ids` 等 | 不按租户隔离的缓存 Key | + +### 11.7 短信验证码配置 + +| 配置项 | 值 | 说明 | +|--------|-----|------| +| `nl.sms-code.expire-times` | `10m` | 验证码有效期 10 分钟 | +| `nl.sms-code.send-frequency` | `1m` | 发送频率限制:每 1 分钟只能发一次 | +| `nl.sms-code.send-maximum-quantity-per-day` | `10` | 每天最多发送 10 次 | +| `nl.sms-code.begin-code` | `9999` | 测试用的固定验证码(范围起始) | +| `nl.sms-code.end-code` | `9999` | 测试用的固定验证码(范围结束),两个同时为 9999 表示固定使用 9999 作为验证码 | + +--- + +## 十二、配置间的层级关系 + +``` +application.yaml (主配置) +├── nl.info.base-package = cn.code.nl.module.lms ← 贯穿全局的核心配置 +│ ├── @MapperScan(value = "${nl.info.base-package}") → 扫描 Mapper +│ └── type-aliases-package = ${nl.info.base-package}.dal.dataobject → DO 类型别名 +│ +├── application-{profile}.yaml (环境配置,如 application-dev.yaml) +│ ├── 数据库连接 (datasource) +│ ├── Redis 连接 +│ ├── Nacos 地址 +│ └── RocketMQ / Kafka / RabbitMQ 连接 +│ +└── Nacos 配置中心 + └── lms-server-dev.yaml (运行时动态配置) +``` + +> **注意**:`application.yaml` 中的配置优先级最低,会被 profile 文件和 Nacos 远程配置覆盖。 diff --git a/nl-module-lms/nl-module-lms-api/pom.xml b/nl-module-lms/nl-module-lms-api/pom.xml new file mode 100644 index 00000000..7e232dc1 --- /dev/null +++ b/nl-module-lms/nl-module-lms-api/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + cn.nl.cloud + nl-module-lms + ${revision} + + + nl-module-lms-api + jar + + ${project.artifactId} + + lms 模块 API,暴露给其它模块调用 + + + + + cn.nl.cloud + nl-common + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + provided + + + + + org.springframework.boot + spring-boot-starter-validation + true + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + true + + + + + \ No newline at end of file diff --git a/nl-module-lms/nl-module-lms-api/src/main/java/cn/code/nl/module/lms/package-info.java b/nl-module-lms/nl-module-lms-api/src/main/java/cn/code/nl/module/lms/package-info.java new file mode 100644 index 00000000..ab0103f7 --- /dev/null +++ b/nl-module-lms/nl-module-lms-api/src/main/java/cn/code/nl/module/lms/package-info.java @@ -0,0 +1,6 @@ +/** + * lms - API模块 + * @Author: liyongde + * @Date: 2026/7/10 9:02 + */ +package cn.code.nl.module.lms; \ No newline at end of file diff --git a/nl-module-lms/nl-module-lms-server/pom.xml b/nl-module-lms/nl-module-lms-server/pom.xml new file mode 100644 index 00000000..562d3f5f --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/pom.xml @@ -0,0 +1,131 @@ + + + 4.0.0 + + cn.nl.cloud + nl-module-lms + ${revision} + + + nl-module-lms-server + jar + + ${project.artifactId} + + lms 模块下,我们放通用业务,支撑上层的核心业务。 + 功能点描述: + - xxx + - xxx + + + + + + cn.nl.cloud + nl-spring-boot-starter-env + + + + cn.nl.cloud + nl-module-lms-api + ${revision} + + + + + cn.nl.cloud + nl-spring-boot-starter-biz-data-permission + + + cn.nl.cloud + nl-spring-boot-starter-biz-tenant + + + cn.nl.cloud + nl-spring-boot-starter-biz-ip + + + + + + cn.nl.cloud + nl-spring-boot-starter-security + + + + + cn.nl.cloud + nl-spring-boot-starter-mybatis + + + + cn.nl.cloud + nl-spring-boot-starter-redis + + + + + cn.nl.cloud + nl-spring-boot-starter-rpc + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + cn.nl.cloud + nl-spring-boot-starter-job + + + + + cn.nl.cloud + nl-spring-boot-starter-mq + + + + + cn.nl.cloud + nl-spring-boot-starter-excel + + + + + cn.nl.cloud + nl-spring-boot-starter-monitor + + + + + + ${project.artifactId} + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/LmsServerApplication.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/LmsServerApplication.java new file mode 100644 index 00000000..cd03d0dd --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/LmsServerApplication.java @@ -0,0 +1,16 @@ +package cn.code.nl.module.lms; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * + * @Author: liyongde + * @Date: 2026/7/10 9:12 + */ +@SpringBootApplication +public class LmsServerApplication { + public static void main(String[] args) { + SpringApplication.run(LmsServerApplication.class, args); + } +} diff --git a/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/package-info.java b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/package-info.java new file mode 100644 index 00000000..30fc8730 --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/src/main/java/cn/code/nl/module/lms/package-info.java @@ -0,0 +1,6 @@ +/** + * lms 模块 + * @Author: liyongde + * @Date: 2026/7/10 9:12 + */ +package cn.code.nl.module.lms; \ No newline at end of file diff --git a/nl-module-lms/nl-module-lms-server/src/main/resources/application-dev.yaml b/nl-module-lms/nl-module-lms-server/src/main/resources/application-dev.yaml new file mode 100644 index 00000000..10810337 --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/src/main/resources/application-dev.yaml @@ -0,0 +1,142 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: http://192.168.10.29:8848 # Nacos 服务器地址 + username: # Nacos 账号 + password: # Nacos 密码 + discovery: # 【配置中心】配置项 + namespace: dev # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + metadata: + version: 1.0.0 # 服务实例的版本号,可用于灰度发布 + config: # 【注册中心】配置项 + namespace: dev # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + +--- #################### 数据库相关配置 #################### +spring: + # 数据源配置项 + autoconfigure: + exclude: + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 5 # 初始连接数 + min-idle: 10 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 60000 # 配置获取连接等待超时的时间,单位:毫秒(1 分钟) + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒(1 分钟) + min-evictable-idle-time-millis: 600000 # 配置一个连接在池中最小生存的时间,单位:毫秒(10 分钟) + max-evictable-idle-time-millis: 1800000 # 配置一个连接在池中最大生存的时间,单位:毫秒(30 分钟) + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + pool-prepared-statements: true # 是否开启 PreparedStatement 缓存 + max-pool-prepared-statement-per-connection-size: 20 # 每个连接缓存的 PreparedStatement 数量 + primary: master + datasource: + master: + url: jdbc:mysql://127.0.0.1:3306/huachuang_lms?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + username: root + password: 12356 + slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 + lazy: true # 开启懒加载,保证启动速度 + url: jdbc:mysql://127.0.0.1:3306/huachuang_lms?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + username: root + password: 12356 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + data: + redis: + host: 127.0.0.1 # 地址 + port: 6379 # 端口 + database: 1 # 数据库索引 +# password: 123456 # 密码,建议生产环境开启 + +--- #################### MQ 消息队列相关配置 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv + +spring: + # RabbitMQ 配置项,对应 RabbitProperties 配置类 + rabbitmq: + host: 127.0.0.1 # RabbitMQ 服务的地址 + port: 5672 # RabbitMQ 服务的端口 + username: guest # RabbitMQ 服务的账号 + password: guest # RabbitMQ 服务的密码 + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 + +--- #################### 定时任务相关配置 #################### +xxl: + job: + admin: + addresses: http://192.168.10.29:8080/xxl-job-admin # 调度中心部署跟地址 + executor: + ip: 192.168.10.29 + port: 9992 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30000 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + username: admin + password: admin + # Spring Boot Admin Server 服务端的相关配置 + context-path: /admin # 配置 Spring + +# 日志文件配置 +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +nl: + demo: false # 开启演示模式 \ No newline at end of file diff --git a/nl-module-lms/nl-module-lms-server/src/main/resources/application-local.yaml b/nl-module-lms/nl-module-lms-server/src/main/resources/application-local.yaml new file mode 100644 index 00000000..10810337 --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/src/main/resources/application-local.yaml @@ -0,0 +1,142 @@ +--- #################### 注册中心 + 配置中心相关配置 #################### + +spring: + cloud: + nacos: + server-addr: http://192.168.10.29:8848 # Nacos 服务器地址 + username: # Nacos 账号 + password: # Nacos 密码 + discovery: # 【配置中心】配置项 + namespace: dev # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + metadata: + version: 1.0.0 # 服务实例的版本号,可用于灰度发布 + config: # 【注册中心】配置项 + namespace: dev # 命名空间。这里使用 dev 开发环境 + group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP + +--- #################### 数据库相关配置 #################### +spring: + # 数据源配置项 + autoconfigure: + exclude: + datasource: + druid: # Druid 【监控】相关的全局配置 + web-stat-filter: + enabled: true + stat-view-servlet: + enabled: true + allow: # 设置白名单,不填则允许所有访问 + url-pattern: /druid/* + login-username: # 控制台管理用户名和密码 + login-password: + filter: + stat: + enabled: true + log-slow-sql: true # 慢 SQL 记录 + slow-sql-millis: 100 + merge-sql: true + wall: + config: + multi-statement-allow: true + dynamic: # 多数据源配置 + druid: # Druid 【连接池】相关的全局配置 + initial-size: 5 # 初始连接数 + min-idle: 10 # 最小连接池数量 + max-active: 20 # 最大连接池数量 + max-wait: 60000 # 配置获取连接等待超时的时间,单位:毫秒(1 分钟) + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒(1 分钟) + min-evictable-idle-time-millis: 600000 # 配置一个连接在池中最小生存的时间,单位:毫秒(10 分钟) + max-evictable-idle-time-millis: 1800000 # 配置一个连接在池中最大生存的时间,单位:毫秒(30 分钟) + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + pool-prepared-statements: true # 是否开启 PreparedStatement 缓存 + max-pool-prepared-statement-per-connection-size: 20 # 每个连接缓存的 PreparedStatement 数量 + primary: master + datasource: + master: + url: jdbc:mysql://127.0.0.1:3306/huachuang_lms?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + username: root + password: 12356 + slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 + lazy: true # 开启懒加载,保证启动速度 + url: jdbc:mysql://127.0.0.1:3306/huachuang_lms?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + username: root + password: 12356 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + data: + redis: + host: 127.0.0.1 # 地址 + port: 6379 # 端口 + database: 1 # 数据库索引 +# password: 123456 # 密码,建议生产环境开启 + +--- #################### MQ 消息队列相关配置 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + name-server: 127.0.0.1:9876 # RocketMQ Namesrv + +spring: + # RabbitMQ 配置项,对应 RabbitProperties 配置类 + rabbitmq: + host: 127.0.0.1 # RabbitMQ 服务的地址 + port: 5672 # RabbitMQ 服务的端口 + username: guest # RabbitMQ 服务的账号 + password: guest # RabbitMQ 服务的密码 + # Kafka 配置项,对应 KafkaProperties 配置类 + kafka: + bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 + +--- #################### 定时任务相关配置 #################### +xxl: + job: + admin: + addresses: http://192.168.10.29:8080/xxl-job-admin # 调度中心部署跟地址 + executor: + ip: 192.168.10.29 + port: 9992 + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30000 毫秒 + +--- #################### 监控相关配置 #################### + +# Actuator 监控端点的配置项 +management: + endpoints: + web: + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator + exposure: + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 + +# Spring Boot Admin 配置项 +spring: + boot: + admin: + # Spring Boot Admin Client 客户端的相关配置 + client: + instance: + service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] + username: admin + password: admin + # Spring Boot Admin Server 服务端的相关配置 + context-path: /admin # 配置 Spring + +# 日志文件配置 +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +nl: + demo: false # 开启演示模式 \ No newline at end of file diff --git a/nl-module-lms/nl-module-lms-server/src/main/resources/application.yaml b/nl-module-lms/nl-module-lms-server/src/main/resources/application.yaml new file mode 100644 index 00000000..7ccbd381 --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/src/main/resources/application.yaml @@ -0,0 +1,150 @@ +spring: + application: + name: lms-server + + profiles: + active: dev + + main: + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 + allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 + + config: + import: + - optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置 + - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置 + + # Servlet 配置 + servlet: + # 文件上传相关配置项 + multipart: + max-file-size: 16MB # 单个文件大小 + max-request-size: 32MB # 设置总上传的文件大小 + + # Jackson 配置项 + jackson: + serialization: + write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 + fail-on-empty-beans: false # 允许序列化无属性的 Bean + + # Cache 配置项 + cache: + type: REDIS + redis: + time-to-live: 1h # 设置过期时间为 1 小时 + +server: + port: 48081 + +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 接口文档配置 #################### + +springdoc: + api-docs: + enabled: true # 1. 是否开启 Swagger 接文档的元数据 + path: /v3/api-docs + swagger-ui: + enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 + path: /swagger-ui + default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 + +knife4j: + enable: true + setting: + language: zh_cn + +# MyBatis Plus 的配置项 +mybatis-plus: + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + global-config: + db-config: + id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 + # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 + # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 + # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + banner: false # 关闭控制台的 Banner 打印 + type-aliases-package: ${nl.info.base-package}.dal.dataobject + encryptor: + password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 + +mybatis-plus-join: + banner: false # 关闭控制台的 Banner 打印 + +# Spring Data Redis 配置 +spring: + data: + redis: + repositories: + enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 + +# VO 转换(数据翻译)相关 +easy-trans: + is-enable-global: false # 【默认禁用,对性能确认压力大】启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 + +--- #################### RPC 远程调用相关配置 #################### + +--- #################### 消息队列相关 #################### + +# rocketmq 配置项,对应 RocketMQProperties 配置类 +rocketmq: + # Producer 配置项 + producer: + group: ${spring.application.name}_PRODUCER # 生产者分组 + +--- #################### 定时任务相关配置 #################### + +xxl: + job: + executor: + appname: ${spring.application.name} # 执行器 AppName + logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 + accessToken: 123456 # 执行器通讯TOKEN + +--- #################### 芋道相关配置 #################### + +nl: + info: + version: 1.0.0 + base-package: cn.code.nl.module.lms + web: + admin-ui: + url: http://dashboard.nl.iocoder.cn # Admin 管理后台 UI 的地址 + xss: + enable: false + exclude-urls: # 如下 url,仅仅是为了演示,去掉配置也没关系 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + api-encrypt: + enable: true # 是否开启 API 加密 + algorithm: AES # 加密算法,支持 AES、RSA 等 + request-key: 52549111389893486934626385991395 # 【AES 案例】请求加密的秘钥,,必须 16、24、32 位 + response-key: 96103715984234343991809655248883 # 【AES 案例】响应加密的秘钥,AES 案例,必须 16、24、32 位 + # request-key: MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKWzasimcZ1icsWDPVdTXcZs1DkOWjI+m9bTQU8aOqflnomkr6QO1WWeSHBHzuJGsTlV/ZY2pFfq/NstKC94hBjx7yioYJvzb2bKN/Uy4j5nM3iCF//u0RiFkkY8j0Bt/EWoFTOb6RHf8cHIAjbYYtP3pYzbpCIwryfe0g//KIuzAgMBAAECgYADDjZrYcpZjR2xr7RbXmGtzYbyUGXwZEAqa3XaWBD51J2iSyOkAlQEDjGmxGQ3vvb4qDHHadWI+3/TKNeDXJUO+xTVJrnismK5BsHyC6dfxlIK/5BAuknryTca/3UoA1yomS9ZlF3Q0wcecaDoEnSmZEaTrp9T3itPAz4KnGjv5QJBAN5mNcfu6iJ5ktNvEdzqcxkKwbXb9Nq1SLnmTvt+d5TPX7eQ9fCwtOfVu5iBLhhZzb5PJ7pSN3Zt6rl5/jPOGv0CQQC+vETX9oe1wbxZSv6/RBGy0Xow6GndbJwvd89PcAJ2h+OJXWtg/rRHB3t9EQm7iis0XbZTapj19E4U6l8EibhvAkEA1CvYpRwmHKu1SqdM+GBnW/2qHlBwwXJvpoK02TOm674HR/4w0+YRQJfkd7LOAgcyxJuJgDTNmtt0MmzS+iNoFQJAMVSUIZ77XoDq69U/qcw7H5qaFcgmiUQr6QL9tTftCyb+LGri+MUnby96OtCLSdvkbLjIDS8GvKYhA7vSM2RDNQJBAKGyVVnFFIrbK3yuwW71yvxQEGoGxlgvZSezZ4vGgqTxrr9HvAtvWLwR6rpe6ybR/x8uUtoW7NRBWgpiIFwjvY4= # 【RSA 案例】请求解密的私钥 + # response-key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDh/CHyBcS/zEfVyINVA7+c9Xxl0CPdxPMK1OIjxaLy/7BLfbkoEpI8onQtjuzfpuxCraDem9bu3BMF0pMH95HytI3Vi0kGjaV+WLIalwgc2w37oA2sbsmKzQOP7SDLO5s2QJNAD7kVwd+Q5rqaLu2MO0xVv+0IUJhn83hClC0L5wIDAQAB # 【RSA 案例】响应加密的公钥 + swagger: + title: 管理后台 + description: 提供管理员管理的所有功能 + version: ${nl.info.version} + tenant: # 多租户相关配置项 + enable: true + ignore-urls: + ignore-visit-urls: + - /admin-api/system/user/profile/** + - /admin-api/system/auth/** + ignore-tables: + ignore-caches: + sms-code: # 短信验证码相关的配置项 + expire-times: 10m + send-frequency: 1m + send-maximum-quantity-per-day: 10 + begin-code: 9999 # 这里配置 9999 的原因是,测试方便。 + end-code: 9999 # 这里配置 9999 的原因是,测试方便。 + +debug: false diff --git a/nl-module-lms/nl-module-lms-server/src/main/resources/logback-spring.xml b/nl-module-lms/nl-module-lms-server/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..15b28cfd --- /dev/null +++ b/nl-module-lms/nl-module-lms-server/src/main/resources/logback-spring.xml @@ -0,0 +1,56 @@ + + + + + + + + +       + + ${CONSOLE_LOG_PATTERN} + + + + + + + + ${FILE_LOG_PATTERN} + + + ${LOG_FILE} + + + ${LOG_FILE}.%d{yyyy-MM-dd}.%i.log + 30 + 10MB + + + + + 0 + 512 + + + + + + + + + + + + + + + diff --git a/nl-module-lms/pom.xml b/nl-module-lms/pom.xml new file mode 100644 index 00000000..2acadf68 --- /dev/null +++ b/nl-module-lms/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + cn.nl.cloud + nl + ${revision} + + + nl-module-lms + pom + + ${project.artifactId} + + lms 模块下,我们放生产的核心业务。 + + + nl-module-lms-api + nl-module-lms-server + + + \ No newline at end of file diff --git a/nl-server/pom.xml b/nl-server/pom.xml index 7cac89f4..bd4bb865 100644 --- a/nl-server/pom.xml +++ b/nl-server/pom.xml @@ -31,6 +31,11 @@ nl-module-infra-server ${revision} + + cn.nl.cloud + nl-module-lms-server + ${revision} + diff --git a/pom.xml b/pom.xml index 14015c20..10589434 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,8 @@ nl-module-system nl-module-infra - + nl-module-lms +