Commit 930cdfe2b26ae2a2d5fc6f0d98b021fda00f0071

Authored by YunaiV
1 parent d0a7c059

创建 yudao-user-server

Showing 20 changed files with 745 additions and 5 deletions
... ... @@ -11,6 +11,7 @@
11 11 <module>yudao-dependencies</module>
12 12 <module>yudao-framework</module>
13 13 <module>yudao-admin-server</module>
  14 + <module>yudao-user-server</module>
14 15 </modules>
15 16  
16 17 <name>${artifactId}</name>
... ...
yudao-admin-server/pom.xml
... ... @@ -110,10 +110,6 @@
110 110 <groupId>cn.smallbun.screw</groupId>
111 111 <artifactId>screw-core</artifactId> <!-- 实现数据库文档 -->
112 112 </dependency>
113   - <dependency>
114   - <groupId>cn.iocoder.boot</groupId>
115   - <artifactId>yudao-spring-boot-starter-mq</artifactId>
116   - </dependency>
117 113  
118 114 </dependencies>
119 115  
... ...
yudao-framework/yudao-spring-boot-starter-biz-dict/src/main/resources/META-INF/spring.factories
1 1 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2   - cn.iocoder.yudao.framework.operatelog.config.YudaoOperateLogAutoConfiguration
  2 + cn.iocoder.yudao.framework.dict.config.YudaoDictAutoConfiguration
