mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-11-25 02:16:46 +08:00
Compare commits
71 Commits
v5.4.2
...
48213bc9c9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48213bc9c9 | ||
|
|
3995d9699d | ||
|
|
ecd4e3eaf0 | ||
|
|
2e3a42c669 | ||
|
|
82997fc6cd | ||
|
|
0dce571270 | ||
|
|
9375578925 | ||
|
|
e19ccf5064 | ||
|
|
1cea7b72d7 | ||
|
|
5da9ddf5e3 | ||
|
|
93ee01c6b9 | ||
|
|
acd30fda3c | ||
|
|
3f62a76cc8 | ||
|
|
b0b4e573f6 | ||
|
|
de61899eed | ||
|
|
3a9bdb36f1 | ||
|
|
b815b8e574 | ||
|
|
45edee4e63 | ||
|
|
868bc492a2 | ||
|
|
90fef1bb17 | ||
|
|
d79b48ea99 | ||
|
|
f6993a1491 | ||
|
|
6b0b7382a6 | ||
|
|
c41add355f | ||
|
|
74e3d232f5 | ||
|
|
03fca40c7d | ||
|
|
b2ad257bd8 | ||
|
|
7e4f0d73f4 | ||
|
|
2ec802f17f | ||
|
|
e0ce662c28 | ||
|
|
3d9ed1b92f | ||
|
|
d4e6e70c43 | ||
|
|
2095a96e67 | ||
|
|
328b61b252 | ||
|
|
781463417c | ||
|
|
446a14b928 | ||
|
|
6c2518640b | ||
|
|
d8d138092f | ||
|
|
ec31b736c7 | ||
|
|
e7467b2c5c | ||
|
|
8050e2f1b1 | ||
|
|
7de4559b4a | ||
|
|
fc9c0d7657 | ||
|
|
ab3037dc4f | ||
|
|
8281b838b9 | ||
|
|
2bc7171abd | ||
|
|
4f99487d24 | ||
|
|
a7cddc8d40 | ||
|
|
f3c4c02d73 | ||
|
|
eb631360f4 | ||
|
|
a62bf04428 | ||
|
|
7147f81b42 | ||
|
|
c9098563ca | ||
|
|
d4a8c25eab | ||
|
|
0ddba506bf | ||
|
|
d02bea85cb | ||
|
|
d27c58bfe8 | ||
|
|
34bb51f5c0 | ||
|
|
64c37aaec6 | ||
|
|
3de036adde | ||
|
|
e0df8c15d8 | ||
|
|
176793e15b | ||
|
|
589ec1fdbc | ||
|
|
b421c8d017 | ||
|
|
e2200bac71 | ||
|
|
f8950d1e20 | ||
|
|
9dfe9f610d | ||
|
|
17610e8721 | ||
|
|
f29b787767 | ||
|
|
9775283a24 | ||
|
|
debc73d7d4 |
@@ -37,6 +37,8 @@ CCFlow 驰聘低代码-流程-表单 - https://gitee.com/opencc/RuoYi-JFlow <br>
|
||||
引迈信息 软件开发平台 - https://www.jnpfsoft.com/index.html?from=plus-doc <br>
|
||||
<font color="red">**启山商城系统 多租户商城源码可免费商用可二次开发 - https://www.73app.cn/** </font><br>
|
||||
Mall4J 高质量Java商城系统 - https://www.mall4j.com/cn/?statId=11 <br>
|
||||
aizuda flowlong 工作流 - https://gitee.com/aizuda/flowlong <br>
|
||||
|
||||
[如何成为赞助商 加群联系作者详谈](https://plus-doc.dromara.org/#/common/add_group)
|
||||
|
||||
# 本框架与RuoYi的功能差异
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -31,7 +31,7 @@
|
||||
<redisson.version>3.50.0</redisson.version>
|
||||
<lock4j.version>2.2.7</lock4j.version>
|
||||
<dynamic-ds.version>4.3.1</dynamic-ds.version>
|
||||
<snailjob.version>1.5.0</snailjob.version>
|
||||
<snailjob.version>1.6.0</snailjob.version>
|
||||
<mapstruct-plus.version>1.4.8</mapstruct-plus.version>
|
||||
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
|
||||
<lombok.version>1.18.36</lombok.version>
|
||||
|
||||
@@ -21,6 +21,8 @@ import org.dromara.common.core.domain.model.SocialLoginBody;
|
||||
import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.ratelimiter.annotation.RateLimiter;
|
||||
import org.dromara.common.ratelimiter.enums.LimitType;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.social.config.properties.SocialLoginConfigProperties;
|
||||
import org.dromara.common.social.config.properties.SocialProperties;
|
||||
@@ -198,6 +200,7 @@ public class AuthController {
|
||||
*
|
||||
* @return 租户列表
|
||||
*/
|
||||
@RateLimiter(time = 60, count = 20, limitType = LimitType.IP)
|
||||
@GetMapping("/tenant/list")
|
||||
public R<LoginTenantVo> tenantList(HttpServletRequest request) throws Exception {
|
||||
// 返回对象
|
||||
|
||||
@@ -127,6 +127,7 @@ tenant:
|
||||
- sys_user_role
|
||||
- sys_client
|
||||
- sys_oss_config
|
||||
- flow_spel
|
||||
|
||||
# MyBatisPlus配置
|
||||
# https://baomidou.com/config/
|
||||
@@ -189,13 +190,6 @@ springdoc:
|
||||
name: Lion Li
|
||||
email: crazylionli@163.com
|
||||
url: https://gitee.com/dromara/RuoYi-Vue-Plus
|
||||
components:
|
||||
# 鉴权方式配置
|
||||
security-schemes:
|
||||
apiKey:
|
||||
type: APIKEY
|
||||
in: HEADER
|
||||
name: ${sa-token.token-name}
|
||||
#这里定义了两个分组,可定义多个,也可以不定义
|
||||
group-configs:
|
||||
- group: 1.演示模块
|
||||
@@ -213,7 +207,7 @@ springdoc:
|
||||
xss:
|
||||
# 过滤开关
|
||||
enabled: true
|
||||
# 排除链接(多个用逗号分隔)
|
||||
# 排除链接
|
||||
excludeUrls:
|
||||
- /system/notice
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
||||
user.password.not.blank=用户密码不能为空
|
||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
||||
user.password.not.valid=* 5-50个字符
|
||||
user.password.format.valid=密码必须包含大写字母、小写字母、数字和特殊字符
|
||||
user.email.not.valid=邮箱格式错误
|
||||
user.email.not.blank=邮箱不能为空
|
||||
user.phonenumber.not.blank=用户手机号不能为空
|
||||
|
||||
@@ -17,6 +17,7 @@ user.username.length.valid=Account length must be between {min} and {max} charac
|
||||
user.password.not.blank=Password cannot be empty
|
||||
user.password.length.valid=Password length must be between {min} and {max} characters
|
||||
user.password.not.valid=* 5-50 characters
|
||||
user.password.format.valid=Password must contain uppercase, lowercase, digit, and special character
|
||||
user.email.not.valid=Mailbox format error
|
||||
user.email.not.blank=Mailbox cannot be blank
|
||||
user.phonenumber.not.blank=Phone number cannot be blank
|
||||
|
||||
@@ -17,6 +17,7 @@ user.username.length.valid=账户长度必须在{min}到{max}个字符之间
|
||||
user.password.not.blank=用户密码不能为空
|
||||
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
|
||||
user.password.not.valid=* 5-50个字符
|
||||
user.password.format.valid=密码必须包含大写字母、小写字母、数字和特殊字符
|
||||
user.email.not.valid=邮箱格式错误
|
||||
user.email.not.blank=邮箱不能为空
|
||||
user.phonenumber.not.blank=用户手机号不能为空
|
||||
|
||||
@@ -52,14 +52,14 @@ public class TaskAssigneeDTO implements Serializable {
|
||||
*/
|
||||
public static <T> List<TaskHandler> convertToHandlerList(
|
||||
List<T> sourceList,
|
||||
Function<T, Long> storageId,
|
||||
Function<T, String> storageId,
|
||||
Function<T, String> handlerCode,
|
||||
Function<T, String> handlerName,
|
||||
Function<T, Long> groupName,
|
||||
Function<T, Date> createTimeMapper) {
|
||||
return sourceList.stream()
|
||||
.map(item -> new TaskHandler(
|
||||
String.valueOf(storageId.apply(item)),
|
||||
storageId.apply(item),
|
||||
handlerCode.apply(item),
|
||||
handlerName.apply(item),
|
||||
groupName != null ? String.valueOf(groupName.apply(item)) : null,
|
||||
|
||||
@@ -27,6 +27,11 @@ public class ProcessEvent implements Serializable {
|
||||
*/
|
||||
private String flowCode;
|
||||
|
||||
/**
|
||||
* 实例id
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程任务监听
|
||||
@@ -46,6 +47,11 @@ public class ProcessTaskEvent implements Serializable {
|
||||
*/
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 实例id
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
@@ -56,4 +62,9 @@ public class ProcessTaskEvent implements Serializable {
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 办理参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class PasswordLoginBody extends LoginBody {
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||
// @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
|
||||
private String password;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,12 @@ public class RegisterBody extends LoginBody {
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||
// @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dromara.common.core.service;
|
||||
import org.dromara.common.core.domain.dto.DeptDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用 部门服务
|
||||
@@ -34,4 +35,12 @@ public interface DeptService {
|
||||
*/
|
||||
List<DeptDTO> selectDeptsByList();
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.dromara.common.core.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用 岗位服务
|
||||
*
|
||||
@@ -7,4 +10,12 @@ package org.dromara.common.core.service;
|
||||
*/
|
||||
public interface PostService {
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.dromara.common.core.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用 角色服务
|
||||
*
|
||||
@@ -7,4 +10,12 @@ package org.dromara.common.core.service;
|
||||
*/
|
||||
public interface RoleService {
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -100,28 +100,4 @@ public interface UserService {
|
||||
*/
|
||||
Map<Long, String> selectUserNamesByIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
Map<Long, String> selectRoleNamesByIds(List<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
Map<Long, String> selectDeptNamesByIds(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
Map<Long, String> selectPostNamesByIds(List<Long> postIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -54,14 +54,15 @@ public class SpringDocConfig {
|
||||
openApi.externalDocs(properties.getExternalDocs());
|
||||
openApi.tags(properties.getTags());
|
||||
openApi.paths(properties.getPaths());
|
||||
openApi.components(properties.getComponents());
|
||||
Set<String> keySet = properties.getComponents().getSecuritySchemes().keySet();
|
||||
List<SecurityRequirement> list = new ArrayList<>();
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
keySet.forEach(securityRequirement::addList);
|
||||
list.add(securityRequirement);
|
||||
openApi.security(list);
|
||||
|
||||
if (properties.getComponents() != null) {
|
||||
openApi.components(properties.getComponents());
|
||||
Set<String> keySet = properties.getComponents().getSecuritySchemes().keySet();
|
||||
List<SecurityRequirement> list = new ArrayList<>();
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
keySet.forEach(securityRequirement::addList);
|
||||
list.add(securityRequirement);
|
||||
openApi.security(list);
|
||||
}
|
||||
return openApi;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 操作日志记录处理
|
||||
@@ -176,14 +174,28 @@ public class LogAspect {
|
||||
if (ArrayUtil.isEmpty(paramsArray)) {
|
||||
return params.toString();
|
||||
}
|
||||
String[] exclude = ArrayUtil.addAll(excludeParamNames, EXCLUDE_PROPERTIES);
|
||||
for (Object o : paramsArray) {
|
||||
if (ObjectUtil.isNotNull(o) && !isFilterObject(o)) {
|
||||
String str = JsonUtils.toJsonString(o);
|
||||
Dict dict = JsonUtils.parseMap(str);
|
||||
if (MapUtil.isNotEmpty(dict)) {
|
||||
MapUtil.removeAny(dict, EXCLUDE_PROPERTIES);
|
||||
MapUtil.removeAny(dict, excludeParamNames);
|
||||
str = JsonUtils.toJsonString(dict);
|
||||
String str = "";
|
||||
if (o instanceof List<?> list) {
|
||||
List<Dict> list1 = new ArrayList<>();
|
||||
for (Object obj : list) {
|
||||
String str1 = JsonUtils.toJsonString(obj);
|
||||
Dict dict = JsonUtils.parseMap(str1);
|
||||
if (MapUtil.isNotEmpty(dict)) {
|
||||
MapUtil.removeAny(dict, exclude);
|
||||
list1.add(dict);
|
||||
}
|
||||
}
|
||||
str = JsonUtils.toJsonString(list1);
|
||||
} else {
|
||||
str = JsonUtils.toJsonString(o);
|
||||
Dict dict = JsonUtils.parseMap(str);
|
||||
if (MapUtil.isNotEmpty(dict)) {
|
||||
MapUtil.removeAny(dict, exclude);
|
||||
str = JsonUtils.toJsonString(dict);
|
||||
}
|
||||
}
|
||||
params.add(str);
|
||||
}
|
||||
|
||||
@@ -177,12 +177,12 @@ public class OssClient {
|
||||
// 创建异步请求体(length如果为空会报错)
|
||||
BlockingInputStreamAsyncRequestBody body = BlockingInputStreamAsyncRequestBody.builder()
|
||||
.contentLength(length)
|
||||
.subscribeTimeout(Duration.ofSeconds(30))
|
||||
.subscribeTimeout(Duration.ofSeconds(120))
|
||||
.build();
|
||||
|
||||
// 使用 transferManager 进行上传
|
||||
Upload upload = transferManager.upload(
|
||||
x -> x.requestBody(body)
|
||||
x -> x.requestBody(body).addTransferListener(LoggingTransferListener.create())
|
||||
.putObjectRequest(
|
||||
y -> y.bucket(properties.getBucketName())
|
||||
.key(key)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.dromara.common.redis.utils;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
@@ -10,6 +9,10 @@ import org.redisson.api.RIdGenerator;
|
||||
import org.redisson.api.RedissonClient;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
|
||||
/**
|
||||
* 发号器工具类
|
||||
@@ -23,12 +26,12 @@ public class SequenceUtils {
|
||||
/**
|
||||
* 默认初始值
|
||||
*/
|
||||
public static final Long DEFAULT_INIT_VALUE = 1L;
|
||||
public static final long DEFAULT_INIT_VALUE = 1L;
|
||||
|
||||
/**
|
||||
* 默认步长
|
||||
*/
|
||||
public static final Long DEFAULT_STEP_VALUE = 1L;
|
||||
public static final long DEFAULT_STEP_VALUE = 1L;
|
||||
|
||||
/**
|
||||
* 默认过期时间-天
|
||||
@@ -40,6 +43,11 @@ public class SequenceUtils {
|
||||
*/
|
||||
public static final Duration DEFAULT_EXPIRE_TIME_MINUTE = Duration.ofMinutes(1);
|
||||
|
||||
/**
|
||||
* 默认最小ID容量位数 - 6位数(即至少可以生成的ID为999999个)
|
||||
*/
|
||||
public static final int DEFAULT_MIN_ID_CAPACITY_BITS = 6;
|
||||
|
||||
/**
|
||||
* 获取Redisson客户端实例
|
||||
*/
|
||||
@@ -54,14 +62,11 @@ public class SequenceUtils {
|
||||
* @param stepValue ID步长
|
||||
* @return ID生成器
|
||||
*/
|
||||
private static RIdGenerator getIdGenerator(String key, Duration expireTime, Long initValue, Long stepValue) {
|
||||
if (initValue == null || initValue <= 0) {
|
||||
initValue = DEFAULT_INIT_VALUE;
|
||||
}
|
||||
if (stepValue == null || stepValue <= 0) {
|
||||
stepValue = DEFAULT_STEP_VALUE;
|
||||
}
|
||||
public static RIdGenerator getIdGenerator(String key, Duration expireTime, long initValue, long stepValue) {
|
||||
RIdGenerator idGenerator = REDISSON_CLIENT.getIdGenerator(key);
|
||||
// 初始值和步长不能小于等于0
|
||||
initValue = initValue <= 0 ? DEFAULT_INIT_VALUE : initValue;
|
||||
stepValue = stepValue <= 0 ? DEFAULT_STEP_VALUE : stepValue;
|
||||
// 设置初始值和步长
|
||||
idGenerator.tryInit(initValue, stepValue);
|
||||
// 设置过期时间
|
||||
@@ -69,6 +74,17 @@ public class SequenceUtils {
|
||||
return idGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ID生成器
|
||||
*
|
||||
* @param key 业务key
|
||||
* @param expireTime 过期时间
|
||||
* @return ID生成器
|
||||
*/
|
||||
public static RIdGenerator getIdGenerator(String key, Duration expireTime) {
|
||||
return getIdGenerator(key, expireTime, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定业务key的唯一id
|
||||
*
|
||||
@@ -78,10 +94,21 @@ public class SequenceUtils {
|
||||
* @param stepValue ID步长
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static long nextId(String key, Duration expireTime, Long initValue, Long stepValue) {
|
||||
public static long getNextId(String key, Duration expireTime, long initValue, long stepValue) {
|
||||
return getIdGenerator(key, expireTime, initValue, stepValue).nextId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定业务key的唯一id (ID初始值=1,ID步长=1)
|
||||
*
|
||||
* @param key 业务key
|
||||
* @param expireTime 过期时间
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static long getNextId(String key, Duration expireTime) {
|
||||
return getIdGenerator(key, expireTime).nextId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定业务key的唯一id字符串
|
||||
*
|
||||
@@ -91,19 +118,8 @@ public class SequenceUtils {
|
||||
* @param stepValue ID步长
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String nextIdStr(String key, Duration expireTime, Long initValue, Long stepValue) {
|
||||
return String.valueOf(nextId(key, expireTime, initValue, stepValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定业务key的唯一id (ID初始值=1,ID步长=1)
|
||||
*
|
||||
* @param key 业务key
|
||||
* @param expireTime 过期时间
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static long nextId(String key, Duration expireTime) {
|
||||
return getIdGenerator(key, expireTime, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE).nextId();
|
||||
public static String getNextIdString(String key, Duration expireTime, long initValue, long stepValue) {
|
||||
return String.valueOf(getNextId(key, expireTime, initValue, stepValue));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,8 +129,8 @@ public class SequenceUtils {
|
||||
* @param expireTime 过期时间
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String nextIdStr(String key, Duration expireTime) {
|
||||
return String.valueOf(nextId(key, expireTime));
|
||||
public static String getNextIdString(String key, Duration expireTime) {
|
||||
return String.valueOf(getNextId(key, expireTime));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,56 +141,210 @@ public class SequenceUtils {
|
||||
* @param width 位数,不足左补0
|
||||
* @return 补零后的唯一id字符串
|
||||
*/
|
||||
public static String nextPaddedIdStr(String key, Duration expireTime, Integer width) {
|
||||
return StringUtils.leftPad(nextIdStr(key, expireTime), width, '0');
|
||||
public static String getPaddedNextIdString(String key, Duration expireTime, Integer width) {
|
||||
return StringUtils.leftPad(getNextIdString(key, expireTime), width, '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 yyyyMMdd 开头的唯一id
|
||||
* 获取 yyyyMMdd 格式的唯一id
|
||||
*
|
||||
* @return 唯一id
|
||||
* @deprecated 请使用 {@link #getDateId(String)} 或 {@link #getDateId(String, boolean)}、{@link #getDateId(String, boolean, int)},确保不同业务的ID连续性
|
||||
*/
|
||||
public static String nextIdDate() {
|
||||
return nextIdDate("");
|
||||
@Deprecated
|
||||
public static String getDateId() {
|
||||
return getDateId("");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMdd 开头的唯一id
|
||||
* 获取 prefix + yyyyMMdd 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String nextIdDate(String prefix) {
|
||||
// 前缀+日期 构建 prefixKey
|
||||
String prefixKey = StringUtils.format("{}{}", StringUtils.blankToDefault(prefix, ""), DateUtil.format(DateUtil.date(), DatePattern.PURE_DATE_FORMATTER));
|
||||
// 获取下一个id
|
||||
long nextId = getIdGenerator(prefixKey, DEFAULT_EXPIRE_TIME_DAY, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE).nextId();
|
||||
// 返回完整id
|
||||
return StringUtils.format("{}{}", prefixKey, nextId);
|
||||
public static String getDateId(String prefix) {
|
||||
return getDateId(prefix, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 yyyyMMddHHmmss 开头的唯一id
|
||||
* 获取 prefix + yyyyMMdd 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String nextIdDateTime() {
|
||||
return nextIdDateTime("");
|
||||
public static String getDateId(String prefix, boolean isWithPrefix) {
|
||||
return getDateId(prefix, isWithPrefix, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 开头的唯一id
|
||||
* 获取 prefix + yyyyMMdd 格式的唯一id (启用ID补位,补位长度 = {@link #DEFAULT_MIN_ID_CAPACITY_BITS})})
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getPaddedDateId(String prefix, boolean isWithPrefix) {
|
||||
return getDateId(prefix, isWithPrefix, DEFAULT_MIN_ID_CAPACITY_BITS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMdd 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateId(String prefix, boolean isWithPrefix, int minIdCapacityBits) {
|
||||
return getDateId(prefix, isWithPrefix, minIdCapacityBits, LocalDate.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMdd 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @param time 时间
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateId(String prefix, boolean isWithPrefix, int minIdCapacityBits, LocalDate time) {
|
||||
return getDateId(prefix, isWithPrefix, minIdCapacityBits, time, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMdd 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @param time 时间
|
||||
* @param initValue ID初始值
|
||||
* @param stepValue ID步长
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateId(String prefix, boolean isWithPrefix, int minIdCapacityBits, LocalDate time, long initValue, long stepValue) {
|
||||
return getDatePatternId(prefix, isWithPrefix, minIdCapacityBits, time, DatePattern.PURE_DATE_FORMATTER, DEFAULT_EXPIRE_TIME_DAY, initValue, stepValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 yyyyMMddHHmmss 格式的唯一id
|
||||
*
|
||||
* @return 唯一id
|
||||
* @deprecated 请使用 {@link #getDateTimeId(String)} 或 {@link #getDateTimeId(String, boolean)}、{@link #getDateTimeId(String, boolean, int)},确保不同业务的ID连续性
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getDateTimeId() {
|
||||
return getDateTimeId("", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String nextIdDateTime(String prefix) {
|
||||
// 前缀+日期时间 构建 prefixKey
|
||||
String prefixKey = StringUtils.format("{}{}", StringUtils.blankToDefault(prefix, ""), DateUtil.format(DateUtil.date(), DatePattern.PURE_DATETIME_FORMATTER));
|
||||
// 获取下一个id
|
||||
long nextId = getIdGenerator(prefixKey, DEFAULT_EXPIRE_TIME_MINUTE, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE).nextId();
|
||||
// 返回完整id
|
||||
return StringUtils.format("{}{}", prefixKey, nextId);
|
||||
public static String getDateTimeId(String prefix) {
|
||||
return getDateTimeId(prefix, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateTimeId(String prefix, boolean isWithPrefix) {
|
||||
return getDateTimeId(prefix, isWithPrefix, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 格式的唯一id (启用ID补位,补位长度 = {@link #DEFAULT_MIN_ID_CAPACITY_BITS})})
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getPaddedDateTimeId(String prefix, boolean isWithPrefix) {
|
||||
return getDateTimeId(prefix, isWithPrefix, DEFAULT_MIN_ID_CAPACITY_BITS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateTimeId(String prefix, boolean isWithPrefix, int minIdCapacityBits) {
|
||||
return getDateTimeId(prefix, isWithPrefix, minIdCapacityBits, LocalDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @param time 时间
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateTimeId(String prefix, boolean isWithPrefix, int minIdCapacityBits, LocalDateTime time) {
|
||||
return getDateTimeId(prefix, isWithPrefix, minIdCapacityBits, time, DEFAULT_INIT_VALUE, DEFAULT_STEP_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 prefix + yyyyMMddHHmmss 格式的唯一id
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @param initValue ID初始值
|
||||
* @param stepValue ID步长
|
||||
* @return 唯一id
|
||||
*/
|
||||
public static String getDateTimeId(String prefix, boolean isWithPrefix, int minIdCapacityBits, LocalDateTime time, long initValue, long stepValue) {
|
||||
return getDatePatternId(prefix, isWithPrefix, minIdCapacityBits, time, DatePattern.PURE_DATETIME_FORMATTER, DEFAULT_EXPIRE_TIME_MINUTE, initValue, stepValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定业务key的指定时间格式的ID
|
||||
*
|
||||
* @param prefix 业务前缀
|
||||
* @param isWithPrefix id是否携带业务前缀
|
||||
* @param minIdCapacityBits 最小ID容量位数,小于该位数的ID,左补0(小于等于0表示不启用补位)
|
||||
* @param temporalAccessor 时间访问器
|
||||
* @param timeFormatter 时间格式
|
||||
* @param expireTime 过期时间
|
||||
* @param initValue ID初始值
|
||||
* @param stepValue ID步长
|
||||
* @return 唯一id
|
||||
*/
|
||||
private static String getDatePatternId(String prefix, boolean isWithPrefix, int minIdCapacityBits, TemporalAccessor temporalAccessor, DateTimeFormatter timeFormatter, Duration expireTime, long initValue, long stepValue) {
|
||||
// 时间前缀
|
||||
String timePrefix = timeFormatter.format(temporalAccessor);
|
||||
// 业务前缀 + 时间前缀 构建 prefixKey
|
||||
String prefixKey = StringUtils.format("{}{}", StringUtils.blankToDefault(prefix, ""), timePrefix);
|
||||
|
||||
// 获取id,例 -> 1
|
||||
String nextId = getNextIdString(prefixKey, expireTime, initValue, stepValue);
|
||||
|
||||
// minIdCapacityBits 大于0,且 nextId 的长度小于 minIdCapacityBits,则左补0
|
||||
if (minIdCapacityBits > 0 && nextId.length() < minIdCapacityBits) {
|
||||
nextId = StringUtils.leftPad(nextId, minIdCapacityBits, '0');
|
||||
}
|
||||
|
||||
// 是否携带业务前缀
|
||||
if (isWithPrefix) {
|
||||
// 例 -> P202507031
|
||||
// 其中 P 为业务前缀,202507031 为 yyyyMMdd 格式时间, 1 为nextId
|
||||
return StringUtils.format("{}{}", prefixKey, nextId);
|
||||
}
|
||||
// 例 -> 202507031
|
||||
// 其中 202507031 为 yyyyMMdd 格式时间, 1 为nextId
|
||||
return StringUtils.format("{}{}", timePrefix, nextId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,7 @@ public class PlusSaTokenDao implements SaTokenDaoBySessionFollowObject {
|
||||
if (timeout == NEVER_EXPIRE) {
|
||||
RedisUtils.setCacheObject(key, value);
|
||||
} else {
|
||||
if (RedisUtils.hasKey(key)) {
|
||||
RedisUtils.setCacheObject(key, value, true);
|
||||
} else {
|
||||
RedisUtils.setCacheObject(key, value, Duration.ofSeconds(timeout));
|
||||
}
|
||||
RedisUtils.setCacheObject(key, value, Duration.ofSeconds(timeout));
|
||||
}
|
||||
CAFFEINE.invalidate(key);
|
||||
}
|
||||
@@ -134,11 +130,7 @@ public class PlusSaTokenDao implements SaTokenDaoBySessionFollowObject {
|
||||
if (timeout == NEVER_EXPIRE) {
|
||||
RedisUtils.setCacheObject(key, object);
|
||||
} else {
|
||||
if (RedisUtils.hasKey(key)) {
|
||||
RedisUtils.setCacheObject(key, object, true);
|
||||
} else {
|
||||
RedisUtils.setCacheObject(key, object, Duration.ofSeconds(timeout));
|
||||
}
|
||||
RedisUtils.setCacheObject(key, object, Duration.ofSeconds(timeout));
|
||||
}
|
||||
CAFFEINE.invalidate(key);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.common.satoken.core.service;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.enums.UserType;
|
||||
@@ -39,8 +40,12 @@ public class SaPermissionImpl implements StpInterface {
|
||||
if (userType == UserType.APP_USER) {
|
||||
// 其他端 自行根据业务编写
|
||||
}
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
if (CollUtil.isNotEmpty(loginUser.getMenuPermission())) {
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,8 +67,12 @@ public class SaPermissionImpl implements StpInterface {
|
||||
if (userType == UserType.APP_USER) {
|
||||
// 其他端 自行根据业务编写
|
||||
}
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getRolePermission());
|
||||
if (CollUtil.isNotEmpty(loginUser.getRolePermission())) {
|
||||
// SYS_USER 默认返回权限
|
||||
return new ArrayList<>(loginUser.getMenuPermission());
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
private PermissionService getPermissionService() {
|
||||
|
||||
@@ -6,7 +6,6 @@ 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;
|
||||
@@ -14,8 +13,6 @@ 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;
|
||||
|
||||
/**
|
||||
* SSE 控制器
|
||||
*
|
||||
@@ -33,7 +30,9 @@ public class SseController implements DisposableBean {
|
||||
*/
|
||||
@GetMapping(value = "${sse.path}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public SseEmitter connect() {
|
||||
StpUtil.checkLogin();
|
||||
if (!StpUtil.isLogin()) {
|
||||
return null;
|
||||
}
|
||||
String tokenValue = StpUtil.getTokenValue();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
return sseEmitterManager.connect(userId, tokenValue);
|
||||
@@ -51,31 +50,32 @@ public class SseController implements DisposableBean {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 向特定用户发送消息
|
||||
*
|
||||
* @param userId 目标用户的 ID
|
||||
* @param msg 要发送的消息内容
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 向所有用户发送消息
|
||||
*
|
||||
* @param msg 要发送的消息内容
|
||||
*/
|
||||
@GetMapping(value = "${sse.path}/sendAll")
|
||||
public R<Void> send(String msg) {
|
||||
sseEmitterManager.publishAll(msg);
|
||||
return R.ok();
|
||||
}
|
||||
// 以下为demo仅供参考 禁止使用 请在业务逻辑中使用工具发送而不是用接口发送
|
||||
// /**
|
||||
// * 向特定用户发送消息
|
||||
// *
|
||||
// * @param userId 目标用户的 ID
|
||||
// * @param msg 要发送的消息内容
|
||||
// */
|
||||
// @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();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 向所有用户发送消息
|
||||
// *
|
||||
// * @param msg 要发送的消息内容
|
||||
// */
|
||||
// @GetMapping(value = "${sse.path}/sendAll")
|
||||
// public R<Void> send(String msg) {
|
||||
// sseEmitterManager.publishAll(msg);
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 清理资源。此方法目前不执行任何操作,但避免因未实现而导致错误
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dromara.monitor.admin.config;
|
||||
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.config.Customizer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
@@ -10,7 +11,8 @@ import org.springframework.security.config.annotation.web.configurers.AbstractHt
|
||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
|
||||
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
|
||||
|
||||
/**
|
||||
* admin 监控 安全配置
|
||||
@@ -28,7 +30,7 @@ public class SecurityConfig {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
|
||||
public SecurityFilterChain filterChain(HttpSecurity httpSecurity, MvcRequestMatcher.Builder mvc) throws Exception {
|
||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||
successHandler.setTargetUrlParameter("redirectTo");
|
||||
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
||||
@@ -38,8 +40,8 @@ public class SecurityConfig {
|
||||
header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
||||
.authorizeHttpRequests((authorize) ->
|
||||
authorize.requestMatchers(
|
||||
new AntPathRequestMatcher(adminContextPath + "/assets/**"),
|
||||
new AntPathRequestMatcher(adminContextPath + "/login")
|
||||
mvc.pattern(adminContextPath + "/assets/**"),
|
||||
mvc.pattern(adminContextPath + "/login")
|
||||
).permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.formLogin((formLogin) ->
|
||||
@@ -51,4 +53,10 @@ public class SecurityConfig {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Scope("prototype")
|
||||
@Bean
|
||||
public MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
||||
return new MvcRequestMatcher.Builder(introspector);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,15 +16,28 @@ spring:
|
||||
|
||||
--- # snail-job 服务端配置
|
||||
snail-job:
|
||||
# 拉取重试数据的每批次的大小
|
||||
retry-pull-page-size: 1000
|
||||
# 拉取重试数据的每批次的大小
|
||||
job-pull-page-size: 1000
|
||||
# 服务器端口
|
||||
# 服务端节点IP(默认按照`NetUtil.getLocalIpStr()`)
|
||||
server-host:
|
||||
# 服务端netty的端口号
|
||||
server-port: 17888
|
||||
# 日志保存时间(单位: day)
|
||||
# 合并日志默认保存天数
|
||||
merge-Log-days: 1
|
||||
# 合并日志默认的条数
|
||||
merge-Log-num: 500
|
||||
# 配置每批次拉取重试数据的大小
|
||||
retry-pull-page-size: 100
|
||||
# 配置日志保存时间(单位:天)
|
||||
log-storage: 7
|
||||
# bucket的总数量
|
||||
bucket-total: 128
|
||||
# Dashboard 任务容错天数
|
||||
summary-day: 7
|
||||
# 配置负载均衡周期时间
|
||||
load-balance-cycle-time: 10
|
||||
# 通知类型默认使用grpc(netty 已经下线)
|
||||
rpc-type: grpc
|
||||
# 重试任务拉取的并行度
|
||||
retry-max-pull-parallel: 2
|
||||
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
|
||||
@@ -16,15 +16,28 @@ spring:
|
||||
|
||||
--- # snail-job 服务端配置
|
||||
snail-job:
|
||||
# 拉取重试数据的每批次的大小
|
||||
retry-pull-page-size: 1000
|
||||
# 拉取重试数据的每批次的大小
|
||||
job-pull-page-size: 1000
|
||||
# 服务器端口
|
||||
# 服务端节点IP(默认按照`NetUtil.getLocalIpStr()`)
|
||||
server-host:
|
||||
# 服务端netty的端口号
|
||||
server-port: 17888
|
||||
# 日志保存时间(单位: day)
|
||||
# 合并日志默认保存天数
|
||||
merge-Log-days: 1
|
||||
# 合并日志默认的条数
|
||||
merge-Log-num: 500
|
||||
# 配置每批次拉取重试数据的大小
|
||||
retry-pull-page-size: 100
|
||||
# 配置日志保存时间(单位:天)
|
||||
log-storage: 7
|
||||
# bucket的总数量
|
||||
bucket-total: 128
|
||||
# Dashboard 任务容错天数
|
||||
summary-day: 7
|
||||
# 配置负载均衡周期时间
|
||||
load-balance-cycle-time: 10
|
||||
# 通知类型默认使用grpc(netty 已经下线)
|
||||
rpc-type: grpc
|
||||
# 重试任务拉取的并行度
|
||||
retry-max-pull-parallel: 2
|
||||
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mail.utils.MailUtils;
|
||||
@@ -18,12 +17,11 @@ import java.util.Arrays;
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@SaIgnore
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/demo/mail")
|
||||
public class MailController {
|
||||
public class MailSendController {
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
@@ -44,11 +42,11 @@ public class MailController {
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param filePath 附件路径
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachment")
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) {
|
||||
MailUtils.sendText(to, subject, text, new File(filePath));
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text) {
|
||||
// 附件路径 禁止前端传递 有任意读取系统文件风险
|
||||
MailUtils.sendText(to, subject, text, new File("/xxx/xxx"));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -58,10 +56,11 @@ public class MailController {
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param paths 附件路径
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachments")
|
||||
public R<Void> sendMessageWithAttachments(String to, String subject, String text, String[] paths) {
|
||||
public R<Void> sendMessageWithAttachments(String to, String subject, String text) {
|
||||
// 附件路径 禁止前端传递 有任意读取系统文件风险
|
||||
String[] paths = new String[]{"/xxx/xxx", "/xxx/xxx"};
|
||||
File[] array = Arrays.stream(paths).map(File::new).toArray(File[]::new);
|
||||
MailUtils.sendText(to, subject, text, array);
|
||||
return R.ok();
|
||||
@@ -42,6 +42,11 @@
|
||||
<artifactId>ruoyi-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-idempotent</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
|
||||
@@ -3,9 +3,11 @@ package org.dromara.generator.controller;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -50,6 +52,7 @@ public class GenController extends BaseController {
|
||||
*
|
||||
* @param tableId 表ID
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@SaCheckPermission("tool:gen:query")
|
||||
@GetMapping(value = "/{tableId}")
|
||||
public R<Map<String, Object>> getInfo(@PathVariable Long tableId) {
|
||||
@@ -91,6 +94,7 @@ public class GenController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("tool:gen:import")
|
||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/importTable")
|
||||
public R<Void> importTableSave(String tables, String dataName) {
|
||||
String[] tableNames = Convert.toStrArray(tables);
|
||||
@@ -105,6 +109,7 @@ public class GenController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("tool:gen:edit")
|
||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> editSave(@Validated @RequestBody GenTable genTable) {
|
||||
genTableService.validateEdit(genTable);
|
||||
@@ -170,6 +175,7 @@ public class GenController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("tool:gen:edit")
|
||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||
@Lock4j
|
||||
@GetMapping("/synchDb/{tableId}")
|
||||
public R<Void> synchDb(@PathVariable("tableId") Long tableId) {
|
||||
genTableService.synchDb(tableId);
|
||||
|
||||
@@ -302,7 +302,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||
tableColumn.setColumnComment(column.getComment());
|
||||
tableColumn.setColumnType(column.getOriginType().toLowerCase());
|
||||
tableColumn.setSort(column.getPosition());
|
||||
tableColumn.setIsRequired(column.isNullable() ? "1" : "0");
|
||||
tableColumn.setIsRequired(column.isNullable() ? "0" : "1");
|
||||
tableColumn.setIsIncrement(column.isAutoIncrement() ? "1" : "0");
|
||||
tableColumns.add(tableColumn);
|
||||
});
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.dromara.system.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
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.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -69,6 +71,7 @@ public class SysLogininforController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("monitor:logininfor:remove")
|
||||
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
||||
@Lock4j
|
||||
@DeleteMapping("/clean")
|
||||
public R<Void> clean() {
|
||||
logininforService.cleanLogininfor();
|
||||
@@ -77,6 +80,7 @@ public class SysLogininforController extends BaseController {
|
||||
|
||||
@SaCheckPermission("monitor:logininfor:unlock")
|
||||
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
||||
@RepeatSubmit()
|
||||
@GetMapping("/unlock/{userName}")
|
||||
public R<Void> unlock(@PathVariable("userName") String userName) {
|
||||
String loginName = CacheConstants.PWD_ERR_CNT_KEY + userName;
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package org.dromara.system.controller.monitor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
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.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysOperLogBo;
|
||||
import org.dromara.system.domain.vo.SysOperLogVo;
|
||||
import org.dromara.system.service.ISysOperLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -67,6 +68,7 @@ public class SysOperlogController extends BaseController {
|
||||
*/
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@SaCheckPermission("monitor:operlog:remove")
|
||||
@Lock4j
|
||||
@DeleteMapping("/clean")
|
||||
public R<Void> clean() {
|
||||
operLogService.cleanOperLog();
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.domain.dto.UserOnlineDTO;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -81,6 +82,7 @@ public class SysUserOnlineController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("monitor:online:forceLogout")
|
||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||
@RepeatSubmit()
|
||||
@DeleteMapping("/{tokenId}")
|
||||
public R<Void> forceLogout(@PathVariable String tokenId) {
|
||||
try {
|
||||
@@ -114,6 +116,7 @@ public class SysUserOnlineController extends BaseController {
|
||||
* @param tokenId token值
|
||||
*/
|
||||
@Log(title = "在线设备", businessType = BusinessType.FORCE)
|
||||
@RepeatSubmit()
|
||||
@DeleteMapping("/myself/{tokenId}")
|
||||
public R<Void> remove(@PathVariable("tokenId") String tokenId) {
|
||||
try {
|
||||
|
||||
@@ -5,6 +5,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -78,6 +79,7 @@ public class SysConfigController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:config:add")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysConfigBo config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
@@ -92,6 +94,7 @@ public class SysConfigController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysConfigBo config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
@@ -106,6 +109,7 @@ public class SysConfigController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/updateByKey")
|
||||
public R<Void> updateByKey(@RequestBody SysConfigBo config) {
|
||||
configService.updateConfig(config);
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
@@ -73,6 +74,7 @@ public class SysDeptController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dept:add")
|
||||
@Log(title = "部门管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysDeptBo dept) {
|
||||
if (!deptService.checkDeptNameUnique(dept)) {
|
||||
@@ -86,6 +88,7 @@ public class SysDeptController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dept:edit")
|
||||
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDeptBo dept) {
|
||||
Long deptId = dept.getDeptId();
|
||||
|
||||
@@ -6,6 +6,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -86,6 +87,7 @@ public class SysDictDataController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:add")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysDictDataBo dict) {
|
||||
if (!dictDataService.checkDictDataUnique(dict)) {
|
||||
@@ -100,6 +102,7 @@ public class SysDictDataController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:edit")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDictDataBo dict) {
|
||||
if (!dictDataService.checkDictDataUnique(dict)) {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.dromara.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -68,6 +70,7 @@ public class SysDictTypeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:add")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysDictTypeBo dict) {
|
||||
if (!dictTypeService.checkDictTypeUnique(dict)) {
|
||||
@@ -82,6 +85,7 @@ public class SysDictTypeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:edit")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysDictTypeBo dict) {
|
||||
if (!dictTypeService.checkDictTypeUnique(dict)) {
|
||||
@@ -109,6 +113,7 @@ public class SysDictTypeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@Lock4j
|
||||
@DeleteMapping("/refreshCache")
|
||||
public R<Void> refreshCache() {
|
||||
dictTypeService.resetDictCache();
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
@@ -129,6 +130,7 @@ public class SysMenuController extends BaseController {
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:menu:add")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysMenuBo menu) {
|
||||
if (!menuService.checkMenuNameUnique(menu)) {
|
||||
@@ -145,6 +147,7 @@ public class SysMenuController extends BaseController {
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:menu:edit")
|
||||
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysMenuBo menu) {
|
||||
if (!menuService.checkMenuNameUnique(menu)) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.service.DictService;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -55,6 +56,7 @@ public class SysNoticeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:notice:add")
|
||||
@Log(title = "通知公告", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysNoticeBo notice) {
|
||||
int rows = noticeService.insertNotice(notice);
|
||||
@@ -71,6 +73,7 @@ public class SysNoticeController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:notice:edit")
|
||||
@Log(title = "通知公告", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysNoticeBo notice) {
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
|
||||
@@ -98,6 +98,7 @@ public class SysOssConfigController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:ossConfig:edit")
|
||||
@Log(title = "对象存储状态修改", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysOssConfigBo bo) {
|
||||
return toAjax(ossConfigService.updateOssConfigStatus(bo));
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -19,6 +20,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -70,6 +72,7 @@ public class SysPostController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:post:add")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysPostBo post) {
|
||||
if (!postService.checkPostNameUnique(post)) {
|
||||
@@ -85,6 +88,7 @@ public class SysPostController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:post:edit")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysPostBo post) {
|
||||
if (!postService.checkPostNameUnique(post)) {
|
||||
@@ -107,7 +111,7 @@ public class SysPostController extends BaseController {
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public R<Void> remove(@PathVariable Long[] postIds) {
|
||||
return toAjax(postService.deletePostByIds(postIds));
|
||||
return toAjax(postService.deletePostByIds(Arrays.asList(postIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.bo.SysUserPasswordBo;
|
||||
import org.dromara.system.domain.bo.SysUserProfileBo;
|
||||
import org.dromara.system.domain.vo.ProfileUserVo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
@@ -50,7 +51,9 @@ public class SysProfileController extends BaseController {
|
||||
SysUserVo user = userService.selectUserById(LoginHelper.getUserId());
|
||||
String roleGroup = userService.selectUserRoleGroup(user.getUserId());
|
||||
String postGroup = userService.selectUserPostGroup(user.getUserId());
|
||||
ProfileVo profileVo = new ProfileVo(user, roleGroup, postGroup);
|
||||
// 单独做一个vo专门给个人中心用 避免数据被脱敏
|
||||
ProfileUserVo profileUser = BeanUtil.toBean(user, ProfileUserVo.class);
|
||||
ProfileVo profileVo = new ProfileVo(profileUser, roleGroup, postGroup);
|
||||
return R.ok(profileVo);
|
||||
}
|
||||
|
||||
@@ -128,6 +131,6 @@ public class SysProfileController extends BaseController {
|
||||
|
||||
public record AvatarVo(String imgUrl) {}
|
||||
|
||||
public record ProfileVo(SysUserVo user, String roleGroup, String postGroup) {}
|
||||
public record ProfileVo(ProfileUserVo user, String roleGroup, String postGroup) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -77,6 +78,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:add")
|
||||
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysRoleBo role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
@@ -94,6 +96,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysRoleBo role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
@@ -116,6 +119,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/dataScope")
|
||||
public R<Void> dataScope(@RequestBody SysRoleBo role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
@@ -128,6 +132,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysRoleBo role) {
|
||||
roleService.checkRoleAllowed(role);
|
||||
@@ -144,7 +149,7 @@ public class SysRoleController extends BaseController {
|
||||
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{roleIds}")
|
||||
public R<Void> remove(@PathVariable Long[] roleIds) {
|
||||
return toAjax(roleService.deleteRoleByIds(roleIds));
|
||||
return toAjax(roleService.deleteRoleByIds(List.of(roleIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +186,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/authUser/cancel")
|
||||
public R<Void> cancelAuthUser(@RequestBody SysUserRole userRole) {
|
||||
return toAjax(roleService.deleteAuthUser(userRole));
|
||||
@@ -194,6 +200,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public R<Void> cancelAuthUserAll(Long roleId, Long[] userIds) {
|
||||
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
||||
@@ -207,6 +214,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public R<Void> selectAuthUserAll(Long roleId, Long[] userIds) {
|
||||
roleService.checkRoleDataScope(roleId);
|
||||
|
||||
@@ -118,6 +118,7 @@ public class SysTenantController extends BaseController {
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:edit")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysTenantBo bo) {
|
||||
tenantService.checkTenantAllowed(bo.getTenantId());
|
||||
@@ -170,6 +171,7 @@ public class SysTenantController extends BaseController {
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:edit")
|
||||
@Log(title = "租户管理", businessType = BusinessType.UPDATE)
|
||||
@Lock4j
|
||||
@GetMapping("/syncTenantPackage")
|
||||
public R<Void> syncTenantPackage(@NotBlank(message = "租户ID不能为空") String tenantId,
|
||||
@NotNull(message = "套餐ID不能为空") Long packageId) {
|
||||
@@ -181,6 +183,7 @@ public class SysTenantController extends BaseController {
|
||||
*/
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@Log(title = "租户管理", businessType = BusinessType.INSERT)
|
||||
@Lock4j
|
||||
@GetMapping("/syncTenantDict")
|
||||
public R<Void> syncTenantDict() {
|
||||
if (!TenantHelper.isEnable()) {
|
||||
|
||||
@@ -121,6 +121,7 @@ public class SysTenantPackageController extends BaseController {
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenantPackage:edit")
|
||||
@Log(title = "租户套餐", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysTenantPackageBo bo) {
|
||||
return toAjax(tenantPackageService.updatePackageStatus(bo));
|
||||
|
||||
@@ -16,10 +16,12 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
||||
import org.dromara.common.excel.core.ExcelResult;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
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.mybatis.helper.DataPermissionHelper;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
@@ -110,7 +112,8 @@ public class SysUserController extends BaseController {
|
||||
// 超级管理员 如果重新加载用户信息需清除动态租户
|
||||
TenantHelper.clearDynamic();
|
||||
}
|
||||
SysUserVo user = userService.selectUserById(loginUser.getUserId());
|
||||
|
||||
SysUserVo user = DataPermissionHelper.ignore(() -> userService.selectUserById(loginUser.getUserId()));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
return R.fail("没有权限访问用户数据!");
|
||||
}
|
||||
@@ -154,6 +157,7 @@ public class SysUserController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:user:add")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysUserBo user) {
|
||||
deptService.checkDeptDataScope(user.getDeptId());
|
||||
@@ -178,6 +182,7 @@ public class SysUserController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysUserBo user) {
|
||||
userService.checkUserAllowed(user.getUserId());
|
||||
@@ -227,6 +232,7 @@ public class SysUserController extends BaseController {
|
||||
@ApiEncrypt
|
||||
@SaCheckPermission("system:user:resetPwd")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/resetPwd")
|
||||
public R<Void> resetPwd(@RequestBody SysUserBo user) {
|
||||
userService.checkUserAllowed(user.getUserId());
|
||||
@@ -240,6 +246,7 @@ public class SysUserController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/changeStatus")
|
||||
public R<Void> changeStatus(@RequestBody SysUserBo user) {
|
||||
userService.checkUserAllowed(user.getUserId());
|
||||
@@ -272,6 +279,7 @@ public class SysUserController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.GRANT)
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/authRole")
|
||||
public R<Void> insertAuthRole(Long userId, Long[] roleIds) {
|
||||
userService.checkUserDataScope(userId);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.dromara.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 附件扩展字段对象(存储在 SysOss.ext1 的 JSON 字符串中)
|
||||
*
|
||||
* @author AprilWind
|
||||
*/
|
||||
@Data
|
||||
public class SysOssExt implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 所属业务类型(如 avatar、report、contract)
|
||||
*/
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 文件大小(单位:字节)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 文件类型(MIME类型,如 image/png)
|
||||
*/
|
||||
private String contentType;
|
||||
|
||||
/**
|
||||
* 来源标识(如 userUpload、systemImport)
|
||||
*/
|
||||
private String source;
|
||||
|
||||
/**
|
||||
* 上传 IP 地址,便于审计和追踪
|
||||
*/
|
||||
private String uploadIp;
|
||||
|
||||
/**
|
||||
* 附件说明或备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 附件标签,如 ["图片", "证件"]
|
||||
*/
|
||||
private List<String> tags;
|
||||
|
||||
/**
|
||||
* 业务绑定ID(如某业务记录ID)
|
||||
*/
|
||||
private String refId;
|
||||
|
||||
/**
|
||||
* 绑定业务类型
|
||||
*/
|
||||
private String refType;
|
||||
|
||||
/**
|
||||
* 是否为临时文件,用于区分正式或待清理
|
||||
*/
|
||||
private Boolean isTemp;
|
||||
|
||||
/**
|
||||
* 文件MD5值(可用于去重或校验)
|
||||
*/
|
||||
private String md5;
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package org.dromara.system.domain.bo;
|
||||
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.system.domain.SysTenant;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.system.domain.SysTenant;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 租户业务对象 sys_tenant
|
||||
*
|
||||
@@ -62,6 +62,7 @@ public class SysTenantBo extends BaseEntity {
|
||||
* 密码(创建系统用户)
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空", groups = { AddGroup.class })
|
||||
// @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}", groups = { AddGroup.class })
|
||||
private String password;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.dromara.system.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 用户信息视图对象 sys_user
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
public class ProfileUserVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户类型(sys_user系统用户)
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phonenumber;
|
||||
|
||||
/**
|
||||
* 用户性别(0男 1女 2未知)
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
@Translation(type = TransConstant.OSS_ID_TO_URL)
|
||||
private Long avatar;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date loginDate;
|
||||
|
||||
/**
|
||||
* 部门名
|
||||
*/
|
||||
@Translation(type = TransConstant.DEPT_ID_TO_NAME, mapper = "deptId")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package org.dromara.system.mapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
@@ -20,6 +20,38 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
|
||||
/**
|
||||
* 构建角色对应的部门 SQL 查询语句
|
||||
*
|
||||
* <p>该 SQL 用于查询某个角色关联的所有部门 ID,常用于数据权限控制</p>
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 查询部门ID的 SQL 语句字符串
|
||||
*/
|
||||
default String buildDeptByRoleSql(Long roleId) {
|
||||
return """
|
||||
select dept_id from sys_role_dept where role_id = %d
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 SQL 查询,用于获取当前角色拥有的部门中所有的父部门ID
|
||||
*
|
||||
* <p>
|
||||
* 该 SQL 用于 deptCheckStrictly 场景下,排除非叶子节点(父节点)用。
|
||||
* </p>
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return SQL 语句字符串,查询角色下部门的所有父部门ID
|
||||
*/
|
||||
default String buildParentDeptByRoleSql(Long roleId) {
|
||||
return """
|
||||
select parent_id from sys_dept where dept_id in (
|
||||
select dept_id from sys_role_dept where role_id = %d
|
||||
)
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
@@ -72,6 +104,19 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
.apply(DataBaseHelper.findInSet(parentId, "ancestors")));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个部门及其所有子部门ID(含自身)
|
||||
*
|
||||
* @param parentId 父部门ID
|
||||
* @return 部门ID集合
|
||||
*/
|
||||
default List<Long> selectDeptAndChildById(Long parentId) {
|
||||
List<SysDept> deptList = this.selectListByParentId(parentId);
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(parentId);
|
||||
return deptIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门树信息
|
||||
*
|
||||
@@ -79,6 +124,16 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
|
||||
* @param deptCheckStrictly 部门树选择项是否关联显示
|
||||
* @return 选中部门列表
|
||||
*/
|
||||
List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
|
||||
default List<Long> selectDeptListByRoleId(Long roleId, boolean deptCheckStrictly) {
|
||||
LambdaQueryWrapper<SysDept> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(SysDept::getDeptId)
|
||||
.inSql(SysDept::getDeptId, this.buildDeptByRoleSql(roleId))
|
||||
.orderByAsc(SysDept::getParentId)
|
||||
.orderByAsc(SysDept::getOrderNum);
|
||||
if (deptCheckStrictly) {
|
||||
wrapper.notInSql(SysDept::getDeptId, this.buildParentDeptByRoleSql(roleId));
|
||||
}
|
||||
return this.selectObjs(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysMenu;
|
||||
import org.dromara.system.domain.vo.SysMenuVo;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单表 数据层
|
||||
@@ -19,12 +20,58 @@ import java.util.List;
|
||||
public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
* 构建用户权限菜单 SQL
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 菜单列表
|
||||
* <p>
|
||||
* 查询用户所属角色所拥有的菜单权限,用于权限判断、菜单加载等场景
|
||||
* </p>
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return SQL 字符串,用于 inSql 条件
|
||||
*/
|
||||
List<SysMenu> selectMenuListByUserId(@Param(Constants.WRAPPER) Wrapper<SysMenu> queryWrapper);
|
||||
default String buildMenuByUserSql(Long userId) {
|
||||
return """
|
||||
select menu_id from sys_role_menu where role_id in (
|
||||
select role_id from sys_user_role where user_id = %d
|
||||
)
|
||||
""".formatted(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建角色对应的菜单ID SQL 子查询
|
||||
*
|
||||
* <p>
|
||||
* 用于根据角色ID查询其所拥有的菜单权限(用于权限标识、菜单显示等场景)
|
||||
* 通常配合 inSql 使用
|
||||
* </p>
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 查询菜单ID的 SQL 子查询字符串
|
||||
*/
|
||||
default String buildMenuByRoleSql(Long roleId) {
|
||||
return """
|
||||
select menu_id from sys_role_menu where role_id = %d
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建角色所关联菜单的父菜单ID查询 SQL
|
||||
*
|
||||
* <p>
|
||||
* 用于配合菜单勾选树结构的 {@code menuCheckStrictly} 模式,过滤掉非叶子节点(父菜单),
|
||||
* 只返回角色实际勾选的末级菜单
|
||||
* </p>
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return SQL 语句字符串(查询菜单的父菜单ID)
|
||||
*/
|
||||
default String buildParentMenuByRoleSql(Long roleId) {
|
||||
return """
|
||||
select parent_id from sys_menu where menu_id in (
|
||||
select menu_id from sys_role_menu where role_id = %d
|
||||
)
|
||||
""".formatted(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
@@ -32,7 +79,15 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByUserId(Long userId);
|
||||
default Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> list = this.selectObjs(
|
||||
new LambdaQueryWrapper<SysMenu>()
|
||||
.select(SysMenu::getPerms)
|
||||
.inSql(SysMenu::getMenuId, this.buildMenuByUserSql(userId))
|
||||
.isNotNull(SysMenu::getPerms)
|
||||
);
|
||||
return new HashSet<>(StreamUtils.filter(list, StringUtils::isNotBlank));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询权限
|
||||
@@ -40,7 +95,15 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
* @param roleId 角色ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByRoleId(Long roleId);
|
||||
default Set<String> selectMenuPermsByRoleId(Long roleId) {
|
||||
List<String> list = this.selectObjs(
|
||||
new LambdaQueryWrapper<SysMenu>()
|
||||
.select(SysMenu::getPerms)
|
||||
.inSql(SysMenu::getMenuId, this.buildMenuByRoleSql(roleId))
|
||||
.isNotNull(SysMenu::getPerms)
|
||||
);
|
||||
return new HashSet<>(StreamUtils.filter(list, StringUtils::isNotBlank));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
@@ -56,14 +119,6 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
return this.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
@@ -71,6 +126,16 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||
default List<Long> selectMenuListByRoleId(Long roleId, boolean menuCheckStrictly) {
|
||||
LambdaQueryWrapper<SysMenu> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(SysMenu::getMenuId)
|
||||
.inSql(SysMenu::getMenuId, buildMenuByRoleSql(roleId))
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum);
|
||||
if (menuCheckStrictly) {
|
||||
wrapper.notInSql(SysMenu::getMenuId, this.buildParentMenuByRoleSql(roleId));
|
||||
}
|
||||
return this.selectObjs(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
@@ -33,11 +34,42 @@ public interface SysPostMapper extends BaseMapperPlus<SysPost, SysPostVo> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户所属岗位组
|
||||
* 查询岗位列表
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 岗位信息列表
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default List<SysPostVo> selectPostList(Wrapper<SysPost> queryWrapper) {
|
||||
return this.selectVoList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位ID集合查询岗位数量
|
||||
*
|
||||
* @param postIds 岗位ID列表
|
||||
* @return 匹配的岗位数量
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default long selectPostCount(List<Long> postIds) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysPost>().in(SysPost::getPostId, postIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询其关联的岗位列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
* @return 岗位信息列表
|
||||
*/
|
||||
List<SysPostVo> selectPostsByUserId(Long userId);
|
||||
default List<SysPostVo> selectPostsByUserId(Long userId) {
|
||||
return this.selectVoList(new LambdaQueryWrapper<SysPost>()
|
||||
.inSql(SysPost::getPostId, "select post_id from sys_user_post where user_id = " + userId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -19,6 +20,18 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
|
||||
|
||||
/**
|
||||
* 构建根据用户ID查询角色ID的SQL子查询
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 查询用户对应角色ID的SQL语句字符串
|
||||
*/
|
||||
default String buildRoleByUserSql(Long userId) {
|
||||
return """
|
||||
select role_id from sys_user_role where user_id = %d
|
||||
""".formatted(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询角色列表
|
||||
*
|
||||
@@ -27,22 +40,40 @@ public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
|
||||
* @return 包含角色信息的分页结果
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "r.create_by")
|
||||
@DataColumn(key = "deptName", value = "create_dept"),
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
Page<SysRoleVo> selectPageRoleList(@Param("page") Page<SysRole> page, @Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper);
|
||||
default Page<SysRoleVo> selectPageRoleList(@Param("page") Page<SysRole> page, @Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper) {
|
||||
return this.selectVoPage(page, queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
* 根据条件查询角色数据
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "r.create_by")
|
||||
@DataColumn(key = "deptName", value = "create_dept"),
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
List<SysRoleVo> selectRoleList(@Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper);
|
||||
default List<SysRoleVo> selectRoleList(@Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper) {
|
||||
return this.selectVoList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID集合查询角色数量
|
||||
*
|
||||
* @param roleIds 角色ID列表
|
||||
* @return 匹配的角色数量
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "create_dept"),
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default long selectRoleCount(List<Long> roleIds) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysRole>().in(SysRole::getRoleId, roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID查询角色信息
|
||||
@@ -51,10 +82,12 @@ public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
|
||||
* @return 对应的角色信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "r.create_by")
|
||||
@DataColumn(key = "deptName", value = "create_dept"),
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
SysRoleVo selectRoleById(Long roleId);
|
||||
default SysRoleVo selectRoleById(Long roleId) {
|
||||
return this.selectVoById(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
@@ -62,14 +95,11 @@ public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<SysRoleVo> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<SysRoleVo> selectRolesByUserId(Long userId);
|
||||
default List<SysRoleVo> selectRolesByUserId(Long userId) {
|
||||
return this.selectVoList(new LambdaQueryWrapper<SysRole>()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName, SysRole::getRoleKey,
|
||||
SysRole::getRoleSort, SysRole::getDataScope, SysRole::getStatus)
|
||||
.inSql(SysRole::getRoleId, this.buildRoleByUserSql(userId)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default Page<SysUserVo> selectPageUserList(Page<SysUser> page, Wrapper<SysUser> queryWrapper) {
|
||||
return this.selectVoPage(page, queryWrapper);
|
||||
@@ -44,7 +44,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default List<SysUserVo> selectUserList(Wrapper<SysUser> queryWrapper) {
|
||||
return this.selectVoList(queryWrapper);
|
||||
@@ -58,7 +58,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
@DataColumn(key = "userName", value = "u.create_by")
|
||||
})
|
||||
List<SysUserExportVo> selectUserExportList(@Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
@@ -71,7 +71,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
@DataColumn(key = "userName", value = "u.create_by")
|
||||
})
|
||||
Page<SysUserVo> selectAllocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
@@ -83,7 +83,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
@DataColumn(key = "userName", value = "u.create_by")
|
||||
})
|
||||
Page<SysUserVo> selectUnallocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
@@ -95,7 +95,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
default long countUserById(Long userId) {
|
||||
return this.selectCount(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserId, userId));
|
||||
@@ -111,7 +111,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
@Override
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
int update(@Param(Constants.ENTITY) SysUser user, @Param(Constants.WRAPPER) Wrapper<SysUser> updateWrapper);
|
||||
|
||||
@@ -124,7 +124,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
@Override
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
@DataColumn(key = "userName", value = "create_by")
|
||||
})
|
||||
int updateById(@Param(Constants.ENTITY) SysUser user);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysUserRole;
|
||||
|
||||
@@ -18,6 +19,10 @@ public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole, SysUserRo
|
||||
* @param roleId 角色ID
|
||||
* @return 关联到指定角色的用户ID列表
|
||||
*/
|
||||
List<Long> selectUserIdsByRoleId(Long roleId);
|
||||
default List<Long> selectUserIdsByRoleId(Long roleId) {
|
||||
return this.selectObjs(new LambdaQueryWrapper<SysUserRole>()
|
||||
.select(SysUserRole::getUserId).eq(SysUserRole::getRoleId, roleId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysConfigService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询参数配置列表
|
||||
*
|
||||
* @param config 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 参数配置分页列表
|
||||
*/
|
||||
TableDataInfo<SysConfigVo> selectPageConfigList(SysConfigBo config, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysDictDataService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询字典数据列表
|
||||
*
|
||||
* @param dictData 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 字典数据分页列表
|
||||
*/
|
||||
TableDataInfo<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysDictTypeService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询字典类型列表
|
||||
*
|
||||
* @param dictType 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 字典类型分页列表
|
||||
*/
|
||||
TableDataInfo<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysLogininforService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询登录日志列表
|
||||
*
|
||||
* @param logininfor 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 登录日志分页列表
|
||||
*/
|
||||
TableDataInfo<SysLogininforVo> selectPageLogininforList(SysLogininforBo logininfor, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysNoticeService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询通知公告列表
|
||||
*
|
||||
* @param notice 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
TableDataInfo<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysOperLogService {
|
||||
|
||||
/**
|
||||
* 分页查询操作日志列表
|
||||
*
|
||||
* @param operLog 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 操作日志分页列表
|
||||
*/
|
||||
TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysPostService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询岗位列表
|
||||
*
|
||||
* @param post 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 岗位分页列表
|
||||
*/
|
||||
TableDataInfo<SysPostVo> selectPagePostList(SysPostBo post, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
@@ -110,7 +116,7 @@ public interface ISysPostService {
|
||||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePostByIds(Long[] postIds);
|
||||
int deletePostByIds(List<Long> postIds);
|
||||
|
||||
/**
|
||||
* 新增保存岗位信息
|
||||
|
||||
@@ -16,11 +16,17 @@ import java.util.Set;
|
||||
*/
|
||||
public interface ISysRoleService {
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询角色列表
|
||||
*
|
||||
* @param role 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 角色分页列表
|
||||
*/
|
||||
TableDataInfo<SysRoleVo> selectPageRoleList(SysRoleBo role, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
* 根据条件查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
@@ -112,6 +118,13 @@ public interface ISysRoleService {
|
||||
*/
|
||||
void checkRoleDataScope(Long roleId);
|
||||
|
||||
/**
|
||||
* 校验角色是否有数据权限
|
||||
*
|
||||
* @param roleIds 角色ID列表(支持传单个ID)
|
||||
*/
|
||||
void checkRoleDataScope(List<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
@@ -167,7 +180,7 @@ public interface ISysRoleService {
|
||||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRoleByIds(Long[] roleIds);
|
||||
int deleteRoleByIds(List<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 取消授权用户角色
|
||||
@@ -195,8 +208,29 @@ public interface ISysRoleService {
|
||||
*/
|
||||
int insertAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
/**
|
||||
* 根据角色ID清除该角色关联的所有在线用户的登录状态(踢出在线用户)
|
||||
*
|
||||
* <p>
|
||||
* 先判断角色是否绑定用户,若无绑定则直接返回
|
||||
* 然后遍历当前所有在线Token,查找拥有该角色的用户并强制登出
|
||||
* 注意:在线用户量过大时,操作可能导致 Redis 阻塞,需谨慎调用
|
||||
* </p>
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
void cleanOnlineUserByRole(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID列表清除对应在线用户的登录状态(踢出指定用户)
|
||||
*
|
||||
* <p>
|
||||
* 遍历当前所有在线Token,匹配用户ID列表中的用户,强制登出
|
||||
* 注意:在线用户量过大时,操作可能导致 Redis 阻塞,需谨慎调用
|
||||
* </p>
|
||||
*
|
||||
* @param userIds 需要清除的用户ID列表
|
||||
*/
|
||||
void cleanOnlineUser(List<Long> userIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,13 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
|
||||
private final SysConfigMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 分页查询参数配置列表
|
||||
*
|
||||
* @param config 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 参数配置分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysConfigVo> selectPageConfigList(SysConfigBo config, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysConfig> lqw = buildQueryWrapper(config);
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysRoleDept;
|
||||
import org.dromara.system.mapper.SysDeptMapper;
|
||||
import org.dromara.system.mapper.SysRoleDeptMapper;
|
||||
@@ -66,13 +65,8 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
|
||||
if (ObjectUtil.isNull(deptId)) {
|
||||
return "-1";
|
||||
}
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(deptId);
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(deptId);
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
return StreamUtils.join(ids, Convert::toStr);
|
||||
}
|
||||
return "-1";
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(deptId);
|
||||
return CollUtil.isNotEmpty(deptIds) ? StreamUtils.join(deptIds, Convert::toStr) : "-1";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,10 +36,7 @@ import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 部门管理 服务实现
|
||||
@@ -110,10 +107,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
lqw.and(x -> {
|
||||
Long parentId = bo.getBelongDeptId();
|
||||
List<SysDept> deptList = baseMapper.selectListByParentId(parentId);
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(parentId);
|
||||
List<Long> deptIds = baseMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysDept::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
@@ -409,4 +403,24 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
return baseMapper.deleteById(deptId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysDept> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysDept::getDeptId, SysDept::getDeptName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
|
||||
private final SysDictDataMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 分页查询字典数据列表
|
||||
*
|
||||
* @param dictData 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 字典数据分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysDictData> lqw = buildQueryWrapper(dictData);
|
||||
|
||||
@@ -48,6 +48,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
private final SysDictTypeMapper baseMapper;
|
||||
private final SysDictDataMapper dictDataMapper;
|
||||
|
||||
/**
|
||||
* 分页查询字典类型列表
|
||||
*
|
||||
* @param dictType 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 字典类型分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysDictType> lqw = buildQueryWrapper(dictType);
|
||||
|
||||
@@ -108,6 +108,13 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
||||
return "[" + msg.toString() + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询登录日志列表
|
||||
*
|
||||
* @param logininfor 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 登录日志分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysLogininforVo> selectPageLogininforList(SysLogininforBo logininfor, PageQuery pageQuery) {
|
||||
Map<String, Object> params = logininfor.getParams();
|
||||
|
||||
@@ -5,8 +5,6 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
@@ -67,29 +65,20 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
@Override
|
||||
public List<SysMenuVo> selectMenuList(SysMenuBo menu, Long userId) {
|
||||
List<SysMenuVo> menuList;
|
||||
// 管理员显示所有菜单信息
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
menuList = baseMapper.selectVoList(new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
LambdaQueryWrapper<SysMenu> wrapper = new LambdaQueryWrapper<>();
|
||||
// 管理员显示所有菜单信息 不是管理员 按用户id过滤菜单
|
||||
if (!LoginHelper.isSuperAdmin(userId)) {
|
||||
// 通过用户id获取角色id 通过角色id获取菜单id 然后in菜单
|
||||
wrapper.inSql(SysMenu::getMenuId, baseMapper.buildMenuByUserSql(userId));
|
||||
}
|
||||
menuList = baseMapper.selectVoList(
|
||||
wrapper.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
.eq(StringUtils.isNotBlank(menu.getMenuType()), SysMenu::getMenuType, menu.getMenuType())
|
||||
.eq(ObjectUtil.isNotNull(menu.getParentId()), SysMenu::getParentId, menu.getParentId())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
} else {
|
||||
QueryWrapper<SysMenu> wrapper = Wrappers.query();
|
||||
wrapper.inSql("r.role_id", "select role_id from sys_user_role where user_id = " + userId)
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
|
||||
.eq(StringUtils.isNotBlank(menu.getMenuType()), "m.menu_type", menu.getMenuType())
|
||||
.eq(ObjectUtil.isNotNull(menu.getParentId()), "m.parent_id", menu.getParentId())
|
||||
.orderByAsc("m.parent_id")
|
||||
.orderByAsc("m.order_num");
|
||||
List<SysMenu> list = baseMapper.selectMenuListByUserId(wrapper);
|
||||
menuList = MapstructUtils.convert(list, SysMenuVo.class);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
@@ -101,14 +90,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = baseMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
return baseMapper.selectMenuPermsByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,14 +101,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId) {
|
||||
List<String> perms = baseMapper.selectMenuPermsByRoleId(roleId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
return baseMapper.selectMenuPermsByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,7 +116,13 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
menus = baseMapper.selectMenuTreeAll();
|
||||
} else {
|
||||
menus = baseMapper.selectMenuTreeByUserId(userId);
|
||||
LambdaQueryWrapper<SysMenu> wrapper = new LambdaQueryWrapper<>();
|
||||
menus = baseMapper.selectList(
|
||||
wrapper.in(SysMenu::getMenuType, SystemConstants.TYPE_DIR, SystemConstants.TYPE_MENU)
|
||||
.eq(SysMenu::getStatus, SystemConstants.NORMAL)
|
||||
.inSql(SysMenu::getMenuId, baseMapper.buildMenuByUserSql(userId))
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
}
|
||||
return getChildPerms(menus, Constants.TOP_PARENT_ID);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.dromara.system.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.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@@ -16,7 +17,6 @@ import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.mapper.SysNoticeMapper;
|
||||
import org.dromara.system.mapper.SysUserMapper;
|
||||
import org.dromara.system.service.ISysNoticeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -34,6 +34,13 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
private final SysNoticeMapper baseMapper;
|
||||
private final SysUserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 分页查询通知公告列表
|
||||
*
|
||||
* @param notice 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 通知公告分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice);
|
||||
|
||||
@@ -49,6 +49,13 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
||||
insertOperlog(operLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询操作日志列表
|
||||
*
|
||||
* @param operLog 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 操作日志分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysOperLog> lqw = buildQueryWrapper(operLog);
|
||||
|
||||
@@ -17,6 +17,7 @@ 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;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.oss.core.OssClient;
|
||||
@@ -24,6 +25,7 @@ import org.dromara.common.oss.entity.UploadResult;
|
||||
import org.dromara.common.oss.enums.AccessPolicyType;
|
||||
import org.dromara.common.oss.factory.OssFactory;
|
||||
import org.dromara.system.domain.SysOss;
|
||||
import org.dromara.system.domain.SysOssExt;
|
||||
import org.dromara.system.domain.bo.SysOssBo;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.mapper.SysOssMapper;
|
||||
@@ -199,8 +201,11 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
} catch (IOException e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
SysOssExt ext1 = new SysOssExt();
|
||||
ext1.setFileSize(file.getSize());
|
||||
ext1.setContentType(file.getContentType());
|
||||
// 保存文件信息
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, ext1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,18 +220,21 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
|
||||
OssClient storage = OssFactory.instance();
|
||||
UploadResult uploadResult = storage.uploadSuffix(file, suffix);
|
||||
SysOssExt ext1 = new SysOssExt();
|
||||
ext1.setFileSize(file.length());
|
||||
// 保存文件信息
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult, ext1);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, UploadResult uploadResult) {
|
||||
private SysOssVo buildResultEntity(String originalfileName, String suffix, String configKey, UploadResult uploadResult, SysOssExt ext1) {
|
||||
SysOss oss = new SysOss();
|
||||
oss.setUrl(uploadResult.getUrl());
|
||||
oss.setFileSuffix(suffix);
|
||||
oss.setFileName(uploadResult.getFilename());
|
||||
oss.setOriginalName(originalfileName);
|
||||
oss.setService(configKey);
|
||||
oss.setExt1(JsonUtils.toJsonString(ext1));
|
||||
baseMapper.insert(oss);
|
||||
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
|
||||
return this.matchingUrl(sysOssVo);
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.system.domain.SysDept;
|
||||
import org.dromara.system.domain.SysPost;
|
||||
import org.dromara.system.domain.SysUserPost;
|
||||
import org.dromara.system.domain.bo.SysPostBo;
|
||||
@@ -25,7 +24,7 @@ import org.dromara.system.mapper.SysUserPostMapper;
|
||||
import org.dromara.system.service.ISysPostService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -42,6 +41,13 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
private final SysDeptMapper deptMapper;
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
|
||||
/**
|
||||
* 分页查询岗位列表
|
||||
*
|
||||
* @param post 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 岗位分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysPostVo> selectPagePostList(SysPostBo post, PageQuery pageQuery) {
|
||||
Page<SysPostVo> page = baseMapper.selectPagePostList(pageQuery.build(), buildQueryWrapper(post));
|
||||
@@ -92,9 +98,7 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
} else if (ObjectUtil.isNotNull(bo.getBelongDeptId())) {
|
||||
//部门树搜索
|
||||
wrapper.and(x -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(bo.getBelongDeptId());
|
||||
List<Long> deptIds = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
deptIds.add(bo.getBelongDeptId());
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(bo.getBelongDeptId());
|
||||
x.in(SysPost::getDeptId, deptIds);
|
||||
});
|
||||
}
|
||||
@@ -217,14 +221,14 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] postIds) {
|
||||
for (Long postId : postIds) {
|
||||
SysPost post = baseMapper.selectById(postId);
|
||||
if (countUserPostById(postId) > 0) {
|
||||
public int deletePostByIds(List<Long> postIds) {
|
||||
List<SysPost> list = baseMapper.selectByIds(postIds);
|
||||
for (SysPost post : list) {
|
||||
if (this.countUserPostById(post.getPostId()) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除!", post.getPostName()));
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteByIds(Arrays.asList(postIds));
|
||||
return baseMapper.deleteByIds(postIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,4 +255,23 @@ public class SysPostServiceImpl implements ISysPostService, PostService {
|
||||
return baseMapper.updateById(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
|
||||
if (CollUtil.isEmpty(postIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysPost> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysPost>()
|
||||
.select(SysPost::getPostId, SysPost::getPostName)
|
||||
.in(SysPost::getPostId, postIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysPost::getPostId, SysPost::getPostName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -55,6 +54,13 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
private final SysUserRoleMapper userRoleMapper;
|
||||
private final SysRoleDeptMapper roleDeptMapper;
|
||||
|
||||
/**
|
||||
* 分页查询角色列表
|
||||
*
|
||||
* @param role 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 角色分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysRoleVo> selectPageRoleList(SysRoleBo role, PageQuery pageQuery) {
|
||||
Page<SysRoleVo> page = baseMapper.selectPageRoleList(pageQuery.build(), this.buildQueryWrapper(role));
|
||||
@@ -62,7 +68,7 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
* 根据条件查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 角色数据集合信息
|
||||
@@ -74,15 +80,14 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
|
||||
private Wrapper<SysRole> buildQueryWrapper(SysRoleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
QueryWrapper<SysRole> wrapper = Wrappers.query();
|
||||
wrapper.eq("r.del_flag", SystemConstants.NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(bo.getRoleId()), "r.role_id", bo.getRoleId())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleName()), "r.role_name", bo.getRoleName())
|
||||
.eq(StringUtils.isNotBlank(bo.getStatus()), "r.status", bo.getStatus())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleKey()), "r.role_key", bo.getRoleKey())
|
||||
LambdaQueryWrapper<SysRole> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(ObjectUtil.isNotNull(bo.getRoleId()), SysRole::getRoleId, bo.getRoleId())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleName()), SysRole::getRoleName, bo.getRoleName())
|
||||
.eq(StringUtils.isNotBlank(bo.getStatus()), SysRole::getStatus, bo.getStatus())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleKey()), SysRole::getRoleKey, bo.getRoleKey())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"r.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.orderByAsc("r.role_sort").orderByAsc("r.create_time");
|
||||
SysRole::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
.orderByAsc(SysRole::getRoleSort).orderByAsc(SysRole::getCreateTime);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -176,9 +181,9 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
@Override
|
||||
public List<SysRoleVo> selectRoleByIds(List<Long> roleIds) {
|
||||
return baseMapper.selectRoleList(new QueryWrapper<SysRole>()
|
||||
.eq("r.status", SystemConstants.NORMAL)
|
||||
.in(CollUtil.isNotEmpty(roleIds), "r.role_id", roleIds));
|
||||
return baseMapper.selectRoleList(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getStatus, SystemConstants.NORMAL)
|
||||
.in(CollUtil.isNotEmpty(roleIds), SysRole::getRoleId, roleIds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,14 +254,23 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
if (ObjectUtil.isNull(roleId)) {
|
||||
return;
|
||||
}
|
||||
if (LoginHelper.isSuperAdmin()) {
|
||||
this.checkRoleDataScope(Collections.singletonList(roleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色是否有数据权限
|
||||
*
|
||||
* @param roleIds 角色ID列表(支持传单个ID)
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleDataScope(List<Long> roleIds) {
|
||||
if (CollUtil.isEmpty(roleIds) || LoginHelper.isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
List<SysRoleVo> roles = this.selectRoleList(new SysRoleBo(roleId));
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色数据!");
|
||||
long count = baseMapper.selectRoleCount(roleIds);
|
||||
if (count != roleIds.size()) {
|
||||
throw new ServiceException("没有权限访问部分角色数据!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,7 +373,7 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
rows = roleMenuMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
@@ -380,7 +394,7 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
rows = roleDeptMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
@@ -412,21 +426,20 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_ROLE_CUSTOM, allEntries = true)
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleByIds(Long[] roleIds) {
|
||||
for (Long roleId : roleIds) {
|
||||
SysRole role = baseMapper.selectById(roleId);
|
||||
public int deleteRoleByIds(List<Long> roleIds) {
|
||||
this.checkRoleDataScope(roleIds);
|
||||
List<SysRole> roles = baseMapper.selectByIds(roleIds);
|
||||
for (SysRole role : roles) {
|
||||
checkRoleAllowed(BeanUtil.toBean(role, SysRoleBo.class));
|
||||
checkRoleDataScope(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0) {
|
||||
if (countUserRoleByRoleId(role.getRoleId()) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除!", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
List<Long> ids = Arrays.asList(roleIds);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids));
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds));
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids));
|
||||
return baseMapper.deleteByIds(ids);
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, roleIds));
|
||||
return baseMapper.deleteByIds(roleIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,6 +450,9 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUser(SysUserRole userRole) {
|
||||
if (LoginHelper.getUserId().equals(userRole.getUserId())) {
|
||||
throw new ServiceException("不允许修改当前用户角色!");
|
||||
}
|
||||
int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getRoleId, userRole.getRoleId())
|
||||
.eq(SysUserRole::getUserId, userRole.getUserId()));
|
||||
@@ -456,6 +472,9 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
@Override
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds) {
|
||||
List<Long> ids = List.of(userIds);
|
||||
if (ids.contains(LoginHelper.getUserId())) {
|
||||
throw new ServiceException("不允许修改当前用户角色!");
|
||||
}
|
||||
int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getRoleId, roleId)
|
||||
.in(SysUserRole::getUserId, ids));
|
||||
@@ -477,6 +496,9 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
// 新增用户与角色管理
|
||||
int rows = 1;
|
||||
List<Long> ids = List.of(userIds);
|
||||
if (ids.contains(LoginHelper.getUserId())) {
|
||||
throw new ServiceException("不允许修改当前用户角色!");
|
||||
}
|
||||
List<SysUserRole> list = StreamUtils.toList(ids, userId -> {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
@@ -492,6 +514,17 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID清除该角色关联的所有在线用户的登录状态(踢出在线用户)
|
||||
*
|
||||
* <p>
|
||||
* 先判断角色是否绑定用户,若无绑定则直接返回
|
||||
* 然后遍历当前所有在线Token,查找拥有该角色的用户并强制登出
|
||||
* 注意:在线用户量过大时,操作可能导致 Redis 阻塞,需谨慎调用
|
||||
* </p>
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
*/
|
||||
@Override
|
||||
public void cleanOnlineUserByRole(Long roleId) {
|
||||
// 如果角色未绑定用户 直接返回
|
||||
@@ -523,6 +556,16 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID列表清除对应在线用户的登录状态(踢出指定用户)
|
||||
*
|
||||
* <p>
|
||||
* 遍历当前所有在线Token,匹配用户ID列表中的用户,强制登出
|
||||
* 注意:在线用户量过大时,操作可能导致 Redis 阻塞,需谨慎调用
|
||||
* </p>
|
||||
*
|
||||
* @param userIds 需要清除的用户ID列表
|
||||
*/
|
||||
@Override
|
||||
public void cleanOnlineUser(List<Long> userIds) {
|
||||
List<String> keys = StpUtil.searchTokenValue("", 0, -1, false);
|
||||
@@ -549,4 +592,23 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
List<SysRole> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysRole::getRoleId, SysRole::getRoleName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SysTaskAssigneeServiceImpl implements TaskAssigneeService {
|
||||
TableDataInfo<SysRoleVo> page = roleService.selectPageRoleList(bo, pageQuery);
|
||||
// 使用封装的字段映射方法进行转换
|
||||
List<TaskAssigneeDTO.TaskHandler> handlers = TaskAssigneeDTO.convertToHandlerList(page.getRows(),
|
||||
SysRoleVo::getRoleId, SysRoleVo::getRoleKey, SysRoleVo::getRoleName, null, SysRoleVo::getCreateTime);
|
||||
item -> String.valueOf(item.getRoleId()), SysRoleVo::getRoleKey, SysRoleVo::getRoleName, null, SysRoleVo::getCreateTime);
|
||||
return new TaskAssigneeDTO(page.getTotal(), handlers);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class SysTaskAssigneeServiceImpl implements TaskAssigneeService {
|
||||
TableDataInfo<SysPostVo> page = postService.selectPagePostList(bo, pageQuery);
|
||||
// 使用封装的字段映射方法进行转换
|
||||
List<TaskAssigneeDTO.TaskHandler> handlers = TaskAssigneeDTO.convertToHandlerList(page.getRows(),
|
||||
SysPostVo::getPostId, SysPostVo::getPostCategory, SysPostVo::getPostName, SysPostVo::getDeptId, SysPostVo::getCreateTime);
|
||||
p -> String.valueOf(p.getPostId()), SysPostVo::getPostCategory, SysPostVo::getPostName, SysPostVo::getDeptId, SysPostVo::getCreateTime);
|
||||
return new TaskAssigneeDTO(page.getTotal(), handlers);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class SysTaskAssigneeServiceImpl implements TaskAssigneeService {
|
||||
TableDataInfo<SysDeptVo> page = deptService.selectPageDeptList(bo, pageQuery);
|
||||
// 使用封装的字段映射方法进行转换
|
||||
List<TaskAssigneeDTO.TaskHandler> handlers = TaskAssigneeDTO.convertToHandlerList(page.getRows(),
|
||||
SysDeptVo::getDeptId, SysDeptVo::getDeptCategory, SysDeptVo::getDeptName, SysDeptVo::getParentId, SysDeptVo::getCreateTime);
|
||||
d -> String.valueOf(d.getDeptId()), SysDeptVo::getDeptCategory, SysDeptVo::getDeptName, SysDeptVo::getParentId, SysDeptVo::getCreateTime);
|
||||
return new TaskAssigneeDTO(page.getTotal(), handlers);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class SysTaskAssigneeServiceImpl implements TaskAssigneeService {
|
||||
TableDataInfo<SysUserVo> page = userService.selectPageUserList(bo, pageQuery);
|
||||
// 使用封装的字段映射方法进行转换
|
||||
List<TaskAssigneeDTO.TaskHandler> handlers = TaskAssigneeDTO.convertToHandlerList(page.getRows(),
|
||||
SysUserVo::getUserId, SysUserVo::getUserName, SysUserVo::getNickName, SysUserVo::getDeptId, SysUserVo::getCreateTime);
|
||||
u -> String.valueOf(u.getUserId()), SysUserVo::getUserName, SysUserVo::getNickName, SysUserVo::getDeptId, SysUserVo::getCreateTime);
|
||||
return new TaskAssigneeDTO(page.getTotal(), handlers);
|
||||
}
|
||||
|
||||
|
||||
@@ -414,12 +414,15 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
dictTypeList.addAll(dictTypeMapper.selectList());
|
||||
dictDataList.addAll(dictDataMapper.selectList());
|
||||
});
|
||||
Map<String, List<SysDictType>> typeMap = StreamUtils.groupByKey(dictTypeList, TenantEntity::getTenantId);
|
||||
Map<String, Map<String, List<SysDictData>>> typeDataMap = StreamUtils.groupBy2Key(
|
||||
dictDataList, TenantEntity::getTenantId, SysDictData::getDictType);
|
||||
// 管理租户字典数据
|
||||
List<SysDictType> defaultTypeMap = typeMap.get(TenantConstants.DEFAULT_TENANT_ID);
|
||||
Map<String, List<SysDictData>> defaultTypeDataMap = typeDataMap.get(TenantConstants.DEFAULT_TENANT_ID);
|
||||
// 所有租户字典类型
|
||||
Map<String, List<SysDictType>> dictTypeMap = StreamUtils.groupByKey(dictTypeList, TenantEntity::getTenantId);
|
||||
// 所有租户字典数据
|
||||
Map<String, Map<String, List<SysDictData>>> dictDataMap = StreamUtils.groupBy2Key(dictDataList, TenantEntity::getTenantId, SysDictData::getDictType);
|
||||
|
||||
// 默认租户字典类型列表
|
||||
List<SysDictType> defaultDictTypeList = dictTypeMap.get(TenantConstants.DEFAULT_TENANT_ID);
|
||||
// 默认租户字典数据
|
||||
Map<String, List<SysDictData>> defaultDictDataMap = dictDataMap.get(TenantConstants.DEFAULT_TENANT_ID);
|
||||
|
||||
// 获取所有租户编号
|
||||
List<String> tenantIds = baseMapper.selectObjs(
|
||||
@@ -427,57 +430,67 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
.eq(SysTenant::getStatus, SystemConstants.NORMAL), x -> {
|
||||
return Convert.toStr(x);
|
||||
});
|
||||
// 待入库的字典类型和字典数据
|
||||
List<SysDictType> saveTypeList = new ArrayList<>();
|
||||
List<SysDictData> saveDataList = new ArrayList<>();
|
||||
Set<String> set = new HashSet<>();
|
||||
// 待同步的租户编号(用于清除对于租户的字典缓存)
|
||||
Set<String> syncTenantIds = new HashSet<>();
|
||||
// 循环所有租户,处理需要同步的数据
|
||||
for (String tenantId : tenantIds) {
|
||||
// 排除默认租户
|
||||
if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
||||
continue;
|
||||
}
|
||||
for (SysDictType dictType : defaultTypeMap) {
|
||||
List<String> typeList = StreamUtils.toList(typeMap.get(tenantId), SysDictType::getDictType);
|
||||
List<SysDictData> dataList = defaultTypeDataMap.get(dictType.getDictType());
|
||||
// 根据默认租户的字典类型进行数据同步
|
||||
for (SysDictType dictType : defaultDictTypeList) {
|
||||
// 获取当前租户的字典类型列表
|
||||
List<String> typeList = StreamUtils.toList(dictTypeMap.get(tenantId), SysDictType::getDictType);
|
||||
// 根据字典类型获取默认租户的字典数据
|
||||
List<SysDictData> defaultDictDataList = defaultDictDataMap.get(dictType.getDictType());
|
||||
// 排除不需要同步的字典数据
|
||||
Set<String> excludeDictDataSet = CollUtil.newHashSet();
|
||||
// 处理 存在type不存在data 的情况
|
||||
if (typeList.contains(dictType.getDictType())) {
|
||||
List<SysDictData> dataListTenant = typeDataMap.get(tenantId).get(dictType.getDictType());
|
||||
Map<String, SysDictData> map = StreamUtils.toIdentityMap(dataListTenant, SysDictData::getDictValue);
|
||||
for (SysDictData dictData : dataList) {
|
||||
if (!map.containsKey(dictData.getDictValue())) {
|
||||
SysDictData data = BeanUtil.toBean(dictData, SysDictData.class);
|
||||
// 设置字典编码为 null
|
||||
data.setDictCode(null);
|
||||
data.setTenantId(tenantId);
|
||||
data.setCreateTime(null);
|
||||
data.setUpdateTime(null);
|
||||
data.setCreateDept(null);
|
||||
data.setCreateBy(null);
|
||||
data.setUpdateBy(null);
|
||||
set.add(tenantId);
|
||||
saveDataList.add(data);
|
||||
}
|
||||
}
|
||||
// 获取租户字典数据
|
||||
Optional.ofNullable(dictDataMap.get(tenantId))
|
||||
// 获取租户当前字典类型的字典数据
|
||||
.map(tenantDictDataMap -> tenantDictDataMap.get(dictType.getDictType()))
|
||||
// 保存字典数据项的字典键值,用于判断数据是否需要同步
|
||||
.map(data -> StreamUtils.toSet(data, SysDictData::getDictValue))
|
||||
// 添加到排除集合中
|
||||
.ifPresent(excludeDictDataSet::addAll);
|
||||
} else {
|
||||
// 同步字典类型
|
||||
SysDictType type = BeanUtil.toBean(dictType, SysDictType.class);
|
||||
type.setDictId(null);
|
||||
type.setTenantId(tenantId);
|
||||
type.setCreateTime(null);
|
||||
type.setUpdateTime(null);
|
||||
set.add(tenantId);
|
||||
syncTenantIds.add(tenantId);
|
||||
saveTypeList.add(type);
|
||||
if (CollUtil.isNotEmpty(dataList)) {
|
||||
// 筛选出 dictType 对应的 data
|
||||
for (SysDictData dictData : dataList) {
|
||||
SysDictData data = BeanUtil.toBean(dictData, SysDictData.class);
|
||||
// 设置字典编码为 null
|
||||
data.setDictCode(null);
|
||||
data.setTenantId(tenantId);
|
||||
data.setCreateTime(null);
|
||||
data.setUpdateTime(null);
|
||||
data.setCreateDept(null);
|
||||
data.setCreateBy(null);
|
||||
data.setUpdateBy(null);
|
||||
set.add(tenantId);
|
||||
saveDataList.add(data);
|
||||
}
|
||||
|
||||
// 默认租户字典数据不为空再去处理
|
||||
if (CollUtil.isNotEmpty(defaultDictDataList)) {
|
||||
// 提前优化排除判断if条件语句,对于 && 并联条件,该优化可以避免不必要的 excludeDictDataSet.contains() 函数调用
|
||||
boolean isExclude = CollUtil.isNotEmpty(excludeDictDataSet);
|
||||
// 筛选出 dictType 对应的 data
|
||||
for (SysDictData dictData : defaultDictDataList) {
|
||||
// 排除不需要同步的字典数据
|
||||
if (isExclude && excludeDictDataSet.contains(dictData.getDictValue())) {
|
||||
continue;
|
||||
}
|
||||
SysDictData data = BeanUtil.toBean(dictData, SysDictData.class);
|
||||
// 设置字典编码为 null
|
||||
data.setDictCode(null);
|
||||
data.setTenantId(tenantId);
|
||||
data.setCreateTime(null);
|
||||
data.setUpdateTime(null);
|
||||
data.setCreateDept(null);
|
||||
data.setCreateBy(null);
|
||||
data.setUpdateBy(null);
|
||||
syncTenantIds.add(tenantId);
|
||||
saveDataList.add(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -490,7 +503,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
dictDataMapper.insertBatch(saveDataList);
|
||||
}
|
||||
});
|
||||
for (String tenantId : set) {
|
||||
for (String tenantId : syncTenantIds) {
|
||||
TenantHelper.dynamic(tenantId, () -> CacheUtils.clear(CacheNames.SYS_DICT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@ import org.dromara.common.core.utils.*;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.SysUserPost;
|
||||
import org.dromara.system.domain.SysUserRole;
|
||||
import org.dromara.system.domain.bo.SysUserBo;
|
||||
import org.dromara.system.domain.vo.SysPostVo;
|
||||
import org.dromara.system.domain.vo.SysRoleVo;
|
||||
@@ -36,7 +38,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
@@ -79,10 +80,8 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
w.in("u.dept_id", ids);
|
||||
List<Long> deptIds = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in("u.dept_id", deptIds);
|
||||
}).orderByAsc("u.user_id");
|
||||
return baseMapper.selectUserExportList(wrapper);
|
||||
}
|
||||
@@ -100,9 +99,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysUser::getCreateTime, params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectListByParentId(user.getDeptId());
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
List<Long> ids = deptMapper.selectDeptAndChildById(user.getDeptId());
|
||||
w.in(SysUser::getDeptId, ids);
|
||||
}).orderByAsc(SysUser::getUserId);
|
||||
if (StringUtils.isNotBlank(user.getExcludeUserIds())) {
|
||||
@@ -454,21 +451,31 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
* @param clear 清除已存在的关联数据
|
||||
*/
|
||||
private void insertUserPost(SysUserBo user, boolean clear) {
|
||||
Long[] posts = user.getPostIds();
|
||||
if (ArrayUtil.isNotEmpty(posts)) {
|
||||
if (clear) {
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, user.getUserId()));
|
||||
}
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = StreamUtils.toList(List.of(posts), postId -> {
|
||||
Long[] postIdArr = user.getPostIds();
|
||||
if (ArrayUtil.isEmpty(postIdArr)) {
|
||||
return;
|
||||
}
|
||||
List<Long> postIds = Arrays.asList(postIdArr);
|
||||
|
||||
// 校验是否有权限操作这些岗位(含数据权限控制)
|
||||
if (postMapper.selectPostCount(postIds) != postIds.size()) {
|
||||
throw new ServiceException("没有权限访问岗位的数据");
|
||||
}
|
||||
|
||||
// 是否清除旧的用户岗位绑定
|
||||
if (clear) {
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, user.getUserId()));
|
||||
}
|
||||
|
||||
// 构建用户岗位关联列表并批量插入
|
||||
List<SysUserPost> list = StreamUtils.toList(postIds,
|
||||
postId -> {
|
||||
SysUserPost up = new SysUserPost();
|
||||
up.setUserId(user.getUserId());
|
||||
up.setPostId(postId);
|
||||
return up;
|
||||
});
|
||||
userPostMapper.insertBatch(list);
|
||||
}
|
||||
userPostMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -479,30 +486,36 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
* @param clear 清除已存在的关联数据
|
||||
*/
|
||||
private void insertUserRole(Long userId, Long[] roleIds, boolean clear) {
|
||||
if (ArrayUtil.isNotEmpty(roleIds)) {
|
||||
List<Long> roleList = new ArrayList<>(List.of(roleIds));
|
||||
if (!LoginHelper.isSuperAdmin(userId)) {
|
||||
roleList.remove(SystemConstants.SUPER_ADMIN_ID);
|
||||
}
|
||||
// 判断是否具有此角色的操作权限
|
||||
List<SysRoleVo> roles = roleMapper.selectRoleList(
|
||||
new QueryWrapper<SysRole>().in("r.role_id", roleList));
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
throw new ServiceException("没有权限访问角色的数据");
|
||||
}
|
||||
if (clear) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
}
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = StreamUtils.toList(roleList, roleId -> {
|
||||
if (ArrayUtil.isEmpty(roleIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Long> roleList = new ArrayList<>(Arrays.asList(roleIds));
|
||||
|
||||
// 非超级管理员,禁止包含超级管理员角色
|
||||
if (!LoginHelper.isSuperAdmin(userId)) {
|
||||
roleList.remove(SystemConstants.SUPER_ADMIN_ID);
|
||||
}
|
||||
|
||||
// 校验是否有权限访问这些角色(含数据权限控制)
|
||||
if (roleMapper.selectRoleCount(roleList) != roleList.size()) {
|
||||
throw new ServiceException("没有权限访问角色的数据");
|
||||
}
|
||||
|
||||
// 是否清除原有绑定
|
||||
if (clear) {
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
}
|
||||
|
||||
// 批量插入用户-角色关联
|
||||
List<SysUserRole> list = StreamUtils.toList(roleList,
|
||||
roleId -> {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
return ur;
|
||||
});
|
||||
userRoleMapper.insertBatch(list);
|
||||
}
|
||||
userRoleMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -748,69 +761,12 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
if (CollUtil.isEmpty(userIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色 ID 列表查询角色名称映射关系
|
||||
*
|
||||
* @param roleIds 角色 ID 列表
|
||||
* @return Map,其中 key 为角色 ID,value 为对应的角色名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectRoleNamesByIds(List<Long> roleIds) {
|
||||
if (CollUtil.isEmpty(roleIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return roleMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>()
|
||||
.select(SysRole::getRoleId, SysRole::getRoleName)
|
||||
.in(SysRole::getRoleId, roleIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysRole::getRoleId, SysRole::getRoleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门 ID 列表查询部门名称映射关系
|
||||
*
|
||||
* @param deptIds 部门 ID 列表
|
||||
* @return Map,其中 key 为部门 ID,value 为对应的部门名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectDeptNamesByIds(List<Long> deptIds) {
|
||||
if (CollUtil.isEmpty(deptIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return deptMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId, SysDept::getDeptName)
|
||||
.in(SysDept::getDeptId, deptIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据岗位 ID 列表查询岗位名称映射关系
|
||||
*
|
||||
* @param postIds 岗位 ID 列表
|
||||
* @return Map,其中 key 为岗位 ID,value 为对应的岗位名称
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, String> selectPostNamesByIds(List<Long> postIds) {
|
||||
if (CollUtil.isEmpty(postIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return postMapper.selectList(
|
||||
new LambdaQueryWrapper<SysPost>()
|
||||
.select(SysPost::getPostId, SysPost::getPostName)
|
||||
.in(SysPost::getPostId, postIds)
|
||||
).stream()
|
||||
.collect(Collectors.toMap(SysPost::getPostId, SysPost::getPostName));
|
||||
List<SysUser> list = baseMapper.selectList(
|
||||
new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserId, SysUser::getNickName)
|
||||
.in(SysUser::getUserId, userIds)
|
||||
);
|
||||
return StreamUtils.toMap(list, SysUser::getUserId, SysUser::getNickName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,18 +4,4 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.SysDeptMapper">
|
||||
|
||||
<resultMap type="org.dromara.system.domain.vo.SysDeptVo" id="SysDeptResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectDeptListByRoleId" resultType="Long">
|
||||
select d.dept_id
|
||||
from sys_dept d
|
||||
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
||||
where rd.role_id = #{roleId}
|
||||
<if test="deptCheckStrictly">
|
||||
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
||||
</if>
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,67 +4,4 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.SysMenuMapper">
|
||||
|
||||
<resultMap type="org.dromara.system.domain.SysMenu" id="SysMenuResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectMenuListByUserId" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query_param, m.visible, m.status,
|
||||
m.perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
left join sys_role r on rm.role_id = r.role_id
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectMenuTreeByUserId" parameterType="Long" resultMap="SysMenuResult">
|
||||
select distinct m.menu_id,
|
||||
m.parent_id,
|
||||
m.menu_name,
|
||||
m.path,
|
||||
m.component,
|
||||
m.query_param,
|
||||
m.visible,
|
||||
m.status,
|
||||
m.perms,
|
||||
m.is_frame,
|
||||
m.is_cache,
|
||||
m.menu_type,
|
||||
m.icon,
|
||||
m.order_num,
|
||||
m.create_time
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id and m.status = '0'
|
||||
left join sys_role r on rm.role_id = r.role_id and r.status = '0'
|
||||
where m.menu_type in ('M', 'C')
|
||||
and r.role_id in (select role_id from sys_user_role where user_id = #{userId})
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuListByRoleId" resultType="Long">
|
||||
select m.menu_id
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where rm.role_id = #{roleId}
|
||||
<if test="menuCheckStrictly">
|
||||
and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id =
|
||||
rm.menu_id and rm.role_id = #{roleId})
|
||||
</if>
|
||||
order by m.parent_id, m.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPermsByUserId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id and m.status = '0'
|
||||
left join sys_role r on r.role_id = rm.role_id and r.status = '0'
|
||||
where r.role_id in (select role_id from sys_user_role where user_id = #{userId})
|
||||
</select>
|
||||
|
||||
<select id="selectMenuPermsByRoleId" parameterType="Long" resultType="String">
|
||||
select distinct m.perms
|
||||
from sys_menu m
|
||||
left join sys_role_menu rm on m.menu_id = rm.menu_id
|
||||
where m.status = '0' and rm.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,15 +4,4 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.SysPostMapper">
|
||||
|
||||
<resultMap type="org.dromara.system.domain.vo.SysPostVo" id="SysPostResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectPostsByUserId" parameterType="Long" resultMap="SysPostResult">
|
||||
select p.post_id, p.dept_id, p.post_name, p.post_code, p.post_category
|
||||
from sys_post p
|
||||
left join sys_user_post up on up.post_id = p.post_id
|
||||
left join sys_user u on u.user_id = up.user_id
|
||||
where u.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,56 +4,4 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.SysRoleMapper">
|
||||
|
||||
<resultMap type="org.dromara.system.domain.vo.SysRoleVo" id="SysRoleResult">
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
select distinct r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.menu_check_strictly,
|
||||
r.dept_check_strictly,
|
||||
r.status,
|
||||
r.del_flag,
|
||||
r.create_time,
|
||||
r.remark
|
||||
from sys_role r
|
||||
left join sys_user_role sur on sur.role_id = r.role_id
|
||||
left join sys_user u on u.user_id = sur.user_id
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectPageRoleList" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectRoleList" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and sur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectRolesByUserId" parameterType="Long" resultMap="SysRoleResult">
|
||||
select r.role_id,
|
||||
r.role_name,
|
||||
r.role_key,
|
||||
r.role_sort,
|
||||
r.data_scope,
|
||||
r.status
|
||||
from sys_role r
|
||||
WHERE r.del_flag = '0' and r.role_id in (select role_id from sys_user_role where user_id = #{userId})
|
||||
</select>
|
||||
|
||||
<select id="selectRoleById" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
WHERE r.del_flag = '0' and r.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,10 +4,4 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.system.mapper.SysUserRoleMapper">
|
||||
|
||||
<select id="selectUserIdsByRoleId" resultType="Long">
|
||||
select u.user_id from sys_user u
|
||||
inner join sys_user_role sur
|
||||
on u.user_id = sur.user_id and sur.role_id = #{roleId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -18,6 +18,11 @@ public interface FlowConstant {
|
||||
*/
|
||||
String BUSINESS_ID = "businessId";
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
String INITIATOR_DEPT_ID = "initiatorDeptId";
|
||||
|
||||
/**
|
||||
* 委托
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,12 @@ public enum TaskAssigneeEnum {
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
POST("岗位", "post:");
|
||||
POST("岗位", "post:"),
|
||||
|
||||
/**
|
||||
* SPEL表达式
|
||||
*/
|
||||
SPEL("SpEL表达式", "");
|
||||
|
||||
private final String desc;
|
||||
private final String code;
|
||||
|
||||
@@ -100,5 +100,15 @@ public enum TaskStatusEnum {
|
||||
return STATUS_DESC_MAP.getOrDefault(status, StrUtil.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断状态是否为通过或退回
|
||||
*
|
||||
* @param status 状态值
|
||||
* @return true 表示是通过或退回状态
|
||||
*/
|
||||
public static boolean isPassOrBack(String status) {
|
||||
return PASS.getStatus().equals(status) || BACK.getStatus().equals(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ public class FlwCategoryController extends BaseController {
|
||||
@SaCheckPermission("workflow:category:query")
|
||||
@GetMapping("/{categoryId}")
|
||||
public R<FlowCategoryVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long categoryId) {
|
||||
flwCategoryService.checkCategoryDataScope(categoryId);
|
||||
return R.ok(flwCategoryService.queryById(categoryId));
|
||||
}
|
||||
|
||||
@@ -93,7 +92,6 @@ public class FlwCategoryController extends BaseController {
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowCategoryBo category) {
|
||||
Long categoryId = category.getCategoryId();
|
||||
flwCategoryService.checkCategoryDataScope(categoryId);
|
||||
if (!flwCategoryService.checkCategoryNameUnique(category)) {
|
||||
return R.fail("修改流程分类'" + category.getCategoryName() + "'失败,流程分类名称已存在");
|
||||
} else if (category.getParentId().equals(categoryId)) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.domain.bo.FlowCancelBo;
|
||||
import org.dromara.workflow.domain.bo.FlowInstanceBo;
|
||||
import org.dromara.workflow.domain.bo.FlowInvalidBo;
|
||||
import org.dromara.workflow.domain.bo.FlowVariableBo;
|
||||
import org.dromara.workflow.domain.vo.FlowInstanceVo;
|
||||
import org.dromara.workflow.service.IFlwInstanceService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -142,6 +143,17 @@ public class FlwInstanceController extends BaseController {
|
||||
return R.ok(flwInstanceService.instanceVariable(instanceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程变量
|
||||
*
|
||||
* @param bo 参数
|
||||
*/
|
||||
@RepeatSubmit()
|
||||
@PutMapping("/updateVariable")
|
||||
public R<Void> updateVariable(@Validated @RequestBody FlowVariableBo bo) {
|
||||
return toAjax(flwInstanceService.updateVariable(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废流程
|
||||
*
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.dromara.workflow.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
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.web.core.BaseController;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.domain.bo.FlowSpelBo;
|
||||
import org.dromara.workflow.domain.vo.FlowSpelVo;
|
||||
import org.dromara.workflow.service.IFlwSpelService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@ConditionalOnEnable
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/workflow/spel")
|
||||
public class FlwSpelController extends BaseController {
|
||||
|
||||
private final IFlwSpelService flwSpelService;
|
||||
|
||||
/**
|
||||
* 查询流程spel达式定义列表
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<FlowSpelVo> list(FlowSpelBo bo, PageQuery pageQuery) {
|
||||
return flwSpelService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取流程spel达式定义详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<FlowSpelVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
||||
return R.ok(flwSpelService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增流程spel达式定义
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:add")
|
||||
@Log(title = "流程spel达式定义", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody FlowSpelBo bo) {
|
||||
return toAjax(flwSpelService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改流程spel达式定义
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:edit")
|
||||
@Log(title = "流程spel达式定义", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody FlowSpelBo bo) {
|
||||
return toAjax(flwSpelService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除流程spel达式定义
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("workflow:spel:remove")
|
||||
@Log(title = "流程spel达式定义", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
||||
return toAjax(flwSpelService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,19 @@ public class FlwTaskController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/currentTaskAllUser/{taskId}")
|
||||
public R<List<UserDTO>> currentTaskAllUser(@PathVariable Long taskId) {
|
||||
return R.ok(flwTaskService.currentTaskAllUser(taskId));
|
||||
return R.ok(flwTaskService.currentTaskAllUser(List.of(taskId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 催办任务
|
||||
*
|
||||
* @param bo 参数
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/urgeTask")
|
||||
public R<Void> urgeTask(@RequestBody FlowUrgeTaskBo bo) {
|
||||
return toAjax(flwTaskService.urgeTask(bo));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -82,6 +82,17 @@ public class TestLeaveController extends BaseController {
|
||||
return R.ok(testLeaveService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交请假并提交流程
|
||||
*/
|
||||
@SaCheckPermission("workflow:leave:add")
|
||||
@Log(title = "请假", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/submitAndFlowStart")
|
||||
public R<TestLeaveVo> submitAndFlowStart(@Validated(AddGroup.class) @RequestBody TestLeaveBo bo) {
|
||||
return R.ok(testLeaveService.submitAndFlowStart(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改请假
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.dromara.workflow.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义对象 flow_spel
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("flow_spel")
|
||||
public class FlowSpel extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
private String methodName;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String methodParams;
|
||||
|
||||
/**
|
||||
* 预览spel表达式
|
||||
*/
|
||||
private String viewSpel;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.dromara.workflow.domain.bo;
|
||||
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.dromara.workflow.domain.FlowSpel;
|
||||
|
||||
/**
|
||||
* 流程spel达式定义业务对象 flow_spel
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = FlowSpel.class, reverseConvertGenerate = false)
|
||||
public class FlowSpelBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
private String methodName;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String methodParams;
|
||||
|
||||
/**
|
||||
* 预览spel值
|
||||
*/
|
||||
@NotBlank(message = "预览spel值不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String viewSpel;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@NotBlank(message = "状态(0正常 1停用)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.dromara.workflow.domain.bo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 流程变量参数
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
@Data
|
||||
public class FlowUrgeTaskBo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
@NotNull(message = "任务id为空", groups = AddGroup.class)
|
||||
private List<Long> taskIdList;
|
||||
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private List<String> messageType;
|
||||
|
||||
/**
|
||||
* 催办内容
|
||||
*/
|
||||
@NotNull(message = "催办内容为空", groups = AddGroup.class)
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.dromara.workflow.domain.bo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 流程变量参数
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
@Data
|
||||
public class FlowVariableBo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 流程实例id
|
||||
*/
|
||||
@NotNull(message = "流程实例id为空", groups = AddGroup.class)
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 流程变量key
|
||||
*/
|
||||
@NotNull(message = "流程变量key为空", groups = AddGroup.class)
|
||||
private String key;
|
||||
|
||||
/**
|
||||
* 流程变量value
|
||||
*/
|
||||
@NotNull(message = "流程变量value为空", groups = AddGroup.class)
|
||||
private String value;
|
||||
|
||||
}
|
||||
@@ -31,6 +31,11 @@ public class TestLeaveBo extends BaseEntity {
|
||||
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 流程code
|
||||
*/
|
||||
private String flowCode;
|
||||
|
||||
/**
|
||||
* 请假类型
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.dromara.workflow.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.dromara.workflow.domain.FlowSpel;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 流程spel达式定义视图对象 flow_spel
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = FlowSpel.class)
|
||||
public class FlowSpelVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ExcelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 组件名称
|
||||
*/
|
||||
@ExcelProperty(value = "组件名称")
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
@ExcelProperty(value = "方法名")
|
||||
private String methodName;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
@ExcelProperty(value = "参数")
|
||||
private String methodParams;
|
||||
|
||||
/**
|
||||
* 预览spel值
|
||||
*/
|
||||
@ExcelProperty(value = "预览spel值")
|
||||
private String viewSpel;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@ExcelProperty(value = "状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -145,6 +145,7 @@ public class FlowTaskVo implements Serializable {
|
||||
/**
|
||||
* 办理人名称
|
||||
*/
|
||||
@Translation(type = TransConstant.USER_ID_TO_NICKNAME, mapper = "assigneeIds")
|
||||
private String assigneeNames;
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@ public class FlowProcessEventHandler {
|
||||
ProcessEvent processEvent = new ProcessEvent();
|
||||
processEvent.setTenantId(tenantId);
|
||||
processEvent.setFlowCode(flowCode);
|
||||
processEvent.setInstanceId(instance.getId());
|
||||
processEvent.setBusinessId(instance.getBusinessId());
|
||||
processEvent.setNodeType(instance.getNodeType());
|
||||
processEvent.setNodeCode(instance.getNodeCode());
|
||||
@@ -55,20 +56,23 @@ public class FlowProcessEventHandler {
|
||||
* @param flowCode 流程定义编码
|
||||
* @param instance 实例数据
|
||||
* @param taskId 任务id
|
||||
* @param params 上一个任务的办理参数
|
||||
*/
|
||||
public void processTaskHandler(String flowCode, Instance instance, Long taskId) {
|
||||
public void processTaskHandler(String flowCode, Instance instance, Long taskId, Map<String, Object> params) {
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
log.info("【流程任务事件发布】租户ID: {}, 流程编码: {}, 业务ID: {}, 节点类型: {}, 节点编码: {}, 节点名称: {}, 任务ID: {}",
|
||||
tenantId, flowCode, instance.getBusinessId(), instance.getNodeType(), instance.getNodeCode(), instance.getNodeName(), taskId);
|
||||
ProcessTaskEvent processTaskEvent = new ProcessTaskEvent();
|
||||
processTaskEvent.setTenantId(tenantId);
|
||||
processTaskEvent.setFlowCode(flowCode);
|
||||
processTaskEvent.setInstanceId(instance.getId());
|
||||
processTaskEvent.setBusinessId(instance.getBusinessId());
|
||||
processTaskEvent.setNodeType(instance.getNodeType());
|
||||
processTaskEvent.setNodeCode(instance.getNodeCode());
|
||||
processTaskEvent.setNodeName(instance.getNodeName());
|
||||
processTaskEvent.setTaskId(taskId);
|
||||
processTaskEvent.setStatus(instance.getFlowStatus());
|
||||
processTaskEvent.setParams(params);
|
||||
SpringUtils.context().publishEvent(processTaskEvent);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,14 @@ package org.dromara.workflow.handler;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.warm.flow.core.dto.FlowParams;
|
||||
import org.dromara.warm.flow.core.handler.PermissionHandler;
|
||||
import org.dromara.workflow.common.ConditionalOnEnable;
|
||||
import org.dromara.workflow.service.IFlwCommonService;
|
||||
import org.dromara.workflow.service.IFlwTaskAssigneeService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -24,7 +27,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class WorkflowPermissionHandler implements PermissionHandler {
|
||||
|
||||
private final IFlwCommonService flwCommonService;
|
||||
private final IFlwTaskAssigneeService flwTaskAssigneeService;
|
||||
|
||||
/**
|
||||
* 办理人权限标识,比如用户,角色,部门等,用于校验是否有权限办理任务
|
||||
@@ -51,9 +54,11 @@ public class WorkflowPermissionHandler implements PermissionHandler {
|
||||
*/
|
||||
@Override
|
||||
public List<String> convertPermissions(List<String> permissions) {
|
||||
if (CollUtil.isNotEmpty(permissions)) {
|
||||
permissions = flwCommonService.buildUser(permissions);
|
||||
if (CollUtil.isEmpty(permissions)) {
|
||||
return permissions;
|
||||
}
|
||||
return permissions;
|
||||
String storageIds = CollUtil.join(permissions, StringUtils.SEPARATOR);
|
||||
List<UserDTO> users = flwTaskAssigneeService.fetchUsersByStorageIds(storageIds);
|
||||
return StreamUtils.toList(users, userDTO -> String.valueOf(userDTO.getUserId()));
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user