feat(admin): 选人组件数据源-userTree——管理端「选择用户」弹窗接学校组树 (组→组内用户叶子, GET /admin/user/tree), 替代管理页手输用户ID
build / build-push (push) Successful in 45s

This commit is contained in:
chenxing
2026-09-17 11:09:40 +08:00
parent 808e1c68b0
commit 5a7d93a48f
2 changed files with 68 additions and 0 deletions
@@ -138,6 +138,14 @@ public class FlowAdminController {
return mapAdminService.importGroups(adminGuard.requireAdmin(user, null));
}
// ==================== 选人组件数据源 ====================
/** 选人组件树:学校组树(组→组内用户叶子),管理端「选择用户」弹窗共用 */
@GetMapping("/user/tree")
public List<FlowMapAdminService.SelectUserNodeVo> userTree(BoaUser user) {
return mapAdminService.userTree(adminGuard.requireAdmin(user, null));
}
// ==================== 回调注册/推送日志/死信 ====================
@GetMapping("/callback/regList")
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@@ -92,6 +93,65 @@ public class FlowMapAdminService {
}
}
// ==================== 选人组件数据源 ====================
/** 选人组件树节点:组=isParent(true)+children;用户=叶子(isParent 缺省 false) */
@Getter
@Setter
public static class SelectUserNodeVo {
private Integer id;
private String name;
private Boolean isParent;
private List<SelectUserNodeVo> children = new ArrayList<>();
}
/**
* 学校组树(组→组内用户叶子),供管理端「选择用户」弹窗(多选指定用户/单选映射办理人)。
* 与 {@link #previewGroupDepts(Long)} 同源:UserBase getGroupById(schId, withSub) 子树 + 逐组挂成员。
*/
public List<SelectUserNodeVo> userTree(Long schId) {
BoaGroup subtree;
try {
subtree = groupClient.getGroupById(schId.intValue(), true);
} catch (Exception e) {
throw new BizException(ErrorCode.PARAM_ERROR, "UserBase 组树不可达:" + e.getMessage());
}
if (subtree == null || subtree.getId() == null) {
throw new BizException(ErrorCode.PARAM_ERROR, "学校组不存在(schId=" + schId + ")");
}
return Collections.singletonList(groupNode(subtree));
}
/** 组节点:先挂用户叶子再递归子组;isParent=UserBase 已宣告子组,防"空组"被当作用户叶子 */
private SelectUserNodeVo groupNode(BoaGroup group) {
SelectUserNodeVo vo = new SelectUserNodeVo();
vo.setId(group.getId());
vo.setName(group.getName());
boolean declaredSub = group.getChildren() != null && !group.getChildren().isEmpty();
try {
List<BoaUser> members = groupClient.getGroupUsers(group.getId(), false, null);
if (members != null) {
for (BoaUser u : members) {
if (u != null && u.getId() != null) {
SelectUserNodeVo leaf = new SelectUserNodeVo();
leaf.setId(u.getId());
leaf.setName(u.getName() == null ? "" : u.getName());
vo.getChildren().add(leaf);
}
}
}
} catch (Exception e) {
log.warn("[flow-center] 组成员拉取失败(groupId={}, name={}):{}", group.getId(), group.getName(), e.getMessage());
}
for (BoaGroup child : group.getChildren() == null ? Collections.<BoaGroup>emptyList() : group.getChildren()) {
if (child != null && child.getId() != null) {
vo.getChildren().add(groupNode(child));
}
}
vo.setIsParent(declaredSub || !vo.getChildren().isEmpty());
return vo;
}
// ==================== 一键拉取教师组 ====================
/** 科室预览/导入项(deptKey=UserBase 组 id) */