... ...
yudao-user-server/pom.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0"
  3 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5 + <parent>
  6 + <groupId>cn.iocoder.boot</groupId>
  7 + <artifactId>yudao</artifactId>
  8 + <version>${revision}</version>
  9 + </parent>
  10 + <modelVersion>4.0.0</modelVersion>
  11 +
  12 + <artifactId>yudao-user-server</artifactId>
  13 + <packaging>jar</packaging>
  14 +
  15 + <name>yudao-admin-server</name>
  16 + <description>用户前台 Server,提供其 API 接口</description>
  17 + <url>https://github.com/YunaiV/ruoyi-vue-pro</url>
  18 +
  19 + <dependencies>
  20 + <!-- 业务组件 -->
  21 + <dependency>
  22 + <groupId>cn.iocoder.boot</groupId>
  23 + <artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
  24 + </dependency>
  25 + <dependency>
  26 + <groupId>cn.iocoder.boot</groupId>
  27 + <artifactId>yudao-spring-boot-starter-biz-sms</artifactId>
  28 + </dependency>
  29 +
  30 + <!-- Web 相关 -->
  31 + <dependency>
  32 + <groupId>cn.iocoder.boot</groupId>
  33 + <artifactId>yudao-spring-boot-starter-web</artifactId>
  34 + </dependency>
  35 +
  36 + <dependency>
  37 + <groupId>cn.iocoder.boot</groupId>
  38 + <artifactId>yudao-spring-boot-starter-security</artifactId>
  39 + </dependency>
  40 +
  41 + <!-- DB 相关 -->
  42 + <dependency>
  43 + <groupId>cn.iocoder.boot</groupId>
  44 + <artifactId>yudao-spring-boot-starter-mybatis</artifactId>
  45 + </dependency>
  46 +
  47 + <dependency>
  48 + <groupId>cn.iocoder.boot</groupId>
  49 + <artifactId>yudao-spring-boot-starter-redis</artifactId>
  50 + </dependency>
  51 +
  52 + <!-- Config 配置中心相关 -->
  53 + <dependency>
  54 + <groupId>cn.iocoder.boot</groupId>
  55 + <artifactId>yudao-spring-boot-starter-config</artifactId>
  56 + </dependency>
  57 +
  58 + <!-- Job 定时任务相关 -->
  59 +
  60 + <!-- 消息队列相关 -->
  61 + <dependency>
  62 + <groupId>cn.iocoder.boot</groupId>
  63 + <artifactId>yudao-spring-boot-starter-mq</artifactId>
  64 + </dependency>
  65 +
  66 + <!-- 服务保障相关 -->
  67 + <dependency>
  68 + <groupId>cn.iocoder.boot</groupId>
  69 + <artifactId>yudao-spring-boot-starter-protection</artifactId>
  70 + </dependency>
  71 +
  72 + <!-- 监控相关 -->
  73 + <dependency>
  74 + <groupId>cn.iocoder.boot</groupId>
  75 + <artifactId>yudao-spring-boot-starter-monitor</artifactId>
  76 + </dependency>
  77 +
  78 + <!-- Test 测试相关 -->
  79 + <dependency>
  80 + <groupId>cn.iocoder.boot</groupId>
  81 + <artifactId>yudao-spring-boot-starter-test</artifactId>
  82 + <scope>test</scope>
  83 + </dependency>
  84 +
  85 + <!-- 工具类相关 -->
  86 +
  87 + </dependencies>
  88 +
  89 + <build>
  90 + <!-- 设置构建的 jar 包名 -->
  91 + <finalName>${artifactId}</finalName>
  92 + <plugins>
  93 + <!-- 打包 -->
  94 + <plugin>
  95 + <groupId>org.springframework.boot</groupId>
  96 + <artifactId>spring-boot-maven-plugin</artifactId>
  97 + <configuration>
  98 + <fork>true</fork>
  99 + </configuration>
  100 + <executions>
  101 + <execution>
  102 + <goals>
  103 + <goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
  104 + </goals>
  105 + </execution>
  106 + </executions>
  107 + </plugin>
  108 + </plugins>
  109 + </build>
  110 +
  111 +</project>
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/UserServerApplication.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver;
  2 +
  3 +import org.springframework.boot.SpringApplication;
  4 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  5 +
  6 +@SpringBootApplication
  7 +public class UserServerApplication {
  8 +
  9 + public static void main(String[] args) {
  10 + SpringApplication.run(UserServerApplication.class, args);
  11 + }
  12 +
  13 +}
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/config/AsyncConfiguration.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.framework.async.config;
  2 +
  3 +import org.springframework.context.annotation.Configuration;
  4 +import org.springframework.scheduling.annotation.EnableAsync;
  5 +
  6 +@Configuration
  7 +@EnableAsync
  8 +public class AsyncConfiguration {
  9 +}
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/package-info.java 0 → 100644
  1 +/**
  2 + * 异步执行,基于 Spring @Async 实现
  3 + */
  4 +package cn.iocoder.yudao.userserver.framework.async;
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/async/《芋道 Spring Boot 异步任务入门》.md 0 → 100644
  1 +<http://www.iocoder.cn/Spring-Boot/Async-Job/?yudao>
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/package-info.java 0 → 100644
  1 +/**
  2 + * 属于整个 yudao-user-server 的 framework 封装
  3 + *
  4 + * @author 芋道源码
  5 + */
  6 +package cn.iocoder.yudao.userserver.framework;
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.config;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.Data;
  8 +import lombok.EqualsAndHashCode;
  9 +import lombok.ToString;
  10 +
  11 +/**
  12 + * 参数配置表
  13 + *
  14 + * @author ruoyi
  15 + */
  16 +@TableName("inf_config")
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +public class InfConfigDO extends BaseDO {
  21 +
  22 + /**
  23 + * 参数主键
  24 + */
  25 + @TableId
  26 + private Long id;
  27 + /**
  28 + * 参数分组
  29 + */
  30 + @TableField("`group`")
  31 + private String group;
  32 + /**
  33 + * 参数名称
  34 + */
  35 + private String name;
  36 + /**
  37 + * 参数键名
  38 + */
  39 + @TableField("`key`")
  40 + private String key;
  41 + /**
  42 + * 参数键值
  43 + */
  44 + private String value;
  45 + /**
  46 + * 参数类型
  47 + *
  48 + * 枚举 {@link InfConfigTypeEnum}
  49 + */
  50 + @TableField("`type`")
  51 + private Integer type;
  52 + /**
  53 + * 是否敏感
  54 + *
  55 + * 对于敏感配置,需要管理权限才能查看
  56 + */
  57 + @TableField("`sensitive`")
  58 + private Boolean sensitive;
  59 + /**
  60 + * 备注
  61 + */
  62 + private String remark;
  63 +
  64 +}
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.IdType;
  5 +import com.baomidou.mybatisplus.annotation.TableField;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import lombok.*;
  9 +
  10 +import java.io.InputStream;
  11 +
  12 +/**
  13 + * 文件表
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Data
  18 +@TableName("inf_file")
  19 +@EqualsAndHashCode(callSuper = true)
  20 +@ToString(callSuper = true)
  21 +@Builder
  22 +@NoArgsConstructor
  23 +@AllArgsConstructor
  24 +public class InfFileDO extends BaseDO {
  25 +
  26 + /**
  27 + * 文件路径
  28 + */
  29 + @TableId(type = IdType.INPUT)
  30 + private String id;
  31 + /**
  32 + * 文件类型
  33 + *
  34 + * 通过 {@link cn.hutool.core.io.FileTypeUtil#getType(InputStream)} 获取
  35 + */
  36 + @TableField(value = "`type`")
  37 + private String type;
  38 + /**
  39 + * 文件内容
  40 + */
  41 + private byte[] content;
  42 +
  43 +}
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config;
  2 +
  3 +import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO;
  4 +import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO;
  5 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  6 +import org.springframework.jdbc.core.JdbcTemplate;
  7 +import org.springframework.jdbc.datasource.DriverManagerDataSource;
  8 +
  9 +import javax.sql.DataSource;
  10 +import java.sql.ResultSet;
  11 +import java.util.Date;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * ConfigFrameworkDAO 实现类
  16 + *
  17 + * @author 芋道源码
  18 + */
  19 +public class InfConfigDAOImpl implements ConfigFrameworkDAO {
  20 +
  21 + private final JdbcTemplate jdbcTemplate;
  22 +
  23 + public InfConfigDAOImpl(String jdbcUrl, String username, String password) {
  24 + DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password);
  25 + this.jdbcTemplate = new JdbcTemplate(dataSource);
  26 + }
  27 +
  28 + @Override
  29 + public boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
  30 + return jdbcTemplate.query("SELECT id FROM inf_config WHERE update_time > ? LIMIT 1",
  31 + ResultSet::next, maxUpdateTime);
  32 + }
  33 +
  34 + @Override
  35 + public List<ConfigRespDTO> selectList() {
  36 + return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(ConfigRespDTO.class));
  37 + }
  38 +
  39 +}
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.file;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  4 +import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file.InfFileDO;
  5 +import org.apache.ibatis.annotations.Mapper;
  6 +
  7 +@Mapper
  8 +public interface InfFileMapper extends BaseMapperX<InfFileDO> {
  9 +
  10 +}
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java 0 → 100644
  1 +/**
  2 + * infra 包下,我们放基础设施的运维与管理,支撑上层的通用与核心业务。
  3 + * 例如说:定时任务的管理、服务器的信息等等
  4 + *
  5 + * 缩写:inf
  6 + */
  7 +package cn.iocoder.yudao.userserver.modules.infra;
