实现根据输入的jsonData,deptId,以及roleId查询uesrNameList

This commit is contained in:
wsm
2026-04-23 23:43:08 +08:00
parent bea321c2e9
commit a77a63df31
6 changed files with 148 additions and 22 deletions
@@ -562,4 +562,6 @@ public interface ISysBaseAPI extends CommonAPI {
Map<String, Object> queryFileMapById(String id);
String updateBusinessId(String businessId, List<String> deliverablesList);
List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId);
}
@@ -0,0 +1,25 @@
package org.jeecg.modules.system.constant;
/**
* 用户密级常量
*/
public final class UserSecretLevel {
private UserSecretLevel() {
}
/**
* 非密
*/
public static final Integer SECRET_LEVEL_NONE = 3;
/**
* 一般
*/
public static final Integer SECRET_LEVEL_NORMAL = 4;
/**
* 重要
*/
public static final Integer SECRET_LEVEL_IMPORTANT = 5;
}
@@ -50,6 +50,7 @@ import org.jeecg.modules.message.handle.impl.QywxSendMsgHandle;
import org.jeecg.modules.message.handle.impl.SystemSendMsgHandle;
import org.jeecg.modules.message.service.ISysMessageTemplateService;
import org.jeecg.modules.message.websocket.WebSocket;
import org.jeecg.modules.system.constant.UserSecretLevel;
import org.jeecg.modules.system.entity.*;
import org.jeecg.modules.system.mapper.*;
import org.jeecg.modules.system.service.*;
@@ -2099,4 +2100,42 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return "";
}
public List<String> getUsersListByJsonLocalAPI(Object jsonData, String deptKeyName, String roleId) {
if (jsonData == null || StringUtils.isEmpty(deptKeyName) || StringUtils.isEmpty(roleId)) {
return Collections.emptyList();
}
// 统一转成 JSONObject(一步到位,不用来回转字符串)
JSONObject json;
if (jsonData instanceof String) {
json = JSON.parseObject((String) jsonData);
} else if (jsonData instanceof JSONObject) {
json = (JSONObject) jsonData;
} else {
return Collections.emptyList();
}
// 关键参数无效 → 直接返回空
if (json == null) {
return Collections.emptyList();
}
String deptId = json.getString(deptKeyName);
if (StringUtils.isEmpty(deptId)) {
return Collections.emptyList();
}
List<SysUser> sysUserList = sysUserService.queryUserByDeptAndROle(
deptId,
roleId,
UserSecretLevel.SECRET_LEVEL_NONE
);
return Optional.ofNullable(sysUserList)
.orElse(Collections.emptyList())
.stream()
.map(SysUser::getUsername)
.collect(Collectors.toList());
}
}