同步商业版 SVN 代码至 v3.9.6(后端 r85531,前端 r85552)

- 后端:同步系统管理、基础模块、AI 等开源模块的修复与优化;新增 v3.9.6 升级 SQL(已去掉商业表与商业数据)
- 依赖:jeecg-boot-starter 3.9.6、jeecg-online 3.9.6-beta、jeecg-aiflow-boot4 3.9.6
- 前端:同步 Online、系统管理、AI 应用等页面的修复与优化;aiflow 改为从 @jeecg/aiflow 包引入
- 保持开源版差异:数据库名 jeecg-boot、去掉商业版版权声明、百度统计 ID 不变

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
scott 2026-11-02 06:15:14 -05:00
parent a4d5234755
commit d7d641090d
248 changed files with 5386 additions and 762 deletions

View File

@ -1,4 +1,3 @@
version: '2'
services:
jeecg-boot-mysql:
build:
@ -30,8 +29,8 @@ services:
jeecg-boot-redis:
image: registry.cn-hangzhou.aliyuncs.com/jeecgdocker/redis:5.0
# ports:
# - 6379:6379
# ports:
# - 6379:6379
restart: always
hostname: jeecg-boot-redis
container_name: jeecg-boot-redis
@ -50,25 +49,25 @@ services:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: vector_db
# ports:
# - 5432:5432
# ports:
# - 5432:5432
restart: always
networks:
- jeecg-boot
# jeecg-boot-rabbitmq:
# image: rabbitmq:3.7.7-management
## ports:
## - 5672:5672
## - 15672:15672
# restart: always
# container_name: jeecg-boot-rabbitmq
# hostname: jeecg-boot-rabbitmq
# environment:
# RABBITMQ_DEFAULT_USER: guest
# RABBITMQ_DEFAULT_PASS: guest
# networks:
# - jeecg-boot
# jeecg-boot-rabbitmq:
# image: rabbitmq:3.7.7-management
## ports:
## - 5672:5672
## - 15672:15672
# restart: always
# container_name: jeecg-boot-rabbitmq
# hostname: jeecg-boot-rabbitmq
# environment:
# RABBITMQ_DEFAULT_USER: guest
# RABBITMQ_DEFAULT_PASS: guest
# networks:
# - jeecg-boot
jeecg-boot-system:
build:
@ -93,4 +92,4 @@ services:
networks:
jeecg-boot:
name: jeecg_boot
name: jeecg_boot

View File

@ -362,11 +362,6 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
</dependency>
<!-- chatgpt -->
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>jeecg-boot-starter-ai</artifactId>
</dependency>
<!-- 腾讯云 -->
<dependency>
<groupId>com.tencentcloudapi</groupId>

View File

