mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2026-01-12 02:06:00 +08:00
Compare commits
77 Commits
v5.2.1
...
7f60ba9888
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f60ba9888 | ||
|
|
31569646b0 | ||
|
|
3fc37d6362 | ||
|
|
6d28072167 | ||
|
|
f124fbd6aa | ||
|
|
88a4a51956 | ||
|
|
4306ea4181 | ||
|
|
e19140462d | ||
|
|
20cc8a6d6c | ||
|
|
a9d7a42c65 | ||
|
|
f51e6d81b1 | ||
|
|
f119d082cf | ||
|
|
ecfaa9ad5c | ||
|
|
f32d0266ee | ||
|
|
7393a61305 | ||
|
|
2b0efd1f93 | ||
|
|
b615a3b088 | ||
|
|
85403e975f | ||
|
|
615ad918ca | ||
|
|
b886f3a04b | ||
|
|
588a47897a | ||
|
|
2869d590e6 | ||
|
|
6b14bce25e | ||
|
|
5aa346327f | ||
|
|
fcf8516f0d | ||
|
|
2a340d4d83 | ||
|
|
508d7a37e3 | ||
|
|
08fece39d8 | ||
|
|
857a0b1006 | ||
|
|
239d59c864 | ||
|
|
7297053dd6 | ||
|
|
bd872f624a | ||
|
|
86acb14f05 | ||
|
|
9825f349ac | ||
|
|
19fd562c24 | ||
|
|
b6d939a9ff | ||
|
|
1619edb8a1 | ||
|
|
782821aeb2 | ||
|
|
51498958fa | ||
|
|
51edb74474 | ||
|
|
d5ab2a7557 | ||
|
|
ee3525cfb2 | ||
|
|
e9bd0858e2 | ||
|
|
f46d881866 | ||
|
|
ee5e718f83 | ||
|
|
e25083aea4 | ||
|
|
e74f0ca6f8 | ||
|
|
52b0fa9a54 | ||
|
|
105c007f03 | ||
|
|
0a3d5fd5d4 | ||
|
|
ae3c02d4b2 | ||
|
|
9e17d07a17 | ||
|
|
dcfab4e011 | ||
|
|
0b78f9361d | ||
|
|
0c4e9dc813 | ||
|
|
d894cae073 | ||
|
|
84f553a911 | ||
|
|
05580deaa9 | ||
|
|
aac83bbb91 | ||
|
|
249f1f48a6 | ||
|
|
bfb92fe667 | ||
|
|
640dc43bbe | ||
|
|
8859d915b0 | ||
|
|
82fdb37c6b | ||
|
|
49c18dab63 | ||
|
|
f5b8a22bde | ||
|
|
b6b0f9c47d | ||
|
|
a2a2fa2311 | ||
|
|
34690e3e65 | ||
|
|
54f58257f9 | ||
|
|
58b6c4668f | ||
|
|
d0e7eb8409 | ||
|
|
77a7a8f30e | ||
|
|
f76738e02b | ||
|
|
ab147df2f1 | ||
|
|
5444ccc857 | ||
|
|
fc89d62f1a |
@@ -1,49 +0,0 @@
|
||||
### 使用版本(未按照模板填写直接删除)
|
||||
|
||||
- jdk版本(带上尾号): 例如 1.8.0_202
|
||||
- 框架版本(项目启动时输出的版本号): 例如 4.4.0
|
||||
- 其他依赖版本(你觉得有必要的):
|
||||
|
||||
### 问题前提
|
||||
|
||||
> 功能不好用 不会用 是否已经看过项目文档
|
||||
> 项目运行报错 是否已经拿着报错信息去百度 常见报错百度百度足以
|
||||
> 是否搜索过其他issue 一些已经解决的问题 会在issue内留下解决方法
|
||||
> 无法线上解决或者与框架无关的问题的欢迎加VIP群跟作者一对一谈
|
||||
|
||||
### 异常模块
|
||||
|
||||
> 此报错都涉及到那些系统模块
|
||||
|
||||
例如 ruoyi-system ruoyi-auth 等等
|
||||
|
||||
### 问题描述
|
||||
|
||||
> 越详细越容易直击问题所在
|
||||
|
||||
已知: XXX功能不好用 或 XXX数据不正常 等等
|
||||
|
||||
### 希望结果
|
||||
|
||||
> 想知道你觉得怎么样是正常或者合理的
|
||||
|
||||
希望功能可以有XXX结果 或者 XXX现象
|
||||
|
||||
### 重现步骤
|
||||
|
||||
> 作者并不知道这个问题是如何出现的
|
||||
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
|
||||
### 相关代码与报错信息(请勿发混乱格式)
|
||||
|
||||
> 代码可按照如下形式提供或者截图均可 越详细越好
|
||||
> 大多数问题都是 代码编写错误问题 逻辑问题 或者用法错误等问题
|
||||
|
||||
```java
|
||||
public class XXX {
|
||||
|
||||
}
|
||||
```
|
||||
@@ -9,8 +9,9 @@ body:
|
||||
label: 版本
|
||||
description: 你当前正在使用我们软件的哪个版本(pom文件内的版本号)?
|
||||
value: |
|
||||
jdk版本(带上尾号): 例如 17.0.8
|
||||
框架版本(项目启动时输出的版本号): 例如 5.1.1
|
||||
注意: 未填写版本号不予处理直接关闭或删除
|
||||
jdk版本(带上尾号):
|
||||
框架版本(项目启动时输出的版本号):
|
||||
其他依赖版本(你觉得有必要的):
|
||||
validations:
|
||||
required: true
|
||||
|
||||
@@ -61,6 +61,7 @@ CCFlow 驰聘低代码-流程-表单 - https://gitee.com/opencc/RuoYi-JFlow <br>
|
||||
| 数据库连接池 | 采用 HikariCP Spring官方内置连接池 配置简单 以性能与稳定性闻名天下 | 采用 druid bug众多 社区维护差 活跃度低 配置众多繁琐性能一般 |
|
||||
| 数据库主键 | 采用 雪花ID 基于时间戳的 有序增长 唯一ID 再也不用为分库分表 数据合并主键冲突重复而发愁 | 采用 数据库自增ID 支持数据量有限 不支持多数据源主键唯一 |
|
||||
| WebSocket协议 | 基于 Spring 封装的 WebSocket 协议 扩展了Token鉴权与分布式会话同步 不再只是基于单机的废物 | 无 |
|
||||
| SSE推送 | 采用 Spring SSE 实现 扩展了Token鉴权与分布式会话同步 | 无 |
|
||||
| 序列化 | 采用 Jackson Spring官方内置序列化 靠谱!!! | 采用 fastjson bugjson 远近闻名 |
|
||||
| 分布式幂等 | 参考美团GTIS防重系统简化实现(细节可看文档) | 手动编写注解基于aop实现 |
|
||||
| 分布式锁 | 采用 Lock4j 底层基于 Redisson | 无 |
|
||||
@@ -72,6 +73,7 @@ CCFlow 驰聘低代码-流程-表单 - https://gitee.com/opencc/RuoYi-JFlow <br>
|
||||
| 接口文档 | 采用 SpringDoc、javadoc 无注解零入侵基于java注释<br/>只需把注释写好 无需再写一大堆的文档注解了 | 采用 Springfox 已停止维护 需要编写大量的注解来支持文档生成 |
|
||||
| 校验框架 | 采用 Validation 支持注解与工具类校验 注解支持国际化 | 仅支持注解 且注解不支持国际化 |
|
||||
| Excel框架 | 采用 Alibaba EasyExcel 基于插件化<br/>框架对其增加了很多功能 例如 自动合并相同内容 自动排列布局 字典翻译等 | 基于 POI 手写实现 功能有限 复杂 扩展性差 |
|
||||
| 工作流支持 | 支持各种复杂审批 转办 委派 加减签 会签 或签 票签 等功能 | 无 |
|
||||
| 工具类框架 | 采用 Hutool、Lombok 上百种工具覆盖90%的使用需求 基于注解自动生成 get set 等简化框架大量代码 | 手写工具稳定性差易出问题 工具数量有限 代码臃肿需自己手写 get set 等 |
|
||||
| 监控框架 | 采用 SpringBoot-Admin 基于SpringBoot官方 actuator 探针机制<br/>实时监控服务状态 框架还为其扩展了在线日志查看监控 | 无 |
|
||||
| 链路追踪 | 采用 Apache SkyWalking 还在为请求不知道去哪了 到哪出了问题而烦恼吗<br/>用了它即可实时查看请求经过的每一处每一个节点 | 无 |
|
||||
|
||||
62
pom.xml
62
pom.xml
@@ -14,44 +14,46 @@
|
||||
|
||||
<properties>
|
||||
<revision>5.2.1</revision>
|
||||
<spring-boot.version>3.2.6</spring-boot.version>
|
||||
<spring-boot.version>3.2.8</spring-boot.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>17</java.version>
|
||||
<mybatis.version>3.5.16</mybatis.version>
|
||||
<springdoc.version>2.5.0</springdoc.version>
|
||||
<springdoc.version>2.6.0</springdoc.version>
|
||||
<therapi-javadoc.version>0.15.0</therapi-javadoc.version>
|
||||
<poi.version>5.2.3</poi.version>
|
||||
<easyexcel.version>3.3.4</easyexcel.version>
|
||||
<easyexcel.version>4.0.2</easyexcel.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<satoken.version>1.38.0</satoken.version>
|
||||
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
||||
<p6spy.version>3.9.1</p6spy.version>
|
||||
<hutool.version>5.8.27</hutool.version>
|
||||
<hutool.version>5.8.29</hutool.version>
|
||||
<okhttp.version>4.10.0</okhttp.version>
|
||||
<spring-boot-admin.version>3.2.3</spring-boot-admin.version>
|
||||
<redisson.version>3.31.0</redisson.version>
|
||||
<redisson.version>3.34.1</redisson.version>
|
||||
<lock4j.version>2.2.7</lock4j.version>
|
||||
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
||||
<alibaba-ttl.version>2.14.4</alibaba-ttl.version>
|
||||
<snailjob.version>1.0.1</snailjob.version>
|
||||
<mapstruct-plus.version>1.3.6</mapstruct-plus.version>
|
||||
<snailjob.version>1.1.1</snailjob.version>
|
||||
<mapstruct-plus.version>1.4.3</mapstruct-plus.version>
|
||||
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
||||
<lombok.version>1.18.32</lombok.version>
|
||||
<lombok.version>1.18.34</lombok.version>
|
||||
<bouncycastle.version>1.76</bouncycastle.version>
|
||||
<justauth.version>1.16.6</justauth.version>
|
||||
<!-- 离线IP地址定位库 -->
|
||||
<ip2region.version>2.7.0</ip2region.version>
|
||||
<undertow.version>2.3.15.Final</undertow.version>
|
||||
|
||||
<!-- OSS 配置 -->
|
||||
<aws.sdk.version>2.25.15</aws.sdk.version>
|
||||
<aws.crt.version>0.29.13</aws.crt.version>
|
||||
<!-- SMS 配置 -->
|
||||
<sms4j.version>3.2.1</sms4j.version>
|
||||
<sms4j.version>3.3.1</sms4j.version>
|
||||
<!-- 限制框架中的fastjson版本 -->
|
||||
<fastjson.version>1.2.83</fastjson.version>
|
||||
<!-- 面向运行时的D-ORM依赖 -->
|
||||
<anyline.version>8.7.2-20240728</anyline.version>
|
||||
<!--工作流配置-->
|
||||
<flowable.version>7.0.0</flowable.version>
|
||||
<flowable.version>7.0.1</flowable.version>
|
||||
|
||||
<!-- 插件版本 -->
|
||||
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
|
||||
@@ -155,26 +157,10 @@
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>${easyexcel.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- velocity代码生成使用模板 -->
|
||||
@@ -333,6 +319,28 @@
|
||||
<version>${ip2region.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.undertow</groupId>
|
||||
<artifactId>undertow-core</artifactId>
|
||||
<version>${undertow.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.undertow</groupId>
|
||||
<artifactId>undertow-servlet</artifactId>
|
||||
<version>${undertow.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.undertow</groupId>
|
||||
<artifactId>undertow-websockets-jsr</artifactId>
|
||||
<version>${undertow.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<version>1.26.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
|
||||
@@ -22,21 +22,28 @@
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<!-- Oracle -->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
</dependency>
|
||||
<!-- PostgreSql -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<!-- SqlServer -->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.sqlserver</groupId>
|
||||
<artifactId>mssql-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– mp支持的数据库均支持 只需要增加对应的jdbc依赖即可 –>-->
|
||||
<!-- <!– Oracle –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
|
||||
<!-- <artifactId>ojdbc8</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– 兼容oracle低版本 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.oracle.database.nls</groupId>-->
|
||||
<!-- <artifactId>orai18n</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– PostgreSql –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.postgresql</groupId>-->
|
||||
<!-- <artifactId>postgresql</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– SqlServer –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.microsoft.sqlserver</groupId>-->
|
||||
<!-- <artifactId>mssql-jdbc</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
|
||||
@@ -24,9 +24,9 @@ import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.social.config.properties.SocialLoginConfigProperties;
|
||||
import org.dromara.common.social.config.properties.SocialProperties;
|
||||
import org.dromara.common.social.utils.SocialUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.common.websocket.dto.WebSocketMessageDto;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
@@ -102,11 +102,11 @@ public class AuthController {
|
||||
|
||||
Long userId = LoginHelper.getUserId();
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
WebSocketMessageDto dto = new WebSocketMessageDto();
|
||||
SseMessageDto dto = new SseMessageDto();
|
||||
dto.setMessage("欢迎登录RuoYi-Vue-Plus后台管理系统");
|
||||
dto.setSessionKeys(List.of(userId));
|
||||
WebSocketUtils.publishMessage(dto);
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
dto.setUserIds(List.of(userId));
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
return R.ok(loginVo);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.dromara.web.listener;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.listener.SaTokenListener;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.http.useragent.UserAgent;
|
||||
import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -81,7 +83,10 @@ public class UserActionListener implements SaTokenListener {
|
||||
*/
|
||||
@Override
|
||||
public void doLogout(String loginType, Object loginId, String tokenValue) {
|
||||
RedisUtils.deleteObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue);
|
||||
String tenantId = Convert.toStr(StpUtil.getExtra(tokenValue, LoginHelper.TENANT_KEY));
|
||||
TenantHelper.dynamic(tenantId, () -> {
|
||||
RedisUtils.deleteObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue);
|
||||
});
|
||||
log.info("user doLogout, userId:{}, token:{}", loginId, tokenValue);
|
||||
}
|
||||
|
||||
@@ -90,7 +95,10 @@ public class UserActionListener implements SaTokenListener {
|
||||
*/
|
||||
@Override
|
||||
public void doKickout(String loginType, Object loginId, String tokenValue) {
|
||||
RedisUtils.deleteObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue);
|
||||
String tenantId = Convert.toStr(StpUtil.getExtra(tokenValue, LoginHelper.TENANT_KEY));
|
||||
TenantHelper.dynamic(tenantId, () -> {
|
||||
RedisUtils.deleteObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue);
|
||||
});
|
||||
log.info("user doKickout, userId:{}, token:{}", loginId, tokenValue);
|
||||
}
|
||||
|
||||
@@ -99,7 +107,10 @@ public class UserActionListener implements SaTokenListener {
|
||||
*/
|
||||
@Override
|
||||
public void doReplaced(String loginType, Object loginId, String tokenValue) {
|
||||
RedisUtils.deleteObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue);
|
||||
String tenantId = Convert.toStr(StpUtil.getExtra(tokenValue, LoginHelper.TENANT_KEY));
|
||||
TenantHelper.dynamic(tenantId, () -> {
|
||||
RedisUtils.deleteObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue);
|
||||
});
|
||||
log.info("user doReplaced, userId:{}, token:{}", loginId, tokenValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
import org.dromara.common.core.constant.CacheConstants;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.domain.dto.RoleDTO;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
@@ -155,16 +156,11 @@ public class SysLoginService {
|
||||
loginUser.setUserType(user.getUserType());
|
||||
loginUser.setMenuPermission(permissionService.getMenuPermission(user.getUserId()));
|
||||
loginUser.setRolePermission(permissionService.getRolePermission(user.getUserId()));
|
||||
TenantHelper.dynamic(user.getTenantId(), () -> {
|
||||
SysDeptVo dept = null;
|
||||
if (ObjectUtil.isNotNull(user.getDeptId())) {
|
||||
dept = deptService.selectDeptById(user.getDeptId());
|
||||
}
|
||||
loginUser.setDeptName(ObjectUtil.isNull(dept) ? "" : dept.getDeptName());
|
||||
loginUser.setDeptCategory(ObjectUtil.isNull(dept) ? "" : dept.getDeptCategory());
|
||||
List<SysRoleVo> roles = roleService.selectRolesByUserId(user.getUserId());
|
||||
loginUser.setRoles(BeanUtil.copyToList(roles, RoleDTO.class));
|
||||
});
|
||||
Opt<SysDeptVo> deptOpt = Opt.of(user.getDeptId()).map(deptService::selectDeptById);
|
||||
loginUser.setDeptName(deptOpt.map(SysDeptVo::getDeptName).orElse(StringUtils.EMPTY));
|
||||
loginUser.setDeptCategory(deptOpt.map(SysDeptVo::getDeptCategory).orElse(StringUtils.EMPTY));
|
||||
List<SysRoleVo> roles = roleService.selectRolesByUserId(user.getUserId());
|
||||
loginUser.setRoles(BeanUtil.copyToList(roles, RoleDTO.class));
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
@@ -186,7 +182,7 @@ public class SysLoginService {
|
||||
* 登录校验
|
||||
*/
|
||||
public void checkLogin(LoginType loginType, String tenantId, String username, Supplier<Boolean> supplier) {
|
||||
String errorKey = GlobalConstants.PWD_ERR_CNT_KEY + username;
|
||||
String errorKey = CacheConstants.PWD_ERR_CNT_KEY + username;
|
||||
String loginFail = Constants.LOGIN_FAIL;
|
||||
|
||||
// 获取用户登录错误次数,默认为0 (可自定义限制策略 例如: key + username + ip)
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.system.domain.SysClient;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
@@ -51,13 +50,12 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
String tenantId = loginBody.getTenantId();
|
||||
String email = loginBody.getEmail();
|
||||
String emailCode = loginBody.getEmailCode();
|
||||
|
||||
// 通过邮箱查找用户
|
||||
SysUserVo user = loadUserByEmail(tenantId, email);
|
||||
|
||||
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), () -> !validateEmailCode(tenantId, email, emailCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = loadUserByEmail(email);
|
||||
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), () -> !validateEmailCode(tenantId, email, emailCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginModel model = new SaLoginModel();
|
||||
@@ -89,18 +87,16 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
return code.equals(emailCode);
|
||||
}
|
||||
|
||||
private SysUserVo loadUserByEmail(String tenantId, String email) {
|
||||
return TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getEmail, email));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", email);
|
||||
throw new UserException("user.not.exists", email);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", email);
|
||||
throw new UserException("user.blocked", email);
|
||||
}
|
||||
return user;
|
||||
});
|
||||
private SysUserVo loadUserByEmail(String email) {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getEmail, email));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", email);
|
||||
throw new UserException("user.not.exists", email);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", email);
|
||||
throw new UserException("user.blocked", email);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,11 +62,12 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
if (captchaEnabled) {
|
||||
validateCaptcha(tenantId, username, code, uuid);
|
||||
}
|
||||
|
||||
SysUserVo user = loadUserByUsername(tenantId, username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = loadUserByUsername(username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginModel model = new SaLoginModel();
|
||||
@@ -107,18 +108,16 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
private SysUserVo loadUserByUsername(String tenantId, String username) {
|
||||
return TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return user;
|
||||
});
|
||||
private SysUserVo loadUserByUsername(String username) {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.system.domain.SysClient;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.vo.SysClientVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
@@ -51,13 +50,12 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
String tenantId = loginBody.getTenantId();
|
||||
String phonenumber = loginBody.getPhonenumber();
|
||||
String smsCode = loginBody.getSmsCode();
|
||||
|
||||
// 通过手机号查找用户
|
||||
SysUserVo user = loadUserByPhonenumber(tenantId, phonenumber);
|
||||
|
||||
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = loadUserByPhonenumber(phonenumber);
|
||||
loginService.checkLogin(LoginType.SMS, tenantId, user.getUserName(), () -> !validateSmsCode(tenantId, phonenumber, smsCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginModel model = new SaLoginModel();
|
||||
@@ -89,18 +87,16 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
||||
return code.equals(smsCode);
|
||||
}
|
||||
|
||||
private SysUserVo loadUserByPhonenumber(String tenantId, String phonenumber) {
|
||||
return TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhonenumber, phonenumber));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", phonenumber);
|
||||
throw new UserException("user.not.exists", phonenumber);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
||||
throw new UserException("user.blocked", phonenumber);
|
||||
}
|
||||
return user;
|
||||
});
|
||||
private SysUserVo loadUserByPhonenumber(String phonenumber) {
|
||||
SysUserVo user = userMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhonenumber, phonenumber));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", phonenumber);
|
||||
throw new UserException("user.not.exists", phonenumber);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
||||
throw new UserException("user.blocked", phonenumber);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,11 +92,11 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
||||
} else {
|
||||
social = list.get(0);
|
||||
}
|
||||
// 查找用户
|
||||
SysUserVo user = loadUser(social.getTenantId(), social.getUserId());
|
||||
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
LoginUser loginUser = TenantHelper.dynamic(social.getTenantId(), () -> {
|
||||
SysUserVo user = loadUser(social.getUserId());
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginModel model = new SaLoginModel();
|
||||
@@ -116,18 +116,16 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
||||
return loginVo;
|
||||
}
|
||||
|
||||
private SysUserVo loadUser(String tenantId, Long userId) {
|
||||
return TenantHelper.dynamic(tenantId, () -> {
|
||||
SysUserVo user = userMapper.selectVoById(userId);
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", "");
|
||||
throw new UserException("user.not.exists", "");
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", "");
|
||||
throw new UserException("user.blocked", "");
|
||||
}
|
||||
return user;
|
||||
});
|
||||
private SysUserVo loadUser(Long userId) {
|
||||
SysUserVo user = userMapper.selectVoById(userId);
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", "");
|
||||
throw new UserException("user.not.exists", "");
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", "");
|
||||
throw new UserException("user.blocked", "");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ spring.boot.admin.client:
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
metadata:
|
||||
username: ${spring.boot.admin.client.username}
|
||||
userpassword: ${spring.boot.admin.client.password}
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ spring.boot.admin.client:
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
metadata:
|
||||
username: ${spring.boot.admin.client.username}
|
||||
userpassword: ${spring.boot.admin.client.password}
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
|
||||
|
||||
@@ -121,9 +121,6 @@ security:
|
||||
# swagger 文档配置
|
||||
- /*/api-docs
|
||||
- /*/api-docs/**
|
||||
# actuator 监控配置
|
||||
- /actuator
|
||||
- /actuator/**
|
||||
|
||||
# 多租户配置
|
||||
tenant:
|
||||
@@ -259,10 +256,15 @@ management:
|
||||
logfile:
|
||||
external-file: ./logs/sys-console.log
|
||||
|
||||
--- # 默认/推荐使用sse推送
|
||||
sse:
|
||||
enabled: true
|
||||
path: /resource/sse
|
||||
|
||||
--- # websocket
|
||||
websocket:
|
||||
# 如果关闭 需要和前端开关一起关闭
|
||||
enabled: true
|
||||
enabled: false
|
||||
# 路径
|
||||
path: /resource/websocket
|
||||
# 设置访问源地址
|
||||
@@ -270,6 +272,10 @@ websocket:
|
||||
|
||||
--- #flowable配置
|
||||
flowable:
|
||||
# 开关 用于启动/停用工作流
|
||||
enabled: true
|
||||
process.enabled: ${flowable.enabled}
|
||||
eventregistry.enabled: ${flowable.enabled}
|
||||
async-executor-activate: false #关闭定时任务JOB
|
||||
# 将databaseSchemaUpdate设置为true。当Flowable发现库与数据库表结构不一致时,会自动将数据库表结构升级至新版本。
|
||||
database-schema-update: true
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
<module>ruoyi-common-encrypt</module>
|
||||
<module>ruoyi-common-tenant</module>
|
||||
<module>ruoyi-common-websocket</module>
|
||||
<module>ruoyi-common-sse</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
|
||||
@@ -172,6 +172,13 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SSE模块 -->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -22,4 +22,9 @@ public interface CacheConstants {
|
||||
*/
|
||||
String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
}
|
||||
|
||||
@@ -27,11 +27,6 @@ public interface GlobalConstants {
|
||||
*/
|
||||
String RATE_LIMIT_KEY = GLOBAL_REDIS_KEY + "rate_limit:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
String PWD_ERR_CNT_KEY = GLOBAL_REDIS_KEY + "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* 三方认证 redis key
|
||||
*/
|
||||
|
||||
@@ -67,6 +67,16 @@ public interface UserConstants {
|
||||
*/
|
||||
String DICT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 通用存在标志
|
||||
*/
|
||||
String DEL_FLAG_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 通用删除标志
|
||||
*/
|
||||
String DEL_FLAG_REMOVED = "2";
|
||||
|
||||
/**
|
||||
* 是否为系统默认(是)
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<version>1.26.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CellMergeStrategy extends AbstractMergeStrategy implements Workbook
|
||||
}
|
||||
|
||||
if (!cellValue.equals(val)) {
|
||||
if ((i - repeatCell.getCurrent() > 1) && isMerge(list, i, field)) {
|
||||
if ((i - repeatCell.getCurrent() > 1)) {
|
||||
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
|
||||
}
|
||||
map.put(field, new RepeatCell(val, i));
|
||||
@@ -115,6 +115,11 @@ public class CellMergeStrategy extends AbstractMergeStrategy implements Workbook
|
||||
if (i > repeatCell.getCurrent() && isMerge(list, i, field)) {
|
||||
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
|
||||
}
|
||||
} else if (!isMerge(list, i, field)) {
|
||||
if ((i - repeatCell.getCurrent() > 1)) {
|
||||
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
|
||||
}
|
||||
map.put(field, new RepeatCell(val, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,11 @@ public @interface DataColumn {
|
||||
*/
|
||||
String[] value() default "dept_id";
|
||||
|
||||
/**
|
||||
* 权限标识符 用于通过菜单权限标识符来获取数据权限
|
||||
* 拥有此标识符的角色 将不会拼接此角色的数据过滤sql
|
||||
*
|
||||
* @return 权限标识符
|
||||
*/
|
||||
String permission() default "";
|
||||
}
|
||||
|
||||
@@ -20,4 +20,11 @@ public @interface DataPermission {
|
||||
*/
|
||||
DataColumn[] value();
|
||||
|
||||
/**
|
||||
* 权限拼接标识符(用于指定连接语句的sql符号)
|
||||
* 如不填 默认 select 用 OR 其他语句用 AND
|
||||
* 内容 OR 或者 AND
|
||||
*/
|
||||
String joinStr() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,10 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
|
||||
? baseEntity.getCreateDept() : loginUser.getDeptId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Date date = new Date();
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, date);
|
||||
this.strictInsertFill(metaObject, "updateTime", Date.class, date);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
||||
@@ -72,6 +76,8 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
|
||||
if (ObjectUtil.isNotNull(userId)) {
|
||||
baseEntity.setUpdateBy(userId);
|
||||
}
|
||||
} else {
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class PlusDataPermissionHandler {
|
||||
return where;
|
||||
}
|
||||
// 构造数据过滤条件的 SQL 片段
|
||||
String dataFilterSql = buildDataFilter(dataPermission.value(), isSelect);
|
||||
String dataFilterSql = buildDataFilter(dataPermission, isSelect);
|
||||
if (StringUtils.isBlank(dataFilterSql)) {
|
||||
return where;
|
||||
}
|
||||
@@ -120,14 +120,17 @@ public class PlusDataPermissionHandler {
|
||||
/**
|
||||
* 构建数据过滤条件的 SQL 语句
|
||||
*
|
||||
* @param dataColumns 数据权限注解中的列信息
|
||||
* @param isSelect 标志当前操作是否为查询操作,查询操作和更新或删除操作在处理过滤条件时会有不同的处理方式
|
||||
* @param dataPermission 数据权限注解
|
||||
* @param isSelect 标志当前操作是否为查询操作,查询操作和更新或删除操作在处理过滤条件时会有不同的处理方式
|
||||
* @return 构建的数据过滤条件的 SQL 语句
|
||||
* @throws ServiceException 如果角色的数据范围异常或者 key 与 value 的长度不匹配,则抛出 ServiceException 异常
|
||||
*/
|
||||
private String buildDataFilter(DataColumn[] dataColumns, boolean isSelect) {
|
||||
private String buildDataFilter(DataPermission dataPermission, boolean isSelect) {
|
||||
// 更新或删除需满足所有条件
|
||||
String joinStr = isSelect ? " OR " : " AND ";
|
||||
if (StringUtils.isNotBlank(dataPermission.joinStr())) {
|
||||
joinStr = " " + dataPermission.joinStr() + " ";
|
||||
}
|
||||
LoginUser user = DataPermissionHelper.getVariable("user");
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setBeanResolver(beanResolver);
|
||||
@@ -145,7 +148,7 @@ public class PlusDataPermissionHandler {
|
||||
return "";
|
||||
}
|
||||
boolean isSuccess = false;
|
||||
for (DataColumn dataColumn : dataColumns) {
|
||||
for (DataColumn dataColumn : dataPermission.value()) {
|
||||
if (dataColumn.key().length != dataColumn.value().length) {
|
||||
throw new ServiceException("角色数据范围异常 => key与value长度不匹配");
|
||||
}
|
||||
@@ -155,6 +158,13 @@ public class PlusDataPermissionHandler {
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
// 包含权限标识符 这直接跳过
|
||||
if (StringUtils.isNotBlank(dataColumn.permission()) &&
|
||||
CollUtil.contains(user.getMenuPermission(), dataColumn.permission())
|
||||
) {
|
||||
isSuccess = true;
|
||||
continue;
|
||||
}
|
||||
// 设置注解变量 key 为表达式变量 value 为变量值
|
||||
for (int i = 0; i < dataColumn.key().length; i++) {
|
||||
context.setVariable(dataColumn.key()[i], dataColumn.value()[i]);
|
||||
|
||||
@@ -80,11 +80,11 @@ public class RateLimiterAspect {
|
||||
|
||||
private String getCombineKey(RateLimiter rateLimiter, JoinPoint point) {
|
||||
String key = rateLimiter.key();
|
||||
if (StringUtils.isNotBlank(key)) {
|
||||
// 判断 key 不为空 和 不是表达式
|
||||
if (StringUtils.isNotBlank(key) && StringUtils.containsAny(key, "#")) {
|
||||
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||
Method targetMethod = signature.getMethod();
|
||||
Object[] args = point.getArgs();
|
||||
//noinspection DataFlowIssue
|
||||
MethodBasedEvaluationContext context =
|
||||
new MethodBasedEvaluationContext(null, targetMethod, args, pnd);
|
||||
context.setBeanResolver(new BeanFactoryResolver(SpringUtils.getBeanFactory()));
|
||||
|
||||
@@ -15,15 +15,17 @@ public class CaffeineCacheDecorator implements Cache {
|
||||
private static final com.github.benmanes.caffeine.cache.Cache<Object, Object>
|
||||
CAFFEINE = SpringUtils.getBean("caffeine");
|
||||
|
||||
private final String name;
|
||||
private final Cache cache;
|
||||
|
||||
public CaffeineCacheDecorator(Cache cache) {
|
||||
public CaffeineCacheDecorator(String name, Cache cache) {
|
||||
this.name = name;
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return cache.getName();
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,7 +34,7 @@ public class CaffeineCacheDecorator implements Cache {
|
||||
}
|
||||
|
||||
public String getUniqueKey(Object key) {
|
||||
return cache.getName() + ":" + key;
|
||||
return name + ":" + key;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -156,7 +156,7 @@ public class PlusSpringCacheManager implements CacheManager {
|
||||
private Cache createMap(String name, CacheConfig config) {
|
||||
RMap<Object, Object> map = RedisUtils.getClient().getMap(name);
|
||||
|
||||
Cache cache = new CaffeineCacheDecorator(new RedissonCache(map, allowNullValues));
|
||||
Cache cache = new CaffeineCacheDecorator(name, new RedissonCache(map, allowNullValues));
|
||||
if (transactionAware) {
|
||||
cache = new TransactionAwareCacheDecorator(cache);
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class PlusSpringCacheManager implements CacheManager {
|
||||
private Cache createMapCache(String name, CacheConfig config) {
|
||||
RMapCache<Object, Object> map = RedisUtils.getClient().getMapCache(name);
|
||||
|
||||
Cache cache = new CaffeineCacheDecorator(new RedissonCache(map, config, allowNullValues));
|
||||
Cache cache = new CaffeineCacheDecorator(name, new RedissonCache(map, config, allowNullValues));
|
||||
if (transactionAware) {
|
||||
cache = new TransactionAwareCacheDecorator(cache);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package org.dromara.common.security.config;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.filter.SaServletFilter;
|
||||
import cn.dev33.satoken.httpauth.basic.SaHttpBasicUtil;
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.utils.ServletUtils;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@@ -14,6 +18,7 @@ import org.dromara.common.security.config.properties.SecurityProperties;
|
||||
import org.dromara.common.security.handler.AllUrlHandler;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@@ -71,4 +76,19 @@ public class SecurityConfig implements WebMvcConfigurer {
|
||||
.excludePathPatterns(securityProperties.getExcludes());
|
||||
}
|
||||
|
||||
/**
|
||||
* 对 actuator 健康检查接口 做账号密码鉴权
|
||||
*/
|
||||
@Bean
|
||||
public SaServletFilter getSaServletFilter() {
|
||||
String username = SpringUtils.getProperty("spring.boot.admin.client.username");
|
||||
String password = SpringUtils.getProperty("spring.boot.admin.client.password");
|
||||
return new SaServletFilter()
|
||||
.addInclude("/actuator", "/actuator/**")
|
||||
.setAuth(obj -> {
|
||||
SaHttpBasicUtil.check(username + ":" + password);
|
||||
})
|
||||
.setError(e -> SaResult.error(e.getMessage()).setCode(HttpStatus.UNAUTHORIZED));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,57 @@ public enum SensitiveStrategy {
|
||||
/**
|
||||
* 银行卡
|
||||
*/
|
||||
BANK_CARD(DesensitizedUtil::bankCard);
|
||||
BANK_CARD(DesensitizedUtil::bankCard),
|
||||
|
||||
/**
|
||||
* 中文名
|
||||
*/
|
||||
CHINESE_NAME(DesensitizedUtil::chineseName),
|
||||
|
||||
/**
|
||||
* 固定电话
|
||||
*/
|
||||
FIXED_PHONE(DesensitizedUtil::fixedPhone),
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
USER_ID(s -> String.valueOf(DesensitizedUtil.userId())),
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
PASSWORD(DesensitizedUtil::password),
|
||||
|
||||
/**
|
||||
* ipv4
|
||||
*/
|
||||
IPV4(DesensitizedUtil::ipv4),
|
||||
|
||||
/**
|
||||
* ipv6
|
||||
*/
|
||||
IPV6(DesensitizedUtil::ipv6),
|
||||
|
||||
/**
|
||||
* 中国大陆车牌,包含普通车辆、新能源车辆
|
||||
*/
|
||||
CAR_LICENSE(DesensitizedUtil::carLicense),
|
||||
|
||||
/**
|
||||
* 只显示第一个字符
|
||||
*/
|
||||
FIRST_MASK(DesensitizedUtil::firstMask),
|
||||
|
||||
/**
|
||||
* 清空为null
|
||||
*/
|
||||
CLEAR(s -> DesensitizedUtil.clear()),
|
||||
|
||||
/**
|
||||
* 清空为""
|
||||
*/
|
||||
CLEAR_TO_NULL(s -> DesensitizedUtil.clearToNull());
|
||||
|
||||
//可自行添加其他脱敏策略
|
||||
|
||||
|
||||
36
ruoyi-common/ruoyi-common-sse/pom.xml
Normal file
36
ruoyi-common/ruoyi-common-sse/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-common-sse 模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-satoken</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-json</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.dromara.common.sse.config;
|
||||
|
||||
import org.dromara.common.sse.controller.SseController;
|
||||
import org.dromara.common.sse.core.SseEmitterManager;
|
||||
import org.dromara.common.sse.listener.SseTopicListener;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* SSE 自动装配
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(value = "sse.enabled", havingValue = "true")
|
||||
@EnableConfigurationProperties(SseProperties.class)
|
||||
public class SseAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public SseEmitterManager sseEmitterManager() {
|
||||
return new SseEmitterManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SseTopicListener sseTopicListener() {
|
||||
return new SseTopicListener();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SseController sseController(SseEmitterManager sseEmitterManager) {
|
||||
return new SseController(sseEmitterManager);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.dromara.common.sse.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* SSE 配置项
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties("sse")
|
||||
public class SseProperties {
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String path;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package org.dromara.common.sse.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.sse.core.SseEmitterManager;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@ConditionalOnProperty(value = "sse.enabled", havingValue = "true")
|
||||
@RequiredArgsConstructor
|
||||
public class SseController implements DisposableBean {
|
||||
|
||||
private final SseEmitterManager sseEmitterManager;
|
||||
|
||||
@GetMapping(value = "${sse.path}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public SseEmitter connect() {
|
||||
String tokenValue = StpUtil.getTokenValue();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
return sseEmitterManager.connect(userId, tokenValue);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@GetMapping(value = "${sse.path}/close")
|
||||
public R<Void> close() {
|
||||
String tokenValue = StpUtil.getTokenValue();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
sseEmitterManager.disconnect(userId, tokenValue);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping(value = "${sse.path}/send")
|
||||
public R<Void> send(Long userId, String msg) {
|
||||
SseMessageDto dto = new SseMessageDto();
|
||||
dto.setUserIds(List.of(userId));
|
||||
dto.setMessage(msg);
|
||||
sseEmitterManager.publishMessage(dto);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping(value = "${sse.path}/sendAll")
|
||||
public R<Void> send(String msg) {
|
||||
sseEmitterManager.publishAll(msg);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
// 销毁时不需要做什么 此方法避免无用操作报错
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.dromara.common.sse.core;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Slf4j
|
||||
public class SseEmitterManager {
|
||||
/**
|
||||
* 订阅的频道
|
||||
*/
|
||||
private final static String SSE_TOPIC = "global:sse";
|
||||
|
||||
private final static Map<Long, Map<String, SseEmitter>> USER_TOKEN_EMITTERS = new ConcurrentHashMap<>();
|
||||
|
||||
public SseEmitter connect(Long userId, String token) {
|
||||
Map<String, SseEmitter> emitters = USER_TOKEN_EMITTERS.computeIfAbsent(userId, k -> new ConcurrentHashMap<>());
|
||||
SseEmitter emitter = new SseEmitter(0L);
|
||||
|
||||
emitters.put(token, emitter);
|
||||
|
||||
emitter.onCompletion(() -> emitters.remove(token));
|
||||
emitter.onTimeout(() -> emitters.remove(token));
|
||||
emitter.onError((e) -> emitters.remove(token));
|
||||
|
||||
try {
|
||||
emitter.send(SseEmitter.event().comment("connected"));
|
||||
} catch (IOException e) {
|
||||
emitters.remove(token);
|
||||
}
|
||||
return emitter;
|
||||
}
|
||||
|
||||
public void disconnect(Long userId, String token) {
|
||||
Map<String, SseEmitter> emitters = USER_TOKEN_EMITTERS.get(userId);
|
||||
if (emitters != null) {
|
||||
try {
|
||||
emitters.get(token).send(SseEmitter.event().comment("disconnected"));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
emitters.remove(token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅SSE消息主题,并提供一个消费者函数来处理接收到的消息
|
||||
*
|
||||
* @param consumer 处理SSE消息的消费者函数
|
||||
*/
|
||||
public void subscribeMessage(Consumer<SseMessageDto> consumer) {
|
||||
RedisUtils.subscribe(SSE_TOPIC, SseMessageDto.class, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定的用户会话发送消息
|
||||
*
|
||||
* @param userId 要发送消息的用户id
|
||||
* @param message 要发送的消息内容
|
||||
*/
|
||||
public void sendMessage(Long userId, String message) {
|
||||
Map<String, SseEmitter> emitters = USER_TOKEN_EMITTERS.get(userId);
|
||||
if (emitters != null) {
|
||||
for (Map.Entry<String, SseEmitter> entry : emitters.entrySet()) {
|
||||
try {
|
||||
entry.getValue().send(SseEmitter.event()
|
||||
.name("message")
|
||||
.data(message));
|
||||
} catch (Exception e) {
|
||||
emitters.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本机全用户会话发送消息
|
||||
*
|
||||
* @param message 要发送的消息内容
|
||||
*/
|
||||
public void sendMessage(String message) {
|
||||
for (Long userId : USER_TOKEN_EMITTERS.keySet()) {
|
||||
sendMessage(userId, message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布SSE订阅消息
|
||||
*
|
||||
* @param sseMessageDto 要发布的SSE消息对象
|
||||
*/
|
||||
public void publishMessage(SseMessageDto sseMessageDto) {
|
||||
List<Long> unsentUserIds = new ArrayList<>();
|
||||
// 当前服务内用户,直接发送消息
|
||||
for (Long userId : sseMessageDto.getUserIds()) {
|
||||
if (USER_TOKEN_EMITTERS.containsKey(userId)) {
|
||||
sendMessage(userId, sseMessageDto.getMessage());
|
||||
continue;
|
||||
}
|
||||
unsentUserIds.add(userId);
|
||||
}
|
||||
// 不在当前服务内用户,发布订阅消息
|
||||
if (CollUtil.isNotEmpty(unsentUserIds)) {
|
||||
SseMessageDto broadcastMessage = new SseMessageDto();
|
||||
broadcastMessage.setMessage(sseMessageDto.getMessage());
|
||||
broadcastMessage.setUserIds(unsentUserIds);
|
||||
RedisUtils.publish(SSE_TOPIC, broadcastMessage, consumer -> {
|
||||
log.info("SSE发送主题订阅消息topic:{} session keys:{} message:{}",
|
||||
SSE_TOPIC, unsentUserIds, sseMessageDto.getMessage());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向所有的用户发布订阅的消息(群发)
|
||||
*
|
||||
* @param message 要发布的消息内容
|
||||
*/
|
||||
public void publishAll(String message) {
|
||||
SseMessageDto broadcastMessage = new SseMessageDto();
|
||||
broadcastMessage.setMessage(message);
|
||||
RedisUtils.publish(SSE_TOPIC, broadcastMessage, consumer -> {
|
||||
log.info("SSE发送主题订阅消息topic:{} message:{}", SSE_TOPIC, message);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.dromara.common.sse.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息的dto
|
||||
*
|
||||
* @author zendwang
|
||||
*/
|
||||
@Data
|
||||
public class SseMessageDto implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 需要推送到的session key 列表
|
||||
*/
|
||||
private List<Long> userIds;
|
||||
|
||||
/**
|
||||
* 需要发送的消息
|
||||
*/
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.dromara.common.sse.listener;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.sse.core.SseEmitterManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
/**
|
||||
* SSE 主题订阅监听器
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
public class SseTopicListener implements ApplicationRunner, Ordered {
|
||||
|
||||
@Autowired
|
||||
private SseEmitterManager sseEmitterManager;
|
||||
|
||||
/**
|
||||
* 在Spring Boot应用程序启动时初始化SSE主题订阅监听器
|
||||
*
|
||||
* @param args 应用程序参数
|
||||
* @throws Exception 初始化过程中可能抛出的异常
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
sseEmitterManager.subscribeMessage((message) -> {
|
||||
log.info("SSE主题订阅收到消息session keys={} message={}", message.getUserIds(), message.getMessage());
|
||||
// 如果key不为空就按照key发消息 如果为空就群发
|
||||
if (CollUtil.isNotEmpty(message.getUserIds())) {
|
||||
message.getUserIds().forEach(key -> {
|
||||
sseEmitterManager.sendMessage(key, message.getMessage());
|
||||
});
|
||||
} else {
|
||||
sseEmitterManager.sendMessage(message.getMessage());
|
||||
}
|
||||
});
|
||||
log.info("初始化SSE主题订阅监听器成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.dromara.common.sse.utils;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.sse.core.SseEmitterManager;
|
||||
import org.dromara.common.sse.dto.SseMessageDto;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class SseMessageUtils {
|
||||
|
||||
private final static SseEmitterManager MANAGER = SpringUtils.getBean(SseEmitterManager.class);
|
||||
|
||||
/**
|
||||
* 向指定的WebSocket会话发送消息
|
||||
*
|
||||
* @param userId 要发送消息的用户id
|
||||
* @param message 要发送的消息内容
|
||||
*/
|
||||
public static void sendMessage(Long userId, String message) {
|
||||
MANAGER.sendMessage(userId, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本机全用户会话发送消息
|
||||
*
|
||||
* @param message 要发送的消息内容
|
||||
*/
|
||||
public static void sendMessage(String message) {
|
||||
MANAGER.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布SSE订阅消息
|
||||
*
|
||||
* @param sseMessageDto 要发布的SSE消息对象
|
||||
*/
|
||||
public static void publishMessage(SseMessageDto sseMessageDto) {
|
||||
MANAGER.publishMessage(sseMessageDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向所有的用户发布订阅的消息(群发)
|
||||
*
|
||||
* @param message 要发布的消息内容
|
||||
*/
|
||||
public static void publishAll(String message) {
|
||||
MANAGER.publishAll(message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.dromara.common.sse.config.SseAutoConfiguration
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.dromara.common.tenant.manager;
|
||||
|
||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.redis.manager.PlusSpringCacheManager;
|
||||
@@ -11,6 +13,7 @@ import org.springframework.cache.Cache;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
public class TenantSpringCacheManager extends PlusSpringCacheManager {
|
||||
|
||||
public TenantSpringCacheManager() {
|
||||
@@ -18,10 +21,16 @@ public class TenantSpringCacheManager extends PlusSpringCacheManager {
|
||||
|
||||
@Override
|
||||
public Cache getCache(String name) {
|
||||
if (InterceptorIgnoreHelper.willIgnoreTenantLine("")) {
|
||||
return super.getCache(name);
|
||||
}
|
||||
if (StringUtils.contains(name, GlobalConstants.GLOBAL_REDIS_KEY)) {
|
||||
return super.getCache(name);
|
||||
}
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
if (StringUtils.isBlank(tenantId)) {
|
||||
log.error("无法获取有效的租户id -> Null");
|
||||
}
|
||||
if (StringUtils.startsWith(name, tenantId)) {
|
||||
// 如果存在则直接返回
|
||||
return super.getCache(name);
|
||||
|
||||
@@ -43,6 +43,19 @@
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.undertow</groupId>
|
||||
<artifactId>undertow-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.undertow</groupId>
|
||||
<artifactId>undertow-servlet</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.undertow</groupId>
|
||||
<artifactId>undertow-websockets-jsr</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
|
||||
@@ -16,10 +16,13 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingPathVariableException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*
|
||||
@@ -89,6 +92,20 @@ public class GlobalExceptionHandler {
|
||||
return R.fail(HttpStatus.HTTP_NOT_FOUND, e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ResponseStatus(org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(IOException.class)
|
||||
public void handleRuntimeException(IOException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
if (requestURI.contains("sse")) {
|
||||
// sse 经常性连接中断 例如关闭浏览器 直接屏蔽
|
||||
return;
|
||||
}
|
||||
log.error("请求地址'{}',连接中断", requestURI, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
|
||||
@@ -12,10 +12,21 @@
|
||||
<artifactId>ruoyi-monitor-admin</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- SpringWeb模块 -->
|
||||
<!-- SpringBoot Web容器 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- web 容器使用 undertow 性能更强 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring security 安全认证 -->
|
||||
|
||||
@@ -39,9 +39,7 @@ public class SecurityConfig {
|
||||
.authorizeHttpRequests((authorize) ->
|
||||
authorize.requestMatchers(
|
||||
new AntPathRequestMatcher(adminContextPath + "/assets/**"),
|
||||
new AntPathRequestMatcher(adminContextPath + "/login"),
|
||||
new AntPathRequestMatcher("/actuator"),
|
||||
new AntPathRequestMatcher("/actuator/**")
|
||||
new AntPathRequestMatcher(adminContextPath + "/login")
|
||||
).permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.formLogin((formLogin) ->
|
||||
|
||||
@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import static de.codecentric.boot.admin.server.domain.values.StatusInfo.*;
|
||||
|
||||
/**
|
||||
* 自定义事件通知处理
|
||||
*
|
||||
@@ -28,13 +30,26 @@ public class CustomNotifier extends AbstractEventNotifier {
|
||||
return Mono.fromRunnable(() -> {
|
||||
// 实例状态改变事件
|
||||
if (event instanceof InstanceStatusChangedEvent) {
|
||||
// 获取实例注册名称
|
||||
String registName = instance.getRegistration().getName();
|
||||
// 获取实例ID
|
||||
String instanceId = event.getInstance().getValue();
|
||||
// 获取实例状态
|
||||
String status = ((InstanceStatusChangedEvent) event).getStatusInfo().getStatus();
|
||||
log.info("Instance Status Change: [{}],[{}],[{}]", registName, instanceId, status);
|
||||
// 获取服务URL
|
||||
String serviceUrl = instance.getRegistration().getServiceUrl();
|
||||
String statusName = switch (status) {
|
||||
case STATUS_UP -> "服务上线"; // 实例成功启动并可以正常处理请求
|
||||
case STATUS_OFFLINE -> "服务离线"; //实例被手动或自动地从服务中移除
|
||||
case STATUS_RESTRICTED -> "服务受限"; //表示实例在某些方面受限,可能无法完全提供所有服务
|
||||
case STATUS_OUT_OF_SERVICE -> "停止服务状态"; //表示实例已被标记为停止提供服务,可能是计划内维护或测试
|
||||
case STATUS_DOWN -> "服务下线"; //实例因崩溃、错误或其他原因停止运行
|
||||
case STATUS_UNKNOWN -> "服务未知异常"; //监控系统无法确定实例的当前状态
|
||||
default -> "未知状态"; //没有匹配的状态
|
||||
};
|
||||
log.info("Instance Status Change: 状态名称【{}】, 注册名称【{}】, 实例ID【{}】, 状态【{}】, 服务URL【{}】",
|
||||
statusName, registName, instanceId, status, serviceUrl);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,5 +41,8 @@ spring.boot.admin.client:
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
metadata:
|
||||
username: ${spring.boot.admin.client.username}
|
||||
userpassword: ${spring.boot.admin.client.password}
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.aizuda.snailjob.server.starter.filter;
|
||||
|
||||
import jakarta.servlet.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
public class ActuatorAuthFilter implements Filter {
|
||||
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public ActuatorAuthFilter(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
|
||||
// 获取 Authorization 头
|
||||
String authHeader = request.getHeader("Authorization");
|
||||
|
||||
if (authHeader == null || !authHeader.startsWith("Basic ")) {
|
||||
// 如果没有提供 Authorization 或者格式不对,则返回 401
|
||||
response.setHeader("WWW-Authenticate", "Basic realm=\"realm\"");
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
||||
return;
|
||||
}
|
||||
|
||||
// 解码 Base64 编码的用户名和密码
|
||||
String base64Credentials = authHeader.substring("Basic ".length());
|
||||
byte[] credDecoded = Base64.getDecoder().decode(base64Credentials);
|
||||
String credentials = new String(credDecoded, StandardCharsets.UTF_8);
|
||||
String[] split = credentials.split(":");
|
||||
if (split.length != 2) {
|
||||
response.setHeader("WWW-Authenticate", "Basic realm=\"realm\"");
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
||||
return;
|
||||
}
|
||||
// 验证用户名和密码
|
||||
if (!username.equals(split[0]) && password.equals(split[1])) {
|
||||
response.setHeader("WWW-Authenticate", "Basic realm=\"realm\"");
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
|
||||
return;
|
||||
}
|
||||
// 如果认证成功,继续处理请求
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.aizuda.snailjob.server.starter.filter;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 权限安全配置
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
@Value("${spring.boot.admin.client.username}")
|
||||
private String username;
|
||||
@Value("${spring.boot.admin.client.password}")
|
||||
private String password;
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<ActuatorAuthFilter> actuatorFilterRegistrationBean() {
|
||||
FilterRegistrationBean<ActuatorAuthFilter> registrationBean = new FilterRegistrationBean<>();
|
||||
registrationBean.setFilter(new ActuatorAuthFilter(username, password));
|
||||
registrationBean.addUrlPatterns("/actuator", "/actuator/**");
|
||||
return registrationBean;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,5 +43,8 @@ spring.boot.admin.client:
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
metadata:
|
||||
username: ${spring.boot.admin.client.username}
|
||||
userpassword: ${spring.boot.admin.client.password}
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
|
||||
@@ -43,5 +43,8 @@ spring.boot.admin.client:
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
metadata:
|
||||
username: ${spring.boot.admin.client.username}
|
||||
userpassword: ${spring.boot.admin.client.password}
|
||||
username: ruoyi
|
||||
password: 123456
|
||||
|
||||
@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import org.dromara.demo.domain.vo.TestDemoVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,16 +44,17 @@ public interface TestDemoMapper extends BaseMapperPlus<TestDemo, TestDemoVo> {
|
||||
List<TestDemo> selectList(@Param(Constants.WRAPPER) Wrapper<TestDemo> queryWrapper);
|
||||
|
||||
@Override
|
||||
@DataPermission({
|
||||
@DataPermission(value = {
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
})
|
||||
int updateById(@Param(Constants.ENTITY) TestDemo entity);
|
||||
}, joinStr = "AND")
|
||||
List<TestDemo> selectBatchIds(@Param(Constants.COLL) Collection<? extends Serializable> idList);
|
||||
|
||||
@Override
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
})
|
||||
int deleteByIds(@Param(Constants.COLL) Collection<?> idList);
|
||||
int updateById(@Param(Constants.ENTITY) TestDemo entity);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package org.dromara.demo.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -12,7 +14,6 @@ import org.dromara.demo.domain.bo.TestDemoBo;
|
||||
import org.dromara.demo.domain.vo.TestDemoVo;
|
||||
import org.dromara.demo.mapper.TestDemoMapper;
|
||||
import org.dromara.demo.service.ITestDemoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -99,7 +100,11 @@ public class TestDemoServiceImpl implements ITestDemoService {
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
// 做一些业务上的校验,判断是否需要校验
|
||||
List<TestDemo> list = baseMapper.selectBatchIds(ids);
|
||||
if (list.size() != ids.size()) {
|
||||
throw new ServiceException("您没有删除权限!");
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,38 @@
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.anyline</groupId>
|
||||
<artifactId>anyline-environment-spring-data-jdbc</artifactId>
|
||||
<version>${anyline.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.anyline</groupId>
|
||||
<artifactId>anyline-data-jdbc-mysql</artifactId>
|
||||
<version>${anyline.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- anyline支持100+种类型数据库 添加对应的jdbc依赖与anyline对应数据库依赖包即可 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.anyline</groupId>-->
|
||||
<!-- <artifactId>anyline-data-jdbc-oracle</artifactId>-->
|
||||
<!-- <version>${anyline.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.anyline</groupId>-->
|
||||
<!-- <artifactId>anyline-data-jdbc-postgresql</artifactId>-->
|
||||
<!-- <version>${anyline.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.anyline</groupId>-->
|
||||
<!-- <artifactId>anyline-data-jdbc-mssql</artifactId>-->
|
||||
<!-- <version>${anyline.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package org.dromara.generator.config;
|
||||
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.anyline.data.datasource.DataSourceMonitor;
|
||||
import org.anyline.data.runtime.DataRuntime;
|
||||
import org.anyline.util.ConfigTable;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* anyline 适配 动态数据源改造
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MyBatisDataSourceMonitor implements DataSourceMonitor {
|
||||
|
||||
public MyBatisDataSourceMonitor() {
|
||||
// 调整执行模式为自定义
|
||||
ConfigTable.KEEP_ADAPTER = 2;
|
||||
// 禁用缓存
|
||||
ConfigTable.METADATA_CACHE_SCOPE = 0;
|
||||
}
|
||||
|
||||
private final Map<String, String> features = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 数据源特征 用来定准 adapter 包含数据库或JDBC协议关键字<br/>
|
||||
* 一般会通过 产品名_url 合成 如果返回null 上层方法会通过driver_产品名_url合成
|
||||
*
|
||||
* @param datasource 数据源
|
||||
* @return String 返回null由上层自动提取
|
||||
*/
|
||||
@Override
|
||||
public String feature(DataRuntime runtime, Object datasource) {
|
||||
String feature = null;
|
||||
if (datasource instanceof JdbcTemplate jdbc) {
|
||||
DataSource ds = jdbc.getDataSource();
|
||||
if (ds instanceof DynamicRoutingDataSource) {
|
||||
String key = DynamicDataSourceContextHolder.peek();
|
||||
feature = features.get(key);
|
||||
if (null == feature) {
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DataSourceUtils.getConnection(ds);
|
||||
DatabaseMetaData meta = con.getMetaData();
|
||||
String url = meta.getURL();
|
||||
feature = meta.getDatabaseProductName().toLowerCase().replace(" ", "") + "_" + url;
|
||||
features.put(key, feature);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
if (null != con && !DataSourceUtils.isConnectionTransactional(con, ds)) {
|
||||
DataSourceUtils.releaseConnection(con, ds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源唯一标识 如果不实现则默认feature
|
||||
* @param datasource 数据源
|
||||
* @return String 返回null由上层自动提取
|
||||
*/
|
||||
@Override
|
||||
public String key(DataRuntime runtime, Object datasource) {
|
||||
if(datasource instanceof JdbcTemplate jdbc){
|
||||
DataSource ds = jdbc.getDataSource();
|
||||
if(ds instanceof DynamicRoutingDataSource){
|
||||
return DynamicDataSourceContextHolder.peek();
|
||||
}
|
||||
}
|
||||
return runtime.getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* ConfigTable.KEEP_ADAPTER=2 : 根据当前接口判断是否保持同一个数据源绑定同一个adapter<br/>
|
||||
* DynamicRoutingDataSource类型的返回false,因为同一个DynamicRoutingDataSource可能对应多类数据库, 如果项目中只有一种数据库 应该直接返回true
|
||||
*
|
||||
* @param datasource 数据源
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean keepAdapter(DataRuntime runtime, Object datasource) {
|
||||
if (datasource instanceof JdbcTemplate jdbc) {
|
||||
DataSource ds = jdbc.getDataSource();
|
||||
return !(ds instanceof DynamicRoutingDataSource);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import jakarta.validation.constraints.NotBlank;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("gen_table_column")
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package org.dromara.generator.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.generator.domain.GenTableColumn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务字段 数据层
|
||||
*
|
||||
@@ -15,14 +11,5 @@ import java.util.List;
|
||||
*/
|
||||
@InterceptorIgnore(dataPermission = "true", tenantLine = "true")
|
||||
public interface GenTableColumnMapper extends BaseMapperPlus<GenTableColumn, GenTableColumn> {
|
||||
/**
|
||||
* 根据表名称查询列信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param dataName 数据源名称
|
||||
* @return 列信息
|
||||
*/
|
||||
@DS("#dataName")
|
||||
List<GenTableColumn> selectDbTableColumnsByName(@Param("tableName") String tableName, String dataName);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,22 +17,6 @@ import java.util.List;
|
||||
@InterceptorIgnore(dataPermission = "true", tenantLine = "true")
|
||||
public interface GenTableMapper extends BaseMapperPlus<GenTable, GenTable> {
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
*
|
||||
* @param genTable 查询条件
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
Page<GenTable> selectPageDbTableList(@Param("page") Page<GenTable> page, @Param("genTable") GenTable genTable);
|
||||
|
||||
/**
|
||||
* 查询据库列表
|
||||
*
|
||||
* @param tableNames 表名称组
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
List<GenTable> selectDbTableListByNames(String[] tableNames);
|
||||
|
||||
/**
|
||||
* 查询所有表信息
|
||||
*
|
||||
|
||||
@@ -3,21 +3,27 @@ package org.dromara.generator.service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.anyline.metadata.Column;
|
||||
import org.anyline.metadata.Table;
|
||||
import org.anyline.proxy.ServiceProxy;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.file.FileUtils;
|
||||
@@ -41,11 +47,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -63,6 +65,8 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
private final GenTableColumnMapper genTableColumnMapper;
|
||||
private final IdentifierGenerator identifierGenerator;
|
||||
|
||||
private static final String[] TABLE_IGNORE = new String[]{"sj_", "act_", "flw_", "gen_"};
|
||||
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
@@ -99,7 +103,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
Map<String, Object> params = genTable.getParams();
|
||||
QueryWrapper<GenTable> wrapper = Wrappers.query();
|
||||
wrapper
|
||||
.eq(StringUtils.isNotEmpty(genTable.getDataName()),"data_name", genTable.getDataName())
|
||||
.eq(StringUtils.isNotEmpty(genTable.getDataName()), "data_name", genTable.getDataName())
|
||||
.like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName()))
|
||||
.like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment()))
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
@@ -107,11 +111,67 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据库列表
|
||||
*
|
||||
* @param genTable 包含查询条件的GenTable对象
|
||||
* @param pageQuery 包含分页信息的PageQuery对象
|
||||
* @return 包含分页结果的TableDataInfo对象
|
||||
*/
|
||||
@DS("#genTable.dataName")
|
||||
@Override
|
||||
public TableDataInfo<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) {
|
||||
genTable.getParams().put("genTableNames",baseMapper.selectTableNameList(genTable.getDataName()));
|
||||
Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable);
|
||||
// 获取查询条件
|
||||
String tableName = genTable.getTableName();
|
||||
String tableComment = genTable.getTableComment();
|
||||
|
||||
LinkedHashMap<String, Table<?>> tablesMap = ServiceProxy.metadata().tables();
|
||||
if (CollUtil.isEmpty(tablesMap)) {
|
||||
return TableDataInfo.build();
|
||||
}
|
||||
List<String> tableNames = baseMapper.selectTableNameList(genTable.getDataName());
|
||||
String[] tableArrays;
|
||||
if (CollUtil.isNotEmpty(tableNames)) {
|
||||
tableArrays = tableNames.toArray(new String[0]);
|
||||
} else {
|
||||
tableArrays = new String[0];
|
||||
}
|
||||
// 过滤并转换表格数据
|
||||
List<GenTable> tables = tablesMap.values().stream()
|
||||
.filter(x -> !StringUtils.containsAnyIgnoreCase(x.getName(), TABLE_IGNORE))
|
||||
.filter(x -> {
|
||||
if (CollUtil.isEmpty(tableNames)) {
|
||||
return true;
|
||||
}
|
||||
return !StringUtils.equalsAnyIgnoreCase(x.getName(), tableArrays);
|
||||
})
|
||||
.filter(x -> {
|
||||
boolean nameMatches = true;
|
||||
boolean commentMatches = true;
|
||||
// 进行表名称的模糊查询
|
||||
if (StringUtils.isNotBlank(tableName)) {
|
||||
nameMatches = StringUtils.containsIgnoreCase(x.getName(), tableName);
|
||||
}
|
||||
// 进行表描述的模糊查询
|
||||
if (StringUtils.isNotBlank(tableComment)) {
|
||||
commentMatches = StringUtils.containsIgnoreCase(x.getComment(), tableComment);
|
||||
}
|
||||
// 同时匹配名称和描述
|
||||
return nameMatches && commentMatches;
|
||||
})
|
||||
.map(x -> {
|
||||
GenTable gen = new GenTable();
|
||||
gen.setTableName(x.getName());
|
||||
gen.setTableComment(x.getComment());
|
||||
gen.setCreateTime(x.getCreateTime());
|
||||
gen.setUpdateTime(x.getUpdateTime());
|
||||
return gen;
|
||||
}).toList();
|
||||
|
||||
IPage<GenTable> page = pageQuery.build();
|
||||
page.setTotal(tables.size());
|
||||
// 手动分页 set数据
|
||||
page.setRecords(CollUtil.page((int) page.getCurrent() - 1, (int) page.getSize(), tables));
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
@@ -125,7 +185,29 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
@DS("#dataName")
|
||||
@Override
|
||||
public List<GenTable> selectDbTableListByNames(String[] tableNames, String dataName) {
|
||||
return baseMapper.selectDbTableListByNames(tableNames);
|
||||
Set<String> tableNameSet = new HashSet<>(List.of(tableNames));
|
||||
LinkedHashMap<String, Table<?>> tablesMap = ServiceProxy.metadata().tables();
|
||||
|
||||
if (CollUtil.isEmpty(tablesMap)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<Table<?>> tableList = tablesMap.values().stream()
|
||||
.filter(x -> !StringUtils.containsAnyIgnoreCase(x.getName(), TABLE_IGNORE))
|
||||
.filter(x -> tableNameSet.contains(x.getName())).toList();
|
||||
|
||||
if (ArrayUtil.isEmpty(tableList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return tableList.stream().map(x -> {
|
||||
GenTable gen = new GenTable();
|
||||
gen.setDataName(dataName);
|
||||
gen.setTableName(x.getName());
|
||||
gen.setTableComment(x.getComment());
|
||||
gen.setCreateTime(x.getCreateTime());
|
||||
gen.setUpdateTime(x.getUpdateTime());
|
||||
return gen;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +269,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
int row = baseMapper.insert(table);
|
||||
if (row > 0) {
|
||||
// 保存列信息
|
||||
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dataName);
|
||||
List<GenTableColumn> genTableColumns = SpringUtils.getAopProxy(this).selectDbTableColumnsByName(tableName, dataName);
|
||||
List<GenTableColumn> saveColumns = new ArrayList<>();
|
||||
for (GenTableColumn column : genTableColumns) {
|
||||
GenUtils.initColumnField(column, table);
|
||||
@@ -203,6 +285,32 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名称查询列信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param dataName 数据源名称
|
||||
* @return 列信息
|
||||
*/
|
||||
@DS("#dataName")
|
||||
@Override
|
||||
public List<GenTableColumn> selectDbTableColumnsByName(String tableName, String dataName) {
|
||||
LinkedHashMap<String, Column> columns = ServiceProxy.metadata().columns(tableName);
|
||||
List<GenTableColumn> tableColumns = new ArrayList<>();
|
||||
columns.forEach((columnName, column) -> {
|
||||
GenTableColumn tableColumn = new GenTableColumn();
|
||||
tableColumn.setIsPk(String.valueOf(column.isPrimaryKey()));
|
||||
tableColumn.setColumnName(column.getName());
|
||||
tableColumn.setColumnComment(column.getComment());
|
||||
tableColumn.setColumnType(column.getTypeName().toLowerCase());
|
||||
tableColumn.setSort(column.getPosition());
|
||||
tableColumn.setIsRequired(column.isNullable() == 0 ? "1" : "0");
|
||||
tableColumn.setIsIncrement(column.isAutoIncrement() == -1 ? "0" : "1");
|
||||
tableColumns.add(tableColumn);
|
||||
});
|
||||
return tableColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览代码
|
||||
*
|
||||
@@ -298,7 +406,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
List<GenTableColumn> tableColumns = table.getColumns();
|
||||
Map<String, GenTableColumn> tableColumnMap = StreamUtils.toIdentityMap(tableColumns, GenTableColumn::getColumnName);
|
||||
|
||||
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(table.getTableName(), table.getDataName());
|
||||
List<GenTableColumn> dbTableColumns = SpringUtils.getAopProxy(this).selectDbTableColumnsByName(table.getTableName(), table.getDataName());
|
||||
if (CollUtil.isEmpty(dbTableColumns)) {
|
||||
throw new ServiceException("同步数据失败,原表结构不存在");
|
||||
}
|
||||
|
||||
@@ -85,6 +85,15 @@ public interface IGenTableService {
|
||||
*/
|
||||
void importGenTable(List<GenTable> tableList, String dataName);
|
||||
|
||||
/**
|
||||
* 根据表名称查询列信息
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @param dataName 数据源名称
|
||||
* @return 列信息
|
||||
*/
|
||||
List<GenTableColumn> selectDbTableColumnsByName(String tableName, String dataName);
|
||||
|
||||
/**
|
||||
* 预览代码
|
||||
*
|
||||
|
||||
@@ -7,87 +7,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="org.dromara.generator.domain.GenTableColumn" id="GenTableColumnResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()">
|
||||
select column_name,
|
||||
(case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required,
|
||||
(case when column_key = 'PRI' then '1' else '0' end) as is_pk,
|
||||
ordinal_position as sort,
|
||||
column_comment,
|
||||
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
|
||||
column_type
|
||||
from information_schema.columns where table_schema = (select database()) and table_name = (#{tableName})
|
||||
order by ordinal_position
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()">
|
||||
select lower(temp.column_name) as column_name,
|
||||
(case when (temp.nullable = 'N' and temp.constraint_type != 'P') then '1' else '0' end) as is_required,
|
||||
(case when temp.constraint_type = 'P' then '1' else '0' end) as is_pk,
|
||||
temp.column_id as sort,
|
||||
temp.comments as column_comment,
|
||||
(case when temp.constraint_type = 'P' then '1' else '0' end) as is_increment,
|
||||
lower(temp.data_type) as column_type
|
||||
from (
|
||||
select col.column_id, col.column_name,col.nullable, col.data_type, colc.comments, uc.constraint_type, row_number()
|
||||
over (partition by col.column_name order by uc.constraint_type desc) as row_flg
|
||||
from user_tab_columns col
|
||||
left join user_col_comments colc on colc.table_name = col.table_name and colc.column_name = col.column_name
|
||||
left join user_cons_columns ucc on ucc.table_name = col.table_name and ucc.column_name = col.column_name
|
||||
left join user_constraints uc on uc.constraint_name = ucc.constraint_name
|
||||
where col.table_name = upper(#{tableName})
|
||||
) temp
|
||||
WHERE temp.row_flg = 1
|
||||
ORDER BY temp.column_id
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
|
||||
SELECT column_name, is_required, is_pk, sort, column_comment, is_increment, column_type
|
||||
FROM (
|
||||
SELECT c.relname AS table_name,
|
||||
a.attname AS column_name,
|
||||
d.description AS column_comment,
|
||||
CASE WHEN a.attnotnull AND con.conname IS NULL THEN 1 ELSE 0
|
||||
END AS is_required,
|
||||
CASE WHEN con.conname IS NOT NULL THEN 1 ELSE 0
|
||||
END AS is_pk,
|
||||
a.attnum AS sort,
|
||||
CASE WHEN "position"(pg_get_expr(ad.adbin, ad.adrelid),
|
||||
((c.relname::text || '_'::text) || a.attname::text) || '_seq'::text) > 0 THEN 1 ELSE 0
|
||||
END AS is_increment,
|
||||
btrim(
|
||||
CASE WHEN t.typelem <![CDATA[ <> ]]> 0::oid AND t.typlen = '-1'::integer THEN 'ARRAY'::text ELSE
|
||||
CASE WHEN t.typtype = 'd'::"char" THEN format_type(t.typbasetype, NULL::integer)
|
||||
ELSE format_type(a.atttypid, NULL::integer) END
|
||||
END, '"'::text
|
||||
) AS column_type
|
||||
FROM pg_attribute a
|
||||
JOIN (pg_class c JOIN pg_namespace n ON c.relnamespace = n.oid) ON a.attrelid = c.oid
|
||||
LEFT JOIN pg_description d ON d.objoid = c.oid AND a.attnum = d.objsubid
|
||||
LEFT JOIN pg_constraint con ON con.conrelid = c.oid AND (a.attnum = ANY (con.conkey))
|
||||
LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
|
||||
LEFT JOIN pg_type t ON a.atttypid = t.oid
|
||||
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
|
||||
AND a.attnum > 0
|
||||
AND n.nspname = 'public'::name
|
||||
ORDER BY c.relname, a.attnum
|
||||
) temp
|
||||
WHERE table_name = (#{tableName})
|
||||
AND column_type <![CDATA[ <> ]]> '-'
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isSqlServer()">
|
||||
SELECT
|
||||
cast(A.NAME as nvarchar) as column_name,
|
||||
cast(B.NAME as nvarchar) + (case when B.NAME = 'numeric' then '(' + cast(A.prec as nvarchar) + ',' + cast(A.scale as nvarchar) + ')' else '' end) as column_type,
|
||||
cast(G.[VALUE] as nvarchar) as column_comment,
|
||||
(SELECT 1 FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE Z WHERE TABLE_NAME = D.NAME and A.NAME = Z.column_name ) as is_pk,
|
||||
colorder as sort
|
||||
FROM SYSCOLUMNS A
|
||||
LEFT JOIN SYSTYPES B ON A.XTYPE = B.XUSERTYPE
|
||||
INNER JOIN SYSOBJECTS D ON A.ID = D.ID AND D.XTYPE='U' AND D.NAME != 'DTPROPERTIES'
|
||||
LEFT JOIN SYS.EXTENDED_PROPERTIES G ON A.ID = G.MAJOR_ID AND A.COLID = G.MINOR_ID
|
||||
LEFT JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID AND F.MINOR_ID = 0
|
||||
WHERE D.NAME = #{tableName}
|
||||
ORDER BY A.COLORDER
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -14,239 +14,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<id property="columnId" column="column_id"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectPageDbTableList" resultMap="GenTableResult">
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()">
|
||||
select table_name, table_comment, create_time, update_time
|
||||
from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
AND table_name NOT LIKE 'sj_%' AND table_name NOT LIKE 'gen_%'
|
||||
AND table_name NOT LIKE 'act_%' AND table_name NOT LIKE 'flw_%'
|
||||
<if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
|
||||
AND table_name NOT IN
|
||||
<foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="genTable.tableName != null and genTable.tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
|
||||
</if>
|
||||
<if test="genTable.tableComment != null and genTable.tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
|
||||
</if>
|
||||
order by create_time desc
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()">
|
||||
select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
|
||||
from user_tables dt, user_tab_comments dtc, user_objects uo
|
||||
where dt.table_name = dtc.table_name
|
||||
and dt.table_name = uo.object_name
|
||||
and uo.object_type = 'TABLE'
|
||||
AND dt.table_name NOT LIKE 'SJ_%' AND dt.table_name NOT LIKE 'GEN_%'
|
||||
AND dt.table_name NOT LIKE 'ACT_%' AND dt.table_name NOT LIKE 'FLW_%'
|
||||
<if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
|
||||
AND lower(dt.table_name) NOT IN
|
||||
<foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="genTable.tableName != null and genTable.tableName != ''">
|
||||
AND lower(dt.table_name) like lower(concat(concat('%', #{genTable.tableName}), '%'))
|
||||
</if>
|
||||
<if test="genTable.tableComment != null and genTable.tableComment != ''">
|
||||
AND lower(dtc.comments) like lower(concat(concat('%', #{genTable.tableComment}), '%'))
|
||||
</if>
|
||||
order by create_time desc
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
|
||||
select table_name, table_comment, create_time, update_time
|
||||
from (
|
||||
SELECT c.relname AS table_name,
|
||||
obj_description(c.oid) AS table_comment,
|
||||
CURRENT_TIMESTAMP AS create_time,
|
||||
CURRENT_TIMESTAMP AS update_time
|
||||
FROM pg_class c
|
||||
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
|
||||
AND c.relname != 'spatial_%'::text
|
||||
AND n.nspname = 'public'::name
|
||||
AND n.nspname <![CDATA[ <> ]]> ''::name
|
||||
) list_table
|
||||
where table_name NOT LIKE 'sj_%' AND table_name NOT LIKE 'gen_%'
|
||||
AND table_name NOT LIKE 'act_%' AND table_name NOT LIKE 'flw_%'
|
||||
<if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
|
||||
AND table_name NOT IN
|
||||
<foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="genTable.tableName != null and genTable.tableName != ''">
|
||||
AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
|
||||
</if>
|
||||
<if test="genTable.tableComment != null and genTable.tableComment != ''">
|
||||
AND lower(table_comment) like lower(concat('%', #{genTable.tableComment}, '%'))
|
||||
</if>
|
||||
order by create_time desc
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isSqlServer()">
|
||||
SELECT cast(D.NAME as nvarchar) as table_name,
|
||||
cast(F.VALUE as nvarchar) as table_comment,
|
||||
crdate as create_time,
|
||||
refdate as update_time
|
||||
FROM SYSOBJECTS D
|
||||
INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
|
||||
AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
|
||||
AND D.NAME NOT LIKE 'sj_%' AND D.NAME NOT LIKE 'gen_%'
|
||||
AND D.NAME NOT LIKE 'act_%' AND D.NAME NOT LIKE 'flw_%'
|
||||
<if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
|
||||
AND D.NAME NOT IN
|
||||
<foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="genTable.tableName != null and genTable.tableName != ''">
|
||||
AND lower(D.NAME) like lower(concat(N'%', N'${genTable.tableName}', N'%'))
|
||||
</if>
|
||||
<if test="genTable.tableComment != null and genTable.tableComment != ''">
|
||||
AND lower(CAST(F.VALUE AS nvarchar)) like lower(concat(N'%', N'${genTable.tableComment}', N'%'))
|
||||
</if>
|
||||
order by crdate desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
and table_name NOT LIKE 'sj_%' and table_name NOT LIKE 'gen_%'
|
||||
and table_name NOT LIKE 'act_%' AND table_name NOT LIKE 'flw_%'
|
||||
and table_name in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()">
|
||||
select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
|
||||
from user_tables dt, user_tab_comments dtc, user_objects uo
|
||||
where dt.table_name = dtc.table_name
|
||||
and dt.table_name = uo.object_name
|
||||
and uo.object_type = 'TABLE'
|
||||
and dt.table_name NOT LIKE 'SJ_%' AND dt.table_name NOT LIKE 'GEN_%'
|
||||
and dt.table_name NOT LIKE 'ACT_%' AND dt.table_name NOT LIKE 'FLW_%'
|
||||
and lower(dt.table_name) in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
|
||||
select table_name, table_comment, create_time, update_time
|
||||
from (
|
||||
SELECT c.relname AS table_name,
|
||||
obj_description(c.oid) AS table_comment,
|
||||
CURRENT_TIMESTAMP AS create_time,
|
||||
CURRENT_TIMESTAMP AS update_time
|
||||
FROM pg_class c
|
||||
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
|
||||
AND c.relname != 'spatial_%'::text
|
||||
AND n.nspname = 'public'::name
|
||||
AND n.nspname <![CDATA[ <> ]]> ''::name
|
||||
) list_table
|
||||
where table_name NOT LIKE 'sj_%' and table_name NOT LIKE 'gen_%'
|
||||
and table_name NOT LIKE 'act_%' and table_name NOT LIKE 'flw_%'
|
||||
and table_name in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isSqlServer()">
|
||||
SELECT cast(D.NAME as nvarchar) as table_name,
|
||||
cast(F.VALUE as nvarchar) as table_comment,
|
||||
crdate as create_time,
|
||||
refdate as update_time
|
||||
FROM SYSOBJECTS D
|
||||
INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
|
||||
AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
|
||||
AND D.NAME NOT LIKE 'sj_%' AND D.NAME NOT LIKE 'gen_%'
|
||||
AND D.NAME NOT LIKE 'act_%' AND D.NAME NOT LIKE 'flw_%'
|
||||
AND D.NAME in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isMySql()">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select database())
|
||||
and table_name NOT LIKE 'sj_%' and table_name NOT LIKE 'gen_%'
|
||||
and table_name NOT LIKE 'act_%' AND table_name NOT LIKE 'flw_%'
|
||||
and table_name = #{tableName}
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isOracle()">
|
||||
select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
|
||||
from user_tables dt, user_tab_comments dtc, user_objects uo
|
||||
where dt.table_name = dtc.table_name
|
||||
and dt.table_name = uo.object_name
|
||||
and uo.object_type = 'TABLE'
|
||||
AND dt.table_name NOT LIKE 'SJ_%' AND dt.table_name NOT LIKE 'GEN_%'
|
||||
AND dt.table_name NOT LIKE 'ACT_%' AND dt.table_name NOT LIKE 'FLW_%'
|
||||
AND dt.table_name NOT IN (select table_name from gen_table)
|
||||
and lower(dt.table_name) = #{tableName}
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
|
||||
select table_name, table_comment, create_time, update_time
|
||||
from (
|
||||
SELECT c.relname AS table_name,
|
||||
obj_description(c.oid) AS table_comment,
|
||||
CURRENT_TIMESTAMP AS create_time,
|
||||
CURRENT_TIMESTAMP AS update_time
|
||||
FROM pg_class c
|
||||
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
|
||||
AND c.relname != 'spatial_%'::text
|
||||
AND n.nspname = 'public'::name
|
||||
AND n.nspname <![CDATA[ <> ]]> ''::name
|
||||
) list_table
|
||||
where table_name NOT LIKE 'sj_%' and table_name NOT LIKE 'gen_%'
|
||||
and table_name NOT LIKE 'act_%' and table_name NOT LIKE 'flw_%'
|
||||
and table_name = #{tableName}
|
||||
</if>
|
||||
<if test="@org.dromara.common.mybatis.helper.DataBaseHelper@isSqlServer()">
|
||||
SELECT cast(D.NAME as nvarchar) as table_name,
|
||||
cast(F.VALUE as nvarchar) as table_comment,
|
||||
crdate as create_time,
|
||||
refdate as update_time
|
||||
FROM SYSOBJECTS D
|
||||
INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
|
||||
AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
|
||||
AND D.NAME NOT LIKE 'sj_%' AND D.NAME NOT LIKE 'gen_%'
|
||||
AND D.NAME NOT LIKE 'act_%' AND D.NAME NOT LIKE 'flw_%'
|
||||
AND D.NAME = #{tableName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||
<sql id="genSelect">
|
||||
SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
</sql>
|
||||
|
||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||
<include refid="genSelect"/>
|
||||
where t.table_id = #{tableId} order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
<include refid="genSelect"/>
|
||||
where t.table_name = #{tableName} order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||
SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
<include refid="genSelect"/>
|
||||
order by c.sort
|
||||
</select>
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@
|
||||
<artifactId>ruoyi-common-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package org.dromara.system.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
@@ -13,8 +15,6 @@ import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysLogininforBo;
|
||||
import org.dromara.system.domain.vo.SysLogininforVo;
|
||||
import org.dromara.system.service.ISysLogininforService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SysLogininforController extends BaseController {
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public R<Void> unlock(@PathVariable("userName") String userName) {
|
||||
String loginName = GlobalConstants.PWD_ERR_CNT_KEY + userName;
|
||||
String loginName = CacheConstants.PWD_ERR_CNT_KEY + userName;
|
||||
if (RedisUtils.hasKey(loginName)) {
|
||||
RedisUtils.deleteObject(loginName);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.system.domain.bo.SysNoticeBo;
|
||||
import org.dromara.system.domain.vo.SysNoticeVo;
|
||||
import org.dromara.system.service.ISysNoticeService;
|
||||
@@ -62,7 +62,7 @@ public class SysNoticeController extends BaseController {
|
||||
return R.fail();
|
||||
}
|
||||
String type = dictService.getDictLabel("sys_notice_type", notice.getNoticeType());
|
||||
WebSocketUtils.publishAll("[" + type + "] " + notice.getNoticeTitle());
|
||||
SseMessageUtils.publishAll("[" + type + "] " + notice.getNoticeTitle());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
|
||||
private LambdaQueryWrapper<SysDept> buildQueryWrapper(SysDeptBo bo) {
|
||||
LambdaQueryWrapper<SysDept> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(SysDept::getDelFlag, "0");
|
||||
lqw.eq(SysDept::getDelFlag, UserConstants.DEL_FLAG_NORMAL);
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getDeptId()), SysDept::getDeptId, bo.getDeptId());
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
|
||||
|
||||
@@ -77,8 +77,9 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
@Override
|
||||
public List<SysOssVo> listByIds(Collection<Long> ossIds) {
|
||||
List<SysOssVo> list = new ArrayList<>();
|
||||
SysOssServiceImpl ossService = SpringUtils.getAopProxy(this);
|
||||
for (Long id : ossIds) {
|
||||
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
||||
SysOssVo vo = ossService.getById(id);
|
||||
if (ObjectUtil.isNotNull(vo)) {
|
||||
try {
|
||||
list.add(this.matchingUrl(vo));
|
||||
@@ -100,8 +101,9 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
@Override
|
||||
public String selectUrlByIds(String ossIds) {
|
||||
List<String> list = new ArrayList<>();
|
||||
SysOssServiceImpl ossService = SpringUtils.getAopProxy(this);
|
||||
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
|
||||
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
||||
SysOssVo vo = ossService.getById(id);
|
||||
if (ObjectUtil.isNotNull(vo)) {
|
||||
try {
|
||||
list.add(this.matchingUrl(vo).getUrl());
|
||||
|
||||
@@ -26,10 +26,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.helper.DataBaseHelper;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.SysUserPost;
|
||||
import org.dromara.system.domain.SysUserRole;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.domain.vo.SysRoleVo;
|
||||
@@ -473,17 +470,14 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
*/
|
||||
private void insertUserRole(Long userId, Long[] roleIds, boolean clear) {
|
||||
if (ArrayUtil.isNotEmpty(roleIds)) {
|
||||
// 判断是否具有此角色的操作权限
|
||||
List<SysRoleVo> roles = roleMapper.selectRoleList(new LambdaQueryWrapper<>());
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色的数据");
|
||||
}
|
||||
List<Long> roleList = StreamUtils.toList(roles, SysRoleVo::getRoleId);
|
||||
List<Long> roleList = new ArrayList<>(List.of(roleIds));
|
||||
if (!LoginHelper.isSuperAdmin(userId)) {
|
||||
roleList.remove(UserConstants.SUPER_ADMIN_ID);
|
||||
}
|
||||
List<Long> canDoRoleList = StreamUtils.filter(List.of(roleIds), roleList::contains);
|
||||
if (CollUtil.isEmpty(canDoRoleList)) {
|
||||
// 判断是否具有此角色的操作权限
|
||||
List<SysRoleVo> roles = roleMapper.selectRoleList(
|
||||
new QueryWrapper<SysRole>().in("r.role_id", roleList));
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色的数据");
|
||||
}
|
||||
if (clear) {
|
||||
@@ -491,7 +485,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
}
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = StreamUtils.toList(canDoRoleList, roleId -> {
|
||||
List<SysUserRole> list = StreamUtils.toList(roleList, roleId -> {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
@@ -640,7 +634,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
return List.of();
|
||||
}
|
||||
List<SysUserVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName)
|
||||
.select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName, SysUser::getEmail, SysUser::getPhonenumber)
|
||||
.eq(SysUser::getStatus, UserConstants.USER_NORMAL)
|
||||
.in(CollUtil.isNotEmpty(userIds), SysUser::getUserId, userIds));
|
||||
return BeanUtil.copyToList(list, UserDTO.class);
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlgraphics</groupId>
|
||||
<artifactId>batik-all</artifactId>
|
||||
<version>1.10</version>
|
||||
<version>1.17</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xalan</groupId>
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.dromara.workflow.domain.vo.ModelVo;
|
||||
import org.dromara.workflow.service.IActModelService;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -36,8 +37,8 @@ import java.util.List;
|
||||
@RequestMapping("/workflow/model")
|
||||
public class ActModelController extends BaseController {
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private RepositoryService repositoryService;
|
||||
private final IActModelService actModelService;
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.dromara.workflow.service.IActTaskService;
|
||||
import org.dromara.workflow.service.IWfTaskBackNodeService;
|
||||
import org.dromara.workflow.utils.QueryUtils;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -38,10 +39,9 @@ import java.util.Map;
|
||||
@RequestMapping("/workflow/task")
|
||||
public class ActTaskController extends BaseController {
|
||||
|
||||
@Autowired(required = false)
|
||||
private TaskService taskService;
|
||||
private final IActTaskService actTaskService;
|
||||
|
||||
private final TaskService taskService;
|
||||
|
||||
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.ModelQuery;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.validation.ValidationError;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -65,7 +66,8 @@ import java.util.zip.ZipOutputStream;
|
||||
@Service
|
||||
public class ActModelServiceImpl implements IActModelService {
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
@Autowired(required = false)
|
||||
private RepositoryService repositoryService;
|
||||
private final IWfNodeConfigService wfNodeConfigService;
|
||||
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.impl.bpmn.deployer.ResourceNameUtil;
|
||||
import org.flowable.engine.repository.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -61,8 +62,10 @@ import java.util.zip.ZipInputStream;
|
||||
@Service
|
||||
public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionService {
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
private final ProcessMigrationService processMigrationService;
|
||||
@Autowired(required = false)
|
||||
private RepositoryService repositoryService;
|
||||
@Autowired(required = false)
|
||||
private ProcessMigrationService processMigrationService;
|
||||
private final IWfCategoryService wfCategoryService;
|
||||
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
||||
private final WfDefinitionConfigMapper wfDefinitionConfigMapper;
|
||||
@@ -288,6 +291,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
|
||||
Model modelData = repositoryService.newModel();
|
||||
modelData.setKey(pd.getKey());
|
||||
modelData.setName(pd.getName());
|
||||
modelData.setCategory(pd.getCategory());
|
||||
modelData.setTenantId(pd.getTenantId());
|
||||
repositoryService.saveModel(modelData);
|
||||
repositoryService.addModelEditorSource(modelData.getId(), IoUtil.readBytes(inputStream));
|
||||
@@ -350,8 +354,7 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
|
||||
initWfDefConfig();
|
||||
} else {
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String bpmnResourceSuffix = ResourceNameUtil.BPMN_RESOURCE_SUFFIXES[0];
|
||||
if (originalFilename.contains(bpmnResourceSuffix)) {
|
||||
if (StringUtils.containsAny(originalFilename, ResourceNameUtil.BPMN_RESOURCE_SUFFIXES)) {
|
||||
// 文件名 = 流程名称-流程key
|
||||
String[] splitFilename = originalFilename.substring(0, originalFilename.lastIndexOf(".")).split("-");
|
||||
if (splitFilename.length < 2) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.flowable.engine.task.Comment;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -68,12 +69,17 @@ import java.util.*;
|
||||
@Service
|
||||
public class ActProcessInstanceServiceImpl implements IActProcessInstanceService {
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
private final RuntimeService runtimeService;
|
||||
private final HistoryService historyService;
|
||||
private final TaskService taskService;
|
||||
@Autowired(required = false)
|
||||
private RepositoryService repositoryService;
|
||||
@Autowired(required = false)
|
||||
private RuntimeService runtimeService;
|
||||
@Autowired(required = false)
|
||||
private HistoryService historyService;
|
||||
@Autowired(required = false)
|
||||
private TaskService taskService;
|
||||
@Autowired(required = false)
|
||||
private ManagementService managementService;
|
||||
private final IActHiProcinstService actHiProcinstService;
|
||||
private final ManagementService managementService;
|
||||
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
||||
private final IWfNodeConfigService wfNodeConfigService;
|
||||
private final FlowProcessEventHandler flowProcessEventHandler;
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import org.flowable.variable.api.persistence.entity.VariableInstance;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -71,11 +72,16 @@ import static org.dromara.workflow.common.constant.FlowConstant.*;
|
||||
@Service
|
||||
public class ActTaskServiceImpl implements IActTaskService {
|
||||
|
||||
private final RuntimeService runtimeService;
|
||||
private final TaskService taskService;
|
||||
private final HistoryService historyService;
|
||||
private final IdentityService identityService;
|
||||
private final ManagementService managementService;
|
||||
@Autowired(required = false)
|
||||
private RuntimeService runtimeService;
|
||||
@Autowired(required = false)
|
||||
private TaskService taskService;
|
||||
@Autowired(required = false)
|
||||
private HistoryService historyService;
|
||||
@Autowired(required = false)
|
||||
private IdentityService identityService;
|
||||
@Autowired(required = false)
|
||||
private ManagementService managementService;
|
||||
private final ActTaskMapper actTaskMapper;
|
||||
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
||||
private final ActHiTaskinstMapper actHiTaskinstMapper;
|
||||
@@ -261,7 +267,7 @@ public class ActTaskServiceImpl implements IActTaskService {
|
||||
queryWrapper.eq("t.business_status_", BusinessStatusEnum.WAITING.getStatus());
|
||||
queryWrapper.eq(TenantHelper.isEnable(), "t.tenant_id_", TenantHelper.getTenantId());
|
||||
String ids = StreamUtils.join(roleIds, x -> "'" + x + "'");
|
||||
queryWrapper.and(w1 -> w1.eq("t.assignee_", userId).or(w2 -> w2.isNull("t.assignee_").apply("exists ( select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = t.ID_ and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = {0} or ( LINK.GROUP_ID_ IN ({1}) ) ))", userId, ids)));
|
||||
queryWrapper.and(w1 -> w1.eq("t.assignee_", userId).or(w2 -> w2.isNull("t.assignee_").apply("exists ( select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = t.ID_ and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = {0} or ( LINK.GROUP_ID_ IN (" + ids + ") ) ))", userId)));
|
||||
if (StringUtils.isNotBlank(taskBo.getName())) {
|
||||
queryWrapper.like("t.name_", taskBo.getName());
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.Model;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -32,8 +33,8 @@ import java.util.List;
|
||||
public class WfCategoryServiceImpl implements IWfCategoryService {
|
||||
|
||||
private final WfCategoryMapper baseMapper;
|
||||
|
||||
private final RepositoryService repositoryService;
|
||||
@Autowired(required = false)
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
/**
|
||||
* 查询流程分类
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.dromara.workflow.service.IActHiProcinstService;
|
||||
import org.dromara.workflow.service.IActProcessInstanceService;
|
||||
import org.dromara.workflow.utils.WorkflowUtils;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,8 +23,9 @@ import java.util.Map;
|
||||
@Service
|
||||
public class WorkflowServiceImpl implements WorkflowService {
|
||||
|
||||
@Autowired(required = false)
|
||||
private RuntimeService runtimeService;
|
||||
private final IActProcessInstanceService iActProcessInstanceService;
|
||||
private final RuntimeService runtimeService;
|
||||
private final IActHiProcinstService iActHiProcinstService;
|
||||
/**
|
||||
* 运行中的实例 删除程实例,删除历史记录,删除业务与流程关联信息
|
||||
|
||||
@@ -78,10 +78,13 @@ http {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# websocket参数
|
||||
proxy_read_timeout 86400s;
|
||||
# sse 与 websocket参数
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_pass http://server/;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
SnailJob Database Transfer Tool
|
||||
Source Server Type : MySQL
|
||||
Target Server Type : Oracle
|
||||
Date: 2024-05-14 23:36:38
|
||||
Date: 2024-07-06 12:49:36
|
||||
*/
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id);
|
||||
COMMENT ON COLUMN sj_notify_recipient.id IS '主键';
|
||||
COMMENT ON COLUMN sj_notify_recipient.namespace_id IS '命名空间id';
|
||||
COMMENT ON COLUMN sj_notify_recipient.recipient_name IS '接收人名称';
|
||||
COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书';
|
||||
COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook';
|
||||
COMMENT ON COLUMN sj_notify_recipient.notify_attribute IS '配置属性';
|
||||
COMMENT ON COLUMN sj_notify_recipient.description IS '描述';
|
||||
COMMENT ON COLUMN sj_notify_recipient.create_dt IS '创建时间';
|
||||
@@ -296,8 +296,8 @@ CREATE TABLE sj_retry_task_log_message
|
||||
ALTER TABLE sj_retry_task_log_message
|
||||
ADD CONSTRAINT pk_sj_retry_task_log_message PRIMARY KEY (id);
|
||||
|
||||
CREATE INDEX idx_sj_retry_task_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, unique_id);
|
||||
CREATE INDEX idx_sj_retry_task_log_message_02 ON sj_retry_task_log_message (create_dt);
|
||||
CREATE INDEX idx_sj_rt_log_message_01 ON sj_retry_task_log_message (namespace_id, group_name, unique_id);
|
||||
CREATE INDEX idx_sj_rt_log_message_02 ON sj_retry_task_log_message (create_dt);
|
||||
|
||||
COMMENT ON COLUMN sj_retry_task_log_message.id IS '主键';
|
||||
COMMENT ON COLUMN sj_retry_task_log_message.namespace_id IS '命名空间id';
|
||||
@@ -389,8 +389,7 @@ COMMENT ON TABLE sj_server_node IS '服务器节点';
|
||||
-- sj_distributed_lock
|
||||
CREATE TABLE sj_distributed_lock
|
||||
(
|
||||
id number GENERATED ALWAYS AS IDENTITY,
|
||||
name varchar2(64) NULL,
|
||||
name varchar2(64) NOT NULL,
|
||||
lock_until timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL,
|
||||
locked_at timestamp(3) DEFAULT CURRENT_TIMESTAMP(3) NOT NULL,
|
||||
locked_by varchar2(255) NULL,
|
||||
@@ -399,9 +398,8 @@ CREATE TABLE sj_distributed_lock
|
||||
);
|
||||
|
||||
ALTER TABLE sj_distributed_lock
|
||||
ADD CONSTRAINT pk_sj_distributed_lock PRIMARY KEY (id);
|
||||
ADD CONSTRAINT pk_sj_distributed_lock PRIMARY KEY (name);
|
||||
|
||||
COMMENT ON COLUMN sj_distributed_lock.id IS '主键';
|
||||
COMMENT ON COLUMN sj_distributed_lock.name IS '锁名称';
|
||||
COMMENT ON COLUMN sj_distributed_lock.lock_until IS '锁定时长';
|
||||
COMMENT ON COLUMN sj_distributed_lock.locked_at IS '锁定时间';
|
||||
@@ -449,7 +447,7 @@ CREATE TABLE sj_system_user_permission
|
||||
ALTER TABLE sj_system_user_permission
|
||||
ADD CONSTRAINT pk_sj_system_user_permission PRIMARY KEY (id);
|
||||
|
||||
CREATE UNIQUE INDEX uk_sj_system_user_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id);
|
||||
CREATE UNIQUE INDEX uk_sj_su_permission_01 ON sj_system_user_permission (namespace_id, group_name, system_user_id);
|
||||
|
||||
COMMENT ON COLUMN sj_system_user_permission.id IS '主键';
|
||||
COMMENT ON COLUMN sj_system_user_permission.group_name IS '组名称';
|
||||
@@ -598,7 +596,11 @@ CREATE TABLE sj_job_task
|
||||
parent_id number DEFAULT 0 NOT NULL,
|
||||
task_status smallint DEFAULT 0 NOT NULL,
|
||||
retry_count number DEFAULT 0 NOT NULL,
|
||||
mr_stage smallint DEFAULT NULL NULL,
|
||||
leaf smallint DEFAULT '1' NOT NULL,
|
||||
task_name varchar2(255) DEFAULT '' NULL,
|
||||
client_info varchar2(128) DEFAULT NULL NULL,
|
||||
wf_context clob DEFAULT NULL NULL,
|
||||
result_message clob NULL,
|
||||
args_str clob DEFAULT NULL NULL,
|
||||
args_type smallint DEFAULT 1 NOT NULL,
|
||||
@@ -622,7 +624,11 @@ COMMENT ON COLUMN sj_job_task.task_batch_id IS '调度任务id';
|
||||
COMMENT ON COLUMN sj_job_task.parent_id IS '父执行器id';
|
||||
COMMENT ON COLUMN sj_job_task.task_status IS '执行的状态 0、失败 1、成功';
|
||||
COMMENT ON COLUMN sj_job_task.retry_count IS '重试次数';
|
||||
COMMENT ON COLUMN sj_job_task.mr_stage IS '动态分片所处阶段 1:map 2:reduce 3:mergeReduce';
|
||||
COMMENT ON COLUMN sj_job_task.leaf IS '叶子节点';
|
||||
COMMENT ON COLUMN sj_job_task.task_name IS '任务名称';
|
||||
COMMENT ON COLUMN sj_job_task.client_info IS '客户端地址 clientId#ip:port';
|
||||
COMMENT ON COLUMN sj_job_task.wf_context IS '工作流全局上下文';
|
||||
COMMENT ON COLUMN sj_job_task.result_message IS '执行结果';
|
||||
COMMENT ON COLUMN sj_job_task.args_str IS '执行方法参数';
|
||||
COMMENT ON COLUMN sj_job_task.args_type IS '参数类型 ';
|
||||
@@ -773,6 +779,7 @@ CREATE TABLE sj_workflow
|
||||
executor_timeout number DEFAULT 0 NOT NULL,
|
||||
description varchar2(256) DEFAULT '' NULL,
|
||||
flow_info clob DEFAULT NULL NULL,
|
||||
wf_context clob DEFAULT NULL NULL,
|
||||
bucket_index number DEFAULT 0 NOT NULL,
|
||||
version number NOT NULL,
|
||||
ext_attrs varchar2(256) DEFAULT '' NULL,
|
||||
@@ -799,6 +806,7 @@ COMMENT ON COLUMN sj_workflow.block_strategy IS '阻塞策略 1、丢弃 2、覆
|
||||
COMMENT ON COLUMN sj_workflow.executor_timeout IS '任务执行超时时间,单位秒';
|
||||
COMMENT ON COLUMN sj_workflow.description IS '描述';
|
||||
COMMENT ON COLUMN sj_workflow.flow_info IS '流程信息';
|
||||
COMMENT ON COLUMN sj_workflow.wf_context IS '上下文';
|
||||
COMMENT ON COLUMN sj_workflow.bucket_index IS 'bucket';
|
||||
COMMENT ON COLUMN sj_workflow.version IS '版本号';
|
||||
COMMENT ON COLUMN sj_workflow.ext_attrs IS '扩展字段';
|
||||
@@ -864,8 +872,10 @@ CREATE TABLE sj_workflow_task_batch
|
||||
task_batch_status smallint DEFAULT 0 NOT NULL,
|
||||
operation_reason smallint DEFAULT 0 NOT NULL,
|
||||
flow_info clob DEFAULT NULL NULL,
|
||||
wf_context clob DEFAULT NULL NULL,
|
||||
execution_at number DEFAULT 0 NOT NULL,
|
||||
ext_attrs varchar2(256) DEFAULT '' NULL,
|
||||
version number DEFAULT 1 NOT NULL,
|
||||
deleted smallint DEFAULT 0 NOT NULL,
|
||||
create_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_dt date DEFAULT CURRENT_TIMESTAMP NOT NULL
|
||||
@@ -885,10 +895,11 @@ COMMENT ON COLUMN sj_workflow_task_batch.workflow_id IS '工作流任务id';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.operation_reason IS '操作原因';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.flow_info IS '流程信息';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.wf_context IS '全局上下文';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.execution_at IS '任务执行时间';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.ext_attrs IS '扩展字段';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.version IS '版本号';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.deleted IS '逻辑删除 1、删除';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.create_dt IS '创建时间';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.update_dt IS '修改时间';
|
||||
COMMENT ON TABLE sj_workflow_task_batch IS '工作流批次';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
SnailJob Database Transfer Tool
|
||||
Source Server Type : MySQL
|
||||
Target Server Type : PostgreSQL
|
||||
Date: 2024-05-13 22:49:34
|
||||
Date: 2024-07-06 11:45:40
|
||||
*/
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ CREATE INDEX idx_sj_notify_recipient_01 ON sj_notify_recipient (namespace_id);
|
||||
COMMENT ON COLUMN sj_notify_recipient.id IS '主键';
|
||||
COMMENT ON COLUMN sj_notify_recipient.namespace_id IS '命名空间id';
|
||||
COMMENT ON COLUMN sj_notify_recipient.recipient_name IS '接收人名称';
|
||||
COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书';
|
||||
COMMENT ON COLUMN sj_notify_recipient.notify_type IS '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook';
|
||||
COMMENT ON COLUMN sj_notify_recipient.notify_attribute IS '配置属性';
|
||||
COMMENT ON COLUMN sj_notify_recipient.description IS '描述';
|
||||
COMMENT ON COLUMN sj_notify_recipient.create_dt IS '创建时间';
|
||||
@@ -359,8 +359,7 @@ COMMENT ON TABLE sj_server_node IS '服务器节点';
|
||||
-- sj_distributed_lock
|
||||
CREATE TABLE sj_distributed_lock
|
||||
(
|
||||
id bigserial PRIMARY KEY,
|
||||
name varchar(64) NOT NULL,
|
||||
name varchar(64) PRIMARY KEY,
|
||||
lock_until timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
locked_at timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
locked_by varchar(255) NOT NULL,
|
||||
@@ -368,7 +367,6 @@ CREATE TABLE sj_distributed_lock
|
||||
update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN sj_distributed_lock.id IS '主键';
|
||||
COMMENT ON COLUMN sj_distributed_lock.name IS '锁名称';
|
||||
COMMENT ON COLUMN sj_distributed_lock.lock_until IS '锁定时长';
|
||||
COMMENT ON COLUMN sj_distributed_lock.locked_at IS '锁定时间';
|
||||
@@ -550,7 +548,11 @@ CREATE TABLE sj_job_task
|
||||
parent_id bigint NOT NULL DEFAULT 0,
|
||||
task_status smallint NOT NULL DEFAULT 0,
|
||||
retry_count int NOT NULL DEFAULT 0,
|
||||
mr_stage smallint NULL DEFAULT NULL,
|
||||
leaf smallint NOT NULL DEFAULT '1',
|
||||
task_name varchar(255) NOT NULL DEFAULT '',
|
||||
client_info varchar(128) NULL DEFAULT NULL,
|
||||
wf_context text NULL DEFAULT NULL,
|
||||
result_message text NOT NULL,
|
||||
args_str text NULL DEFAULT NULL,
|
||||
args_type smallint NOT NULL DEFAULT 1,
|
||||
@@ -571,7 +573,11 @@ COMMENT ON COLUMN sj_job_task.task_batch_id IS '调度任务id';
|
||||
COMMENT ON COLUMN sj_job_task.parent_id IS '父执行器id';
|
||||
COMMENT ON COLUMN sj_job_task.task_status IS '执行的状态 0、失败 1、成功';
|
||||
COMMENT ON COLUMN sj_job_task.retry_count IS '重试次数';
|
||||
COMMENT ON COLUMN sj_job_task.mr_stage IS '动态分片所处阶段 1:map 2:reduce 3:mergeReduce';
|
||||
COMMENT ON COLUMN sj_job_task.leaf IS '叶子节点';
|
||||
COMMENT ON COLUMN sj_job_task.task_name IS '任务名称';
|
||||
COMMENT ON COLUMN sj_job_task.client_info IS '客户端地址 clientId#ip:port';
|
||||
COMMENT ON COLUMN sj_job_task.wf_context IS '工作流全局上下文';
|
||||
COMMENT ON COLUMN sj_job_task.result_message IS '执行结果';
|
||||
COMMENT ON COLUMN sj_job_task.args_str IS '执行方法参数';
|
||||
COMMENT ON COLUMN sj_job_task.args_type IS '参数类型 ';
|
||||
@@ -713,6 +719,7 @@ CREATE TABLE sj_workflow
|
||||
executor_timeout int NOT NULL DEFAULT 0,
|
||||
description varchar(256) NOT NULL DEFAULT '',
|
||||
flow_info text NULL DEFAULT NULL,
|
||||
wf_context text NULL DEFAULT NULL,
|
||||
bucket_index int NOT NULL DEFAULT 0,
|
||||
version int NOT NULL,
|
||||
ext_attrs varchar(256) NULL DEFAULT '',
|
||||
@@ -736,6 +743,7 @@ COMMENT ON COLUMN sj_workflow.block_strategy IS '阻塞策略 1、丢弃 2、覆
|
||||
COMMENT ON COLUMN sj_workflow.executor_timeout IS '任务执行超时时间,单位秒';
|
||||
COMMENT ON COLUMN sj_workflow.description IS '描述';
|
||||
COMMENT ON COLUMN sj_workflow.flow_info IS '流程信息';
|
||||
COMMENT ON COLUMN sj_workflow.wf_context IS '上下文';
|
||||
COMMENT ON COLUMN sj_workflow.bucket_index IS 'bucket';
|
||||
COMMENT ON COLUMN sj_workflow.version IS '版本号';
|
||||
COMMENT ON COLUMN sj_workflow.ext_attrs IS '扩展字段';
|
||||
@@ -798,8 +806,10 @@ CREATE TABLE sj_workflow_task_batch
|
||||
task_batch_status smallint NOT NULL DEFAULT 0,
|
||||
operation_reason smallint NOT NULL DEFAULT 0,
|
||||
flow_info text NULL DEFAULT NULL,
|
||||
wf_context text NULL DEFAULT NULL,
|
||||
execution_at bigint NOT NULL DEFAULT 0,
|
||||
ext_attrs varchar(256) NULL DEFAULT '',
|
||||
version int NOT NULL DEFAULT 1,
|
||||
deleted smallint NOT NULL DEFAULT 0,
|
||||
create_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
update_dt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
@@ -816,10 +826,11 @@ COMMENT ON COLUMN sj_workflow_task_batch.workflow_id IS '工作流任务id';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.task_batch_status IS '任务批次状态 0、失败 1、成功';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.operation_reason IS '操作原因';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.flow_info IS '流程信息';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.wf_context IS '全局上下文';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.execution_at IS '任务执行时间';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.ext_attrs IS '扩展字段';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.version IS '版本号';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.deleted IS '逻辑删除 1、删除';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.create_dt IS '创建时间';
|
||||
COMMENT ON COLUMN sj_workflow_task_batch.update_dt IS '修改时间';
|
||||
COMMENT ON TABLE sj_workflow_task_batch IS '工作流批次';
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ CREATE TABLE `sj_notify_recipient`
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id',
|
||||
`recipient_name` varchar(64) NOT NULL COMMENT '接收人名称',
|
||||
`notify_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书',
|
||||
`notify_type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook',
|
||||
`notify_attribute` varchar(512) NOT NULL COMMENT '配置属性',
|
||||
`description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
@@ -222,15 +222,13 @@ CREATE TABLE `sj_server_node`
|
||||
|
||||
CREATE TABLE `sj_distributed_lock`
|
||||
(
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`name` varchar(64) NOT NULL COMMENT '锁名称',
|
||||
`lock_until` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '锁定时长',
|
||||
`locked_at` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '锁定时间',
|
||||
`locked_by` varchar(255) NOT NULL COMMENT '锁定者',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_name` (`name`)
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 0
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='锁定表';
|
||||
@@ -345,12 +343,16 @@ CREATE TABLE `sj_job_task`
|
||||
`job_id` bigint(20) NOT NULL COMMENT '任务信息id',
|
||||
`task_batch_id` bigint(20) NOT NULL COMMENT '调度任务id',
|
||||
`parent_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '父执行器id',
|
||||
`task_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '执行的状态 0、失败 1、成功',
|
||||
`task_status` tinyint NOT NULL DEFAULT 0 COMMENT '执行的状态 0、失败 1、成功',
|
||||
`retry_count` int(11) NOT NULL DEFAULT 0 COMMENT '重试次数',
|
||||
`mr_stage` tinyint DEFAULT NULL COMMENT '动态分片所处阶段 1:map 2:reduce 3:mergeReduce',
|
||||
`leaf` tinyint NOT NULL DEFAULT '1' COMMENT '叶子节点',
|
||||
`task_name` varchar(255) NOT NULL DEFAULT '' COMMENT '任务名称',
|
||||
`client_info` varchar(128) DEFAULT NULL COMMENT '客户端地址 clientId#ip:port',
|
||||
`wf_context` text DEFAULT NULL COMMENT '工作流全局上下文',
|
||||
`result_message` text NOT NULL COMMENT '执行结果',
|
||||
`args_str` text DEFAULT NULL COMMENT '执行方法参数',
|
||||
`args_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '参数类型 ',
|
||||
`args_type` tinyint NOT NULL DEFAULT 1 COMMENT '参数类型 ',
|
||||
`ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
@@ -447,6 +449,7 @@ CREATE TABLE `sj_workflow`
|
||||
`executor_timeout` int(11) NOT NULL DEFAULT 0 COMMENT '任务执行超时时间,单位秒',
|
||||
`description` varchar(256) NOT NULL DEFAULT '' COMMENT '描述',
|
||||
`flow_info` text DEFAULT NULL COMMENT '流程信息',
|
||||
`wf_context` text DEFAULT NULL COMMENT '上下文',
|
||||
`bucket_index` int(11) NOT NULL DEFAULT 0 COMMENT 'bucket',
|
||||
`version` int(11) NOT NULL COMMENT '版本号',
|
||||
`ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段',
|
||||
@@ -495,8 +498,10 @@ CREATE TABLE `sj_workflow_task_batch`
|
||||
`task_batch_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '任务批次状态 0、失败 1、成功',
|
||||
`operation_reason` tinyint(4) NOT NULL DEFAULT 0 COMMENT '操作原因',
|
||||
`flow_info` text DEFAULT NULL COMMENT '流程信息',
|
||||
`wf_context` text DEFAULT NULL COMMENT '全局上下文',
|
||||
`execution_at` bigint(13) NOT NULL DEFAULT 0 COMMENT '任务执行时间',
|
||||
`ext_attrs` varchar(256) NULL DEFAULT '' COMMENT '扩展字段',
|
||||
`version` int(11) NOT NULL DEFAULT 1 COMMENT '版本号',
|
||||
`deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除 1、删除',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
SnailJob Database Transfer Tool
|
||||
Source Server Type : MySQL
|
||||
Target Server Type : Microsoft SQL Server
|
||||
Date: 2024-05-13 23:03:34
|
||||
Date: 2024-07-06 12:55:47
|
||||
*/
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ EXEC sp_addextendedproperty
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书',
|
||||
'MS_Description', N'通知类型 1、钉钉 2、邮件 3、企业微信 4 飞书 5 webhook',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_notify_recipient',
|
||||
'COLUMN', N'notify_type'
|
||||
@@ -1142,8 +1142,7 @@ GO
|
||||
-- sj_distributed_lock
|
||||
CREATE TABLE sj_distributed_lock
|
||||
(
|
||||
id bigint NOT NULL PRIMARY KEY IDENTITY,
|
||||
name nvarchar(64) NOT NULL,
|
||||
name nvarchar(64) NOT NULL PRIMARY KEY,
|
||||
lock_until datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
locked_at datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
locked_by nvarchar(255) NOT NULL,
|
||||
@@ -1152,13 +1151,6 @@ CREATE TABLE sj_distributed_lock
|
||||
)
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'主键',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_distributed_lock',
|
||||
'COLUMN', N'id'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'锁名称',
|
||||
'SCHEMA', N'dbo',
|
||||
@@ -1745,7 +1737,11 @@ CREATE TABLE sj_job_task
|
||||
parent_id bigint NOT NULL DEFAULT 0,
|
||||
task_status tinyint NOT NULL DEFAULT 0,
|
||||
retry_count int NOT NULL DEFAULT 0,
|
||||
mr_stage tinyint NULL DEFAULT NULL,
|
||||
leaf tinyint NOT NULL DEFAULT '1',
|
||||
task_name nvarchar(255) NOT NULL DEFAULT '',
|
||||
client_info nvarchar(128) NULL DEFAULT NULL,
|
||||
wf_context nvarchar(max) NULL DEFAULT NULL,
|
||||
result_message nvarchar(max) NOT NULL,
|
||||
args_str nvarchar(max) NULL DEFAULT NULL,
|
||||
args_type tinyint NOT NULL DEFAULT 1,
|
||||
@@ -1818,6 +1814,27 @@ EXEC sp_addextendedproperty
|
||||
'COLUMN', N'retry_count'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'动态分片所处阶段 1:map 2:reduce 3:mergeReduce',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_job_task',
|
||||
'COLUMN', N'mr_stage'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'叶子节点',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_job_task',
|
||||
'COLUMN', N'leaf'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'任务名称',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_job_task',
|
||||
'COLUMN', N'task_name'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'客户端地址 clientId#ip:port',
|
||||
'SCHEMA', N'dbo',
|
||||
@@ -1825,6 +1842,13 @@ EXEC sp_addextendedproperty
|
||||
'COLUMN', N'client_info'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'工作流全局上下文',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_job_task',
|
||||
'COLUMN', N'wf_context'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'执行结果',
|
||||
'SCHEMA', N'dbo',
|
||||
@@ -2281,6 +2305,7 @@ CREATE TABLE sj_workflow
|
||||
executor_timeout int NOT NULL DEFAULT 0,
|
||||
description nvarchar(256) NOT NULL DEFAULT '',
|
||||
flow_info nvarchar(max) NULL DEFAULT NULL,
|
||||
wf_context nvarchar(max) NULL DEFAULT NULL,
|
||||
bucket_index int NOT NULL DEFAULT 0,
|
||||
version int NOT NULL,
|
||||
ext_attrs nvarchar(256) NULL DEFAULT '',
|
||||
@@ -2379,6 +2404,13 @@ EXEC sp_addextendedproperty
|
||||
'COLUMN', N'flow_info'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'上下文',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_workflow',
|
||||
'COLUMN', N'wf_context'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'bucket',
|
||||
'SCHEMA', N'dbo',
|
||||
@@ -2590,8 +2622,10 @@ CREATE TABLE sj_workflow_task_batch
|
||||
task_batch_status tinyint NOT NULL DEFAULT 0,
|
||||
operation_reason tinyint NOT NULL DEFAULT 0,
|
||||
flow_info nvarchar(max) NULL DEFAULT NULL,
|
||||
wf_context nvarchar(max) NULL DEFAULT NULL,
|
||||
execution_at bigint NOT NULL DEFAULT 0,
|
||||
ext_attrs nvarchar(256) NULL DEFAULT '',
|
||||
version int NOT NULL DEFAULT 1,
|
||||
deleted tinyint NOT NULL DEFAULT 0,
|
||||
create_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
update_dt datetime2 NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
@@ -2654,6 +2688,13 @@ EXEC sp_addextendedproperty
|
||||
'COLUMN', N'flow_info'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'全局上下文',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_workflow_task_batch',
|
||||
'COLUMN', N'wf_context'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'任务执行时间',
|
||||
'SCHEMA', N'dbo',
|
||||
@@ -2668,6 +2709,13 @@ EXEC sp_addextendedproperty
|
||||
'COLUMN', N'ext_attrs'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'版本号',
|
||||
'SCHEMA', N'dbo',
|
||||
'TABLE', N'sj_workflow_task_batch',
|
||||
'COLUMN', N'version'
|
||||
GO
|
||||
|
||||
EXEC sp_addextendedproperty
|
||||
'MS_Description', N'逻辑删除 1、删除',
|
||||
'SCHEMA', N'dbo',
|
||||
|
||||
Reference in New Issue
Block a user