登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
2025 Gitee 年度开源项目评选投票进行中,快为你的心仪项目助力!
代码拉取完成,页面将自动刷新
开源项目
>
程序开发
>
工作流
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
266
Star
8.3K
Fork
834
dromara
/
warm-flow
代码
Issues
25
Pull Requests
1
Wiki
统计
流水线
服务
JavaDoc
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
377
[fix] 修复“流程类别”树形菜单构建时不支持通过setChildren()方法设置子节点的问题
开启的
王志龙:dev
dromara:dev
王志龙
创建于 2025-11-12 15:59
克隆/下载
HTTPS
SSH
复制
下载 Email Patch
下载 Diff 文件
1. [fix] 修复“流程类别”树形菜单构建时不支持通过setChildren()方法设置子节点的问题 --- ### 更改目的 解决了什么问题(请提交到dev分支) **问题描述:** 手动构建树形结构(通过setChildren()方法设置子节点)时,http://ip:port/warm-flow/query-def接口返回的响应体中的children属性是空的,从而导致页面的“流程类别”只显示根节点不显示子孙节点 **图片说明:**   **原因分析:** 在代码中,虽然设置了子节点,但这些子节点并没有被单独添加到trees列表中。buildTree()方法只能看到"hr"这一个节点,因为它只遍历trees列表中的元素。  在递归列表 `recursionFn()` 方法中,调用 `getchildList()` 方法,传入的参数List<Tree> list和Tree t是相同的,这就导致分支判断条件 `StringUtils.isNotEmpty(n.getParentId()) && n.getParentId().equals(t.getId())` 结果为 `false` ,因为循环变量n就是根节点"hr",既然是根节点就不可能有父ID,所以最终 `getchildList()` 方法返回的是一个空集合,所以调用方 `recursionFn()` 方法在往下设置children属性时也就毫无作用,从而最终导致了子孙节点的丢失 ### 改动逻辑 这么写的思路(让作者更好的理解你的意图) 考虑到自己对warm-flow整体代码了解不够深入,为了降低风险,新建一个工具类 `TreeBuildUtil` ,和原有的 `TreeUtil` 类在同一个目录下,只把org.dromara.warm.flow.ui.service.WarmFlowService第105行的方法调用进行修改 ### 测试 都做了哪些测试(未经过测试不采纳) 主要是三种构建节点方式的测试:所有节点平铺测试、所有节点预构建树形结构测试(通过setChildren()方法设置子节点)、混合结构测试(平铺节点+预构建树形结构) 测试结果均符合预期。 **所有节点平铺测试:** ``` List<Tree> trees = new ArrayList<>(); trees.add(new Tree("hr", "人力资源系统", null, null)); trees.add(new Tree("recruit", "招聘管理", "hr", null)); trees.add(new Tree("interview", "面试流程", "recruit", null)); trees.add(new Tree("onboard", "入职流程", "recruit", null)); trees.add(new Tree("probation", "试用期考核", "recruit", null)); trees.add(new Tree("performance", "绩效管理", "hr", null)); trees.add(new Tree("kpi", "KPI考核", "performance", null)); trees.add(new Tree("360", "360评估", "performance", null)); trees.add(new Tree("oa", "OA办公系统", null, null)); trees.add(new Tree("approval", "审批流程", "oa", null)); trees.add(new Tree("leave", "请假审批", "approval", null)); trees.add(new Tree("reimburse", "报销审批", "approval", null)); trees.add(new Tree("purchase", "采购审批", "approval", null)); ``` **所有节点预构建树形结构测试:** ``` List<Tree> trees = new ArrayList<>(); trees.add( new Tree("hr", "人力资源系统", null, null).setChildren( Arrays.asList( new Tree("recruit", "招聘管理", "hr", null).setChildren( Arrays.asList( new Tree("interview", "面试流程", "recruit", null), new Tree("onboard", "入职流程", "recruit", null), new Tree("probation", "试用期考核", "recruit", null) ) ), new Tree("performance", "绩效管理", "hr", null).setChildren( Arrays.asList( new Tree("kpi", "KPI考核", "performance", null), new Tree("360", "360评估", "performance", null) ) ) ) ) ); trees.add( new Tree("oa", "OA办公系统", null, null).setChildren( Arrays.asList( new Tree("approval", "审批流程", "oa", null).setChildren( Arrays.asList( new Tree("leave", "请假审批", "approval", null), new Tree("reimburse", "报销审批", "approval", null), new Tree("purchase", "采购审批", "approval", null) ) ) ) ) ); ``` **混合结构测试(平铺节点+预构建树形结构):** ``` List<Tree> trees = new ArrayList<>(); trees.add(new Tree("hr", "人力资源系统", null, null)); trees.add(new Tree("recruit", "招聘管理", "hr", null)); trees.add(new Tree("interview", "面试流程", "recruit", null)); trees.add(new Tree("onboard", "入职流程", "recruit", null)); trees.add(new Tree("probation", "试用期考核", "recruit", null)); trees.add( new Tree("performance", "绩效管理", "hr", null).setChildren( Arrays.asList( new Tree("kpi", "KPI考核", "performance", null), new Tree("360", "360评估", "performance", null) ) ) ); trees.add( new Tree("oa", "OA办公系统", null, null).setChildren( Arrays.asList( new Tree("approval", "审批流程", "oa", null).setChildren( Arrays.asList( new Tree("leave", "请假审批", "approval", null), new Tree("reimburse", "报销审批", "approval", null), new Tree("purchase", "采购审批", "approval", null) ) ) ) ) ); ```
此 Pull Request 需要通过一些审核项
类型
指派人员
状态
审查
晓华
进行中
(0/1人)
测试
晓华
进行中
(0/1人)
此 Pull Request 暂不能合并,一些审核尚未通过
怎样手动合并此 Pull Request
git checkout dev
git pull https://gitee.com/wang-zhilong1996/warm-flow.git dev
git push origin dev
评论
0
提交
1
文件
2
检查
代码问题
0
批量操作
展开设置
折叠设置
审查
Code Owner
审查人员
Liuyq17
liuyq17
xiarigang
rigangxia
VanLin
vanlin
liangli
liangliyun
Zhen
Zhenln
Levin丶枫过无痕
battcn-levin
晓华
min290
未设置
最少人数
1
测试
Liuyq17
liuyq17
xiarigang
rigangxia
VanLin
vanlin
liangli
liangliyun
Zhen
Zhenln
Levin丶枫过无痕
battcn-levin
晓华
min290
未设置
最少人数
1
优先级
不指定
严重
主要
次要
不重要
标签
标签管理
未设置
关联 Issue
ID60DO
【Bug】 构建“流程类别”树形菜单时,调用Tree对象的setChildren方法不生效的问题
Pull Request 合并后将关闭上述关联 Issue
里程碑
未关联里程碑
合并选项
合并后删除提交分支
提交分支为默认分支,无法删除
合并后关闭提到的 Issue
接受 Pull Request 时使用扁平化(Squash)合并
勾选此选项后,将建议使用 Squash Merge 方式合并以精简提交历史记录
参与者
(1)
Java
1
https://gitee.com/dromara/warm-flow.git
git@gitee.com:dromara/warm-flow.git
dromara
warm-flow
warm-flow
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册