@ -13,10 +13,12 @@ import org.jeecg.common.api.dto.LogDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.enums.ClientTerminalTypeEnum;
import org.jeecg.common.constant.enums.ModuleType;
import org.jeecg.common.constant.enums.OperateTypeEnum;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.BrowserUtils;
import org.jeecg.common.util.IpUtils;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
@ -99,6 +101,12 @@ public class AutoLogAspect {
dto.setRequestParam(getReqestParams(request,joinPoint));
//设置IP地址
dto.setIp(IpUtils.getIpAddr(request));
//设置客户端
if (BrowserUtils.isDesktop(request)) {
dto.setClientType(ClientTerminalTypeEnum.PC.getKey());
} else {
dto.setClientType(ClientTerminalTypeEnum.APP.getKey());
}
//获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(sysUser!=null){

View File

@ -367,6 +367,7 @@ public interface CommonConstant {
String TOKEN_IS_INVALID_MSG = "Token失效,请重新登录!";
String X_FORWARDED_SCHEME = "X-Forwarded-Scheme";
String X_FORWARDED_PROTO = "X-Forwarded-Proto";
/**

View File

@ -222,6 +222,9 @@ public class JeecgController<T, S extends IService<T>> {
params.setNeedSave(true);
try {
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
// update-begin--author:wangshuai---date:20260901---for:【LHZP-985】代码生成 单表和树导出popup字典没有翻译:导入添加翻译
beforeImport(list);
// update-end--author:wangshuai---date:20260804---for:【LHZP-985】代码生成 单表和树导出popup字典没有翻译:导入添加翻译
// 代码逻辑说明: 批量插入数据
long start = System.currentTimeMillis();
service.saveBatch(list);
@ -248,4 +251,13 @@ public class JeecgController<T, S extends IService<T>> {
}
return Result.error("文件导入失败!");
}
/**
* 数据持久化前处理导入数据。
*
* @param list 导入数据
*/
protected void beforeImport(List<T> list) {
// 供生成的控制器扩展导入前处理逻辑
}
}

View File

@ -411,6 +411,9 @@ public class QueryGenerator {
&& oConvertUtils.isNotEmpty(rule.getVal())
)
|| "empty".equals(rule.getRule())
//update-begin---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
|| "not_empty".equals(rule.getRule())
//update-end---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
).collect(Collectors.toList());
if (filterConditions.size() == 0) {
return;
@ -425,6 +428,9 @@ public class QueryGenerator {
oConvertUtils.isNotEmpty(rule.getField()) && oConvertUtils.isNotEmpty(rule.getRule()) && oConvertUtils.isNotEmpty(rule.getVal())
)
|| "empty".equals(rule.getRule())
//update-begin---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
|| "not_empty".equals(rule.getRule())
//update-end---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
) {
log.debug("SuperQuery ==> " + rule.toString());
@ -708,7 +714,11 @@ public class QueryGenerator {
(
name==null || value == null || rule == null || oConvertUtils.isEmpty(value)
)
&& !QueryRuleEnum.EMPTY.equals(rule)) {
&& !QueryRuleEnum.EMPTY.equals(rule)
//update-begin---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
&& !QueryRuleEnum.NOT_EMPTY.equals(rule)
//update-end---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
) {
return;
}
name = oConvertUtils.camelToUnderline(name);
@ -723,6 +733,11 @@ public class QueryGenerator {
case EMPTY:
queryWrapper.isNull(name);
break;
//update-begin---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
case NOT_EMPTY:
queryWrapper.isNotNull(name);
break;
//update-end---author:scott ---date:20261012 for:【issues/9885】高级查询不为空规则无效-----------
case LT:
queryWrapper.lt(name, value);
break;

View File

@ -32,7 +32,8 @@ public class ResourceUtil {
*/
private final static String[] BASE_SCAN_PACKAGES = {
"org.jeecg.common.constant.enums",
"org.jeecg.modules.message.enums"
"org.jeecg.modules.message.enums",
"org.jeecg.modules.online.low.enums"
};
/**

View File

@ -380,6 +380,15 @@ public class CommonUtils {
//2.【兼容】SSL认证之后,request.getScheme()获取不到https的问题
// https://blog.csdn.net/weixin_34376986/article/details/89767950
String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME);
//update-begin---author:scott ---date:20261013 for:【jimureport/issues/4786】HTTPS反代下只传X-Forwarded-Proto时页面资源仍为http://,Mixed Content白屏-----------
if(oConvertUtils.isEmpty(scheme)){
// 多级代理时形如 "https, http",取第一个(最靠近浏览器的那一跳)
String proto = request.getHeader(CommonConstant.X_FORWARDED_PROTO);
if(oConvertUtils.isNotEmpty(proto)){
scheme = proto.split(",")[0].trim();
}
}
//update-end---author:scott ---date:20261013 for:【jimureport/issues/4786】HTTPS反代下只传X-Forwarded-Proto时页面资源仍为http://,Mixed Content白屏-----------
if(oConvertUtils.isEmpty(scheme)){
scheme = request.getScheme();
}
@ -431,7 +440,7 @@ public class CommonUtils {
if (oConvertUtils.isEmpty(host)) {
return null;
}
//update-begin---author:jeecg---for:网关基址头只接受纯路径,拒绝查询串/片段/路径穿越,防止篡改转发目标---
//update-begin---author:jeecg---for:【GHSA-3c5r-mgw9-jq74】网关基址头只接受纯路径,拒绝查询串/片段/路径穿越,防止篡改转发目标---
if (uri.getRawQuery() != null || uri.getRawFragment() != null) {
return null;
}
@ -449,7 +458,7 @@ public class CommonUtils {
sb.append(path);
}
return sb.toString();
//update-end---author:jeecg---for:网关基址头只接受纯路径---
//update-end---author:jeecg---for:【GHSA-3c5r-mgw9-jq74】网关基址头只接受纯路径---
} catch (Exception e) {
return null;
}

View File

@ -209,8 +209,7 @@ public final class DictSqlConditionCheckUtil {
}
if (isComparisonExpression(expression)) {
BinaryExpression comparison = (BinaryExpression) expression;
return addConditionField(comparison.getLeftExpression(), conditionFields)
&& isLiteral(comparison.getRightExpression());
return validateComparisonExpression(comparison, conditionFields);
}
if (expression instanceof LikeExpression likeExpression) {
return addConditionField(likeExpression.getLeftExpression(), conditionFields)
@ -232,6 +231,17 @@ public final class DictSqlConditionCheckUtil {
return false;
}
private static boolean validateComparisonExpression(BinaryExpression comparison, Set<String> conditionFields) {
Expression leftExpression = comparison.getLeftExpression();
Expression rightExpression = comparison.getRightExpression();
//update-begin---author:scott ---date:20260831 for:【issues/9840】兼容1=1字典占位条件-----------
if (comparison instanceof EqualsTo && isLiteral(leftExpression) && isLiteral(rightExpression)) {
return true;
}
//update-end---author:scott ---date:20260831 for:【issues/9840】兼容1=1字典占位条件-----------
return addConditionField(leftExpression, conditionFields) && isLiteral(rightExpression);
}
private static boolean isComparisonExpression(Expression expression) {
return expression instanceof EqualsTo
|| expression instanceof NotEqualsTo

View File

@ -73,6 +73,13 @@ public class SpringContextUtils implements ApplicationContextAware {
//2.【兼容】SSL认证之后,request.getScheme()获取不到https的问题
// https://blog.csdn.net/weixin_34376986/article/details/89767950
String scheme = request.getHeader(CommonConstant.X_FORWARDED_SCHEME);
//update-begin---author:scott ---date:20261013 for:【jimureport/issues/4786】HTTPS反代下只传X-Forwarded-Proto时页面资源仍为http://,Mixed Content白屏-----------
if(oConvertUtils.isEmpty(scheme)){
// 多级代理时形如 "https, http",取第一个(最靠近浏览器的那一跳)
String proto = request.getHeader(CommonConstant.X_FORWARDED_PROTO);
scheme = oConvertUtils.isNotEmpty(proto) ? proto.split(",")[0].trim() : null;
}
//update-end---author:scott ---date:20261013 for:【jimureport/issues/4786】HTTPS反代下只传X-Forwarded-Proto时页面资源仍为http://,Mixed Content白屏-----------
if(scheme!=null && !request.getScheme().equals(scheme)){
domain = domain.replace(request.getScheme(),scheme);
}

View File

@ -22,22 +22,22 @@ public class SqlInjectionUtil {
/**
* sql注入黑名单数据库名
*/
public final static String XSS_STR_TABLE = "peformance_schema|information_schema";
public final static String XSS_STR_TABLE = "performance_schema|information_schema";
/**
* 默认—sql注入关键词
*/
private final static String XSS_STR = "and |exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|--";
private final static String XSS_STR = "and |exec |performance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|--";
/**
* online报表专用—sql注入关键词
*/
private static String specialReportXssStr = "exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |alter |delete |grant |update |drop |master |truncate |declare |--";
private static String specialReportXssStr = "exec |performance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |alter |delete |grant |update |drop |master |truncate |declare |--";
/**
* 字典专用—sql注入关键词
*
* @updateBy: sunjianlei 20260331 加上 substring 注入检测
*/
private static String specialDictSqlXssStr = "exec |peformance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|+|--|substring |substring(";
private static String specialDictSqlXssStr = "exec |performance_schema|information_schema|extractvalue|updatexml|geohash|gtid_subset|gtid_subtract|insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|+|--|substring |substring(";
/**
* 完整匹配的key,不需要考虑前空格
*/

View File

@ -71,7 +71,7 @@ public class TokenUtils {
if (oConvertUtils.isNotEmpty(tenantId) && "undefined".equals(tenantId)) {
return null;
}
//update-begin---author:scott ---date:20261015 for:URL参数tenantId未经登录校验,多租户模式下须属于当前登录用户,否则忽略参数改用请求头(请求头已由ShiroRealm校验),防止传参冒充其他租户-----------
//update-begin---author:scott ---date:20261015 for:【安全 GHSA-2h34-xh29-7w95】URL参数tenantId未经登录校验,多租户模式下须属于当前登录用户,否则忽略参数改用请求头(请求头已由ShiroRealm校验),防止传参冒充其他租户-----------
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL && oConvertUtils.isNotEmpty(tenantId)) {
String headerTenantId = oConvertUtils.getString(request.getHeader(CommonConstant.TENANT_ID));
if (!tenantId.equals(headerTenantId) && !"0".equals(tenantId) && !isLoginUserTenant(tenantId)) {
@ -79,11 +79,11 @@ public class TokenUtils {
return oConvertUtils.isNotEmpty(headerTenantId) && !"undefined".equals(headerTenantId) ? headerTenantId : null;
}
}
//update-end---author:scott ---date:20261015 for:URL参数tenantId未经登录校验,多租户模式下须属于当前登录用户,否则忽略参数改用请求头(请求头已由ShiroRealm校验),防止传参冒充其他租户-----------
//update-end---author:scott ---date:20261015 for:【安全 GHSA-2h34-xh29-7w95】URL参数tenantId未经登录校验,多租户模式下须属于当前登录用户,否则忽略参数改用请求头(请求头已由ShiroRealm校验),防止传参冒充其他租户-----------
return tenantId;
}
//update-begin---author:scott ---date:20261015 for:校验租户是否属于当前登录用户-----------
//update-begin---author:scott ---date:20261015 for:【安全 GHSA-2h34-xh29-7w95】校验租户是否属于当前登录用户-----------
/**
* 租户是否属于当前登录用户(未登录时返回true,保持原逻辑,由各接口自身鉴权)
*
@ -103,7 +103,7 @@ public class TokenUtils {
String relTenantIds = loginUser.getRelTenantIds();
return oConvertUtils.isNotEmpty(relTenantIds) && oConvertUtils.isIn(tenantId, relTenantIds.split(","));
}
//update-end---author:scott ---date:20261015 for:校验租户是否属于当前登录用户-----------
//update-end---author:scott ---date:20261015 for:【安全 GHSA-2h34-xh29-7w95】校验租户是否属于当前登录用户-----------
/**
* 获取 request 里传递的 lowAppId (低代码应用ID)

View File

@ -61,41 +61,19 @@ public class JdbcSecurityUtil {
"init=", // 连接初始化 SQL (带 '=' 防止匹配到正常单词 'init')
"runscript", // 远程/本地 SQL 脚本加载
"trace_level_system_out", // 系统信息泄露
// === Apache Calcite ===
"jdbc:calcite:", // Calcite 连接协议:可经 model=inline 的 functions 注册任意类 UDF 实现 RCE
};
/**
* 允许的 JDBC 驱动类名白名单
* 危险 JDBC 驱动黑名单(小写比较)。仅拦截已知可被用于任意代码执行的驱动,
* 其余驱动(含各类国产/大数据数据库自定义驱动)一律放行,避免误伤正常业务。
*/
private static final String[] ALLOWED_DRIVERS = {
// MySQL 数据库
"com.mysql.jdbc.Driver",
// MySQL5.7+ 数据库
"com.mysql.cj.jdbc.Driver",
// Oracle
"oracle.jdbc.OracleDriver",
"oracle.jdbc.driver.OracleDriver",
// SQLServer 数据库
"com.microsoft.sqlserver.jdbc.SQLServerDriver",
// marialDB 数据库
"org.mariadb.jdbc.Driver",
// postgresql 数据库
"org.postgresql.Driver",
// 达梦 数据库
"dm.jdbc.driver.DmDriver",
// 人大金仓 数据库
"com.kingbase8.Driver",
// 神通 数据库
"com.oscar.Driver",
// SQLite 数据库
"org.sqlite.JDBC",
// DB2 数据库
"com.ibm.db2.jcc.DB2Driver",
// Hsqldb 数据库
"org.hsqldb.jdbc.JDBCDriver",
// Derby 数据库
"org.apache.derby.jdbc.ClientDriver",
// H2 数据库
"org.h2.Driver",
private static final String[] FORBIDDEN_DRIVERS = {
// Apache Calcite:可经 model=inline 的 functions 注册任意类为 UDF 实现 RCE
"org.apache.calcite.jdbc.driver",
"org.apache.calcite.jdbc.calcitedriver",
};
/**
@ -119,20 +97,22 @@ public class JdbcSecurityUtil {
}
/**
* 校验驱动类名是否在白名单中
* 校验驱动类名是否为已知危险驱动(黑名单)。
* 驱动为空时放行(由 DriverManager 按 URL 自动识别,URL 已由 {@link #validate(String)} 拦掉危险协议);
* 命中黑名单(如 Calcite)时抛出异常。
*
* @param driverClassName JDBC 驱动类名
* @throws JeecgBootException 驱动不在白名单时抛出
* @throws JeecgBootException 命中危险驱动黑名单时抛出
*/
public static void validateDriver(String driverClassName) {
if (oConvertUtils.isEmpty(driverClassName)) {
throw new JeecgBootException("数据库驱动类名不能为空");
return;
}
for (String allowed : ALLOWED_DRIVERS) {
if (allowed.equals(driverClassName)) {
return;
String lower = driverClassName.trim().toLowerCase();
for (String forbidden : FORBIDDEN_DRIVERS) {
if (forbidden.equals(lower)) {
throw new JeecgBootException("不支持的数据库驱动【" + driverClassName + "】,存在安全风险,已拒绝");
}
}
throw new JeecgBootException("不支持的数据库驱动【" + driverClassName + "】,如需支持请联系管理员");
}
}

View File

@ -1,7 +1,6 @@
package org.jeecg.config;
import lombok.Data;
import org.jeecg.ai.factory.AiModelFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ -94,7 +93,7 @@ public class AiChatConfig {
/**
* 供应商
*/
private String provider = AiModelFactory.AIMODEL_TYPE_QWEN;
private String provider = "QWEN"; //AiModelFactory.AIMODEL_TYPE_QWEN
}
@Data

View File

@ -13,6 +13,8 @@ import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* websocket 前端将token放到子协议里传入 与后端建立连接时需要用到http协议,此处用于校验token的有效性
@ -24,6 +26,11 @@ public class WebsocketFilter implements Filter {
private static final String TOKEN_KEY = "Sec-WebSocket-Protocol";
/**
* 系统通知websocket端点 /websocket/{userId}(仅单段路径,不含 /websocket/drag/{chartId} 等子路径接口)
*/
private static final Pattern SYS_NOTICE_WS_PATTERN = Pattern.compile("^/websocket/([^/]+)/?$");
private static CommonAPI commonApi;
private static RedisUtil redisUtil;
@ -50,11 +57,13 @@ public class WebsocketFilter implements Filter {
}
//update-begin---author:scott ---date:20261013 for:【安全 GHSA-5j5w-pm5g-5wr8】系统通知websocket(/websocket/{userId})绑定token身份,禁止订阅他人的实时消息-----------
String uri = request.getRequestURI();
int idx = uri.indexOf("/websocket/");
if (idx >= 0) {
String rest = uri.substring(idx + "/websocket/".length());
int slash = rest.indexOf('/');
String pathUserId = slash >= 0 ? rest.substring(0, slash) : rest;
//update-begin---author:scott ---date:20261026 for:【issues/4830】userId身份绑定只针对系统通知端点/websocket/{userId},避免误拦大屏/websocket/drag/{chartId}等其他websocket接口-----------
// 去掉contextPath并合并连续斜杠,与Tomcat端点路由口径一致,防止 /websocket//{userId} 绕过校验
String path = uri.substring(request.getContextPath().length()).replaceAll("/{2,}", "/");
Matcher sysNoticeMatcher = SYS_NOTICE_WS_PATTERN.matcher(path);
if (sysNoticeMatcher.matches()) {
String pathUserId = sysNoticeMatcher.group(1);
//update-end---author:scott ---date:20261026 for:【issues/4830】userId身份绑定只针对系统通知端点/websocket/{userId},避免误拦大屏/websocket/drag/{chartId}等其他websocket接口-----------
// 前端路径userId格式为 {真实userId}_{wsClientId}(md5(token)),取下划线前的真实userId比对;同时兼容无后缀的纯userId
int underline = pathUserId.indexOf('_');
String realPathUserId = underline >= 0 ? pathUserId.substring(0, underline) : pathUserId;

View File

@ -12,7 +12,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
* 只在类路径不存在 jeecg-boot-starter-cloud 时(单体模式)生效;微服务模式下内部接口需供 Feign 调用,由网关拦截外部访问。
*
* @author scott
* @since 2026-10-14 单体模式下内部接口可被任意登录用户直接调用
* @since 2026-10-14 单体模式下内部接口可被任意登录用户直接调用(GHSA-vrqv-3gwg-423j / GHSA-v952-qq2h-377j / GHSA-qj27-82m3-9q8q / GHSA-2xf5-w883-78m9)
*/
@Configuration
@ConditionalOnMissingClass("org.jeecg.config.JeecgCloudBaseConfig")

View File

@ -15,23 +15,23 @@ import java.util.Set;
/**
* 单体模式下禁止外部调用微服务内部接口
* <p>
* /sys/api、/airag/api、/online/api、/drag/api 等是提供给其它微服务 Feign 调用的内部接口,
* 单体模式下各模块为进程内调用,不需要对外暴露。其中部分接口位于依赖 jar 中无法直接修改,
* 因此按 Spring 实际匹配到的接口路径模板统一拦截(不受 URL 编码、大小写、重复斜杠等写法影响)。
* /sys/api、/airag/api、/online/api、/drag/api、/airag/flow/api、/eoa/api 等是提供给其它微服务 Feign 调用的内部接口,
* 单体模式下各模块为进程内调用,不需要对外暴露。按 Spring 实际匹配到的接口路径模板统一拦截
* (不受 URL 编码、大小写、重复斜杠等写法影响),作为控制器加载条件之外的兜底。
*
* @author scott
* @since 2026-10-14 单体模式下内部接口可被任意登录用户直接调用(读写任意数据、读取数据源口令等)
* @since 2026-10-14 单体模式下内部接口可被任意登录用户直接调用(GHSA-vrqv-3gwg-423j / GHSA-v952-qq2h-377j / GHSA-qj27-82m3-9q8q / GHSA-2xf5-w883-78m9)
*/
@Slf4j
public class InnerApiGuardInterceptor implements HandlerInterceptor {
/**
* 微服务内部接口路径前缀
* 微服务内部接口路径前缀(/airag/flow/api:按 id 执行任意租户的 AI 流程;/eoa/api:文件、公文模板、考勤补卡)
*/
private static final String[] INNER_API_PREFIXES = {"/sys/api/", "/airag/api/", "/online/api/", "/drag/api/"};
private static final String[] INNER_API_PREFIXES = {"/sys/api/", "/airag/api/", "/online/api/", "/drag/api/", "/airag/flow/api/", "/eoa/api/"};
/**
* 前端在用、需要放行的接口(Online 报表字典翻译)
* 放行的接口:前端字典翻译在用的 Online 报表字典;旧版 PC 端、移动端 EOA 协同催办在用的过渡接口(下个版本删除)
*/
private static final Set<String> ALLOW_PATTERNS = Set.of("/online/api/cgreportGetDataPackage");

View File

@ -179,12 +179,11 @@ public class ShiroConfig {
//App vue3版本查询版本接口
filterChainDefinitionMap.put("/sys/version/app3version", "anon");
//性能监控——安全隐患泄露TOEKN(durid连接池也有)
//update-begin---author:scott ---date:20261024 for:actuator端点限admin角色访问,避免普通用户通过请求追踪获取他人token------------
//update-begin---author:scott ---date:20261023 for:【GHSA-2899-g99h-hq64】actuator不再整体免登录(请求追踪会泄露他人token):health保留匿名供微服务监控中心探活,其余端点要求登录且为admin角色------------
filterChainDefinitionMap.put("/actuator/health", "anon");
filterChainDefinitionMap.put("/actuator/health/**", "anon");
filterChainDefinitionMap.put("/actuator/**", "jwt,roles[admin]");
//update-end---author:scott ---date:20261024 for:actuator端点限admin角色访问------------
//update-end---author:scott ---date:20261023 for:【GHSA-2899-g99h-hq64】actuator不再整体免登录:health保留匿名,其余端点要求登录且为admin角色------------
//测试模块排除
filterChainDefinitionMap.put("/test/seata/**", "anon");

View File

@ -31,7 +31,7 @@
</div>
<div style="width: 600px; margin: 0 auto; margin-top: 50px; font-size: 12px; -webkit-font-smoothing: subpixel-antialiased; text-size-adjust: 100%;">
<p style="text-align: center; line-height: 20.4px; text-size-adjust: 100%; font-family: 'Microsoft YaHei'!important; padding: 0px !important; margin: 0px !important; color: #7e8890 !important;">
<span class="appleLinks">Copyright © 2023-2024 北京敲敲云科技有限公司. 保留所有权利。</span>
<span class="appleLinks">Copyright © 2023-2024 北京国炬信息技术有限公司. 保留所有权利。</span>
</p>
<p style="text-align: center;line-height: 20.4px; text-size-adjust: 100%; font-family: 'Microsoft YaHei'!important; padding: 0px !important; margin: 0px; color: #7e8890 !important; margin-top: 10px;">
<span class="appleLinks">邮件由系统自动发送,请勿直接回复本邮件!</span>

View File

@ -52,6 +52,7 @@ public class DictSqlConditionBypassTest {
@DisplayName("回归:引号内的 # 与正常条件放行")
void normalConditionAllowed() {
assertDoesNotThrow(() -> check("username = 'a#b'"));
assertDoesNotThrow(() -> check("1=1"));
assertDoesNotThrow(() -> check("status = '1' and sex in ('1','2') order by create_time desc"));
assertDoesNotThrow(() -> check("u.username like 'adm%' and `realname` is not null"));
}

View File

@ -165,14 +165,14 @@ public class Issue9695_OpenApiSsrfHeaderInjectionTest {
}
// ==================================================================
// 二·补:网关头只接受纯路径 —— 拒绝查询串/片段/路径穿越
// 二·补:网关头只接受纯路径 —— 拒绝查询串/片段/路径穿越(GHSA-3c5r-mgw9-jq74)
// 漏洞:validateGatewayBasePath 原用 uri.getPath()(解码后)重建基址,未拒绝
// 解码后出现的 ? / #,攻击者传 X_GATEWAY_BASE_PATH: http://127.0.0.1:8080/jeecg-boot%3f
// (%3f 解码为 ?)即可篡改转发目标。修复:拒绝 rawQuery/rawFragment,且 path 走字符白名单、禁止 ..
// ==================================================================
@Nested
@DisplayName("网关头纯路径校验 —— 拒绝查询串/片段/路径穿越")
@DisplayName("网关头纯路径校验 —— 拒绝查询串/片段/路径穿越 (GHSA-3c5r)")
class GatewayHeaderPathOnly {
@Test

View File

@ -56,6 +56,11 @@
</dependencyManagement>
<dependencies>
<!-- AI 基础能力(LLMHandler/AiModelFactory):商业版经 airag-flow 间接引入,开源版没有 airag-flow,需直接声明 -->
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>jeecg-boot-starter-ai</artifactId>
</dependency>
<!-- system单体 api-->
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
@ -74,7 +79,7 @@
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>jeecg-aiflow-boot4</artifactId>
<version>3.9.5</version>
<version>3.9.6</version>
</dependency>
<!-- begin 注意:这几个依赖体积较大,每个约50MB。若发布时需要使用,请将 <scope>provided</scope> 删除 -->
<dependency>

View File

@ -17,6 +17,7 @@ import org.jeecg.modules.airag.app.entity.AiragApp;
import org.jeecg.modules.airag.app.service.IAiragAppService;
import org.jeecg.modules.airag.app.service.IAiragVariableService;
import org.jeecg.modules.airag.llm.consts.LLMConsts;
import org.jeecg.modules.airag.common.handler.IEmbeddingHandler;
import org.jeecg.modules.airag.llm.entity.AiragKnowledgeDoc;
import org.jeecg.modules.airag.llm.service.IAiragKnowledgeDocService;
import org.jeecg.modules.airag.prompts.entity.AiragPrompts;
@ -36,6 +37,9 @@ public class AiragBaseApiImpl implements IAiragBaseApi {
@Autowired
private IAiragKnowledgeDocService airagKnowledgeDocService;
@Autowired
private IEmbeddingHandler embeddingHandler;
@Override
public String knowledgeWriteTextDocument(String knowledgeId, String title, String content, String segmentConfig) {
AssertUtils.assertNotEmpty("知识库ID不能为空", knowledgeId);
@ -178,4 +182,10 @@ public class AiragBaseApiImpl implements IAiragBaseApi {
return prompt.getContent();
}
@Override
public String parseFileContent(String filePath) {
AssertUtils.assertNotEmpty("文件地址不能为空", filePath);
return embeddingHandler.parseFileContent(filePath);
}
}

View File

@ -418,6 +418,12 @@ public class AiragChatServiceImpl implements IAiragChatService {
files.addAll(currMsg.getFiles());
cacheMsg.setFiles(files);
}
if (currMsg.getOutputValues() != null) {
cacheMsg.setOutputValues(currMsg.getOutputValues());
}
if (currMsg.getOutputTypes() != null) {
cacheMsg.setOutputTypes(currMsg.getOutputTypes());
}
} else {
currContent = obj.toString();
}
@ -1028,6 +1034,19 @@ public class AiragChatServiceImpl implements IAiragChatService {
chatConversation.setMessages(histories);
}
/**
* 将流程最终输出保存到刚追加的AI消息中
*/
private void setFlowResult(ChatConversation chatConversation, EventFlowData data) {
List<MessageHistory> histories = chatConversation.getMessages();
if (oConvertUtils.isObjectEmpty(histories)) {
return;
}
MessageHistory historyMessage = histories.get(histories.size() - 1);
historyMessage.setOutputValues(data.getOutputValues());
historyMessage.setOutputTypes(data.getOutputTypes());
}
/**
* 发送聊天消息
*
@ -1254,6 +1273,7 @@ public class AiragChatServiceImpl implements IAiragChatService {
msgEventData.setRequestId(requestId);
sendMessage2Client(emitter, msgEventData);
appendMessage(messages, aiMessage, chatConversation, topicId);
setFlowResult(chatConversation, data);
// 保存会话
//update-begin---author:wangshuai---date:2025-12-10---for:【QQYUN-14127】【AI】AI应用门户---
saveChatConversation(chatConversation, false, httpRequest, sendParams.getSessionType());
@ -1375,7 +1395,10 @@ public class AiragChatServiceImpl implements IAiragChatService {
//流程不为空,构建插件(携带应用上下文参数,供变量/记忆节点使用)
if(oConvertUtils.isNotEmpty(flowId)){
Map<String, Object> result = airagFlowPluginService.getFlowsToPlugin(flowId, aiApp.getId(), memoryId);
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
// 把当前消息上传的图片带给关联流程,流程开始节点的 images 入参由服务端注入(例如「示例_OCR」流程)
Map<String, Object> result = airagFlowPluginService.getFlowsToPlugin(flowId, aiApp.getId(), memoryId, sendParams.getImages());
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
this.addPluginToParams(aiChatParams, result);
}
@ -1632,7 +1655,9 @@ public class AiragChatServiceImpl implements IAiragChatService {
}
}
final boolean finalShowToolProcess = showToolProcess;
//update-begin---author:wangshuai ---date:20260827 for:【LHZP-1614】【AI】工具调用名称翻译为流程名-----------
final Map<String, String> toolDisplayNames = finalShowToolProcess ? getFlowToolDisplayNames(chatConversation.getApp()) : Collections.emptyMap();
//update-end---author:wangshuai ---date:20260827 for:【LHZP-1614】【AI】工具调用名称翻译为流程名-----------
//update-begin---author:wangshuai ---date:20260804 for:【LHZP-1591】智普模型单轮只调用变量工具时兜底写入记忆库-----------
Set<String> executedToolNames = ConcurrentHashMap.newKeySet();

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
* airag baseAPI Controller
* <p>
* 仅供微服务 Feign 内部调用。单体模式下为进程内调用,无需对外暴露,
* 故只在类路径存在 jeecg-boot-starter-cloud(微服务模式)时加载(2026-10-14)
* 故只在类路径存在 jeecg-boot-starter-cloud(微服务模式)时加载(2026-10-14 GHSA-v952-qq2h-377j)
*
* @author sjlei
* @date 2025-12-30
@ -78,4 +78,9 @@ public class AiragBaseApiController implements IAiragBaseApi {
return airagBaseApi.getPromptContent(promptId);
}
@PostMapping("/airag/api/parseFileContent")
public String parseFileContent(@RequestParam("filePath") String filePath) {
return airagBaseApi.parseFileContent(filePath);
}
}

View File

@ -655,11 +655,11 @@ public class AIChatHandler implements IAIChatHandler {
//update-begin---author:zhangdaihao ---date:2026-08-06 for:【issues/9805】AI图生图imageUrl未校验导致SSRF,增加URL安全校验-----------
SsrfFileTypeFilter.checkSsrfHttpUrl(imageUrl);
//update-end---author:zhangdaihao ---date:2026-08-06 for:【issues/9805】AI图生图imageUrl未校验导致SSRF,增加URL安全校验-----------
//update-begin---author:wangshuai ---date:20261015 for:只校验初始URL、openConnection默认跟随302导致SSRF重定向绕过,改用禁止自动跳转且逐跳SSRF校验的安全下载-----------
//update-begin---author:wangshuai ---date:20261015 for:【GHSA-3wf5-4x79-98fq】只校验初始URL、openConnection默认跟随302导致SSRF重定向绕过,改用禁止自动跳转且逐跳SSRF校验的安全下载-----------
// 原裸 openConnection 默认自动跟随 3xx 且跳转目标不复检,攻击者用跳板 302 跳到 127.0.0.1、169.254.169.254(云元数据) 即可绕过上面的初始校验;
// download2BytesFromNet 内部禁止自动跳转,并对初始URL及每一跳重定向目标都做SSRF校验(与 #9681 同口径)。
fileContent = FileDownloadUtils.download2BytesFromNet(imageUrl);
//update-end---author:wangshuai ---date:20261015 for:只校验初始URL、openConnection默认跟随302导致SSRF重定向绕过,改用禁止自动跳转且逐跳SSRF校验的安全下载-----------
//update-end---author:wangshuai ---date:20261015 for:【GHSA-3wf5-4x79-98fq】只校验初始URL、openConnection默认跟随302导致SSRF重定向绕过,改用禁止自动跳转且逐跳SSRF校验的安全下载-----------
} else {
//update-begin---author:liusq ---date:2026-03-30 for:【issues/9431】修复getFirstImageBase64路径遍历漏洞(CWE-22)-----------
// 本地文件

View File

@ -843,6 +843,20 @@ public class EmbeddingHandler implements IEmbeddingHandler {
return null;
}
//update-begin---author:wangshuai ---date:20260820 for:【LHZP-1627】ai流程文件必填,但是在ai聊天中 是文件输入,而不是文件上传: AI流程文件变量传入LLM前统一解析-----------
@Override
public String parseFileContent(String filePath) {
AssertUtils.assertNotEmpty("文件地址不能为空", filePath);
String localFilePath = ensureFile(filePath);
Document document = new TikaDocumentParser(AutoDetectParser::new, null, null, null)
.parse(new File(localFilePath));
if (document == null || oConvertUtils.isEmpty(document.text())) {
throw new JeecgBootException("文件内容为空或无法解析");
}
return document.text();
}
//update-end---author:wangshuai ---date:20260820 for:【LHZP-1627】ai流程文件必填,但是在ai聊天中 是文件输入,而不是文件上传:AI流程文件变量传入LLM前统一解析-----------
@NotNull
private static StringBuffer replaceImageUrl(String content, String abstractBaseUrl, String relativeBaseUrl) {
// 正则表达式匹配md文件中的图片语法 ![alt text](image url)
@ -983,6 +997,12 @@ public class EmbeddingHandler implements IEmbeddingHandler {
filePath = target.toString();
//update-end---author:wangshuai---date:2026-03-30---for:【issues/9424】CommandExecUtil 命令执行过程中存在疑似路径遍历漏洞/【issues/9425】EmbeddingHandler 知识库解析过程中疑似存在路径遍历漏洞---
}
//update-begin---author:scott ---date:20260820 for:知识库文件写入禁止空文件假成功-----------
File sourceFile = new File(filePath);
if (!sourceFile.isFile() || sourceFile.length() == 0) {
throw new JeecgBootException("文件内容为空或文件不存在,无法写入知识库");
}
//update-end---author:scott ---date:20260820 for:知识库文件写入禁止空文件假成功-----------
return filePath;
}

View File

@ -14,6 +14,7 @@ import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.airag.common.consts.AiragConsts;
import org.jeecg.modules.airag.flow.component.ToolsNode;
import org.jeecg.modules.airag.llm.consts.FlowPluginContent;
import org.jeecg.modules.airag.llm.entity.AiragMcp;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@ -463,7 +464,11 @@ public class PluginToolBuilder {
}
} else {
// 检查是否有默认值
String defaultValue = param.getString("defaultValue");
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
// 默认值按原类型取:流程插件 images 的默认值是图片数组,如 ["temp/a.png","temp/b.png"],
// 用 getString 会变成字符串 "[\"temp/a.png\",\"temp/b.png\"]",流程 LLM 节点会按逗号拆成错误的图片路径
Object defaultValue = param.get(FlowPluginContent.DEFAULT_VALUE);
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
if (oConvertUtils.isNotEmpty(defaultValue)) {
body.put(paramName, defaultValue);
}

View File

@ -1,5 +1,6 @@
package org.jeecg.modules.airag.llm.service;
import java.util.List;
import java.util.Map;
/**
@ -25,4 +26,16 @@ public interface IAiragFlowPluginService {
* @param memoryId 记忆库ID(记忆节点需要)
*/
Map<String, Object> getFlowsToPlugin(String flowIds, String appId, String memoryId);
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
/**
* 获取流程插件(携带应用上下文和当前消息图片)
*
* @param flowIds 多个流程id
* @param appId 应用ID(变量节点需要)
* @param memoryId 记忆库ID(记忆节点需要)
* @param images 当前消息上传的图片(流程开始节点的 images 入参需要)
*/
Map<String, Object> getFlowsToPlugin(String flowIds, String appId, String memoryId, List<String> images);
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
}

View File

@ -43,15 +43,22 @@ public class AiragFlowPluginServiceImpl implements IAiragFlowPluginService {
@Override
public Map<String, Object> getFlowsToPlugin(String flowIds, String appId, String memoryId) {
return doGetFlowsToPlugin(flowIds, appId, memoryId);
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
return doGetFlowsToPlugin(flowIds, appId, memoryId, null);
}
@Override
public Map<String, Object> getFlowsToPlugin(String flowIds, String appId, String memoryId, List<String> images) {
return doGetFlowsToPlugin(flowIds, appId, memoryId, images);
}
@Override
public Map<String, Object> getFlowsToPlugin(String flowIds) {
return doGetFlowsToPlugin(flowIds, null, null);
return doGetFlowsToPlugin(flowIds, null, null, null);
}
private Map<String, Object> doGetFlowsToPlugin(String flowIds, String appId, String memoryId) {
private Map<String, Object> doGetFlowsToPlugin(String flowIds, String appId, String memoryId, List<String> images) {
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
log.info("开始构建流程插件");
// 1. 查询所有启用的流程
LambdaQueryWrapper<AiragFlow> queryWrapper = new LambdaQueryWrapper<>();
@ -86,7 +93,9 @@ public class AiragFlowPluginServiceImpl implements IAiragFlowPluginService {
SubFlowResult flowVo = new SubFlowResult(flow);
// 获取入参参数
JSONArray parameter = getInputParameter(flow, flowVo);
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
JSONArray parameter = getInputParameter(flow, flowVo, images);
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
// 获取出参参数
JSONArray outParams = getOutputParameter(flow, flowVo);
// name必须符合 ^[a-zA-Z0-9_-]+$
@ -196,8 +205,11 @@ public class AiragFlowPluginServiceImpl implements IAiragFlowPluginService {
*
* @param flow
* @param flowVo
* @param images 当前消息上传的图片
*/
private JSONArray getInputParameter(AiragFlow flow, SubFlowResult flowVo) {
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
private JSONArray getInputParameter(AiragFlow flow, SubFlowResult flowVo, List<String> images) {
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
JSONArray parameters = new JSONArray();
/*
String metadata = flow.getMetadata();
@ -222,13 +234,22 @@ public class AiragFlowPluginServiceImpl implements IAiragFlowPluginService {
if (inputParams != null) {
for (FlowNodeConfig.NodeParam param : inputParams) {
String field = param.getField();
// 历史记录、图片由聊天服务在直连流程时自动注入,作为工具入参暴露给模型只会成为噪音且无法被有效填写
if (FlowConsts.FLOW_INPUT_PARAM_HISTORY.equals(field) || FlowConsts.FLOW_INPUT_PARAM_IMAGES.equals(field)) {
// update-begin--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
// 历史记录由聊天服务在直连流程时自动注入,作为工具入参暴露给模型只会成为噪音且无法被有效填写
if (FlowConsts.FLOW_INPUT_PARAM_HISTORY.equals(field)) {
continue;
}
JSONObject p = new JSONObject();
// 参数名
p.put(FlowPluginContent.NAME, param.getField());
// 智能体的关联流程是作为工具让模型调用的,不会像“高级编排”直连流程那样自动注入图片。
// 原来这里直接跳过 images,流程永远拿不到图片,例如「示例_OCR」会直接返回“请提供图片”。
// 改为隐藏参数:不暴露给模型(避免模型编造或遗漏图片地址),由服务端把当前消息上传的图片作为默认值传给流程,如 ["temp/ocr_1760252400000.png"]
if (FlowConsts.FLOW_INPUT_PARAM_IMAGES.equals(field)) {
p.put("hidden", true);
p.put(FlowPluginContent.DEFAULT_VALUE, images);
}
// update-end--author:wangshuai---date:20261012---for:【issues/9872】智能体中,涉及图片输入的流程无法关联对话中上传的图片
// 参数描述
String paramDesc = oConvertUtils.getString(param.getName(), param.getField());
p.put(FlowPluginContent.DESCRIPTION, paramDesc);

View File

@ -19,6 +19,7 @@ import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.config.AiRagConfigBean;
import org.jeecg.modules.airag.llm.entity.AiragMcp;
import org.jeecg.modules.airag.llm.handler.CommandExecUtil;
import org.jeecg.modules.airag.llm.mapper.AiragMcpMapper;
import org.jeecg.modules.airag.llm.service.IAiragMcpService;
import org.springframework.beans.factory.annotation.Autowired;
@ -158,6 +159,9 @@ public class AiragMcpServiceImpl extends ServiceImpl<AiragMcpMapper, AiragMcp> i
String openSafe = aiRagConfigBean.getAllowSensitiveNodes();
if(oConvertUtils.isNotEmpty(openSafe) && openSafe.toLowerCase().contains("stdio")) {
log.info("[MCP]使用STDIO协议(StdioMcpTransport), endpoint:{}", endpoint);
//update-begin---author:wangshuai---date:2026-10-21---for:【GHSA-p3r5-xh32-m66j】/【GHSA-vj3m-vf8p-cvgc】stdio命令注入加固:endpoint 会被 sh -c/cmd.exe /c 执行,执行前先校验拒绝 & | ; < > ` $ 等 shell 元字符,防命令注入(CWE-78) ---
CommandExecUtil.validateArg(endpoint.trim());
//update-end---author:wangshuai---date:2026-10-21---for:【GHSA-p3r5-xh32-m66j】/【GHSA-vj3m-vf8p-cvgc】stdio命令注入加固:endpoint 会被 sh -c/cmd.exe /c 执行,执行前先校验拒绝 & | ; < > ` $ 等 shell 元字符,防命令注入(CWE-78)---
// stdio 类型:endpoint 可能是一个命令行
// Windows 下需要通过 cmd.exe /c 来执行命令,否则找不到 npx 等程序
List<String> cmdParts;

View File

@ -41,6 +41,8 @@ public class VideoGenerationServiceImpl implements IVideoGenerationService {
private static final String REDIS_KEY_PREFIX = "airag:video:";
private static final String MINIMAX_DEFAULT_MODEL = "MiniMax-H3";
private static final Map<String, List<String>> PRESET_PROMPTS = new LinkedHashMap<>();
static {
@ -131,6 +133,9 @@ public class VideoGenerationServiceImpl implements IVideoGenerationService {
@Override
public VideoTaskResultVo submitTask(VideoGenerateVo vo) {
AiChatConfig.ModelConfig config = aiChatConfig.getAiModelVideo();
if (isMiniMaxProvider(config.getProvider())) {
return submitMiniMaxTask(vo, config);
}
String apiKey = config.getApiKey();
String model = config.getModel();
String baseUrl = getVideoApiBaseUrl(config);
@ -177,19 +182,7 @@ public class VideoGenerationServiceImpl implements IVideoGenerationService {
log.info("视频生成任务提交响应: status={}, body={}", response.statusCode(), response.body());
if (response.statusCode() != 200) {
VideoTaskResultVo result = new VideoTaskResultVo();
result.setStatus("FAIL");
String errorMsg = "提交任务失败,状态码: " + response.statusCode();
try {
JSONObject errorJson = JSON.parseObject(response.body());
JSONObject errorObj = errorJson.getJSONObject("error");
if (errorObj != null && errorObj.getString("message") != null) {
errorMsg += "," + errorObj.getString("message");
}
} catch (Exception ignored) {
}
result.setMessage(errorMsg);
return result;
return buildFailResult(null, buildApiErrorMessage("提交视频任务", response.statusCode(), response.body()));
}
JSONObject respJson = JSON.parseObject(response.body());
@ -213,9 +206,116 @@ public class VideoGenerationServiceImpl implements IVideoGenerationService {
}
}
/**
* 提交 MiniMax H3 异步视频生成任务。
*/
private VideoTaskResultVo submitMiniMaxTask(VideoGenerateVo vo, AiChatConfig.ModelConfig config) {
try {
JSONObject body = new JSONObject();
body.put("model", MINIMAX_DEFAULT_MODEL);
JSONArray content = new JSONArray();
JSONObject textContent = new JSONObject();
textContent.put("type", "text");
textContent.put("text", vo.getPrompt());
content.add(textContent);
body.put("content", content);
body.put("resolution", "2K");
body.put("duration", vo.getDuration() == null ? 5 : vo.getDuration());
body.put("ratio", convertSizeToAspectRatio(vo.getSize()));
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(getVideoApiBaseUrl(config) + "/v2/video_generation"))
.header("Authorization", "Bearer " + config.getApiKey())
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body.toJSONString()))
.timeout(Duration.ofSeconds(30))
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
log.info("MiniMax视频生成任务提交响应: status={}, body={}", response.statusCode(), response.body());
if (response.statusCode() != 200) {
return buildFailResult(null, buildApiErrorMessage("提交视频任务", response.statusCode(), response.body()));
}
JSONObject responseJson = JSON.parseObject(response.body());
String taskId = responseJson.getString("task_id");
if (taskId == null || taskId.isBlank()) {
return buildFailResult(null, "MiniMax视频任务提交成功,但未返回task_id");
}
// 缓存生成文案,任务完成后用于保存生成历史。
redisUtil.set(REDIS_KEY_PREFIX + "prompt:" + taskId, vo.getPrompt(), 86400);
VideoTaskResultVo result = new VideoTaskResultVo();
result.setTaskId(taskId);
result.setStatus("PROCESSING");
return result;
} catch (Exception e) {
log.error("提交MiniMax视频生成任务异常", e);
return buildFailResult(null, "提交MiniMax视频任务异常: " + e.getMessage());
}
}
/**
* 查询 MiniMax H3 异步视频生成任务。
*/
private VideoTaskResultVo queryMiniMaxTask(String taskId, AiChatConfig.ModelConfig config) {
try {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(getVideoApiBaseUrl(config) + "/v2/query/video_generation/" + taskId))
.header("Authorization", "Bearer " + config.getApiKey())
.GET()
.timeout(Duration.ofSeconds(30))
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
return buildFailResult(taskId, buildApiErrorMessage("查询视频任务", response.statusCode(), response.body()));
}
JSONObject responseJson = JSON.parseObject(response.body());
JSONObject task = responseJson.getJSONObject("task");
if (task == null) {
return buildFailResult(taskId, "MiniMax查询响应中缺少task");
}
String status = task.getString("status");
log.info("查询MiniMax视频任务: taskId={}, 任务状态={}", taskId, status);
if ("succeeded".equalsIgnoreCase(status)) {
JSONObject taskContent = task.getJSONObject("content");
String remoteVideoUrl = taskContent == null ? null : taskContent.getString("url");
if (remoteVideoUrl == null || remoteVideoUrl.isBlank()) {
return buildFailResult(taskId, "MiniMax视频生成成功,但未返回视频地址");
}
VideoTaskResultVo result = new VideoTaskResultVo();
result.setTaskId(taskId);
result.setStatus("SUCCESS");
String localVideoPath = downloadToLocal(remoteVideoUrl, "video_" + taskId + ".mp4");
result.setVideoUrl(localVideoPath);
// 前端会轮询任务状态,删除成功的请求负责入库,避免同一视频重复写入生成历史。
String promptKey = REDIS_KEY_PREFIX + "prompt:" + taskId;
Object cachedPrompt = redisTemplate.opsForValue().get(promptKey);
if (cachedPrompt != null && Boolean.TRUE.equals(redisTemplate.delete(promptKey))) {
saveVideoToRedis(result, cachedPrompt.toString());
}
return result;
}
if ("failed".equalsIgnoreCase(status) || "cancelled".equalsIgnoreCase(status)) {
return buildFailResult(taskId, parseMiniMaxTaskError(task, status));
}
VideoTaskResultVo result = new VideoTaskResultVo();
result.setTaskId(taskId);
result.setStatus("PROCESSING");
return result;
} catch (Exception e) {
log.error("查询MiniMax视频任务异常, taskId={}", taskId, e);
return buildFailResult(taskId, "查询MiniMax视频任务异常: " + e.getMessage());
}
}
@Override
public VideoTaskResultVo queryTask(String taskId) {
AiChatConfig.ModelConfig config = aiChatConfig.getAiModelVideo();
if (isMiniMaxProvider(config.getProvider())) {
return queryMiniMaxTask(taskId, config);
}
String apiKey = config.getApiKey();
String baseUrl = getVideoApiBaseUrl(config);
@ -230,12 +330,8 @@ public class VideoGenerationServiceImpl implements IVideoGenerationService {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
log.error("查询视频任务HTTP失败: taskId={}, httpStatus={}", taskId, response.statusCode());
VideoTaskResultVo result = new VideoTaskResultVo();
result.setTaskId(taskId);
result.setStatus("FAIL");
result.setMessage("查询任务失败,状态码: " + response.statusCode());
return result;
log.error("查询视频任务HTTP失败: taskId={}, httpStatus={}, body={}", taskId, response.statusCode(), response.body());
return buildFailResult(taskId, buildApiErrorMessage("查询视频任务", response.statusCode(), response.body()));
}
JSONObject respJson = JSON.parseObject(response.body());
@ -313,6 +409,68 @@ public class VideoGenerationServiceImpl implements IVideoGenerationService {
}
}
private boolean isMiniMaxProvider(String provider) {
return "MINIMAX".equalsIgnoreCase(provider);
}
private VideoTaskResultVo buildFailResult(String taskId, String message) {
VideoTaskResultVo result = new VideoTaskResultVo();
result.setTaskId(taskId);
result.setStatus("FAIL");
result.setMessage(message);
return result;
}
/**
* 将视频模型接口的HTTP错误转换为可操作的提示,避免 401 等被误认为是系统登录失效。
*
* @param action 操作名称,如“提交视频任务”
* @param statusCode 第三方接口HTTP状态码
* @param responseBody 第三方接口响应体
*/
private String buildApiErrorMessage(String action, int statusCode, String responseBody) {
String reason = switch (statusCode) {
case 401, 403 -> "视频模型 API Key 无效或已过期,请联系管理员检查配置 jeecg.ai-chat.ai-model-video.apiKey";
case 404 -> "视频模型接口地址或模型不存在,请检查配置 jeecg.ai-chat.ai-model-video 的 apiHost 和 model";
case 429 -> "视频模型调用频率超限或账户余额不足,请稍后重试或检查模型平台账户额度";
case 400 -> "请求参数不被视频模型接受,请调整描述、尺寸或时长后重试";
default -> statusCode >= 500 ? "视频模型服务暂时不可用,请稍后重试" : "视频模型接口调用异常";
};
String apiMessage = parseApiErrorMessage(responseBody);
String detail = apiMessage == null ? "HTTP " + statusCode : "HTTP " + statusCode + ",平台返回:" + apiMessage;
return action + "失败:" + reason + "(" + detail + ")";
}
/**
* 从第三方错误响应中提取错误信息,兼容智谱 error.message 与 MiniMax base_resp.status_msg。
*/
private String parseApiErrorMessage(String responseBody) {
try {
JSONObject responseJson = JSON.parseObject(responseBody);
JSONObject error = responseJson.getJSONObject("error");
if (error != null && error.getString("message") != null) {
return error.getString("message");
}
JSONObject baseResp = responseJson.getJSONObject("base_resp");
if (baseResp != null && baseResp.getString("status_msg") != null) {
return baseResp.getString("status_msg");
}
return responseJson.getString("message");
} catch (Exception ignored) {
// 非JSON错误响应不返回平台信息。
return null;
}
}
private String parseMiniMaxTaskError(JSONObject task, String status) {
JSONObject error = task.getJSONObject("error");
if (error != null && error.getString("message") != null) {
return error.getString("message");
}
String message = task.getString("message");
return message == null || message.isBlank() ? "MiniMax视频任务状态: " + status : message;
}
@Override
public VideoTaskResultVo addVoiceover(String taskId, String prompt) {
// 1. 先查询任务状态,获取视频URL

View File

@ -94,4 +94,10 @@ public interface IAiragBaseApi {
@PostMapping("/airag/api/getPromptContent")
String getPromptContent(@RequestParam("promptId") String promptId);
/**
* 解析本地、MinIO或OSS文件内容。
*/
@PostMapping("/airag/api/parseFileContent")
String parseFileContent(@RequestParam("filePath") String filePath);
}

View File

@ -0,0 +1,43 @@
package org.jeecg.common.airag.api;
import org.jeecg.common.airag.api.fallback.AiragFlowApiFallback;
import org.jeecg.common.api.dto.AiragFlowDTO;
import org.jeecg.common.constant.ServiceNameConstants;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
/**
* airag工作流运行API(微服务Feign版)
* 单体模式下由airag-flow模块的AiragFlowApiImpl直接实现,本Feign接口不生效;
* 微服务模式下通过Feign远程调用airag-flow服务暴露的HTTP端点
*
* @author zhang
* @date 2026-09-10
*/
@Component
@FeignClient(contextId = "airagFlowRemoteApi", value = ServiceNameConstants.SERVICE_SYSTEM, fallbackFactory = AiragFlowApiFallback.class)
@ConditionalOnMissingClass("org.jeecg.modules.airag.flow.api.AiragFlowApiImpl")
public interface IAiragFlowApi {
/**
* 运行AI工作流
*
* @param airagFlowDTO 流程运行参数
* @return 流程执行结果
*/
@PostMapping("/airag/flow/api/runFlow")
Object runFlow(@RequestBody AiragFlowDTO airagFlowDTO);
/**
* 流式运行AI工作流
*
* @param airagFlowDTO 流程运行参数
* @return SSE流
*/
@PostMapping("/airag/flow/api/runFlowStream")
SseEmitter runFlowStream(@RequestBody AiragFlowDTO airagFlowDTO);
}

View File

@ -0,0 +1,24 @@
package org.jeecg.common.airag.api.factory;
import org.jeecg.common.airag.api.IAiragFlowApi;
import org.jeecg.common.airag.api.fallback.AiragFlowApiFallback;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* airag工作流运行API 降级工厂
*
* @author zhang
* @date 2026-09-10
*/
@Component
public class AiragFlowApiFallbackFactory implements FallbackFactory<IAiragFlowApi> {
@Override
public IAiragFlowApi create(Throwable cause) {
AiragFlowApiFallback fallback = new AiragFlowApiFallback();
fallback.setCause(cause);
return fallback;
}
}

View File

@ -42,4 +42,9 @@ public class AiragBaseApiFallback implements IAiragBaseApi {
return null;
}
@Override
public String parseFileContent(String filePath) {
return null;
}
}

View File

@ -0,0 +1,29 @@
package org.jeecg.common.airag.api.fallback;
import lombok.Setter;
import org.jeecg.common.airag.api.IAiragFlowApi;
import org.jeecg.common.api.dto.AiragFlowDTO;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
/**
* airag工作流运行API 降级实现
*
* @author zhang
* @date 2026-09-10
*/
public class AiragFlowApiFallback implements IAiragFlowApi {
@Setter
private Throwable cause;
@Override
public Object runFlow(AiragFlowDTO airagFlowDTO) {
return null;
}
@Override
public SseEmitter runFlowStream(AiragFlowDTO airagFlowDTO) {
return null;
}
}

View File

@ -38,6 +38,15 @@ import java.util.Set;
@ConditionalOnMissingClass("org.jeecg.modules.system.service.impl.SysBaseApiImpl")
public interface ISysBaseAPI extends CommonAPI {
/**
* 批量查询 Popup 字典项。
*/
@GetMapping("/sys/api/queryPopupDictItems")
List<DictModel> queryPopupDictItems(@RequestParam("reportCode") String reportCode,
@RequestParam("dictCode") String dictCode,
@RequestParam("dictText") String dictText,
@RequestParam("dataList") String dataList);
/**
* 1发送系统消息
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息

View File

@ -29,6 +29,12 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
@Setter
private Throwable cause;
@Override
public List<DictModel> queryPopupDictItems(String reportCode, String dictCode, String dictText, String dataList) {
log.error("查询popup字典项失败", cause);
return List.of();
}
@Override
public void sendSysAnnouncement(MessageDTO message) {
log.error("发送消息失败 {}", cause);

View File

@ -76,4 +76,9 @@ public interface IAiragBaseApi {
*/
String getPromptContent(String promptId);
/**
* 解析本地、MinIO或OSS文件内容。
*/
String parseFileContent(String filePath);
}

View File

@ -0,0 +1,31 @@
package org.jeecg.common.airag.api;
import org.jeecg.common.api.dto.AiragFlowDTO;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
/**
* airag工作流运行API
* 供system等基础模块软依赖AI工作流能力,实现由jeecg-boot-module-airag-flow模块提供;
* 未集成AI模块时无实现bean,注入方使用ObjectProvider判空即可正常启动
*
* @author zhang
* @date 2026-09-10
*/
public interface IAiragFlowApi {
/**
* 运行AI工作流
*
* @param airagFlowDTO 流程运行参数
* @return 流程执行结果
*/
Object runFlow(AiragFlowDTO airagFlowDTO);
/**
* 流式运行AI工作流
*
* @param airagFlowDTO 流程运行参数
* @return SSE流
*/
SseEmitter runFlowStream(AiragFlowDTO airagFlowDTO);
}

View File

@ -26,6 +26,11 @@ import java.util.Set;
*/
public interface ISysBaseAPI extends CommonAPI {
/**
* 批量查询 Popup 字典项。
*/
List<DictModel> queryPopupDictItems(String reportCode, String dictCode, String dictText, String dataList);
//=======OLD 系统消息推送接口============================
/**
* 1发送系统消息

View File

@ -25,6 +25,7 @@ import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@ -38,6 +39,8 @@ import java.util.*;
*/
@Slf4j
@Component
// AI工具提供者:仅在classpath存在airag模块(JeecgToolsProvider接口)时装配,去AI依赖后跳过注册,不影响应用启动
@ConditionalOnClass(name = "org.jeecg.modules.airag.llm.handler.JeecgToolsProvider")
public class JeecgBizToolsProvider implements JeecgToolsProvider {
@Autowired

View File

@ -29,7 +29,8 @@ import java.util.Set;
* 服务化 system模块 对外接口请求类
* <p>
* 仅供微服务 Feign 内部调用。单体模式下 ISysBaseAPI 为进程内调用,无需对外暴露,
* 故只在类路径存在 jeecg-boot-starter-cloud(微服务模式)时加载,防止 /sys/api/** 被普通登录用户直接调用(2026-10-14)
* 故只在类路径存在 jeecg-boot-starter-cloud(微服务模式)时加载,防止 /sys/api/** 被普通登录用户直接调用
* (2026-10-14 GHSA-vrqv-3gwg-423j / GHSA-hh6j-6p7c-8hrf / GHSA-483m-f38h-369m / GHSA-5q28-hq94-q2fj)
* @author: jeecg-boot
*/
@Slf4j
@ -43,6 +44,17 @@ public class SystemApiController {
@Autowired
private ISysUserService sysUserService;
/**
* 批量查询 Popup 字典项。
*/
@GetMapping("/queryPopupDictItems")
public List<DictModel> queryPopupDictItems(@RequestParam("reportCode") String reportCode,
@RequestParam("dictCode") String dictCode,
@RequestParam("dictText") String dictText,
@RequestParam("dataList") String dataList) {
return sysBaseApi.queryPopupDictItems(reportCode, dictCode, dictText, dataList);
}
/**
* 发送系统消息
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
@ -49,6 +50,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param req
* @return
*/
@RequiresPermissions("system:message:list")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysMessage sysMessage, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
@ -64,6 +66,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param sysMessage
* @return
*/
@RequiresPermissions("system:message:add")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysMessage sysMessage) {
sysMessageService.save(sysMessage);
@ -76,6 +79,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param sysMessage
* @return
*/
@RequiresPermissions("system:message:edit")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysMessage sysMessage) {
sysMessageService.updateById(sysMessage);
@ -89,6 +93,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param id
* @return
*/
@RequiresPermissions("system:message:delete")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
sysMessageService.removeById(id);
@ -101,6 +106,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param ids
* @return
*/
@RequiresPermissions("system:message:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
@ -114,6 +120,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param id
* @return
*/
@RequiresPermissions("system:message:queryById")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
SysMessage sysMessage = sysMessageService.getById(id);
@ -125,6 +132,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
*
* @param request
*/
@RequiresPermissions("system:message:exportXls")
@GetMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysMessage sysMessage) {
return super.exportXls(request,sysMessage,SysMessage.class, "推送消息模板");
@ -137,6 +145,7 @@ public class SysMessageController extends JeecgController<SysMessage, ISysMessag
* @param response
* @return
*/
@RequiresPermissions("system:message:importExcel")
@PostMapping(value = "/importExcel")
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, SysMessage.class);

View File

@ -6,6 +6,7 @@ import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.api.ISysBaseAPI;
@ -79,6 +80,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
* @param sysMessageTemplate
* @return
*/
@RequiresPermissions("system:messageTemplate:add")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysMessageTemplate sysMessageTemplate) {
sysMessageTemplateService.save(sysMessageTemplate);
@ -91,6 +93,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
* @param sysMessageTemplate
* @return
*/
@RequiresPermissions("system:messageTemplate:edit")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysMessageTemplate sysMessageTemplate) {
sysMessageTemplateService.updateById(sysMessageTemplate);
@ -103,6 +106,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
* @param id
* @return
*/
@RequiresPermissions("system:messageTemplate:delete")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
sysMessageTemplateService.removeById(id);
@ -115,6 +119,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
* @param ids
* @return
*/
@RequiresPermissions("system:messageTemplate:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.sysMessageTemplateService.removeByIds(Arrays.asList(ids.split(",")));
@ -138,6 +143,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
*
* @param request
*/
@RequiresPermissions("system:messageTemplate:exportXls")
@GetMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request,SysMessageTemplate sysMessageTemplate) {
return super.exportXls(request, sysMessageTemplate, SysMessageTemplate.class,"推送消息模板");
@ -150,6 +156,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
* @param response
* @return
*/
@RequiresPermissions("system:messageTemplate:importExcel")
@PostMapping(value = "/importExcel")
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
@ -172,6 +179,7 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
/**
* 发送消息
*/
@RequiresPermissions("system:messageTemplate:sendMsg")
@PostMapping(value = "/sendMsg")
public Result<SysMessageTemplate> sendMessage(@RequestBody MsgParams msgParams) {
Result<SysMessageTemplate> result = new Result<SysMessageTemplate>();

View File

@ -36,9 +36,9 @@ public class CustomInMemoryHttpTraceRepository extends InMemoryHttpExchangeRepos
// 只有当请求不是OPTIONS方法,并且URI不包含httptrace时才记录数据
if (!"OPTIONS".equals(trace.getRequest().getMethod()) &&
!trace.getRequest().getUri().toString().contains("httptrace")) {
//update-begin---author:scott ---date:20261023 for:请求追踪记录前脱敏,避免token、cookie等凭据经追踪接口泄露------------
//update-begin---author:scott ---date:20261023 for:【GHSA-2899-g99h-hq64】请求追踪记录前脱敏,避免他人token、cookie等凭据经追踪接口泄露------------
super.add(desensitize(trace));
//update-end---author:scott ---date:20261023 for:请求追踪记录前脱敏------------
//update-end---author:scott ---date:20261023 for:【GHSA-2899-g99h-hq64】请求追踪记录前脱敏------------
}
}
@ -62,7 +62,7 @@ public class CustomInMemoryHttpTraceRepository extends InMemoryHttpExchangeRepos
* 复制一份请求追踪记录,把请求/响应中的凭据替换为占位符后再存储
*
* @author scott
* @since 2026-10-23 请求追踪记录脱敏,避免泄露 X-Access-Token
* @since 2026-10-23 【GHSA-2899-g99h-hq64】请求追踪接口泄露他人 X-Access-Token
*/
private static HttpExchange desensitize(HttpExchange trace) {
HttpExchange.Request request = trace.getRequest();
@ -78,7 +78,7 @@ public class CustomInMemoryHttpTraceRepository extends InMemoryHttpExchangeRepos
* 请求头/响应头脱敏:命中 SENSITIVE_HEADERS 的头(不区分大小写)值替换为占位符
*
* @author scott
* @since 2026-10-23 请求追踪记录脱敏,避免泄露 X-Access-Token
* @since 2026-10-23 【GHSA-2899-g99h-hq64】请求追踪接口泄露他人 X-Access-Token
*/
private static Map<String, List<String>> maskHeaders(Map<String, List<String>> headers) {
if (headers == null || headers.isEmpty()) {
@ -94,7 +94,7 @@ public class CustomInMemoryHttpTraceRepository extends InMemoryHttpExchangeRepos
* URL 脱敏:token/access_token/x-access-token 参数值替换为占位符
*
* @author scott
* @since 2026-10-23 请求追踪记录脱敏,避免泄露 X-Access-Token
* @since 2026-10-23 【GHSA-2899-g99h-hq64】请求追踪接口泄露他人 X-Access-Token
*/
private static URI maskUri(URI uri) {
if (uri == null || uri.getRawQuery() == null) {

View File

@ -158,9 +158,9 @@ public class OpenApiController extends JeecgController<OpenApi, OpenApiService>
* @param path
* @return
*/
//update-begin---author:scott ---date:20261024 for:/call 不再接受 OPTIONS、TRACE,OPTIONS 不能再作为转发入口绕过认证-----------
//update-begin---author:scott ---date:20261024 for:【GHSA-m3rc-w9wv-5qmw】/call 不再接受 OPTIONS、TRACE,OPTIONS 不能再作为转发入口绕过认证-----------
@RequestMapping(value = "/call/{path}", method = {RequestMethod.GET,RequestMethod.POST,RequestMethod.DELETE,RequestMethod.PUT,RequestMethod.PATCH,RequestMethod.HEAD})
//update-end---author:scott ---date:20261024 for:/call 不再接受 OPTIONS、TRACE-----------
//update-end---author:scott ---date:20261024 for:【GHSA-m3rc-w9wv-5qmw】/call 不再接受 OPTIONS、TRACE-----------
public Result<?> call(@PathVariable String path, @RequestBody(required = false) String json, HttpServletRequest request) {
OpenApi openApi = service.findByPath(path);
if (Objects.isNull(openApi)) {
@ -523,7 +523,7 @@ public class OpenApiController extends JeecgController<OpenApi, OpenApiService>
info.setDescription("OpenAPI 接口列表");
info.setVersion("3.9.5");
info.setTitle("OpenAPI 接口列表");
info.setTermsOfService("https://jeecg.com");
//info.setTermsOfService("https://jeecg.com");
SwaggerInfoContact contact = new SwaggerInfoContact();
contact.setName("jeecg@qq.com");

View File

@ -44,7 +44,7 @@ public class ApiAuthFilter implements Filter {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
//update-begin---author:jeecg---for:OPTIONS 预检只应答 CORS,不得进入后续业务链路,否则可绕过签名/AK/授权校验---
//update-begin---author:jeecg---for:【GHSA-3c5r-mgw9-jq74】OPTIONS 预检只应答 CORS,不得进入后续业务链路,否则可绕过签名/AK/授权校验---
// OPTIONS 预检请求:仅回写 CORS 响应头并结束,绝不放行到 filterChain(防止 OPTIONS 绕过 OpenApi 签名鉴权)
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
String origin = request.getHeader("Origin");
@ -60,7 +60,7 @@ public class ApiAuthFilter implements Filter {
response.setStatus(HttpServletResponse.SC_OK);
return;
}
//update-end---author:jeecg---for:OPTIONS 预检只应答 CORS,不得进入后续业务链路---
//update-end---author:jeecg---for:【GHSA-3c5r-mgw9-jq74】OPTIONS 预检只应答 CORS,不得进入后续业务链路---
String ip = IpUtils.getIpAddr(request);
@ -353,11 +353,11 @@ public class ApiAuthFilter implements Filter {
throw new JeecgBootException("不存在认证信息");
}
//update-begin---author:scott ---date:20261014 for:SK为空时签名退化为md5(appKey+timestamp),知道AK即可伪造,空SK一律拒绝-----------
//update-begin---author:scott ---date:20261014 for:【GHSA-qv87-c4w6-699m/GHSA-5jhm-3x8j-wwhr】SK为空时签名退化为md5(appKey+timestamp),知道AK即可伪造,空SK一律拒绝-----------
if (!StringUtils.hasText(openApiAuth.getSk())) {
throw new JeecgBootException("该凭据未配置SK,请在【OpenAPI-授权管理】重新生成AK/SK");
}
//update-end---author:scott ---date:20261014 for:SK为空时签名退化为md5(appKey+timestamp),知道AK即可伪造,空SK一律拒绝-----------
//update-end---author:scott ---date:20261014 for:【GHSA-qv87-c4w6-699m/GHSA-5jhm-3x8j-wwhr】SK为空时签名退化为md5(appKey+timestamp),知道AK即可伪造,空SK一律拒绝-----------
if(!appKey.equals(openApiAuth.getAk())){
throw new JeecgBootException("appkey错误");

View File

@ -203,6 +203,7 @@ public class QuartzJobController {
* @param request
* @param quartzJob
*/
@RequiresPermissions("system:quartzJob:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, QuartzJob quartzJob) {
// Step.1 组装查询条件
@ -233,6 +234,7 @@ public class QuartzJobController {
* @param response
* @return
*/
@RequiresPermissions("system:quartzJob:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

View File

@ -13,7 +13,6 @@ import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.util.HttpFileToMultipartFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;

View File

@ -795,7 +795,9 @@ public class LoginController {
@Operation(summary = "登录二维码")
@GetMapping("/getLoginQrcode")
public Result<?> getLoginQrcode() {
String qrcodeId = CommonConstant.LOGIN_QRCODE_PRE+IdWorker.getIdStr();
//update-begin---author:jeecg---for:【GHSA-gm36-7vvp-c5jh】qrcodeId 改用不可预测的随机串(原雪花ID可被枚举窃取他人token)---
String qrcodeId = CommonConstant.LOGIN_QRCODE_PRE + java.util.UUID.randomUUID().toString().replace("-", "");
//update-end---author:jeecg---for:【GHSA-gm36-7vvp-c5jh】qrcodeId 改用不可预测的随机串---
//定义二维码参数
Map params = new HashMap(5);
params.put("qrcodeId", qrcodeId);
@ -835,6 +837,10 @@ public class LoginController {
return Result.OK(result);
}
if (oConvertUtils.isNotEmpty(token)) {
//update-begin---author:jeecg---for:【GHSA-gm36-7vvp-c5jh】token 一次性读取,读到即删,防止被重复轮询窃取---
redisUtil.del(CommonConstant.LOGIN_QRCODE_TOKEN + qrcodeId);
redisUtil.del(CommonConstant.LOGIN_QRCODE + qrcodeId);
//update-end---author:jeecg---for:【GHSA-gm36-7vvp-c5jh】token 一次性读取---
result.put("success", true);
result.put("token", token);
} else {

View File

@ -286,6 +286,12 @@ public class SysAnnouncementSendController {
}
//update-end---author:scott ---date:20261013 for:【安全 GHSA-63v7-3c98-c3mj】按sendId获取消息正文前校验归属,只能查看本人收到的消息-----------
AnnouncementSendModel model = sysAnnouncementSendService.getOne(sendId);
//update-begin---author:jeecg---for:【安全 GHSA-fp4f-qhf5-hqj8】校验消息归属,只能查看本人站内信---
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (model != null && !sysUser.getId().equals(model.getUserId())) {
return Result.error("无权查看该消息");
}
//update-end---author:jeecg---for:【安全 GHSA-fp4f-qhf5-hqj8】校验消息归属---
return Result.ok(model);
}

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
@ -126,6 +127,7 @@ public class SysCategoryController {
* @param sysCategory
* @return
*/
@RequiresPermissions("system:category:add")
@PostMapping(value = "/add")
public Result<SysCategory> add(@RequestBody SysCategory sysCategory) {
Result<SysCategory> result = new Result<SysCategory>();
@ -144,6 +146,7 @@ public class SysCategoryController {
* @param sysCategory
* @return
*/
@RequiresPermissions("system:category:edit")
@RequestMapping(value = "/edit", method = { RequestMethod.PUT,RequestMethod.POST })
public Result<SysCategory> edit(@RequestBody SysCategory sysCategory) {
Result<SysCategory> result = new Result<SysCategory>();
@ -162,6 +165,7 @@ public class SysCategoryController {
* @param id
* @return
*/
@RequiresPermissions("system:category:delete")
@DeleteMapping(value = "/delete")
public Result<SysCategory> delete(@RequestParam(name="id",required=true) String id) {
Result<SysCategory> result = new Result<SysCategory>();
@ -181,6 +185,7 @@ public class SysCategoryController {
* @param ids
* @return
*/
@RequiresPermissions("system:category:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<SysCategory> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
Result<SysCategory> result = new Result<SysCategory>();
@ -216,6 +221,7 @@ public class SysCategoryController {
*
* @param request
*/
@RequiresPermissions("system:category:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
//------------------------------------------------------------------------------------------------
@ -262,6 +268,7 @@ public class SysCategoryController {
* @param response
* @return
*/
@RequiresPermissions("system:category:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException{
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

View File

@ -177,6 +177,7 @@ public class SysCheckRuleController extends JeecgController<SysCheckRule, ISysCh
* @param request
* @param sysCheckRule
*/
@RequiresPermissions("system:checkRule:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysCheckRule sysCheckRule) {
return super.exportXls(request, sysCheckRule, SysCheckRule.class, "编码校验规则");
@ -189,6 +190,7 @@ public class SysCheckRuleController extends JeecgController<SysCheckRule, ISysCh
* @param response
* @return
*/
@RequiresPermissions("system:checkRule:add")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

View File

@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.dto.DataLogDTO;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
@ -167,6 +168,7 @@ public class SysCommentController extends JeecgController<SysComment, ISysCommen
*/
//@AutoLog(value = "系统评论回复表-分页列表查询")
@Operation(summary = "系统评论回复表-分页列表查询")
@RequiresPermissions("system:comment:list")
@GetMapping(value = "/list")
public Result<IPage<SysComment>> queryPageList(SysComment sysComment,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@ -326,6 +328,7 @@ public class SysCommentController extends JeecgController<SysComment, ISysCommen
* @param request
* @param sysComment
*/
@RequiresPermissions("system:comment:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysComment sysComment) {
return super.exportXls(request, sysComment, SysComment.class, "系统评论回复表");
@ -338,6 +341,7 @@ public class SysCommentController extends JeecgController<SysComment, ISysCommen
* @param response
* @return
*/
@RequiresPermissions("system:comment:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, SysComment.class);

View File

@ -5,6 +5,8 @@ import java.util.List;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
@ -34,6 +36,7 @@ public class SysDataLogController {
@Autowired
private ISysDataLogService service;
@RequiresPermissions("system:dataLog:list")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysDataLog>> queryPageList(SysDataLog dataLog,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
@ -56,6 +59,7 @@ public class SysDataLogController {
* @param req
* @return
*/
@RequiresPermissions("system:dataLog:queryCompareList")
@RequestMapping(value = "/queryCompareList", method = RequestMethod.GET)
public Result<List<SysDataLog>> queryCompareList(HttpServletRequest req) {
Result<List<SysDataLog>> result = new Result<>();
@ -81,6 +85,11 @@ public class SysDataLogController {
*/
@RequestMapping(value = "/queryDataVerList", method = RequestMethod.GET)
public Result<List<SysDataLog>> queryDataVerList(HttpServletRequest req) {
//update-begin---author:wangshuai ---date:2026-10-25 for:【GHSA-p4f8-h832-99pw】数据日志含业务数据快照,除评论组件查询的评论日志(type=comment)外需 system:dataLog:queryDataVerList 按钮权限-----------
if (!CommonConstant.DATA_LOG_TYPE_COMMENT.equals(req.getParameter("type")) && !SecurityUtils.getSubject().isPermitted("system:dataLog:queryDataVerList")) {
return Result.noauth("没有权限,请联系管理员分配权限!");
}
//update-end---author:wangshuai ---date:2026-10-25 for:【GHSA-p4f8-h832-99pw】数据日志含业务数据快照,除评论组件查询的评论日志(type=comment)外需 system:dataLog:queryDataVerList 按钮权限-----------
Result<List<SysDataLog>> result = new Result<>();
String dataTable = req.getParameter("dataTable");
String dataId = req.getParameter("dataId");

View File

@ -381,6 +381,7 @@ public class SysDepartController {
*
* @param request
*/
@RequiresPermissions("system:depart:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
//------------------------------------------------------------------------------------------------
@ -555,7 +556,7 @@ public class SysDepartController {
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<SysUser>();
queryUser.eq(SysUser::getDelFlag,CommonConstant.DEL_FLAG_0);
queryUser.and(i -> i.like(SysUser::getUsername, keyWord).or().like(SysUser::getRealname, keyWord));
//update-begin---author:scott ---date:20261014 for:多租户模式下只查当前租户的用户,防止按关键字跨租户搜索用户信息-----------
//update-begin---author:scott ---date:20261014 for:【安全 GHSA-2h34-xh29-7w95】多租户模式下只查当前租户的用户,防止按关键字跨租户搜索用户信息-----------
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
Integer tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request), 0);
List<String> userIds = userTenantService.getUserIdsByTenantId(tenantId);
@ -565,7 +566,7 @@ public class SysDepartController {
queryUser.eq(SysUser::getId, "通过租户查询不到任何用户");
}
}
//update-end---author:scott ---date:20261014 for:多租户模式下只查当前租户的用户,防止按关键字跨租户搜索用户信息-----------
//update-end---author:scott ---date:20261014 for:【安全 GHSA-2h34-xh29-7w95】多租户模式下只查当前租户的用户,防止按关键字跨租户搜索用户信息-----------
List<SysUser> sysUsers = this.sysUserService.list(queryUser);
map.put("userList",sysUsers);
map.put("departList",list);

View File

@ -159,6 +159,7 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param request
* @param sysDepartPermission
*/
@RequiresPermissions("system:depart:permission:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysDepartPermission sysDepartPermission) {
return super.exportXls(request, sysDepartPermission, SysDepartPermission.class, "部门权限表");

View File

@ -291,6 +291,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param request
* @param sysDepartRole
*/
@RequiresPermissions("system:depart:role:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysDepartRole sysDepartRole) {
return super.exportXls(request, sysDepartRole, SysDepartRole.class, "部门角色");
@ -303,6 +304,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param response
* @return
*/
@RequiresPermissions("system:depart:role:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, SysDepartRole.class);

View File

@ -23,6 +23,7 @@ import org.jeecg.common.system.vo.DictQuery;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.sign.annotation.SignatureCheck;
import org.jeecg.config.shiro.ShiroRealm;
import org.jeecg.modules.system.constant.DefIndexConst;
import org.jeecg.modules.system.entity.SysDict;
@ -615,6 +616,7 @@ public class SysDictController {
*
* @param request
*/
@RequiresPermissions("system:dict:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysDict sysDict,HttpServletRequest request) {
//------------------------------------------------------------------------------------------------
@ -751,6 +753,7 @@ public class SysDictController {
* @param id
* @return
*/
@RequiresPermissions("system:dict:deleteRecycleBin")
@RequestMapping(value = "/deletePhysic/{id}", method = RequestMethod.DELETE)
public Result<?> deletePhysic(@PathVariable("id") String id) {
try {
@ -908,4 +911,26 @@ public class SysDictController {
return Result.error("查询失败:" + e.getMessage());
}
}
/**
* 查询有效的数据字典项:表单设计器专用,用于设计器页面查询字典的维护
* for: 【LHZP-1163】字典换接口,过滤掉停用的
* @param dictCode 字典code
* @return
*/
@SignatureCheck
@RequestMapping(value = "/queryEnableDictItemsByCode/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> queryEnableDictItemsByCode(@PathVariable("dictCode") String dictCode) {
Result<List<DictModel>> result = new Result<List<DictModel>>();
try {
List<DictModel> ls = sysDictService.queryEnableDictItemsByCode(dictCode);
result.setSuccess(true);
result.setResult(ls);
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败");
}
return result;
}
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
@ -45,6 +46,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
*/
@AutoLog(value = "表单评论文件-分页列表查询")
@Operation(summary = "表单评论文件-分页列表查询")
@RequiresPermissions("system:formFile:list")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysFormFile sysFormFile,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@ -64,6 +66,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
*/
@AutoLog(value = "表单评论文件-添加")
@Operation(summary = "表单评论文件-添加")
@RequiresPermissions("system:formFile:add")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysFormFile sysFormFile) {
sysFormFileService.save(sysFormFile);
@ -78,6 +81,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
*/
@AutoLog(value = "表单评论文件-编辑")
@Operation(summary = "表单评论文件-编辑")
@RequiresPermissions("system:formFile:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<?> edit(@RequestBody SysFormFile sysFormFile) {
sysFormFileService.updateById(sysFormFile);
@ -92,6 +96,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
*/
@AutoLog(value = "表单评论文件-通过id删除")
@Operation(summary = "表单评论文件-通过id删除")
@RequiresPermissions("system:formFile:delete")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
sysFormFileService.removeById(id);
@ -106,6 +111,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
*/
@AutoLog(value = "表单评论文件-批量删除")
@Operation(summary = "表单评论文件-批量删除")
@RequiresPermissions("system:formFile:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.sysFormFileService.removeByIds(Arrays.asList(ids.split(",")));
@ -120,6 +126,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
*/
@AutoLog(value = "表单评论文件-通过id查询")
@Operation(summary = "表单评论文件-通过id查询")
@RequiresPermissions("system:formFile:queryById")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name = "id", required = true) String id) {
SysFormFile sysFormFile = sysFormFileService.getById(id);
@ -132,6 +139,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
* @param request
* @param sysFormFile
*/
@RequiresPermissions("system:formFile:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysFormFile sysFormFile) {
return super.exportXls(request, sysFormFile, SysFormFile.class, "表单评论文件");
@ -144,6 +152,7 @@ public class SysFormFileController extends JeecgController<SysFormFile, ISysForm
* @param response
* @return
*/
@RequiresPermissions("system:formFile:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, SysFormFile.class);

View File

@ -145,6 +145,7 @@ public class SysLogController extends JeecgController<SysLog, ISysLogService> {
* @param request
* @param syslog
*/
@RequiresPermissions("system:log:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysLog syslog) {
// 复制参数,移除排序相关键(column/order 等)防止前端传入排序影响导出顺序

View File

@ -23,6 +23,7 @@ import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysPositionService;
import org.jeecg.modules.system.service.ISysUserPositionService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.service.ISysUserTenantService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -67,6 +68,9 @@ public class SysPositionController {
@Autowired
private ISysUserService userService;
@Autowired
private ISysUserTenantService userTenantService;
/**
* 分页列表查询
*
@ -110,6 +114,13 @@ public class SysPositionController {
@Operation(summary = "职务表-添加")
@PostMapping(value = "/add")
public Result<SysPosition> add(@RequestBody SysPosition sysPosition) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Integer tenantId = sysPositionService.checkPositionAuth("system:position:add", true);
if (tenantId != null) {
// 敲敲云租户管理员新增的职务归属当前租户
sysPosition.setTenantId(tenantId);
}
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Result<SysPosition> result = new Result<SysPosition>();
try {
//编号是空的,不需要判断多租户隔离了
@ -136,6 +147,16 @@ public class SysPositionController {
@Operation(summary = "职务表-编辑")
@RequestMapping(value = "/edit", method ={RequestMethod.PUT, RequestMethod.POST})
public Result<SysPosition> edit(@RequestBody SysPosition sysPosition) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Integer tenantId = sysPositionService.checkPositionAuth("system:position:edit", true);
if (tenantId != null) {
if (!sysPositionService.isPositionInTenant(sysPosition.getId(), tenantId)) {
return Result.error("只能编辑当前租户的职务!");
}
// 不允许把职务改到其它租户
sysPosition.setTenantId(tenantId);
}
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Result<SysPosition> result = new Result<SysPosition>();
SysPosition sysPositionEntity = sysPositionService.getById(sysPosition.getId());
if (sysPositionEntity == null) {
@ -161,6 +182,12 @@ public class SysPositionController {
@Operation(summary = "职务表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Integer tenantId = sysPositionService.checkPositionAuth("system:position:delete", true);
if (tenantId != null && !sysPositionService.isPositionInTenant(id, tenantId)) {
return Result.error("只能删除当前租户的职务!");
}
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
try {
sysPositionService.removeById(id);
//删除用户职位关系表
@ -182,6 +209,10 @@ public class SysPositionController {
@Operation(summary = "职务表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<SysPosition> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
// 敲敲云组织管理页面不用批量删除,不放行租户管理员
sysPositionService.checkPositionAuth("system:position:deleteBatch", false);
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Result<SysPosition> result = new Result<SysPosition>();
if (ids == null || "".equals(ids.trim())) {
result.error500("参数不识别!");
@ -221,6 +252,10 @@ public class SysPositionController {
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysPosition sysPosition,HttpServletRequest request, HttpServletResponse response) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务导出补充权限校验-----------
// 敲敲云组织管理页面不用导出,不放行租户管理员
sysPositionService.checkPositionAuth("system:position:exportXls", false);
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务导出补充权限校验-----------
// Step.1 组装查询条件
QueryWrapper<SysPosition> queryWrapper = null;
try {
@ -271,6 +306,10 @@ public class SysPositionController {
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response)throws IOException {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
// 敲敲云组织管理页面不用导入,不放行租户管理员
sysPositionService.checkPositionAuth("system:position:importExcel", false);
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
// 错误信息
@ -363,6 +402,13 @@ public class SysPositionController {
public Result<IPage<SysUser>> getPositionUserList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "positionId") String positionId) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
// 返回成员手机号、邮箱,按成员管理权限控制
Integer tenantId = sysPositionService.checkPositionAuth("system:position:edit", true);
if (tenantId != null && !sysPositionService.isPositionInTenant(positionId, tenantId)) {
return Result.error("只能查看当前租户职务的成员!");
}
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Page<SysUser> page = new Page<>(pageNo, pageSize);
IPage<SysUser> pageList = userPositionService.getPositionUserList(page, positionId);
@ -386,6 +432,18 @@ public class SysPositionController {
@PostMapping("/savePositionUser")
public Result<String> saveUserPosition(@RequestParam(name = "userIds") String userIds,
@RequestParam(name = "positionId") String positionId) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Integer tenantId = sysPositionService.checkPositionAuth("system:position:edit", true);
if (tenantId != null) {
if (!sysPositionService.isPositionInTenant(positionId, tenantId)) {
return Result.error("只能操作当前租户的职务!");
}
List<String> tenantUserIds = userTenantService.getUserIdsByTenantId(tenantId);
if (tenantUserIds == null || !tenantUserIds.containsAll(Arrays.asList(userIds.split(",")))) {
return Result.error("只能添加当前租户下的用户!");
}
}
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
userPositionService.saveUserPosition(userIds, positionId);
return Result.ok("添加成功");
}
@ -400,6 +458,12 @@ public class SysPositionController {
@DeleteMapping("/removePositionUser")
public Result<String> removeUserPosition(@RequestParam(name = "userIds") String userIds,
@RequestParam(name = "positionId") String positionId) {
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
Integer tenantId = sysPositionService.checkPositionAuth("system:position:edit", true);
if (tenantId != null && !sysPositionService.isPositionInTenant(positionId, tenantId)) {
return Result.error("只能操作当前租户的职务!");
}
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
userPositionService.removePositionUser(userIds, positionId);
return Result.OK("移除成员成功");
}

View File

@ -381,6 +381,7 @@ public class SysRoleController {
* 导出excel
* @param request
*/
@RequiresPermissions("system:role:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
//------------------------------------------------------------------------------------------------
@ -416,6 +417,7 @@ public class SysRoleController {
* @param response
* @return
*/
@RequiresPermissions("system:role:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

View File

@ -71,6 +71,8 @@ public class SysRoleIndexController extends JeecgController<SysRoleIndex, ISysRo
QueryWrapper<SysRoleIndex> queryWrapper = QueryGenerator.initQueryWrapper(sysRoleIndex, req.getParameterMap());
Page<SysRoleIndex> page = new Page<SysRoleIndex>(pageNo, pageSize);
IPage<SysRoleIndex> pageList = sysRoleIndexService.page(page, queryWrapper);
// 翻译用户/角色名称
sysRoleIndexService.fillRelationName(pageList.getRecords());
return Result.OK(pageList);
}
@ -171,6 +173,7 @@ public class SysRoleIndexController extends JeecgController<SysRoleIndex, ISysRo
* @param request
* @param sysRoleIndex
*/
@RequiresPermissions("system:roleindex:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysRoleIndex sysRoleIndex) {
return super.exportXls(request, sysRoleIndex, SysRoleIndex.class, "角色首页配置");

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.system.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -25,6 +26,8 @@ import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
import org.jeecg.config.sign.annotation.SignatureCheck;
import org.jeecg.modules.base.service.BaseCommonService;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.mapper.SysPackPermissionMapper;
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
import org.jeecg.modules.system.service.ISysTenantPackService;
import org.jeecg.modules.system.service.ISysTenantService;
import org.jeecg.modules.system.service.ISysUserService;
@ -68,6 +71,12 @@ public class SysTenantController {
@Autowired
private ISysDepartService sysDepartService;
@Autowired
private SysPackPermissionMapper sysPackPermissionMapper;
@Autowired
private ISysPermissionDataRuleService sysPermissionDataRuleService;
/**
* 获取列表数据
* @param sysTenant
@ -365,6 +374,65 @@ public class SysTenantController {
return Result.ok("修改租户产品包成功");
}
/**
* 查询套餐包菜单的数据规则
*
* @param permissionId 菜单id
* @param packId 套餐包id
* @return datarule:菜单下的数据规则,drChecked:套餐包已选的数据规则
* @author scott
* @since 2026-10-12 【issues/9820】租户套餐包菜单支持分配数据规则
*/
@GetMapping(value = "/packDatarule/{permissionId}/{packId}")
public Result<?> loadPackDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("packId") String packId) {
List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
if (list == null || list.size() == 0) {
return Result.error("未找到权限配置信息");
}
Map<String, Object> map = new HashMap<>(5);
map.put("datarule", list);
LambdaQueryWrapper<SysPackPermission> query = new LambdaQueryWrapper<SysPackPermission>()
.eq(SysPackPermission::getPermissionId, permissionId)
.eq(SysPackPermission::getPackId, packId)
.isNotNull(SysPackPermission::getDataRuleIds);
List<SysPackPermission> packPermissions = sysPackPermissionMapper.selectList(query);
SysPackPermission packPermission = packPermissions.isEmpty() ? null : packPermissions.get(0);
if (packPermission != null && oConvertUtils.isNotEmpty(packPermission.getDataRuleIds())) {
String drChecked = packPermission.getDataRuleIds();
map.put("drChecked", drChecked.endsWith(",") ? drChecked.substring(0, drChecked.length() - 1) : drChecked);
}
return Result.ok(map);
}
/**
* 保存数据规则至套餐包菜单关联表
*
* @param jsonObject permissionId 菜单id,packId 套餐包id,dataRuleIds 数据规则id
* @return
* @author scott
* @since 2026-10-12 【issues/9820】租户套餐包菜单支持分配数据规则
*/
@PostMapping(value = "/packDatarule")
@RequiresPermissions("system:tenant:edit:pack")
public Result<String> savePackDatarule(@RequestBody JSONObject jsonObject) {
String permissionId = jsonObject.getString("permissionId");
String packId = jsonObject.getString("packId");
String dataRuleIds = jsonObject.getString("dataRuleIds");
log.info("保存套餐包数据规则>>菜单ID:{},套餐包ID:{},数据权限ID:{}", permissionId, packId, dataRuleIds);
LambdaQueryWrapper<SysPackPermission> query = new LambdaQueryWrapper<SysPackPermission>()
.eq(SysPackPermission::getPermissionId, permissionId)
.eq(SysPackPermission::getPackId, packId);
List<SysPackPermission> packPermissions = sysPackPermissionMapper.selectList(query);
if (packPermissions.isEmpty()) {
return Result.error("请先保存套餐包菜单权限!");
}
for (SysPackPermission packPermission : packPermissions) {
packPermission.setDataRuleIds(dataRuleIds);
sysPackPermissionMapper.updateById(packPermission);
}
return Result.ok("保存成功!");
}
/**
* 批量删除用户菜单
*

View File

@ -58,11 +58,11 @@ public class SysUgroupController extends JeecgController<SysUgroup, ISysUgroupSe
QueryWrapper<SysUgroup> queryWrapper = QueryGenerator.initQueryWrapper(sysUgroup, req.getParameterMap());
//update-begin---author:scott ---date:20261014 for:多租户模式下只查当前租户的用户组,防止跨租户读取-----------
//update-begin---author:scott ---date:20261014 for:【安全 GHSA-2h34-xh29-7w95】多租户模式下只查当前租户的用户组,防止跨租户读取-----------
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
queryWrapper.eq("tenant_id", oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(req), 0));
}
//update-end---author:scott ---date:20261014 for:多租户模式下只查当前租户的用户组,防止跨租户读取-----------
//update-end---author:scott ---date:20261014 for:【安全 GHSA-2h34-xh29-7w95】多租户模式下只查当前租户的用户组,防止跨租户读取-----------
Page<SysUgroup> page = new Page<SysUgroup>(pageNo, pageSize);
IPage<SysUgroup> pageList = sysUgroupService.page(page, queryWrapper);
return Result.OK(pageList);
@ -150,11 +150,11 @@ public class SysUgroupController extends JeecgController<SysUgroup, ISysUgroupSe
if(sysUgroup==null) {
return Result.error("未找到对应数据");
}
//update-begin---author:scott ---date:20261014 for:多租户模式下只能查看当前租户的用户组,防止按id跨租户读取-----------
//update-begin---author:scott ---date:20261014 for:【安全 GHSA-2h34-xh29-7w95】多租户模式下只能查看当前租户的用户组,防止按id跨租户读取-----------
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL && !java.util.Objects.equals(oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(req), 0), sysUgroup.getTenantId())) {
return Result.error("未找到对应数据");
}
//update-end---author:scott ---date:20261014 for:多租户模式下只能查看当前租户的用户组,防止按id跨租户读取-----------
//update-end---author:scott ---date:20261014 for:【安全 GHSA-2h34-xh29-7w95】多租户模式下只能查看当前租户的用户组,防止按id跨租户读取-----------
return Result.OK(sysUgroup);
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.system.controller;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.MinioUtil;
@ -32,6 +33,7 @@ public class SysUploadController {
* 上传
* @param request
*/
@RequiresPermissions("system:ossFile:uploadMinio")
@PostMapping(value = "/uploadMinio")
public Result<?> uploadMinio(HttpServletRequest request) throws Exception {
Result<?> result = new Result<>();

View File

@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.jeecg.common.api.vo.Result;
@ -57,6 +59,8 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
@ -127,6 +131,7 @@ public class SysUserController {
* @return
*/
@PermissionData(pageComponent = "system/UserList")
@RequiresPermissions(value = {"system:user:list", "system:user:select"}, logical = Logical.OR)
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
@ -143,9 +148,66 @@ public class SysUserController {
}
}
//------------------------------------------------------------------------------------------------
return sysUserService.queryPageList(req, queryWrapper, pageSize, pageNo);
Result<IPage<SysUser>> result = sysUserService.queryPageList(req, queryWrapper, pageSize, pageNo);
//update-begin---author:scott ---date:20260911 for:【安全修复 GHSA-8cj9-3528-wp9p】/sys/user/list 缺少功能级权限校验,任意登录用户可拉取全租户用户信息,此处按权限分级脱敏-----------
if (!hasUserListAuth() && null != result.getResult()) {
desensitizeUserContact(result.getResult());
}
//update-end---author:scott ---date:20260911 for:【安全修复 GHSA-8cj9-3528-wp9p】-----------
return result;
}
/**
* 判断当前登录用户是否具备用户列表查看权限(无权限时响应需剥离隐私字段)
*/
private boolean hasUserListAuth() {
try {
Subject subject = SecurityUtils.getSubject();
return subject.isPermitted("system:user:list") || subject.isPermitted("system:user:listAll");
} catch (Exception e) {
// 取不到权限上下文时按最小权限处理,避免敏感字段外泄
log.warn("获取用户列表权限失败,按无权限处理:" + e.getMessage());
return false;
}
}
/**
* 无用户列表查看权限时可见的字段白名单:选人组件、通讯录等普通用户场景所需的最小字段集
* 未列入白名单的字段一律置空(手机号、邮箱、生日、租户、岗位内部ID、审计字段等),
* 采用白名单而非逐字段清空,可避免实体后续新增字段时遗漏而再次泄露
*/
private static final Set<String> USER_LIST_VISIBLE_FIELDS = new HashSet<>(Arrays.asList(
"id", "username", "realname", "avatar", "sex", "workNo", "sign", "signEnable",
"post", "postText", "orgCodeTxt", "status", "izHideContact", "sort"
));
/**
* 对无用户列表查看权限的响应做字段级脱敏:仅保留白名单字段
*/
private void desensitizeUserContact(IPage<SysUser> page) {
if (null == page || oConvertUtils.listIsEmpty(page.getRecords())) {
return;
}
for (SysUser user : page.getRecords()) {
if (null == user) {
continue;
}
for (Field field : oConvertUtils.getAllFields(user)) {
// 跳过静态字段、基本类型(无法置null)以及白名单字段
if (Modifier.isStatic(field.getModifiers()) || field.getType().isPrimitive()
|| USER_LIST_VISIBLE_FIELDS.contains(field.getName())) {
continue;
}
try {
field.setAccessible(true);
field.set(user, null);
} catch (Exception e) {
log.warn("用户列表脱敏失败,字段:{},原因:{}", field.getName(), e.getMessage());
}
}
}
}
/**
* 获取系统用户数据(查询全部用户,不做租户隔离)
*
@ -316,6 +378,13 @@ public class SysUserController {
sysUserService.checkUserAdminRejectDel(ids);
String status = jsonObject.getString("status");
String[] arr = ids.split(",");
// update-begin--author:wangshuai---date:20261028---for:【LHZP-1066】【系统管理】用户管理 已冻结的用户 可重复冻结
// 已冻结的用户可重复冻结,已是目标状态的用户不允许重复操作------------
long sameStatusCount = sysUserService.count(new LambdaQueryWrapper<SysUser>().in(SysUser::getId, Arrays.asList(arr)).eq(SysUser::getStatus, Integer.parseInt(status)));
if (sameStatusCount > 0) {
return Result.error(CommonConstant.USER_FREEZE.toString().equals(status) ? "所选用户中包含已冻结的用户,请勿重复冻结!" : "所选用户中包含未冻结的用户,无需解冻!");
}
// update-end--author:wangshuai---date:20261028---for:【LHZP-1066】【系统管理】用户管理 已冻结的用户 可重复冻结
for (String id : arr) {
if(oConvertUtils.isNotEmpty(id)) {
// 代码逻辑说明: [QQYUN-5577]用户列表-冻结用户,再解冻之后,用户还是无法登陆,有缓存问题 #5066------------
@ -490,6 +559,7 @@ public class SysUserController {
* @param id
* @return
*/
@RequiresPermissions("system:user:select")
@RequestMapping(value = "/queryUserByDepId", method = RequestMethod.GET)
public Result<List<SysUser>> queryUserByDepId(@RequestParam(name = "id", required = true) String id,@RequestParam(name="realname",required=false) String realname,
@RequestParam(name="status",required=false) Integer status) {
@ -527,6 +597,7 @@ public class SysUserController {
* @param username
* @return
*/
@RequiresPermissions("system:user:select")
@RequestMapping(value = "/queryUserComponentData", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryUserComponentData(
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@ -899,6 +970,7 @@ public class SysUserController {
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
String depId = req.getParameter("depId");
String username = req.getParameter("username");
String realname = req.getParameter("realname");
//根据部门ID查询,当前和下级所有的部门IDS
List<String> subDepids = new ArrayList<>();
//部门id为空时,查询我的部门下所有用户
@ -914,7 +986,7 @@ public class SysUserController {
subDepids = sysDepartService.getSubDepIdsByDepId(depId);
}
if(subDepids != null && subDepids.size()>0){
IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username);
IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username,realname);
//批量查询用户的所属部门
//step.1 先拿到全部的 useids
//step.2 通过 useids,一次性查询用户的所属部门名字
@ -1004,6 +1076,7 @@ public class SysUserController {
/**
* 根据 orgCode 查询用户,包括公司、子公司、岗位部门下的用户
*/
@RequiresPermissions("system:user:select")
@GetMapping("/queryDepartPostByOrgCode")
public Result<?> queryDepartPostByOrgCode(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@ -1152,6 +1225,49 @@ public class SysUserController {
}
return result;
}
/**
* 部门管理-用户列表:将用户移出部门或岗位(只删除关联关系,不删除用户)
* 只处理当前部门/岗位的直属成员,部门会同时清理该部门下的岗位和负责部门,岗位会清空主岗位、删除兼职岗位
*
* @param depId 部门或岗位id
* @param userIds 用户id,多个用逗号分隔
* @return
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
@RequiresPermissions("system:user:deleteUserInDepartBatch")
@DeleteMapping("/removeDepartUser")
public Result<String> removeDepartUser(@RequestParam(name = "depId") String depId,
@RequestParam(name = "userIds") String userIds) {
try {
//去掉空值和重复的用户id
List<String> userIdList = new ArrayList<>();
String[] userIdArr = userIds.split(",");
for (String userId : userIdArr) {
if (oConvertUtils.isEmpty(userId) || userIdList.contains(userId)) {
continue;
}
userIdList.add(userId);
}
//只移出当前部门/岗位的直属成员
List<String> removeUserIds = sysUserService.removeDepartUser(depId, userIdList);
if (removeUserIds.isEmpty()) {
return Result.error("移出失败,目标用户不是当前部门/岗位的直属成员!");
}
//删除用户在该部门的部门角色
departRoleUserService.removeDeptRoleUser(removeUserIds, depId);
//有用户不是直属成员,没有移出
int skipCount = userIdList.size() - removeUserIds.size();
if (skipCount > 0) {
return Result.OK("已移出" + removeUserIds.size() + "人,其余" + skipCount + "人不是当前部门/岗位的直属成员,未移出");
}
return Result.OK("移出成功!");
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("移出失败!");
}
}
/**
* 查询当前用户的所有部门/当前部门编码

View File

@ -19,7 +19,6 @@ import java.io.Serializable;
* @Date: 2021-07-07
* @Version: V1.0
*
* e3e3NcxzbUiGa53YYVXxWc8ADo5ISgQGx/gaZwERF91oAryDlivjqBv3wqRArgChupi+Y/Gg/swwGEyL0PuVFg==
*/
@Data
@Accessors(chain = true)

View File

@ -40,6 +40,9 @@ public class SysPackPermission implements Serializable {
@Excel(name = "菜单id", width = 15)
@Schema(description = "菜单id")
private String permissionId;
/**数据权限ids(【issues/9820】租户套餐包菜单支持分配数据规则)*/
@Schema(description = "数据权限ids")
private String dataRuleIds;
/**创建人*/
@Schema(description = "创建人")
private String createBy;

View File

@ -91,6 +91,11 @@ public class SysRoleIndex {
@Dict(dicCode = "relation_type")
private java.lang.String relationType;
/**关联用户/角色名称(翻译字段,非数据库字段)*/
@TableField(exist = false)
@Schema(description = "关联用户/角色名称")
private java.lang.String relationName;
public SysRoleIndex() {

View File

@ -94,5 +94,6 @@ public class SysTenantPack implements Serializable {
this.packCode = packCode;
this.packName = packName;
this.status = "1";
this.packType = "custom";
}
}

View File

@ -21,8 +21,9 @@ public interface SysPermissionDataRuleMapper extends BaseMapper<SysPermissionDat
* 根据用户名和权限id查询
* @param username
* @param permissionId
* @param tenantId 当前租户ID(请求头 tenant-id),不为空时追加该租户套餐包的数据规则
* @return
*/
public List<String> queryDataRuleIds(@Param("username") String username,@Param("permissionId") String permissionId);
public List<String> queryDataRuleIds(@Param("username") String username,@Param("permissionId") String permissionId,@Param("tenantId") Integer tenantId);
}

View File

@ -74,9 +74,10 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @param page
* @param departIds
* @param username 用户登录账户
* @param realname 用户姓名
* @return
*/
IPage<SysUser> getUserByDepIds(Page page, @Param("departIds") List<String> departIds, @Param("username") String username);
IPage<SysUser> getUserByDepIds(Page page, @Param("departIds") List<String> departIds, @Param("username") String username, @Param("realname") String realname);
/**
* 根据角色Id查询用户信息

View File

@ -51,7 +51,11 @@
and sa.titile LIKE concat(concat('%',#{announcementSendModel.titile}),'%')
</if>
<if test="announcementSendModel.sender !=null and announcementSendModel.sender != ''">
and sa.sender LIKE concat(concat('%',#{announcementSendModel.sender}),'%')
<!-- update-begin author:wangshuai date:20261102 for:【LHZP-1240】【消息中心】我的消息 发布人未翻译 -->
<!-- 发布人:列表显示的是姓名,所以按账号原值或用户姓名都能模糊查询 -->
and (sa.sender LIKE concat(concat('%',#{announcementSendModel.sender}),'%')
or sa.sender in (select su.username from sys_user su where su.realname LIKE concat(concat('%',#{announcementSendModel.sender}),'%')))
<!-- update-end author:wangshuai date:20261102 for:【LHZP-1240】【消息中心】我的消息 发布人未翻译 -->
</if>
<if test="announcementSendModel.noticeType !=null and announcementSendModel.noticeType != ''">
and sa.notice_type = #{announcementSendModel.noticeType}

View File

@ -218,7 +218,7 @@
<!--系统后台导出,根据父级id和租户id查询部门数据-->
<select id="getSysDepartList" resultType="org.jeecg.modules.system.vo.SysDepartExportVo">
SELECT id,depart_name,parent_id,depart_name_en,depart_order,description,org_category,org_code,mobile,fax,address,memo, position_id FROM sys_depart
SELECT id,depart_name,parent_id,depart_name_en,depart_name_abbr,depart_order,description,org_category,org_code,mobile,fax,address,memo, position_id FROM sys_depart
WHERE
1=1
<if test="null != tenantId and 0 != tenantId">

View File

@ -12,7 +12,7 @@
<!-- 通过字典code获取有效的字典数据项 -->
<select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
select s.item_value as "value",s.item_text as "text", s.item_color as "color" from sys_dict_item s
where dict_id = (select id from sys_dict where dict_code = #{code})
where dict_id = (select id from sys_dict where dict_code = #{code} and del_flag = 0)
and s.status = 1
order by s.sort_order asc, s.create_time DESC
</select>

View File

@ -21,6 +21,19 @@
join sys_user e on d.user_id = e.id
where e.username = #{username} and b.id = #{permissionId}
<!--update end Author:lvdandan Date:20200213 for:加入部门权限 -->
<!-- update-begin author:scott date:20261012 for:【issues/9820】租户套餐包菜单的数据规则,只取当前租户下的套餐包 -->
<if test="tenantId != null">
union
select a.data_rule_ids
from sys_tenant_pack_perms a
join sys_tenant_pack b on a.pack_id = b.id and b.status = '1'
join sys_tenant st on st.id = b.tenant_id and st.del_flag = 0
join sys_tenant_pack_user c on c.pack_id = b.id and c.status = '1'
join sys_user e on c.user_id = e.id
where e.username = #{username} and a.permission_id = #{permissionId} and b.tenant_id = #{tenantId}
</if>
<!-- update-end author:scott date:20261012 for:【issues/9820】租户套餐包菜单的数据规则,只取当前租户下的套餐包 -->
</select>
</mapper>

View File

@ -55,7 +55,12 @@
)
</if>
<if test="username!=null and username!=''">
and username = #{username}
<bind name="bindUsername" value="'%' + username + '%'"/>
and username LIKE #{bindUsername}
</if>
<if test="realname!=null and realname!=''">
<bind name="bindRealname" value="'%' + realname + '%'"/>
and realname LIKE #{bindRealname}
</if>
</select>

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@ -30,7 +31,8 @@ public class AnnouncementSendModel implements Serializable {
private java.lang.String titile;
/**内容*/
private java.lang.String msgContent;
/**发布人*/
/**发布人(账号翻译为姓名,非账号的值如 system、流程通知 原样返回)*/
@Dict(dictTable = "sys_user",dicCode = "username",dicText = "realname")
private java.lang.String sender;
/**优先级(L低,M中,H高)*/
private java.lang.String priority;

View File

@ -167,4 +167,9 @@ public class SysUserSysDepPostModel {
* 工号
*/
private String workNo;
/**
* 是否为当前部门/岗位下的用户,不含下级部门、岗位的用户(部门:所属部门是当前部门;岗位:主岗位或兼职岗位是当前岗位)
*/
private Boolean izCurrentDepartPost;
}

View File

@ -27,4 +27,12 @@ public interface ISysDepartRoleUserService extends IService<SysDepartRoleUser> {
* @param depId
*/
void removeDeptRoleUser(List<String> userIds,String depId);
/**
* 清理部门角色下所有用户的Shiro权限缓存
* @param roleId 部门角色id
* @author scott
* @since 2026-10-29 【LHZP-1129】部门角色授权后清理相关用户权限缓存,无需重新登录即生效
*/
void clearDeptRoleUserAuthCache(String roleId);
}

View File

@ -43,4 +43,26 @@ public interface ISysPositionService extends IService<SysPosition> {
*/
List<SysPositionVO> getPositionListByUserIds(List<String> userIds);
//update-begin---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
/**
* 职务管理鉴权:admin、租户管理员(zuhuadmin)角色或拥有对应按钮权限时放行(成员管理沿用 system:position:edit);
* 否则只有敲敲云「组织管理-职位」页面用到的接口可以继续:须为当前租户的组织账户管理员或超级管理员,且只能操作本租户的职务和用户。
* 注册用户可以自建组织成为超级管理员,所以这条路径必须限定在当前租户内
*
* @param permission 按钮权限编码
* @param allowTenantAdmin 是否放行敲敲云租户管理员
* @return 需要限定在当前租户内操作时返回当前租户ID;admin、zuhuadmin、有按钮权限时返回null
*/
Integer checkPositionAuth(String permission, boolean allowTenantAdmin);
/**
* 职务是否属于指定租户
*
* @param positionId 职务ID
* @param tenantId 租户ID
* @return 属于返回true
*/
boolean isPositionInTenant(String positionId, Integer tenantId);
//update-end---author:wangshuai ---date:2026-10-26 for:【GHSA-p4f8-h832-99pw】职务增删改、成员管理补充权限校验-----------
}

View File

@ -3,6 +3,8 @@ package org.jeecg.modules.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.system.entity.SysRoleIndex;
import java.util.List;
/**
* @Description: 角色首页配置
* @Author: jeecg-boot
@ -54,4 +56,11 @@ public interface ISysRoleIndexService extends IService<SysRoleIndex> {
* @param id
*/
void updateOtherDefaultStatus(String roleCode, String status, String id);
/**
* 翻译关联的用户/角色名称,写入relationName(roleCode保持原编码不变)
*
* @param records 首页配置列表
*/
void fillRelationName(List<SysRoleIndex> records);
}

View File

@ -139,9 +139,10 @@ public interface ISysUserService extends IService<SysUser> {
* @param page
* @param departIds 部门id集合
* @param username 用户账户名称
* @param realname 用户姓名
* @return
*/
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username);
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username, String realname);
/**
* 根据 userIds查询,查询用户所属部门的名称(多个部门名逗号隔开)
@ -525,6 +526,19 @@ public interface ISysUserService extends IService<SysUser> {
*/
IPage<SysUserSysDepPostModel> queryDepartPostUserByOrgCode(String orgCode, SysUser userParams, IPage page);
/**
* 将用户移出部门或岗位(只删除关联关系,不删除用户),只处理当前部门/岗位的直属成员
* 部门:删除所属部门关系,清理已不在其它所属部门下的主岗位、兼职岗位,并取消该部门的负责人
* 岗位:清空主岗位、删除兼职岗位
*
* @param depId 部门或岗位id
* @param userIds 用户id
* @return 实际移出的用户id
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
List<String> removeDepartUser(String depId, List<String> userIds);
/**
* 根据 orgCode 查询用户信息(部门全路径,主岗位和兼职岗位的信息),包括公司、子公司、部门
*

View File

@ -28,10 +28,12 @@ import org.jeecg.common.api.dto.PushMessageDTO;
import org.jeecg.common.api.dto.message.*;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.UrlMatchEnum;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.*;
import org.jeecg.common.constant.enums.*;
import org.jeecg.common.desensitization.util.SensitiveInfoUtil;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.online.api.IOnlineBaseExtApi;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.query.QueryCondition;
import org.jeecg.common.system.query.QueryGenerator;
@ -60,6 +62,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
@ -112,6 +115,10 @@ public class SysBaseApiImpl implements ISysBaseAPI {
@Autowired
private RestTemplate restTemplate;
@Lazy
@Autowired
private IOnlineBaseExtApi onlineBaseExtApi;
@Autowired
private ISysMessageTemplateService sysMessageTemplateService;
@Resource
@ -652,6 +659,11 @@ public class SysBaseApiImpl implements ISysBaseAPI {
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
announcement.setBusId(busId);
announcement.setBusType(busType);
//update-begin---author:liusq ---date:2026-10-13 for:【LHZP-2388】【敲敲云】委托后,催办没收到系统通知-----------
if(SysAnnmentTypeEnum.BPM.getType().equals(busType)){
announcement.setNoticeType(NoticeTypeEnum.NOTICE_TYPE_FLOW.getValue());
}
//update-end---author:liusq ---date:2026-10-13 for:【LHZP-2388】【敲敲云】委托后,催办没收到系统通知-----------
announcement.setOpenType(SysAnnmentTypeEnum.getByType(busType).getOpenType());
announcement.setOpenPage(SysAnnmentTypeEnum.getByType(busType).getOpenPage());
sysAnnouncementMapper.insert(announcement);
@ -1710,6 +1722,16 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return sysDictService.queryTableDictTextByKeys(table, text, code, Arrays.asList(keys.split(",")), dataSource);
}
@Override
public List<DictModel> queryPopupDictItems(String reportCode, String dictCode, String dictText, String dataList) {
try {
return onlineBaseExtApi.cgreportGetDataPackage(reportCode, dictText, dictCode, dataList);
} catch (Exception e) {
log.warn("数据字典加载失败, reportCode: {}", reportCode, e);
return Collections.emptyList();
}
}
//-------------------------------------流程节点发送模板消息-----------------------------------------------
@Autowired
private QywxSendMsgHandle qywxSendMsgHandle;
@ -1766,16 +1788,37 @@ public class SysBaseApiImpl implements ISysBaseAPI {
emailSendMsgHandle.sendMessage(message);
}
}else if(MessageTypeEnum.DD.getType().equals(messageType)){
MSG_THREAD_POOL.execute(() -> ddSendMsgHandle.sendMessage(message));
executeWithTenant(() -> ddSendMsgHandle.sendMessage(message));
}else if(MessageTypeEnum.QYWX.getType().equals(messageType)){
MSG_THREAD_POOL.execute(() -> qywxSendMsgHandle.sendMessage(message));
executeWithTenant(() -> qywxSendMsgHandle.sendMessage(message));
}else if(MessageTypeEnum.FS.getType().equals(messageType)){
MSG_THREAD_POOL.execute(() -> fsSendMsgHandle.sendMessage(message));
executeWithTenant(() -> fsSendMsgHandle.sendMessage(message));
}else if(MessageTypeEnum.DX.getType().equals(messageType)){
MSG_THREAD_POOL.execute(() -> smsSendMsgHandle.sendMessage(message));
executeWithTenant(() -> smsSendMsgHandle.sendMessage(message));
}
}
//update-begin---author:liusq ---date:2026-10-19 for:【QQYUN-12767】钉钉/企业微信/飞书/短信异步发送时传递租户ID,修复流程消息在线程池中取到租户0的问题-----------
/**
* 提交到消息异步线程池,并把当前线程的租户ID传递到异步线程。
* <p>TenantContext 是普通 ThreadLocal,切换到线程池后取不到值,钉钉/企业微信/飞书会按租户 0 查询应用配置和第三方绑定账号,导致消息发不出去。</p>
*
* @param task 发送任务
*/
private void executeWithTenant(Runnable task) {
String tenantId = TenantContext.getTenant();
MSG_THREAD_POOL.execute(() -> {
TenantContext.setTenant(tenantId);
try {
task.run();
} finally {
// 线程池的线程会复用,必须清理,避免后续任务串租户
TenantContext.clear();
}
});
}
//update-end---author:liusq ---date:2026-10-19 for:【QQYUN-12767】钉钉/企业微信/飞书/短信异步发送时传递租户ID,修复流程消息在线程池中取到租户0的问题-----------
@Override
public String getTemplateContent(String code) {
List<SysMessageTemplate> list = sysMessageTemplateService.selectByCode(code);

View File

@ -27,7 +27,6 @@ import org.jeecg.modules.system.vo.SysCommentVO;
import org.jeecg.modules.system.vo.UserAvatar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.FileCopyUtils;

View File

@ -7,6 +7,8 @@ import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysDepartRolePermission;
import org.jeecg.modules.system.mapper.SysDepartRolePermissionMapper;
import org.jeecg.modules.system.service.ISysDepartRolePermissionService;
import org.jeecg.modules.system.service.ISysDepartRoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -23,6 +25,9 @@ import java.util.*;
@Service
public class SysDepartRolePermissionServiceImpl extends ServiceImpl<SysDepartRolePermissionMapper, SysDepartRolePermission> implements ISysDepartRolePermissionService {
@Autowired
private ISysDepartRoleUserService sysDepartRoleUserService;
@Override
public void saveDeptRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
String ip = "";
@ -54,6 +59,9 @@ public class SysDepartRolePermissionServiceImpl extends ServiceImpl<SysDepartRol
this.remove(new QueryWrapper<SysDepartRolePermission>().lambda().eq(SysDepartRolePermission::getRoleId, roleId).eq(SysDepartRolePermission::getPermissionId, permissionId));
}
}
//update-begin---author:scott ---date:20261029 for:【LHZP-1129】部门角色授权后清理相关用户Shiro权限缓存,无需重新登录即生效-----------
sysDepartRoleUserService.clearDeptRoleUserAuthCache(roleId);
//update-end---author:scott ---date:20261029 for:【LHZP-1129】部门角色授权后清理相关用户Shiro权限缓存,无需重新登录即生效-----------
}
/**

View File

@ -1,12 +1,14 @@
package org.jeecg.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysDepartRole;
import org.jeecg.modules.system.entity.SysDepartRoleUser;
import org.jeecg.modules.system.mapper.SysDepartRoleMapper;
import org.jeecg.modules.system.mapper.SysDepartRoleUserMapper;
import org.jeecg.modules.system.service.ISysDepartRoleUserService;
import org.jeecg.modules.system.util.ShiroAuthCacheUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -26,6 +28,8 @@ import java.util.stream.Collectors;
public class SysDepartRoleUserServiceImpl extends ServiceImpl<SysDepartRoleUserMapper, SysDepartRoleUser> implements ISysDepartRoleUserService {
@Autowired
private SysDepartRoleMapper sysDepartRoleMapper;
@Autowired
private RedisUtil redisUtil;
@Override
public void deptRoleUserAdd(String userId, String newRoleId, String oldRoleId) {
@ -46,6 +50,9 @@ public class SysDepartRoleUserServiceImpl extends ServiceImpl<SysDepartRoleUserM
this.remove(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, userId).eq(SysDepartRoleUser::getDroleId, roleId));
}
}
//update-begin---author:scott ---date:20261029 for:【LHZP-1129】部门角色授权后清理相关用户Shiro权限缓存,无需重新登录即生效-----------
ShiroAuthCacheUtil.clearUserAuthCache(redisUtil, Collections.singletonList(userId));
//update-end---author:scott ---date:20261029 for:【LHZP-1129】部门角色授权后清理相关用户Shiro权限缓存,无需重新登录即生效-----------
}
@Override
@ -60,6 +67,24 @@ public class SysDepartRoleUserServiceImpl extends ServiceImpl<SysDepartRoleUserM
this.remove(query);
}
}
//update-begin---author:scott ---date:20261029 for:【LHZP-1129】部门角色授权后清理相关用户Shiro权限缓存,无需重新登录即生效-----------
ShiroAuthCacheUtil.clearUserAuthCache(redisUtil, userIds);
//update-end---author:scott ---date:20261029 for:【LHZP-1129】部门角色授权后清理相关用户Shiro权限缓存,无需重新登录即生效-----------
}
/**
* 清理部门角色下所有用户的Shiro权限缓存
* @param roleId 部门角色id
* @author scott
* @since 2026-10-29 【LHZP-1129】部门角色授权后清理相关用户权限缓存,无需重新登录即生效
*/
@Override
public void clearDeptRoleUserAuthCache(String roleId) {
if (oConvertUtils.isEmpty(roleId)) {
return;
}
List<SysDepartRoleUser> roleUsers = this.list(new QueryWrapper<SysDepartRoleUser>().lambda().select(SysDepartRoleUser::getUserId).eq(SysDepartRoleUser::getDroleId, roleId));
ShiroAuthCacheUtil.clearUserAuthCache(redisUtil, roleUsers.stream().map(SysDepartRoleUser::getUserId).collect(Collectors.toSet()));
}
/**

View File

@ -756,13 +756,15 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
//设置用户id,让前台显示
this.setUserIdsByDepList(list);
List<SysDepartTreeModel> records = new ArrayList<>();
//update-begin---author:scott ---date:20261030 for:【LHZP-1974】部门树每个节点单独查一次子部门数量,SQL Server下办理页加载慢,改为一次查出有子部门的节点-----------
Set<String> hasChildIds = getHasNoPostChildParentIds(list.stream().map(SysDepart::getId).collect(Collectors.toList()));
for (int i = 0; i < list.size(); i++) {
SysDepart depart = list.get(i);
// 代码逻辑说明: 【QQYUN-13427】部门选择组件修改:需要过滤掉岗位 只保留 公司 子公司 部门---
long count = getNoDepartPostCount(depart.getId());
if(count == 0){
if(!hasChildIds.contains(depart.getId())){
depart.setIzLeaf(CommonConstant.IS_LEAF);
}
//update-end---author:scott ---date:20261030 for:【LHZP-1974】部门树每个节点单独查一次子部门数量,SQL Server下办理页加载慢,改为一次查出有子部门的节点-----------
SysDepartTreeModel treeModel = new SysDepartTreeModel(depart);
//TODO 异步树加载key拼接__+时间戳,以便于每次展开节点会刷新数据
//treeModel.setKey(treeModel.getKey()+"__"+System.currentTimeMillis());
@ -772,15 +774,23 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
}
/**
* 获取部门数量
* @param departId
* @return
* 一次查出哪些部门下有子部门(不含岗位),用于判断树节点是否叶子,替代逐个部门 count
* @param departIds 部门ID
* @return 有子部门的部门ID
* @author scott
* @since 2026-10-30 【LHZP-1974】部门树每个节点单独查一次子部门数量,SQL Server下办理页加载慢
*/
private long getNoDepartPostCount(String departId) {
LambdaQueryWrapper<SysDepart> queryNoPosition = new LambdaQueryWrapper<>();
queryNoPosition.ne(SysDepart::getOrgCategory,DepartCategoryEnum.DEPART_CATEGORY_POST.getValue());
queryNoPosition.eq(SysDepart::getParentId,departId);
return this.count(queryNoPosition);
private Set<String> getHasNoPostChildParentIds(List<String> departIds) {
Set<String> parentIds = new HashSet<>();
// 分批查询,避免 SQL Server 等数据库 IN 参数个数超限
for (int i = 0; i < departIds.size(); i += 1000) {
LambdaQueryWrapper<SysDepart> queryNoPosition = new LambdaQueryWrapper<>();
queryNoPosition.select(SysDepart::getParentId);
queryNoPosition.ne(SysDepart::getOrgCategory,DepartCategoryEnum.DEPART_CATEGORY_POST.getValue());
queryNoPosition.in(SysDepart::getParentId,departIds.subList(i, Math.min(i + 1000, departIds.size())));
this.list(queryNoPosition).forEach(d -> parentIds.add(d.getParentId()));
}
return parentIds;
}
/**
@ -1550,6 +1560,9 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
sysDepart.setIzLeaf(CommonConstant.IS_LEAF);
sysDepart.setDepartNameEn(departExportVo.getDepartNameEn());
//update-begin---author:wangshuai ---date:20261029 for:【LHZP-1199】部门管理 导出导入支持机构简称------------
sysDepart.setDepartNameAbbr(departExportVo.getDepartNameAbbr());
//update-end---author:wangshuai ---date:20261029 for:【LHZP-1199】部门管理 导出导入支持机构简称------------
sysDepart.setDepartOrder(departExportVo.getDepartOrder());
sysDepart.setOrgCategory(oConvertUtils.getString(departExportVo.getOrgCategory(),"1"));
sysDepart.setMobile(departExportVo.getMobile());

View File

@ -6,6 +6,7 @@ import java.util.Set;
import jakarta.annotation.Resource;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
@ -60,7 +61,11 @@ public class SysPermissionDataRuleImpl extends ServiceImpl<SysPermissionDataRule
@Override
public List<SysPermissionDataRule> queryPermissionDataRules(String username,String permissionId) {
List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId);
//update-begin---author:scott ---date:20261012 for:【issues/9820】追加当前租户套餐包菜单的数据规则(套餐包按租户隔离,只取请求头中当前租户的)-----------
int tenant = oConvertUtils.getInt(TenantContext.getTenant(), -1);
Integer tenantId = tenant != -1 ? tenant : null;
List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId, tenantId);
//update-end---author:scott ---date:20261012 for:【issues/9820】追加当前租户套餐包菜单的数据规则(套餐包按租户隔离,只取请求头中当前租户的)-----------
// 代码逻辑说明: 数据权限失效问题处理--------------------
if(idsList==null || idsList.size()==0) {
return null;

View File

@ -2,11 +2,19 @@ package org.jeecg.modules.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.UnauthorizedException;
import org.jeecg.common.config.TenantContext;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.constant.enums.SysRoleEnum;
import org.jeecg.common.exception.JeecgBootBizTipException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysPosition;
import org.jeecg.modules.system.mapper.SysPositionMapper;
import org.jeecg.modules.system.service.ISysPositionService;
import org.jeecg.modules.system.service.ISysTenantPackService;
import org.jeecg.modules.system.vo.SysPositionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
@ -22,6 +30,9 @@ import java.util.stream.Collectors;
@Service
public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPosition> implements ISysPositionService {
@Autowired
private ISysTenantPackService sysTenantPackService;
@Override
public SysPosition getByCode(String code) {
LambdaQueryWrapper<SysPosition> queryWrapper = new LambdaQueryWrapper<>();
@ -52,4 +63,30 @@ public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPo
return this.baseMapper.getPositionListByUserIds(userIds);
}
//update-end---author:sjlei ---date:2026-04-17 for:【#9496】全量同步N+1查询性能优化-----------
@Override
public Integer checkPositionAuth(String permission, boolean allowTenantAdmin) {
//当前用户有没有 admin 或 zuhuadmin 角色或者有对应按钮权限直接放行
if (SysRoleEnum.hasAnyRole(SysRoleEnum.ADMIN, SysRoleEnum.TENANT_ADMIN) || SecurityUtils.getSubject().isPermitted(permission)) {
return null;
}
//是否需要判断租户管理员,比如导入、导出就不需要敲敲云没有用的地方
String tenantId = TenantContext.getTenant();
if (!allowTenantAdmin || oConvertUtils.isEmpty(tenantId)) {
throw new UnauthorizedException("没有权限,请联系管理员分配权限!");
}
// 非当前租户的组织账户管理员或超级管理员时抛出异常
try {
sysTenantPackService.izHaveManageUserAuth(tenantId);
} catch (Exception e) {
throw new JeecgBootBizTipException("没有权限,请联系管理员分配权限!");
}
return oConvertUtils.getInt(tenantId, 0);
}
@Override
public boolean isPositionInTenant(String positionId, Integer tenantId) {
SysPosition position = oConvertUtils.isEmpty(positionId) ? null : this.getById(positionId);
return position != null && tenantId.equals(position.getTenantId());
}
}

View File

@ -4,18 +4,28 @@ import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.SymbolConstant;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.constant.DefIndexConst;
import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.entity.SysRoleIndex;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.mapper.SysRoleIndexMapper;
import org.jeecg.modules.system.mapper.SysRoleMapper;
import org.jeecg.modules.system.mapper.SysUserMapper;
import org.jeecg.modules.system.service.ISysRoleIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Description: 角色首页配置
* @Author: jeecg-boot
@ -28,6 +38,12 @@ public class SysRoleIndexServiceImpl extends ServiceImpl<SysRoleIndexMapper, Sys
@Autowired
private RedisUtil redisUtil;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private SysRoleMapper sysRoleMapper;
@Override
@Cacheable(cacheNames = DefIndexConst.CACHE_KEY + "#3600", key = "'" + DefIndexConst.DEF_INDEX_ALL + "'")
public SysRoleIndex queryDefaultIndex() {
@ -132,8 +148,16 @@ public class SysRoleIndexServiceImpl extends ServiceImpl<SysRoleIndexMapper, Sys
for (int i = 0; i < list.size(); i++) {
SysRoleIndex roleIndex = list.get(i);
roleIndex.setStatus(CommonConstant.STATUS_0);
success = super.updateById(roleIndex);
success = super.updateById(roleIndex) || success;
}
} else {
//update-begin---author:lvdandan ---date:20260901 for:【LHZP-1145】【vue3】首页配置,用户和角色应该需支持多选
// 保存个人禁用配置,避免继续命中包含该用户的共享配置
sysRoleIndex.setRelationType(CommonConstant.HOME_RELATION_USER);
sysRoleIndex.setStatus(CommonConstant.STATUS_0);
sysRoleIndex.setRoute(true);
success = super.save(sysRoleIndex);
//update-end---author:lvdandan ---date:20260901 for:【LHZP-1145】【vue3】首页配置,用户和角色应该需支持多选
}
}
// 4. 清理缓存
@ -181,4 +205,155 @@ public class SysRoleIndexServiceImpl extends ServiceImpl<SysRoleIndexMapper, Sys
}
}
/**
* 翻译关联的用户/角色名称,写入relationName
* 用户显示真实姓名(逻辑删除的用户也显示),角色显示角色名称,已被物理删除的显示原编码并标注已删除
*
* @param records 首页配置列表
*/
@Override
public void fillRelationName(List<SysRoleIndex> records) {
// 1. 按关联类型收集需要翻译的编码
//同户名
Set<String> usernames = new HashSet<>();
//角色编码
Set<String> roleCodes = new HashSet<>();
for (SysRoleIndex record : records) {
//用户
if (CommonConstant.HOME_RELATION_USER.equals(record.getRelationType())) {
//获取编码集合,里面可能是逗号分割的
List<String> usernameList = splitRelationCodes(record.getRoleCode());
usernames.addAll(usernameList);
//角色
} else if (CommonConstant.HOME_RELATION_ROLE.equals(record.getRelationType())) {
//获取编码集合,里面可能是逗号分割的
List<String> roleCodeList = splitRelationCodes(record.getRoleCode());
roleCodes.addAll(roleCodeList);
}
}
// 2. 批量查询名称
//查询用户名字 key username value realname
Map<String, String> realnameMap = queryRealnameMap(usernames);
//查询角色名字 key roleCode value roleName
Map<String, String> roleNameMap = queryRoleNameMap(roleCodes);
// 3. 逐个编码翻译后逗号拼接
for (SysRoleIndex record : records) {
//用户
if (CommonConstant.HOME_RELATION_USER.equals(record.getRelationType())) {
String relationName = joinRelationNames(record.getRoleCode(), realnameMap, "用户已删除");
record.setRelationName(relationName);
//角色
} else if (CommonConstant.HOME_RELATION_ROLE.equals(record.getRelationType())) {
String relationName = joinRelationNames(record.getRoleCode(), roleNameMap, "角色已删除");
record.setRelationName(relationName);
}
}
}
/**
* 查询用户名对应的真实姓名(包含逻辑删除的用户)
*
* @param usernames 用户名
* @return key:用户名 value:真实姓名
*/
private Map<String, String> queryRealnameMap(Set<String> usernames) {
Map<String, String> realnameMap = new HashMap<>();
if (usernames.isEmpty()) {
return realnameMap;
}
// 查询正常用户
LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
userQuery.in(SysUser::getUsername, usernames);
List<SysUser> userList = sysUserMapper.selectList(userQuery);
for (SysUser user : userList) {
realnameMap.put(user.getUsername(), user.getRealname());
}
// 正常用户中查不到的,再查逻辑删除的用户
List<String> missingUsernames = new ArrayList<>();
for (String username : usernames) {
if (!realnameMap.containsKey(username)) {
missingUsernames.add(username);
}
}
if (!missingUsernames.isEmpty()) {
//查询逻辑删除的用户,普通的查询会带着 del_flag = 0,所以要单独查询
LambdaQueryWrapper<SysUser> deletedUserQuery = new LambdaQueryWrapper<>();
deletedUserQuery.in(SysUser::getUsername, missingUsernames);
deletedUserQuery.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_1);
List<SysUser> deletedUserList = sysUserMapper.selectLogicDeleted(deletedUserQuery);
for (SysUser user : deletedUserList) {
realnameMap.put(user.getUsername(), user.getRealname());
}
}
return realnameMap;
}
/**
* 查询角色编码对应的角色名称
*
* @param roleCodes 角色编码
* @return key:角色编码 value:角色名称
*/
private Map<String, String> queryRoleNameMap(Set<String> roleCodes) {
Map<String, String> roleNameMap = new HashMap<>();
if (roleCodes.isEmpty()) {
return roleNameMap;
}
LambdaQueryWrapper<SysRole> roleQuery = new LambdaQueryWrapper<>();
roleQuery.in(SysRole::getRoleCode, roleCodes);
List<SysRole> roleList = sysRoleMapper.selectList(roleQuery);
for (SysRole role : roleList) {
roleNameMap.put(role.getRoleCode(), role.getRoleName());
}
return roleNameMap;
}
/**
* 逐个编码翻译成名称:名称为空时显示原编码,查不到(已被物理删除)时显示原编码并标注
*
* @param relationCodes 逗号分隔的用户名或角色编码
* @param nameMap 编码与名称的对应关系
* @param deletedTip 已删除的标注
* @return 逗号分隔的名称
*/
private String joinRelationNames(String relationCodes, Map<String, String> nameMap, String deletedTip) {
//获取编码集合,里面可能是逗号分割的
List<String> codeList = splitRelationCodes(relationCodes);
List<String> nameList = new ArrayList<>();
for (String code : codeList) {
String name = nameMap.get(code);
if (!nameMap.containsKey(code)) {
// 查不到说明已被物理删除,显示原编码并标注
nameList.add(code + "(" + deletedTip + ")");
} else if (oConvertUtils.isEmpty(name)) {
// 名称为空时显示原编码
nameList.add(code);
} else {
nameList.add(name);
}
}
return String.join(SymbolConstant.COMMA, nameList);
}
/**
* 拆分逗号分隔的用户名或角色编码
*
* @param relationCodes 逗号分隔的用户名或角色编码
* @return 编码列表
*/
private List<String> splitRelationCodes(String relationCodes) {
List<String> codeList = new ArrayList<>();
if (oConvertUtils.isEmpty(relationCodes)) {
return codeList;
}
String[] codeArray = relationCodes.split(SymbolConstant.COMMA);
for (String code : codeArray) {
String trimCode = code.trim();
if (oConvertUtils.isNotEmpty(trimCode)) {
codeList.add(trimCode);
}
}
return codeList;
}
}

View File

@ -3,19 +3,25 @@ package org.jeecg.modules.system.service.impl;
import java.util.*;
import org.jeecg.common.util.IpUtils;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysRolePermission;
import org.jeecg.modules.system.entity.SysUserRole;
import org.jeecg.modules.system.mapper.SysRolePermissionMapper;
import org.jeecg.modules.system.mapper.SysUserRoleMapper;
import org.jeecg.modules.system.service.ISysRolePermissionService;
import org.jeecg.modules.system.util.ShiroAuthCacheUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import jakarta.servlet.http.HttpServletRequest;
import java.util.stream.Collectors;
/**
* <p>
@ -28,6 +34,11 @@ import jakarta.servlet.http.HttpServletRequest;
@Service
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements ISysRolePermissionService {
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private RedisUtil redisUtil;
@Override
public void saveRolePermission(String roleId, String permissionIds) {
String ip = "";
@ -52,6 +63,9 @@ public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionM
}
}
this.saveBatch(list);
//update-begin---author:scott ---date:20261029 for:【LHZP-1129】角色授权后清理该角色下用户Shiro权限缓存,无需重新登录即生效-----------
clearRoleUserAuthCache(roleId);
//update-end---author:scott ---date:20261029 for:【LHZP-1129】角色授权后清理该角色下用户Shiro权限缓存,无需重新登录即生效-----------
}
@Override
@ -85,6 +99,23 @@ public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionM
this.remove(new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId).eq(SysRolePermission::getPermissionId, permissionId));
}
}
//update-begin---author:scott ---date:20261029 for:【LHZP-1129】角色授权后清理该角色下用户Shiro权限缓存,无需重新登录即生效-----------
clearRoleUserAuthCache(roleId);
//update-end---author:scott ---date:20261029 for:【LHZP-1129】角色授权后清理该角色下用户Shiro权限缓存,无需重新登录即生效-----------
}
/**
* 清理角色下所有用户的Shiro权限缓存
* @param roleId 角色id
* @author scott
* @since 2026-10-29 【LHZP-1129】角色授权后清理该角色下用户权限缓存,无需重新登录即生效
*/
private void clearRoleUserAuthCache(String roleId) {
if (oConvertUtils.isEmpty(roleId)) {
return;
}
List<SysUserRole> userRoles = sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().select(SysUserRole::getUserId).eq(SysUserRole::getRoleId, roleId));
ShiroAuthCacheUtil.clearUserAuthCache(redisUtil, userRoles.stream().map(SysUserRole::getUserId).collect(Collectors.toSet()));
}
/**

View File

@ -229,22 +229,24 @@ public class SysTenantPackServiceImpl extends ServiceImpl<SysTenantPackMapper, S
currentService.savePackUser(packUser);
//step.2 创建租户套餐包(组织账户管理员)和 添加人员关系数据
query = new LambdaQueryWrapper<>();
query.eq(SysTenantPack::getTenantId,tenantId);
query.eq(SysTenantPack::getPackCode, TenantConstant.ACCOUNT_ADMIN);
SysTenantPack sysTenantPackAccountAdmin = currentService.getOne(query);
if(null == sysTenantPackAccountAdmin){
// 创建超级管理员
// 创建组织账户管理员
SysTenantPack accountAdminPack = new SysTenantPack(tenantId, "组织账户管理员", TenantConstant.ACCOUNT_ADMIN);
accountAdminPack.setIzSysn(CommonConstant.STATUS_0);
currentService.saveOne(accountAdminPack);
}
//step.3 创建租户套餐包(组织应用管理员)
query = new LambdaQueryWrapper<>();
query.eq(SysTenantPack::getTenantId,tenantId);
query.eq(SysTenantPack::getPackCode, TenantConstant.APP_ADMIN);
SysTenantPack sysTenantPackAppAdmin = currentService.getOne(query);
if(null == sysTenantPackAppAdmin){
// 创建超级管理员
// 创建组织应用管理员
SysTenantPack appAdminPack = new SysTenantPack(tenantId, "组织应用管理员", TenantConstant.APP_ADMIN);
appAdminPack.setIzSysn(CommonConstant.STATUS_0);
currentService.saveOne(appAdminPack);

View File

@ -426,19 +426,36 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
//只有 X-Version=v3 的时候,才读取sys_role_index表获取角色首页配置
boolean isV3 = CommonConstant.VERSION_V3.equals(version);
if (isV3) {
//1.先查询 用户USER级别 的所有首页配置
if(oConvertUtils.isNotEmpty(username)){
LambdaQueryWrapper<SysRoleIndex> routeIndexUserQuery = new LambdaQueryWrapper<>();
//角色首页状态0:未开启 1:开启
routeIndexUserQuery.eq(SysRoleIndex::getStatus, CommonConstant.STATUS_1);
routeIndexUserQuery.eq(SysRoleIndex::getRelationType, CommonConstant.HOME_RELATION_USER);
routeIndexUserQuery.eq(SysRoleIndex::getRoleCode, username);
//优先级正序排序
routeIndexUserQuery.orderByAsc(SysRoleIndex::getPriority);
List<SysRoleIndex> list = sysRoleIndexService.list(routeIndexUserQuery);
if (CollectionUtils.isNotEmpty(list)) {
roleIndex = list.get(0);
}else{
//update-begin---author:lvdandan ---date:20260901 for:【LHZP-1145】【vue3】首页配置,用户和角色应该需支持多选
//1.先查询 用户USER级别 的所有首页配置
LambdaQueryWrapper<SysRoleIndex> personalIndexQuery = new LambdaQueryWrapper<>();
personalIndexQuery.eq(SysRoleIndex::getRelationType, CommonConstant.HOME_RELATION_USER);
personalIndexQuery.eq(SysRoleIndex::getRoleCode, username);
personalIndexQuery.eq(SysRoleIndex::getStatus, CommonConstant.STATUS_1);
personalIndexQuery.orderByAsc(SysRoleIndex::getPriority);
List<SysRoleIndex> personalIndexList = sysRoleIndexService.list(personalIndexQuery);
List<SysRoleIndex> list = Collections.emptyList();
boolean queryRoleIndex = true;
if (CollectionUtils.isNotEmpty(personalIndexList)) {
roleIndex = personalIndexList.get(0);
queryRoleIndex = false;
} else {
LambdaQueryWrapper<SysRoleIndex> routeIndexUserQuery = new LambdaQueryWrapper<>();
//角色首页状态0:未开启 1:开启
routeIndexUserQuery.eq(SysRoleIndex::getStatus, CommonConstant.STATUS_1);
routeIndexUserQuery.eq(SysRoleIndex::getRelationType, CommonConstant.HOME_RELATION_USER);
//优先级正序排序
routeIndexUserQuery.orderByAsc(SysRoleIndex::getPriority);
list = sysRoleIndexService.list(routeIndexUserQuery).stream()
.filter(item -> containsAnyRelationCode(item.getRoleCode(), Collections.singleton(username)))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
roleIndex = list.get(0);
queryRoleIndex = false;
}
}
if (queryRoleIndex) {
//2.用户没有配置,再查询 角色ROLE级别 的所有首页配置
LambdaQueryWrapper<SysRoleIndex> routeIndexQuery = new LambdaQueryWrapper<>();
//角色首页状态0:未开启 1:开启
@ -450,13 +467,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
String componentUrl = RoleIndexConfigEnum.getIndexByRoles(roles);
roleIndex = new SysRoleIndex(componentUrl);
//用户所有角色
// 代码逻辑说明: [QQYUN-13187]【新用户登录报错】没有添加角色时 报错
if(CollectionUtil.isNotEmpty(roles)){
routeIndexQuery.in(SysRoleIndex::getRoleCode, roles);
}
//优先级正序排序
routeIndexQuery.orderByAsc(SysRoleIndex::getPriority);
list = sysRoleIndexService.list(routeIndexQuery);
list = sysRoleIndexService.list(routeIndexQuery).stream()
.filter(item -> containsAnyRelationCode(item.getRoleCode(), roles))
.collect(Collectors.toList());
//update-end---author:lvdandan ---date:20260901 for:【LHZP-1145】【vue3】首页配置,用户和角色应该需支持多选
if (CollectionUtils.isNotEmpty(list)) {
roleIndex = list.get(0);
}
@ -476,6 +492,27 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return roleIndex;
}
/**
* 判断逗号分隔的关联编码是否与目标编码存在交集
*
* @param relationCodes 逗号分隔的用户或角色编码
* @param targetCodes 目标用户或角色编码
* @return true:存在匹配编码,false:不存在匹配编码
*/
private boolean containsAnyRelationCode(String relationCodes, Collection<String> targetCodes) {
if (oConvertUtils.isEmpty(relationCodes) || CollectionUtil.isEmpty(targetCodes)) {
return false;
}
Set<String> relationCodeSet = Arrays.stream(relationCodes.split(SymbolConstant.COMMA))
.map(String::trim)
.filter(oConvertUtils::isNotEmpty)
.collect(Collectors.toSet());
return targetCodes.stream()
.filter(oConvertUtils::isNotEmpty)
.map(String::trim)
.anyMatch(relationCodeSet::contains);
}
/**
* 通过用户名获取用户角色集合
* @param username 用户名
@ -589,9 +626,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
@Override
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username) {
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username, String realname) {
//update-begin---author:wangshuai ---date:20260811 for:[LHZP-1141]【系统管理】我的部门编辑用户关联信息未正确回显------------
IPage<SysUser> pageList = userMapper.getUserByDepIds(page, departIds,username);
IPage<SysUser> pageList = userMapper.getUserByDepIds(page, departIds, username, realname);
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(userIds)) {
return pageList;
@ -2982,7 +3019,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
List<String> userIds = sysDepartModels.stream().map(SysUserSysDepPostModel::getId).toList();
//获取部门名称
Map<String, String> useDepNames = this.getDepNamesByUserIds(userIds);
//update-begin---author:wangshuai ---date:20261030 for:【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作-----------
//当前部门/岗位下的用户(列表中还包含下级部门、岗位的用户)
Set<String> currentDepartPostUserIds = this.getCurrentDepartPostUserIdsByOrgCode(orgCode, userIds);
//update-end---author:wangshuai ---date:20261030 for:【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作-----------
sysDepartModels.forEach(item -> {
//update-begin---author:wangshuai ---date:20261030 for:【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作-----------
//追加是否为当前部门或当前职位下的用户,前端才会显示移出的操作按钮
item.setIzCurrentDepartPost(currentDepartPostUserIds.contains(item.getId()));
//update-end---author:wangshuai ---date:20261030 for:【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作-----------
List<String> positionList = sysUserPositionMapper.getPositionIdByUserId(item.getId());
item.setPost(CommonUtils.getSplitText(positionList,SymbolConstant.COMMA));
item.setOrgCodeTxt(useDepNames.get(item.getId()));
@ -3003,6 +3048,314 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return page.setRecords(sysDepartModels);
}
/**
* 根据部门/岗位编码获取当前部门/岗位下的用户id(不含下级部门、岗位的用户)
*
* @param orgCode 部门/岗位编码
* @param userIds 用户id
* @return
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
private Set<String> getCurrentDepartPostUserIdsByOrgCode(String orgCode, List<String> userIds) {
if (oConvertUtils.isEmpty(orgCode)) {
return new HashSet<>();
}
LambdaQueryWrapper<SysDepart> departQuery = new LambdaQueryWrapper<>();
departQuery.eq(SysDepart::getOrgCode, orgCode);
SysDepart depart = sysDepartMapper.selectOne(departQuery);
if (depart == null) {
return new HashSet<>();
}
///回去当前部门和岗位下的用户id
return this.getCurrentDepartPostUserIds(depart, userIds);
}
/**
* 获取当前部门/岗位下的用户id(不含下级部门、岗位的用户)
* 公司、子公司、部门:所属部门是当前部门;岗位:主岗位或兼职岗位是当前岗位
*
* @param depart 部门/岗位
* @param userIds 用户id
* @return
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
private Set<String> getCurrentDepartPostUserIds(SysDepart depart, List<String> userIds) {
Set<String> currentDepartPostUserIds = new HashSet<>();
if (CollectionUtil.isEmpty(userIds)) {
return currentDepartPostUserIds;
}
String depId = depart.getId();
boolean isPost = DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(depart.getOrgCategory());
if (isPost) {
//岗位:主岗位是当前岗位
LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
userQuery.select(SysUser::getId);
userQuery.eq(SysUser::getMainDepPostId, depId);
userQuery.in(SysUser::getId, userIds);
List<SysUser> userList = userMapper.selectList(userQuery);
for (SysUser user : userList) {
currentDepartPostUserIds.add(user.getId());
}
//岗位:兼职岗位是当前岗位
LambdaQueryWrapper<SysUserDepPost> depPostQuery = new LambdaQueryWrapper<>();
depPostQuery.select(SysUserDepPost::getUserId);
depPostQuery.eq(SysUserDepPost::getDepId, depId);
depPostQuery.in(SysUserDepPost::getUserId, userIds);
List<String> depPostUserIds = depPostMapper.selectObjs(depPostQuery);
for (String depPostUserId : depPostUserIds) {
currentDepartPostUserIds.add(depPostUserId);
}
} else {
//公司、子公司、部门:所属部门是当前部门
LambdaQueryWrapper<SysUserDepart> userDepartQuery = new LambdaQueryWrapper<>();
userDepartQuery.select(SysUserDepart::getUserId);
userDepartQuery.eq(SysUserDepart::getDepId, depId);
userDepartQuery.in(SysUserDepart::getUserId, userIds);
List<String> departUserIds = sysUserDepartMapper.selectObjs(userDepartQuery);
for (String departUserId : departUserIds) {
currentDepartPostUserIds.add(departUserId);
}
}
return currentDepartPostUserIds;
}
/**
* 将用户移出部门或岗位(只删除关联关系,不删除用户)
*
* @param depId 部门或岗位id
* @param userIds 用户id
* @return 实际移出的用户id
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true)
public List<String> removeDepartUser(String depId, List<String> userIds) {
List<String> removeUserIds = new ArrayList<>();
SysDepart depart = sysDepartMapper.selectById(depId);
if (depart == null) {
return removeUserIds;
}
//只移出当前部门/岗位下的用户,下级部门、岗位的用户不处理
Set<String> currentDepartPostUserIds = this.getCurrentDepartPostUserIds(depart, userIds);
if (currentDepartPostUserIds.isEmpty()) {
return removeUserIds;
}
removeUserIds.addAll(currentDepartPostUserIds);
boolean isPost = DepartCategoryEnum.DEPART_CATEGORY_POST.getValue().equals(depart.getOrgCategory());
//岗位
if (isPost) {
//step.1 移出岗位:清空主岗位
//使用LambdaUpdateWrapper,避免为空时受全局 updateStrategy 影响导致不更新
LambdaUpdateWrapper<SysUser> userUpdate = new LambdaUpdateWrapper<>();
userUpdate.in(SysUser::getId, removeUserIds);
userUpdate.eq(SysUser::getMainDepPostId, depId);
userUpdate.set(SysUser::getMainDepPostId, null);
userMapper.update(userUpdate);
//step.2 移出岗位:删除兼职岗位
LambdaQueryWrapper<SysUserDepPost> depPostQuery = new LambdaQueryWrapper<>();
depPostQuery.in(SysUserDepPost::getUserId, removeUserIds);
depPostQuery.eq(SysUserDepPost::getDepId, depId);
depPostMapper.delete(depPostQuery);
} else {
//step.1 移出公司、子公司、部门:删除所属部门关系
LambdaQueryWrapper<SysUserDepart> userDepartQuery = new LambdaQueryWrapper<>();
userDepartQuery.eq(SysUserDepart::getDepId, depId);
userDepartQuery.in(SysUserDepart::getUserId, removeUserIds);
sysUserDepartMapper.delete(userDepartQuery);
//step.2 清理已不在其它所属部门下的主岗位、兼职岗位(与用户编辑页修改所属部门时的规则一致),要在删除所属部门关系之后执行
//已不再当前部门、公司了 下面的岗位需要清掉,因为岗位是根据公司和部门来的
this.removeDepPostOutOfDepart(depart, removeUserIds);
//step.3 取消该部门的负责人(负责部门只能从所属部门中选择)
this.removeChargeDepart(depId, removeUserIds);
}
return removeUserIds;
}
/**
* 移出部门后,清理用户在该部门下、且已不在其它所属部门下的主岗位和兼职岗位
*
* @param depart 移出的部门
* @param userIds 用户id
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
private void removeDepPostOutOfDepart(SysDepart depart, List<String> userIds) {
//step.1 查询用户的主岗位
LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
userQuery.select(SysUser::getId, SysUser::getMainDepPostId);
userQuery.in(SysUser::getId, userIds);
List<SysUser> userList = userMapper.selectList(userQuery);
//step.2 查询用户的兼职岗位
LambdaQueryWrapper<SysUserDepPost> depPostQuery = new LambdaQueryWrapper<>();
depPostQuery.select(SysUserDepPost::getId, SysUserDepPost::getUserId, SysUserDepPost::getDepId);
depPostQuery.in(SysUserDepPost::getUserId, userIds);
List<SysUserDepPost> depPostList = depPostMapper.selectList(depPostQuery);
//step.3 查询用户移出后剩余的所属部门
LambdaQueryWrapper<SysUserDepart> userDepartQuery = new LambdaQueryWrapper<>();
userDepartQuery.select(SysUserDepart::getUserId, SysUserDepart::getDepId);
userDepartQuery.in(SysUserDepart::getUserId, userIds);
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(userDepartQuery);
//step.4 查询岗位和剩余所属部门的编号
Set<String> departIds = new HashSet<>();
//主岗位
for (SysUser user : userList) {
if (oConvertUtils.isNotEmpty(user.getMainDepPostId())) {
departIds.add(user.getMainDepPostId());
}
}
//兼职岗位
for (SysUserDepPost depPost : depPostList) {
departIds.add(depPost.getDepId());
}
//所属的用户部门
for (SysUserDepart userDepart : userDepartList) {
departIds.add(userDepart.getDepId());
}
if (departIds.isEmpty()) {
return;
}
//根据要删除的部门id查询部门编码
LambdaQueryWrapper<SysDepart> departQuery = new LambdaQueryWrapper<>();
departQuery.select(SysDepart::getId, SysDepart::getOrgCode);
departQuery.in(SysDepart::getId, departIds);
List<SysDepart> departList = sysDepartMapper.selectList(departQuery);
//key:部门/岗位id,value:编码
Map<String, String> orgCodeMap = new HashMap<>();
for (SysDepart sysDepart : departList) {
orgCodeMap.put(sysDepart.getId(), sysDepart.getOrgCode());
}
//key:用户id,value:用户剩余所属部门的编码
Map<String, List<String>> userOrgCodeMap = new HashMap<>();
for (SysUserDepart userDepart : userDepartList) {
String orgCode = orgCodeMap.get(userDepart.getDepId());
if (orgCode == null) {
continue;
}
List<String> userOrgCodes = userOrgCodeMap.get(userDepart.getUserId());
if (userOrgCodes == null) {
userOrgCodes = new ArrayList<>();
userOrgCodeMap.put(userDepart.getUserId(), userOrgCodes);
}
userOrgCodes.add(orgCode);
}
//step.5 清空主岗位
List<String> clearMainPostUserIds = new ArrayList<>();
for (SysUser user : userList) {
if (oConvertUtils.isEmpty(user.getMainDepPostId())) {
continue;
}
String postOrgCode = orgCodeMap.get(user.getMainDepPostId());
List<String> userOrgCodes = userOrgCodeMap.get(user.getId());
if (this.isDepPostOutOfDepart(postOrgCode, depart.getOrgCode(), userOrgCodes)) {
clearMainPostUserIds.add(user.getId());
}
}
if (!clearMainPostUserIds.isEmpty()) {
//使用LambdaUpdateWrapper,避免为空时受全局 updateStrategy 影响导致不更新
LambdaUpdateWrapper<SysUser> userUpdate = new LambdaUpdateWrapper<>();
userUpdate.in(SysUser::getId, clearMainPostUserIds);
userUpdate.set(SysUser::getMainDepPostId, null);
userMapper.update(userUpdate);
}
//step.6 删除兼职岗位
List<String> removeDepPostIds = new ArrayList<>();
for (SysUserDepPost depPost : depPostList) {
String postOrgCode = orgCodeMap.get(depPost.getDepId());
List<String> userOrgCodes = userOrgCodeMap.get(depPost.getUserId());
if (this.isDepPostOutOfDepart(postOrgCode, depart.getOrgCode(), userOrgCodes)) {
removeDepPostIds.add(depPost.getId());
}
}
if (!removeDepPostIds.isEmpty()) {
LambdaQueryWrapper<SysUserDepPost> removeDepPostQuery = new LambdaQueryWrapper<>();
removeDepPostQuery.in(SysUserDepPost::getId, removeDepPostIds);
depPostMapper.delete(removeDepPostQuery);
}
}
/**
* 岗位是否在移出的部门下,且已不在用户其它所属部门下
*
* @param postOrgCode 岗位编码 A01A01
* @param departOrgCode 移出的部门编码 A01
* @param userOrgCodes 用户剩余所属部门的编码
* @return
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
private boolean isDepPostOutOfDepart(String postOrgCode, String departOrgCode, List<String> userOrgCodes) {
//岗位不在移出的部门下,不处理
if (postOrgCode == null || !postOrgCode.startsWith(departOrgCode)) {
return false;
}
//用户已经没有其它所属部门
if (userOrgCodes == null) {
return true;
}
//岗位还在用户其它所属部门下,保留
for (String userOrgCode : userOrgCodes) {
//编码是逐级拼接的,岗位编码以所属部门的编码开头,就说明岗位在这个部门下
//例:公司 A01 下有部门 A01A01,部门下有岗位 A01A01A01,用户从部门 A01A01 移出
//用户还在公司 A01:A01A01A01 以 A01 开头,岗位还在公司下,返回 false,岗位保留
//用户只剩部门 A01A02:A01A01A01 不以 A01A02 开头,循环结束后返回 true,岗位移除
if (postOrgCode.startsWith(userOrgCode)) {
return false;
}
}
return true;
}
/**
* 取消用户在该部门的负责人
*
* @param depId 部门id
* @param userIds 用户id
* @author wangshuai
* @since 2026-10-30 【LHZP-1194】部门管理 用户列表 是不是少一个移出的操作
*/
private void removeChargeDepart(String depId, List<String> userIds) {
LambdaQueryWrapper<SysUser> userQuery = new LambdaQueryWrapper<>();
userQuery.select(SysUser::getId, SysUser::getDepartIds);
userQuery.in(SysUser::getId, userIds);
userQuery.like(SysUser::getDepartIds, depId);
List<SysUser> userList = userMapper.selectList(userQuery);
for (SysUser user : userList) {
//去掉当前部门后的负责部门
List<String> newDepartIds = new ArrayList<>();
boolean isChargeDepart = false;
String[] departIds = user.getDepartIds().split(SymbolConstant.COMMA);
for (String departId : departIds) {
if (oConvertUtils.isEmpty(departId)) {
continue;
}
if (departId.equals(depId)) {
isChargeDepart = true;
} else {
newDepartIds.add(departId);
}
}
//防止 like 匹配到其它部门id,不是当前部门的负责人时跳过
if (!isChargeDepart) {
continue;
}
//使用LambdaUpdateWrapper,避免为空时受全局 updateStrategy 影响导致不更新
LambdaUpdateWrapper<SysUser> userUpdate = new LambdaUpdateWrapper<>();
userUpdate.eq(SysUser::getId, user.getId());
if (newDepartIds.isEmpty()) {
//负责部门为空时,说明已经是普通用户
userUpdate.set(SysUser::getDepartIds, null);
userUpdate.set(SysUser::getUserIdentity, CommonConstant.USER_IDENTITY_1);
} else {
userUpdate.set(SysUser::getDepartIds, String.join(SymbolConstant.COMMA, newDepartIds));
}
userMapper.update(userUpdate);
}
}
/**
* 据 orgCode 查询用户信息(部门全路径,主岗位和兼职岗位的信息),包括公司、子公司、部门
*

View File

@ -30,6 +30,7 @@ import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
import org.jeecg.modules.system.mapper.SysThirdAppConfigMapper;
import org.jeecg.modules.system.mapper.SysTenantMapper;
import org.jeecg.modules.system.mapper.SysUserMapper;
import org.jeecg.modules.system.mapper.SysUserTenantMapper;
import org.jeecg.modules.system.model.ThirdLoginModel;
import org.jeecg.modules.system.service.*;
import org.jeecg.modules.system.vo.thirdapp.SyncInfoVo;
@ -103,6 +104,8 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
@Autowired(required = false)
private JustAuthProperties justAuthProperties;
//update-end---author:jeecg ---date:2026-05-18 for:【QQYUN-12767】飞书集成,注入justauth配置用于yml fallback-----------
@Autowired
private SysUserTenantMapper userTenantMapper;
// ==================== IThirdAppService 接口实现 ====================
@ -182,15 +185,22 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
query.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
query.eq(SysThirdAccount::getTenantId, tenantId);
query.eq(SysThirdAccount::getSysUserId, sysUser.getId());
SysThirdAccount thirdAccount = sysThirdAccountService.getOne(query);
//update-begin---author:liusq ---date:2026-10-19 for:【QQYUN-12767】存在重复的飞书第三方账号时不再抛 TooManyResultsException,取第一条发送-----------
SysThirdAccount thirdAccount = sysThirdAccountService.getOne(query, false);
//update-end---author:liusq ---date:2026-10-19 for:【QQYUN-12767】存在重复的飞书第三方账号时不再抛 TooManyResultsException,取第一条发送-----------
if (thirdAccount == null || StringUtils.isEmpty(thirdAccount.getThirdUserUuid())) {
log.warn("飞书消息发送:用户[{}]未绑定飞书账号", username);
allSuccess = false;
continue;
}
if (!doSendTextMessage(appToken, thirdAccount.getThirdUserUuid(), message.getContent())) {
//update-begin---author:scott ---date:2026-10-09 for:【敲敲云】简流 通知 对接飞书,Markdown 内容改发卡片消息,避免飞书里显示 Markdown 原文-----------
boolean sent = message.isMarkdown()
? doSendMarkdownCardMessage(appToken, thirdAccount.getThirdUserUuid(), message.getTitle(), message.getContent())
: doSendTextMessage(appToken, thirdAccount.getThirdUserUuid(), message.getContent());
if (!sent) {
allSuccess = false;
}
//update-end---author:scott ---date:2026-10-09 for:【敲敲云】简流 通知 对接飞书,Markdown 内容改发卡片消息,避免飞书里显示 Markdown 原文-----------
}
return allSuccess;
} catch (Exception e) {
@ -674,100 +684,119 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
}
//update-end---author:liusq ---date:2026-06-02 for:【QQYUN-12767】手机号为空时打印warn,引导用户检查飞书应用权限
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
query.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
query.eq(SysThirdAccount::getTenantId, tenantId);
query.and(w -> w.eq(SysThirdAccount::getThirdUserUuid, openId)
.or().eq(SysThirdAccount::getThirdUserId, openId));
SysThirdAccount thirdAccount = sysThirdAccountService.getOne(query);
//update-begin---author:jeecg ---date:2026-05-15 for:【QQYUN-12767】飞书集成,已绑定用户执行信息更新(姓名/手机/邮箱/头像),修复同步时已存在用户被跳过不更新的问题-----------
if (thirdAccount != null && StringUtils.isNotEmpty(thirdAccount.getSysUserId())) {
// 已有绑定关系,更新用户基本信息
SysUser existUser = sysUserService.getById(thirdAccount.getSysUserId());
if (existUser != null) {
existUser.setRealname(name);
if (StringUtils.isNotEmpty(email)) {
existUser.setEmail(email);
}
if (StringUtils.isNotEmpty(mobile)) {
existUser.setPhone(mobile.replaceAll("^\\+86\\s*", "").trim());
}
if (StringUtils.isNotEmpty(avatarUrl)) {
existUser.setAvatar(avatarUrl);
}
sysUserService.updateById(existUser);
//update-begin---author:liusq ---date:2026-10-18 for:【QQYUN-12767】飞书同步单个用户异常时记录失败信息并继续,避免一条脏数据中断整次同步-----------
try {
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
query.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
query.eq(SysThirdAccount::getTenantId, tenantId);
query.and(w -> w.eq(SysThirdAccount::getThirdUserUuid, openId)
.or().eq(SysThirdAccount::getThirdUserId, openId));
//update-begin---author:liusq ---date:2026-10-18 for:【QQYUN-12767】存在重复的飞书第三方账号时不再抛 TooManyResultsException,优先取已绑定系统用户的记录-----------
List<SysThirdAccount> thirdAccounts = sysThirdAccountService.list(query);
if (thirdAccounts.size() > 1) {
log.warn("飞书用户[{}]存在 {} 条重复的第三方账号记录,请清理 sys_third_account 重复数据,openId={}", name, thirdAccounts.size(), openId);
}
syncInfo.addSuccessInfo("更新已存在用户:" + name);
if (localDepart != null) {
linkUserToDepart(openId, tenantId, localDepart.getId());
}
continue;
}
//update-end---author:jeecg ---date:2026-05-15 for:【QQYUN-12767】飞书集成,已绑定用户执行信息更新(姓名/手机/邮箱/头像),修复同步时已存在用户被跳过不更新的问题-----------
SysThirdAccount thirdAccount = thirdAccounts.stream()
.filter(a -> StringUtils.isNotEmpty(a.getSysUserId()))
.findFirst()
.orElse(thirdAccounts.isEmpty() ? null : thirdAccounts.get(0));
//update-end---author:liusq ---date:2026-10-18 for:【QQYUN-12767】存在重复的飞书第三方账号时不再抛 TooManyResultsException,优先取已绑定系统用户的记录-----------
//update-begin---author:jeecg ---date:2026-08-04 for:【QQYUN-12767】飞书同步按手机号查重:手机号已存在的本地用户直接绑定,不新增用户-----------
// 兜底逻辑:未通过 thirdUserUuid/thirdUserId 找到绑定记录时,先按手机号匹配本地用户
// 命中则直接将飞书 openId 绑定到该现有用户,避免重复创建账号(对齐钉钉 addDepartUser 行为)
String strippedMobile = StringUtils.isNotEmpty(mobile) ? mobile.replaceAll("^\\+86\\s*", "").trim() : null;
SysUser userByPhone = StringUtils.isNotEmpty(strippedMobile) ? userMapper.getUserByPhone(strippedMobile) : null;
if (userByPhone != null) {
try {
// 1. 用飞书最新信息更新本地已有用户(仅更新邮箱/头像;姓名由业务自行维护,飞书姓名可能与系统姓名不一致,不覆盖)
boolean userChanged = false;
if (StringUtils.isNotEmpty(email) && !email.equals(userByPhone.getEmail())) {
userByPhone.setEmail(email);
userChanged = true;
}
if (StringUtils.isNotEmpty(avatarUrl) && !avatarUrl.equals(userByPhone.getAvatar())) {
userByPhone.setAvatar(avatarUrl);
userChanged = true;
}
if (userChanged) {
sysUserService.updateById(userByPhone);
}
// 2. 复用或创建第三方账号记录,并将 sysUserId 绑定到该现有用户
SysThirdAccount accountToBind;
if (thirdAccount == null) {
ThirdLoginModel tlm = new ThirdLoginModel(THIRD_TYPE, openId, name, avatarUrl);
accountToBind = sysThirdAccountService.saveThirdUser(tlm, tenantId);
} else {
accountToBind = thirdAccount;
accountToBind.setThirdUserUuid(openId);
accountToBind.setThirdUserId(openId);
accountToBind.setRealname(name);
if (StringUtils.isNotEmpty(avatarUrl)) {
accountToBind.setAvatar(avatarUrl);
//update-begin---author:jeecg ---date:2026-05-15 for:【QQYUN-12767】飞书集成,已绑定用户执行信息更新(姓名/手机/邮箱/头像),修复同步时已存在用户被跳过不更新的问题-----------
if (thirdAccount != null && StringUtils.isNotEmpty(thirdAccount.getSysUserId())) {
// 已有绑定关系,更新用户基本信息
SysUser existUser = sysUserService.getById(thirdAccount.getSysUserId());
if (existUser != null) {
existUser.setRealname(name);
if (StringUtils.isNotEmpty(email)) {
existUser.setEmail(email);
}
sysThirdAccountService.updateById(accountToBind);
if (StringUtils.isNotEmpty(mobile)) {
existUser.setPhone(mobile.replaceAll("^\\+86\\s*", "").trim());
}
if (StringUtils.isNotEmpty(avatarUrl)) {
existUser.setAvatar(avatarUrl);
}
sysUserService.updateById(existUser);
//update-begin---author:liusq ---date:2026-10-19 for:【QQYUN-12767】飞书同步用户未关联当前租户,补齐历史同步缺失的租户关系-----------
createUserTenant(existUser.getId(), false, tenantId);
//update-end---author:liusq ---date:2026-10-19 for:【QQYUN-12767】飞书同步用户未关联当前租户,补齐历史同步缺失的租户关系-----------
}
if (StringUtils.isEmpty(accountToBind.getSysUserId())
|| !accountToBind.getSysUserId().equals(userByPhone.getId())) {
accountToBind.setSysUserId(userByPhone.getId());
sysThirdAccountService.updateById(accountToBind);
}
// 3. 关联部门
syncInfo.addSuccessInfo("更新已存在用户:" + name);
if (localDepart != null) {
linkUserToDepart(openId, tenantId, localDepart.getId());
}
syncInfo.addSuccessInfo("按手机号绑定已有用户:" + name + "(" + strippedMobile + ")");
log.info("飞书同步按手机号绑定已有用户:openId={}, phone={}, sysUserId={}",
openId, strippedMobile, userByPhone.getId());
} catch (Exception e) {
log.error("飞书同步按手机号绑定用户异常,name={}", name, e);
syncInfo.addFailInfo("按手机号绑定用户[" + name + "]异常:" + e.getMessage());
continue;
}
continue;
}
//update-end---author:jeecg ---date:2026-08-04 for:【QQYUN-12767】飞书同步按手机号查重:手机号已存在的本地用户直接绑定,不新增用户-----------
//update-end---author:jeecg ---date:2026-05-15 for:【QQYUN-12767】飞书集成,已绑定用户执行信息更新(姓名/手机/邮箱/头像),修复同步时已存在用户被跳过不更新的问题-----------
//update-begin---author:jeecg ---date:2026-08-04 for:【QQYUN-12767】飞书同步按手机号查重:手机号已存在的本地用户直接绑定,不新增用户-----------
// 兜底逻辑:未通过 thirdUserUuid/thirdUserId 找到绑定记录时,先按手机号匹配本地用户
// 命中则直接将飞书 openId 绑定到该现有用户,避免重复创建账号(对齐钉钉 addDepartUser 行为)
String strippedMobile = StringUtils.isNotEmpty(mobile) ? mobile.replaceAll("^\\+86\\s*", "").trim() : null;
SysUser userByPhone = StringUtils.isNotEmpty(strippedMobile) ? userMapper.getUserByPhone(strippedMobile) : null;
if (userByPhone != null) {
try {
// 1. 用飞书最新信息更新本地已有用户(仅更新邮箱/头像;姓名由业务自行维护,飞书姓名可能与系统姓名不一致,不覆盖)
boolean userChanged = false;
if (StringUtils.isNotEmpty(email) && !email.equals(userByPhone.getEmail())) {
userByPhone.setEmail(email);
userChanged = true;
}
if (StringUtils.isNotEmpty(avatarUrl) && !avatarUrl.equals(userByPhone.getAvatar())) {
userByPhone.setAvatar(avatarUrl);
userChanged = true;
}
if (userChanged) {
sysUserService.updateById(userByPhone);
}
// 2. 复用或创建第三方账号记录,并将 sysUserId 绑定到该现有用户
SysThirdAccount accountToBind;
if (thirdAccount == null) {
ThirdLoginModel tlm = new ThirdLoginModel(THIRD_TYPE, openId, name, avatarUrl);
accountToBind = sysThirdAccountService.saveThirdUser(tlm, tenantId);
} else {
accountToBind = thirdAccount;
accountToBind.setThirdUserUuid(openId);
accountToBind.setThirdUserId(openId);
accountToBind.setRealname(name);
if (StringUtils.isNotEmpty(avatarUrl)) {
accountToBind.setAvatar(avatarUrl);
}
sysThirdAccountService.updateById(accountToBind);
}
if (StringUtils.isEmpty(accountToBind.getSysUserId())
|| !accountToBind.getSysUserId().equals(userByPhone.getId())) {
accountToBind.setSysUserId(userByPhone.getId());
sysThirdAccountService.updateById(accountToBind);
}
//update-begin---author:jeecg ---date:2026-10-19 for:【QQYUN-12767】飞书同步用户未关联当前租户,按手机号匹配的已有用户加入租户(审核中,对齐钉钉)-----------
createUserTenant(userByPhone.getId(), true, tenantId);
//update-end---author:jeecg ---date:2026-10-19 for:【QQYUN-12767】飞书同步用户未关联当前租户,按手机号匹配的已有用户加入租户(审核中,对齐钉钉)-----------
// 3. 关联部门
if (localDepart != null) {
linkUserToDepart(openId, tenantId, localDepart.getId());
}
syncInfo.addSuccessInfo("按手机号绑定已有用户:" + name + "(" + strippedMobile + ")");
log.info("飞书同步按手机号绑定已有用户:openId={}, phone={}, sysUserId={}",
openId, strippedMobile, userByPhone.getId());
} catch (Exception e) {
log.error("飞书同步按手机号绑定用户异常,name={}", name, e);
syncInfo.addFailInfo("按手机号绑定用户[" + name + "]异常:" + e.getMessage());
}
continue;
}
//update-end---author:jeecg ---date:2026-08-04 for:【QQYUN-12767】飞书同步按手机号查重:手机号已存在的本地用户直接绑定,不新增用户-----------
try {
SysUser newUser = createLocalUser(name, email, mobile, openId, unionId, avatarUrl, tenantId);
if (newUser != null) {
ThirdLoginModel tlm = new ThirdLoginModel(THIRD_TYPE, openId, name, avatarUrl);
SysThirdAccount saved = sysThirdAccountService.saveThirdUser(tlm, tenantId);
saved.setSysUserId(newUser.getId());
sysThirdAccountService.updateById(saved);
//update-begin---author:liusq ---date:2026-10-19 for:【QQYUN-12767】飞书同步用户未关联当前租户,新建用户加入当前租户-----------
createUserTenant(newUser.getId(), false, tenantId);
//update-end---author:liusq ---date:2026-10-19 for:【QQYUN-12767】飞书同步用户未关联当前租户,新建用户加入当前租户-----------
if (localDepart != null) {
SysUserDepart userDepart = new SysUserDepart(newUser.getId(), localDepart.getId());
sysUserDepartService.save(userDepart);
@ -778,9 +807,10 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
syncInfo.addFailInfo("创建用户失败:" + name);
}
} catch (Exception e) {
log.error("飞书用户同步异常,name={}", name, e);
log.error("飞书用户同步异常,name={}, openId={}", name, openId, e);
syncInfo.addFailInfo("同步用户[" + name + "]异常:" + e.getMessage());
}
//update-end---author:liusq ---date:2026-10-19 for:【QQYUN-12767】飞书同步单个用户异常时记录失败信息并继续,避免一条脏数据中断整次同步-----------
}
}
boolean hasMore = Boolean.TRUE.equals(data.getBoolean("has_more"));
@ -882,6 +912,30 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
}
}
//update-begin---author:jeecg ---date:2026-10-16 for:【QQYUN-12767】飞书同步用户未关联当前租户,补充写入 sys_user_tenant-----------
/**
* 将用户加入租户(sys_user_tenant),已存在关系则跳过;未开启多租户时不处理。
* <p>对齐钉钉 / 企业微信同步中的 createUserTenant 逻辑。</p>
*
* @param userId 系统用户 ID
* @param underReview true=审核中(按手机号匹配到的已有用户,需租户管理员审核,对齐钉钉);false=正常
* @param tenantId 租户 ID
*/
private void createUserTenant(String userId, boolean underReview, Integer tenantId) {
if (!MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL || StringUtils.isEmpty(userId)) {
return;
}
Integer count = userTenantMapper.userTenantIzExist(userId, tenantId);
if (count == null || count == 0) {
SysUserTenant userTenant = new SysUserTenant();
userTenant.setTenantId(tenantId);
userTenant.setUserId(userId);
userTenant.setStatus(underReview ? CommonConstant.USER_TENANT_UNDER_REVIEW : CommonConstant.USER_TENANT_NORMAL);
userTenantMapper.insert(userTenant);
}
}
//update-end---author:jeecg ---date:2026-10-16 for:【QQYUN-12767】飞书同步用户未关联当前租户,补充写入 sys_user_tenant-----------
private SysUser createLocalUser(String name, String email, String mobile,
String openId, String unionId, String avatar, Integer tenantId) {
String username = "feishu_" + (openId.length() > 8 ? openId.substring(openId.length() - 8) : openId);
@ -901,6 +955,7 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
user.setStatus(1);
user.setDelFlag(0);
user.setActivitiSync(1);
user.setSort(CommonConstant.DEFAULT_USER_SORT);
try {
sysUserService.addUserWithRole(user, "");
return user;
@ -1141,6 +1196,47 @@ public class ThirdAppFeishuServiceImpl implements IThirdAppService {
return false;
}
//update-begin---author:scott ---date:2026-10-09 for:【敲敲云】简流 通知 对接飞书,Markdown 内容改发卡片消息,避免飞书里显示 Markdown 原文-----------
/**
* 单发 Markdown 卡片消息(msg_type=interactive,卡片内 markdown 组件渲染内容)
*
* @param title 卡片标题,为空时不显示标题栏
*/
private boolean doSendMarkdownCardMessage(String appToken, String openId, String title, String content) {
String url = SEND_MSG_URL + "?receive_id_type=open_id";
JSONObject card = new JSONObject();
JSONObject cardConfig = new JSONObject();
cardConfig.put("wide_screen_mode", true);
card.put("config", cardConfig);
if (StringUtils.isNotEmpty(title)) {
JSONObject titleObj = new JSONObject();
titleObj.put("tag", "plain_text");
titleObj.put("content", title);
JSONObject header = new JSONObject();
header.put("title", titleObj);
header.put("template", "blue");
card.put("header", header);
}
JSONObject markdown = new JSONObject();
markdown.put("tag", "markdown");
markdown.put("content", content);
JSONArray elements = new JSONArray();
elements.add(markdown);
card.put("elements", elements);
JSONObject body = new JSONObject();
body.put("receive_id", openId);
body.put("msg_type", "interactive");
body.put("content", card.toJSONString());
JSONObject result = doPost(url, appToken, body.toJSONString());
if (result != null && result.getIntValue("code") == 0) {
log.info("飞书卡片消息发送成功: openId={}", openId);
return true;
}
log.error("飞书卡片消息发送失败: openId={}, result={}", openId, result);
return false;
}
//update-end---author:scott ---date:2026-10-09 for:【敲敲云】简流 通知 对接飞书,Markdown 内容改发卡片消息,避免飞书里显示 Markdown 原文-----------
// ==================== HTTP 工具方法(供同步/消息使用)====================
/**

View File

@ -0,0 +1,38 @@
package org.jeecg.modules.system.util;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import java.util.Collection;
/**
* Shiro 权限缓存工具
* 角色授权变更后清理相关用户的权限缓存,使其无需重新登录即生效
*
* @author scott
* @since 2026-10-29 【LHZP-1129】角色/部门角色授权后清理相关用户权限缓存
*/
public class ShiroAuthCacheUtil {
private ShiroAuthCacheUtil() {
}
/**
* 清理用户的Shiro权限缓存
* @param redisUtil redis工具
* @param userIds 用户id集合
* @author scott
* @since 2026-10-29 【LHZP-1129】角色/部门角色授权后清理相关用户权限缓存
*/
public static void clearUserAuthCache(RedisUtil redisUtil, Collection<String> userIds) {
if (userIds == null || userIds.isEmpty()) {
return;
}
String[] keys = userIds.stream().filter(oConvertUtils::isNotEmpty).distinct()
.map(userId -> CommonConstant.PREFIX_USER_SHIRO_CACHE + userId).toArray(String[]::new);
if (keys.length > 0) {
redisUtil.del(keys);
}
}
}

Some files were not shown because too many files have changed in this diff Show More