... ...
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/package-info.java 0 → 100644
  1 +package cn.iocoder.yudao.userserver.modules;
... ...
yudao-user-server/src/main/resources/application-dev.yaml 0 → 100644
  1 +server:
  2 + port: 28080
  3 +
  4 +--- #################### 数据库相关配置 ####################
  5 +
  6 +spring:
  7 + # 数据源配置项
  8 + autoconfigure:
  9 + exclude:
  10 + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
  11 + datasource:
  12 + druid: # Druid 【监控】相关的全局配置
  13 + web-stat-filter:
  14 + enabled: true
  15 + stat-view-servlet:
  16 + enabled: true
  17 + allow: # 设置白名单,不填则允许所有访问
  18 + url-pattern: /druid/*
  19 + login-username: # 控制台管理用户名和密码
  20 + login-password:
  21 + filter:
  22 + stat:
  23 + enabled: true
  24 + log-slow-sql: true # 慢 SQL 记录
  25 + slow-sql-millis: 100
  26 + merge-sql: true
  27 + wall:
  28 + config:
  29 + multi-statement-allow: true
  30 + dynamic: # 多数据源配置
  31 + druid: # Druid 【连接池】相关的全局配置
  32 + initial-size: 5 # 初始连接数
  33 + min-idle: 10 # 最小连接池数量
  34 + max-active: 20 # 最大连接池数量
  35 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
  36 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
  37 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
  38 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
  39 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
  40 + test-while-idle: true
  41 + test-on-borrow: false
  42 + test-on-return: false
  43 + primary: master
  44 + datasource:
  45 + master:
  46 + name: ruoyi-vue-pro
  47 + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
  48 + driver-class-name: com.mysql.jdbc.Driver
  49 + username: root
  50 + password: 3WLiVUBEwTbvAfsh
  51 + slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
  52 + name: ruoyi-vue-pro
  53 + url: jdbc:mysql://400-infra.server.iocoder.cn:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
  54 + driver-class-name: com.mysql.jdbc.Driver
  55 + username: root
  56 + password: 3WLiVUBEwTbvAfsh
  57 +
  58 + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
  59 + redis:
  60 + host: 400-infra.server.iocoder.cn # 地址
  61 + port: 6379 # 端口
  62 + database: 1 # 数据库索引
  63 +
  64 +--- #################### 定时任务相关配置 ####################
  65 +
  66 +--- #################### 配置中心相关配置 ####################
  67 +
  68 +# Apollo 配置中心
  69 +apollo:
  70 + bootstrap:
  71 + enabled: true # 设置 Apollo 在启动阶段生效
  72 + eagerLoad:
  73 + enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
  74 + jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
  75 + dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl
  76 + url: ${spring.datasource.dynamic.datasource.master.url}
  77 + username: ${spring.datasource.dynamic.datasource.master.username}
  78 + password: ${spring.datasource.dynamic.datasource.master.password}
  79 +
  80 +--- #################### 服务保障相关配置 ####################
  81 +
  82 +# Lock4j 配置项
  83 +lock4j:
  84 + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
  85 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
  86 +
  87 +# Resilience4j 配置项
  88 +resilience4j:
  89 + ratelimiter:
  90 + instances:
  91 + backendA:
  92 + limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50
  93 + limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500
  94 + timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s
  95 + register-health-indicator: true # 是否注册到健康监测
  96 +
  97 +--- #################### 监控相关配置 ####################
  98 +
  99 +# Actuator 监控端点的配置项
  100 +management:
  101 + endpoints:
  102 + web:
  103 + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
  104 + exposure:
  105 + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
  106 +
  107 +# Spring Boot Admin 配置项
  108 +spring:
  109 + boot:
  110 + admin:
  111 + # Spring Boot Admin Client 客户端的相关配置
  112 + client:
  113 + url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
  114 + instance:
  115 + prefer-ip: true # 注册实例时,优先使用 IP
  116 +
  117 +# 日志文件配置
  118 +logging:
  119 + file:
  120 + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
  121 +
  122 +--- #################### 芋道相关配置 ####################
  123 +
  124 +# 芋道配置项,设置当前项目所有自定义的配置
  125 +yudao:
  126 + security:
  127 + token-header: Authorization
  128 + token-secret: abcdefghijklmnopqrstuvwxyz
  129 + token-timeout: 1d
  130 + session-timeout: 30m
  131 + mock-enable: true
  132 + mock-secret: test
  133 + file:
  134 + base-path: http://api-dashboard.yudao.iocoder.cn${yudao.web.api-prefix}/infra/file/get/
  135 + xss:
  136 + enable: false
  137 + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
  138 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
  139 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
  140 + demo: true # 开启演示模式
... ...
yudao-user-server/src/main/resources/application-local.yaml 0 → 100644
  1 +server:
  2 + port: 28080
  3 +
  4 +--- #################### 数据库相关配置 ####################
  5 +
  6 +spring:
  7 + # 数据源配置项
  8 + autoconfigure:
  9 + exclude:
  10 + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源
  11 + datasource:
  12 + druid: # Druid 【监控】相关的全局配置
  13 + web-stat-filter:
  14 + enabled: true
  15 + stat-view-servlet:
  16 + enabled: true
  17 + allow: # 设置白名单,不填则允许所有访问
  18 + url-pattern: /druid/*
  19 + login-username: # 控制台管理用户名和密码
  20 + login-password:
  21 + filter:
  22 + stat:
  23 + enabled: true
  24 + log-slow-sql: true # 慢 SQL 记录
  25 + slow-sql-millis: 100
  26 + merge-sql: true
  27 + wall:
  28 + config:
  29 + multi-statement-allow: true
  30 + dynamic: # 多数据源配置
  31 + druid: # Druid 【连接池】相关的全局配置
  32 + initial-size: 5 # 初始连接数
  33 + min-idle: 10 # 最小连接池数量
  34 + max-active: 20 # 最大连接池数量
  35 + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒
  36 + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒
  37 + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒
  38 + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒
  39 + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
  40 + test-while-idle: true
  41 + test-on-borrow: false
  42 + test-on-return: false
  43 + primary: master
  44 + datasource:
  45 + master:
  46 + name: ruoyi-vue-pro
  47 + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
  48 + driver-class-name: com.mysql.jdbc.Driver
  49 + username: root
  50 + password: 123456
  51 + slave: # 模拟从库,可根据自己需要修改
  52 + name: ruoyi-vue-pro
  53 + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT
  54 + driver-class-name: com.mysql.jdbc.Driver
  55 + username: root
  56 + password: 123456
  57 +
  58 + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
  59 + redis:
  60 + host: 127.0.0.1 # 地址
  61 + port: 6379 # 端口
  62 + database: 0 # 数据库索引
  63 +
  64 +--- #################### 定时任务相关配置 ####################
  65 +
  66 +--- #################### 配置中心相关配置 ####################
  67 +
  68 +# Apollo 配置中心
  69 +apollo:
  70 + bootstrap:
  71 + enabled: true # 设置 Apollo 在启动阶段生效
  72 + eagerLoad:
  73 + enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置
  74 + jdbc: # 自定义的 JDBC 配置项,用于数据库的地址
  75 + dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl
  76 + url: ${spring.datasource.dynamic.datasource.master.url}
  77 + username: ${spring.datasource.dynamic.datasource.master.username}
  78 + password: ${spring.datasource.dynamic.datasource.master.password}
  79 +
  80 +--- #################### 服务保障相关配置 ####################
  81 +
  82 +# Lock4j 配置项
  83 +lock4j:
  84 + acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒
  85 + expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒
  86 +
  87 +# Resilience4j 配置项
  88 +resilience4j:
  89 + ratelimiter:
  90 + instances:
  91 + backendA:
  92 + limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50
  93 + limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500
  94 + timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s
  95 + register-health-indicator: true # 是否注册到健康监测
  96 +
  97 +--- #################### 监控相关配置 ####################
  98 +
  99 +# Actuator 监控端点的配置项
  100 +management:
  101 + endpoints:
  102 + web:
  103 + base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator
  104 + exposure:
  105 + include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
  106 +
  107 +# Spring Boot Admin 配置项
  108 +spring:
  109 + boot:
  110 + admin:
  111 + # Spring Boot Admin Client 客户端的相关配置
  112 + client:
  113 + url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path} # 设置 Spring Boot Admin Server 地址
  114 + instance:
  115 + prefer-ip: true # 注册实例时,优先使用 IP
  116 + # Spring Boot Admin Server 服务端的相关配置
  117 + context-path: /admin # 配置 Spring
  118 +
  119 +# 日志文件配置
  120 +logging:
  121 + file:
  122 + name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
  123 +
  124 +--- #################### 芋道相关配置 ####################
  125 +
  126 +# 芋道配置项,设置当前项目所有自定义的配置
  127 +yudao:
  128 + security:
  129 + token-header: Authorization
  130 + token-secret: abcdefghijklmnopqrstuvwxyz
  131 + token-timeout: 1d
  132 + session-timeout: 30m
  133 + mock-enable: true
  134 + mock-secret: test
  135 + file:
  136 + base-path: http://127.0.0.1:${server.port}${yudao.web.api-prefix}/infra/file/get/
  137 + xss:
  138 + enable: false
  139 + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系
  140 + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
  141 + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
  142 + demo: false # 关闭演示模式
... ...
yudao-user-server/src/main/resources/application.yaml 0 → 100644
  1 +spring:
  2 + application:
  3 + name: yudao-user-server
  4 +
  5 + profiles:
  6 + active: local
  7 +
  8 + # Servlet 配置
  9 + servlet:
  10 + # 文件上传相关配置项
  11 + multipart:
  12 + max-file-size: 16MB # 单个文件大小
  13 + max-request-size: 32MB # 设置总上传的文件大小
  14 +
  15 + # Jackson 配置项
  16 + jackson:
  17 + serialization:
  18 + write-dates-as-timestamps: true # 设置 Date 的格式,使用时间戳
  19 + write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401
  20 + write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳
  21 + fail-on-empty-beans: false # 允许序列化无属性的 Bean
  22 +
  23 +# MyBatis Plus 的配置项
  24 +mybatis-plus:
  25 + configuration:
  26 + map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
  27 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印日志
  28 + global-config:
  29 + db-config:
  30 + id-type: AUTO # 自增 ID
  31 + logic-delete-value: 1 # 逻辑已删除值(默认为 1)
  32 + logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
  33 + mapper-locations: classpath*:mapper/*.xml
  34 + type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject
  35 +
  36 +--- #################### 芋道相关配置 ####################
  37 +
  38 +yudao:
  39 + info:
  40 + version: 1.0.0
  41 + base-package: cn.iocoder.yudao.userserver
  42 + web:
  43 + api-prefix: /api
  44 + controller-package: ${yudao.info.base-package}
  45 + swagger:
  46 + title: 管理后台
  47 + description: 提供管理员管理的所有功能
  48 + version: ${yudao.info.version}
  49 + base-package: ${yudao.info.base-package}.modules
  50 + captcha:
  51 + timeout: 5m
  52 + width: 160
  53 + height: 60
  54 + codegen:
  55 + base-package: ${yudao.info.base-package}
  56 + db-schemas: ${spring.datasource.dynamic.datasource.master.name}
  57 + error-code: # 错误码相关配置项
  58 + constants-class-list:
  59 +
  60 +debug: false
... ...
yudao-user-server/src/main/resources/banner.txt 0 → 100644
  1 +芋道源码 http://www.iocoder.cn
  2 +Application Version: ${yudao.info.version}
  3 +Spring Boot Version: ${spring-boot.version}
  4 +
  5 +.__ __. ______ .______ __ __ _______
  6 +| \ | | / __ \ | _ \ | | | | / _____|
  7 +| \| | | | | | | |_) | | | | | | | __
  8 +| . ` | | | | | | _ < | | | | | | |_ |
  9 +| |\ | | `--' | | |_) | | `--' | | |__| |
  10 +|__| \__| \______/ |______/ \______/ \______|
  11 +
  12 +███╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗
  13 +████╗ ██║██╔═══██╗ ██╔══██╗██║ ██║██╔════╝
  14 +██╔██╗ ██║██║ ██║ ██████╔╝██║ ██║██║ ███╗
  15 +██║╚██╗██║██║ ██║ ██╔══██╗██║ ██║██║ ██║
  16 +██║ ╚████║╚██████╔╝ ██████╔╝╚██████╔╝╚██████╔╝
  17 +╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝
... ...
yudao-user-server/src/main/resources/logback-spring.xml 0 → 100644
  1 +<configuration>
  2 + <!-- 引用 Spring Boot 的 logback 基础配置 -->
  3 + <include resource="org/springframework/boot/logging/logback/defaults.xml" />
  4 + <!-- 变量 yudao.info.base-package,基础业务包 -->
  5 + <springProperty scope="context" name="yudao.info.base-package" source="yudao.info.base-package"/>
  6 + <!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level:级别从左显示 5 个字符宽度,%msg:日志消息,%n是换行符 -->
  7 + <property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } --- [%thread] [%tid] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
  8 +
  9 + <!-- 控制台 Appender -->
  10 + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">     
  11 + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
  12 + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
  13 + <pattern>${PATTERN_DEFAULT}</pattern>
  14 + </layout>
  15 + </encoder>
  16 + </appender>
  17 +
  18 + <!-- 文件 Appender -->
  19 + <!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
  20 + <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  21 + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
  22 + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
  23 + <pattern>${PATTERN_DEFAULT}</pattern>
  24 + </layout>
  25 + </encoder>
  26 + <!-- 日志文件名 -->
  27 + <file>${LOG_FILE}</file>
  28 + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  29 + <!-- 滚动后的日志文件名 -->
  30 + <fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
  31 + <!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
  32 + <cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
  33 + <!-- 日志文件,到达多少容量,进行滚动 -->
  34 + <maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
  35 + <!-- 日志文件的总大小,0 表示不限制 -->
  36 + <totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
  37 + <!-- 日志文件的保留天数 -->
  38 + <maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
  39 + </rollingPolicy>
  40 + </appender>
  41 + <!-- 异步写入日志,提升性能 -->
  42 + <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
  43 + <!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
  44 + <discardingThreshold>0</discardingThreshold>
  45 + <!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
  46 + <queueSize>256</queueSize>
  47 + <appender-ref ref="FILE"/>
  48 + </appender>
  49 +
  50 + <!-- SkyWalking GRPC 日志收集,实现日志中心。注意:SkyWalking 8.4.0 版本开始支持 -->
  51 + <appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
  52 + <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
  53 + <layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
  54 + <pattern>${PATTERN_DEFAULT}</pattern>
  55 + </layout>
  56 + </encoder>
  57 + </appender>
  58 +
  59 + <!-- 本地环境 -->
  60 + <springProfile name="local">
  61 + <root level="INFO">
  62 + <appender-ref ref="STDOUT"/>
  63 + <appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
  64 + <appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
  65 + </root>
  66 + </springProfile>
  67 + <!-- 其它环境 -->
  68 + <springProfile name="default">
  69 + <root level="INFO">
  70 + <appender-ref ref="STDOUT"/>
  71 + <appender-ref ref="ASYNC"/>
  72 + <appender-ref ref="GRPC"/>
  73 + </root>
  74 + </springProfile>
  75 +
  76 +</configuration>
... ...