From 930cdfe2b26ae2a2d5fc6f0d98b021fda00f0071 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 7 May 2021 00:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=20yudao-user-server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + yudao-admin-server/pom.xml | 4 - .../main/resources/META-INF/spring.factories | 2 +- yudao-user-server/pom.xml | 111 ++++++++++++++ .../userserver/UserServerApplication.java | 13 ++ .../async/config/AsyncConfiguration.java | 9 ++ .../framework/async/package-info.java | 4 + .../《芋道 Spring Boot 异步任务入门》.md | 1 + .../userserver/framework/package-info.java | 6 + .../dal/dataobject/config/InfConfigDO.java | 64 ++++++++ .../infra/dal/dataobject/file/InfFileDO.java | 43 ++++++ .../dal/mysql/config/InfConfigDAOImpl.java | 39 +++++ .../infra/dal/mysql/file/InfFileMapper.java | 10 ++ .../modules/infra/package-info.java | 7 + .../userserver/modules/package-info.java | 1 + .../src/main/resources/application-dev.yaml | 140 +++++++++++++++++ .../src/main/resources/application-local.yaml | 142 ++++++++++++++++++ .../src/main/resources/application.yaml | 60 ++++++++ .../src/main/resources/banner.txt | 17 +++ .../src/main/resources/logback-spring.xml | 76 ++++++++++ 20 files changed, 745 insertions(+), 5 deletions(-) create mode 100644 yudao-user-server/pom.xml create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/config/AsyncConfiguration.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/package-info.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/《芋道 Spring Boot 异步任务入门》.md create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/package-info.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/package-info.java create mode 100644 yudao-user-server/src/main/resources/application-dev.yaml create mode 100644 yudao-user-server/src/main/resources/application-local.yaml create mode 100644 yudao-user-server/src/main/resources/application.yaml create mode 100644 yudao-user-server/src/main/resources/banner.txt create mode 100644 yudao-user-server/src/main/resources/logback-spring.xml diff --git a/pom.xml b/pom.xml index eec621676..d6bb8301a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ yudao-dependencies yudao-framework yudao-admin-server + yudao-user-server ${artifactId} diff --git a/yudao-admin-server/pom.xml b/yudao-admin-server/pom.xml index 107b67e6b..16e75eb84 100644 --- a/yudao-admin-server/pom.xml +++ b/yudao-admin-server/pom.xml @@ -110,10 +110,6 @@ cn.smallbun.screw screw-core - - cn.iocoder.boot - yudao-spring-boot-starter-mq - diff --git a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/resources/META-INF/spring.factories b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/resources/META-INF/spring.factories index 529a47663..3986b1c2b 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/resources/META-INF/spring.factories +++ b/yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - cn.iocoder.yudao.framework.operatelog.config.YudaoOperateLogAutoConfiguration + cn.iocoder.yudao.framework.dict.config.YudaoDictAutoConfiguration diff --git a/yudao-user-server/pom.xml b/yudao-user-server/pom.xml new file mode 100644 index 000000000..4bd1c5857 --- /dev/null +++ b/yudao-user-server/pom.xml @@ -0,0 +1,111 @@ + + + + cn.iocoder.boot + yudao + ${revision} + + 4.0.0 + + yudao-user-server + jar + + yudao-admin-server + 用户前台 Server,提供其 API 接口 + https://github.com/YunaiV/ruoyi-vue-pro + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-dict + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-sms + + + + + cn.iocoder.boot + yudao-spring-boot-starter-web + + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + + cn.iocoder.boot + yudao-spring-boot-starter-redis + + + + + cn.iocoder.boot + yudao-spring-boot-starter-config + + + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mq + + + + + cn.iocoder.boot + yudao-spring-boot-starter-protection + + + + + cn.iocoder.boot + yudao-spring-boot-starter-monitor + + + + + cn.iocoder.boot + yudao-spring-boot-starter-test + test + + + + + + + + + ${artifactId} + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + repackage + + + + + + + + diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java new file mode 100644 index 000000000..edfbc63dc --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.userserver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class UserServerApplication { + + public static void main(String[] args) { + SpringApplication.run(UserServerApplication.class, args); + } + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/config/AsyncConfiguration.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/config/AsyncConfiguration.java new file mode 100644 index 000000000..ed271220c --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/config/AsyncConfiguration.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.userserver.framework.async.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; + +@Configuration +@EnableAsync +public class AsyncConfiguration { +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/package-info.java new file mode 100644 index 000000000..a06351522 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/package-info.java @@ -0,0 +1,4 @@ +/** + * 异步执行,基于 Spring @Async 实现 + */ +package cn.iocoder.yudao.userserver.framework.async; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/《芋道 Spring Boot 异步任务入门》.md b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/《芋道 Spring Boot 异步任务入门》.md new file mode 100644 index 000000000..5822b838c --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/《芋道 Spring Boot 异步任务入门》.md @@ -0,0 +1 @@ + diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/package-info.java new file mode 100644 index 000000000..db25ed2a4 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/package-info.java @@ -0,0 +1,6 @@ +/** + * 属于整个 yudao-user-server 的 framework 封装 + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.userserver.framework; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java new file mode 100644 index 000000000..a9ab432d6 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.config; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * 参数配置表 + * + * @author ruoyi + */ +@TableName("inf_config") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class InfConfigDO extends BaseDO { + + /** + * 参数主键 + */ + @TableId + private Long id; + /** + * 参数分组 + */ + @TableField("`group`") + private String group; + /** + * 参数名称 + */ + private String name; + /** + * 参数键名 + */ + @TableField("`key`") + private String key; + /** + * 参数键值 + */ + private String value; + /** + * 参数类型 + * + * 枚举 {@link InfConfigTypeEnum} + */ + @TableField("`type`") + private Integer type; + /** + * 是否敏感 + * + * 对于敏感配置,需要管理权限才能查看 + */ + @TableField("`sensitive`") + private Boolean sensitive; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java new file mode 100644 index 000000000..604a888c2 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.io.InputStream; + +/** + * 文件表 + * + * @author 芋道源码 + */ +@Data +@TableName("inf_file") +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class InfFileDO extends BaseDO { + + /** + * 文件路径 + */ + @TableId(type = IdType.INPUT) + private String id; + /** + * 文件类型 + * + * 通过 {@link cn.hutool.core.io.FileTypeUtil#getType(InputStream)} 获取 + */ + @TableField(value = "`type`") + private String type; + /** + * 文件内容 + */ + private byte[] content; + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java new file mode 100644 index 000000000..5453c05a2 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config; + +import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO; +import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.datasource.DriverManagerDataSource; + +import javax.sql.DataSource; +import java.sql.ResultSet; +import java.util.Date; +import java.util.List; + +/** + * ConfigFrameworkDAO 实现类 + * + * @author 芋道源码 + */ +public class InfConfigDAOImpl implements ConfigFrameworkDAO { + + private final JdbcTemplate jdbcTemplate; + + public InfConfigDAOImpl(String jdbcUrl, String username, String password) { + DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password); + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + @Override + public boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) { + return jdbcTemplate.query("SELECT id FROM inf_config WHERE update_time > ? LIMIT 1", + ResultSet::next, maxUpdateTime); + } + + @Override + public List selectList() { + return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(ConfigRespDTO.class)); + } + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java new file mode 100644 index 000000000..1db7d311b --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.file; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file.InfFileDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface InfFileMapper extends BaseMapperX { + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java new file mode 100644 index 000000000..fdf89894e --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java @@ -0,0 +1,7 @@ +/** + * infra 包下,我们放基础设施的运维与管理,支撑上层的通用与核心业务。 + * 例如说:定时任务的管理、服务器的信息等等 + * + * 缩写:inf + */ +package cn.iocoder.yudao.userserver.modules.infra; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/package-info.java new file mode 100644 index 000000000..430f6c945 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.userserver.modules; diff --git a/yudao-user-server/src/main/resources/application-dev.yaml b/yudao-user-server/src/main/resources/application-dev.yaml new file mode 100644 index 000000000..c21eeec80 --- /dev/null +++ b/yudao-user-server/src/main/resources/application-dev.yaml @@ -0,0 +1,140 @@ +server: + port: 28080 + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + 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: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + name: ruoyi-vue-pro + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + driver-class-name: com.mysql.jdbc.Driver + username: root + password: 3WLiVUBEwTbvAfsh + slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 + name: ruoyi-vue-pro + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + driver-class-name: com.mysql.jdbc.Driver + username: root + password: 3WLiVUBEwTbvAfsh + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 400-infra.server.iocoder.cn # 地址 + port: 6379 # 端口 + database: 1 # 数据库索引 + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +# Apollo 配置中心 +apollo: + bootstrap: + enabled: true # 设置 Apollo 在启动阶段生效 + eagerLoad: + enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 + jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 + dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl + url: ${spring.datasource.dynamic.datasource.master.url} + username: ${spring.datasource.dynamic.datasource.master.username} + password: ${spring.datasource.dynamic.datasource.master.password} + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +# Resilience4j 配置项 +resilience4j: + ratelimiter: + instances: + backendA: + limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50 + limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500 + timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s + register-health-indicator: true # 是否注册到健康监测 + +--- #################### 监控相关配置 #################### + +# 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: + url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址 + instance: + prefer-ip: true # 注册实例时,优先使用 IP + +# 日志文件配置 +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + security: + token-header: Authorization + token-secret: abcdefghijklmnopqrstuvwxyz + token-timeout: 1d + session-timeout: 30m + mock-enable: true + mock-secret: test + file: + base-path: http://api-dashboard.yudao.iocoder.cn${yudao.web.api-prefix}/infra/file/get/ + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + demo: true # 开启演示模式 diff --git a/yudao-user-server/src/main/resources/application-local.yaml b/yudao-user-server/src/main/resources/application-local.yaml new file mode 100644 index 000000000..62a53cf07 --- /dev/null +++ b/yudao-user-server/src/main/resources/application-local.yaml @@ -0,0 +1,142 @@ +server: + port: 28080 + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + autoconfigure: + exclude: + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 + 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: 600000 # 配置获取连接等待超时的时间,单位:毫秒 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 + test-while-idle: true + test-on-borrow: false + test-on-return: false + primary: master + datasource: + master: + name: ruoyi-vue-pro + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + driver-class-name: com.mysql.jdbc.Driver + username: root + password: 123456 + slave: # 模拟从库,可根据自己需要修改 + name: ruoyi-vue-pro + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT + driver-class-name: com.mysql.jdbc.Driver + username: root + password: 123456 + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 6379 # 端口 + database: 0 # 数据库索引 + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +# Apollo 配置中心 +apollo: + bootstrap: + enabled: true # 设置 Apollo 在启动阶段生效 + eagerLoad: + enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 + jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 + dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl + url: ${spring.datasource.dynamic.datasource.master.url} + username: ${spring.datasource.dynamic.datasource.master.username} + password: ${spring.datasource.dynamic.datasource.master.password} + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项 +lock4j: + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 + +# Resilience4j 配置项 +resilience4j: + ratelimiter: + instances: + backendA: + limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50 + limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500 + timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s + register-health-indicator: true # 是否注册到健康监测 + +--- #################### 监控相关配置 #################### + +# 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: + url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址 + instance: + prefer-ip: true # 注册实例时,优先使用 IP + # Spring Boot Admin Server 服务端的相关配置 + context-path: /admin # 配置 Spring + +# 日志文件配置 +logging: + file: + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + security: + token-header: Authorization + token-secret: abcdefghijklmnopqrstuvwxyz + token-timeout: 1d + session-timeout: 30m + mock-enable: true + mock-secret: test + file: + base-path: http://127.0.0.1:${server.port}${yudao.web.api-prefix}/infra/file/get/ + xss: + enable: false + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 + demo: false # 关闭演示模式 diff --git a/yudao-user-server/src/main/resources/application.yaml b/yudao-user-server/src/main/resources/application.yaml new file mode 100644 index 000000000..573a9a5e1 --- /dev/null +++ b/yudao-user-server/src/main/resources/application.yaml @@ -0,0 +1,60 @@ +spring: + application: + name: yudao-user-server + + profiles: + active: local + + # Servlet 配置 + servlet: + # 文件上传相关配置项 + multipart: + max-file-size: 16MB # 单个文件大小 + max-request-size: 32MB # 设置总上传的文件大小 + + # Jackson 配置项 + jackson: + serialization: + write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 + fail-on-empty-beans: false # 允许序列化无属性的 Bean + +# MyBatis Plus 的配置项 +mybatis-plus: + configuration: + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志 + global-config: + db-config: + id-type: AUTO # 自增 ID + logic-delete-value: 1 # 逻辑已删除值(默认为 1) + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) + mapper-locations: classpath*:mapper/*.xml + type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject + +--- #################### 芋道相关配置 #################### + +yudao: + info: + version: 1.0.0 + base-package: cn.iocoder.yudao.userserver + web: + api-prefix: /api + controller-package: ${yudao.info.base-package} + swagger: + title: 管理后台 + description: 提供管理员管理的所有功能 + version: ${yudao.info.version} + base-package: ${yudao.info.base-package}.modules + captcha: + timeout: 5m + width: 160 + height: 60 + codegen: + base-package: ${yudao.info.base-package} + db-schemas: ${spring.datasource.dynamic.datasource.master.name} + error-code: # 错误码相关配置项 + constants-class-list: + +debug: false diff --git a/yudao-user-server/src/main/resources/banner.txt b/yudao-user-server/src/main/resources/banner.txt new file mode 100644 index 000000000..39a441d7d --- /dev/null +++ b/yudao-user-server/src/main/resources/banner.txt @@ -0,0 +1,17 @@ +芋道源码 http://www.iocoder.cn +Application Version: ${yudao.info.version} +Spring Boot Version: ${spring-boot.version} + +.__ __. ______ .______ __ __ _______ +| \ | | / __ \ | _ \ | | | | / _____| +| \| | | | | | | |_) | | | | | | | __ +| . ` | | | | | | _ < | | | | | | |_ | +| |\ | | `--' | | |_) | | `--' | | |__| | +|__| \__| \______/ |______/ \______/ \______| + +███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ +████╗ ██║██╔═══██╗ ██╔══██╗██║ ██║██╔════╝ +██╔██╗ ██║██║ ██║ ██████╔╝██║ ██║██║ ███╗ +██║╚██╗██║██║ ██║ ██╔══██╗██║ ██║██║ ██║ +██║ ╚████║╚██████╔╝ ██████╔╝╚██████╔╝╚██████╔╝ +╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ diff --git a/yudao-user-server/src/main/resources/logback-spring.xml b/yudao-user-server/src/main/resources/logback-spring.xml new file mode 100644 index 000000000..5bc181fd2 --- /dev/null +++ b/yudao-user-server/src/main/resources/logback-spring.xml @@ -0,0 +1,76 @@ + + + + + + + + + +       + + + ${PATTERN_DEFAULT} + + + + + + + + + + ${PATTERN_DEFAULT} + + + + ${LOG_FILE} + + + ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} + + ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} + + ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} + + ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} + + ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} + + + + + + 0 + + 256 + + + + + + + + ${PATTERN_DEFAULT} + + + + + + + + + + + + + + + + + + + + + +