feat: 获取评价树时root节点排序

11111
winter 1 year ago
parent 40d4826695
commit ae729c05e8

@ -79,20 +79,21 @@ public class EvaluationServiceImpl implements EvaluationService {
User loginUser = SecurityUtil.getLoginUser(); User loginUser = SecurityUtil.getLoginUser();
String schoolId = loginUser.getSchoolId(); String schoolId = loginUser.getSchoolId();
Appraise appraise = appraiseRepository.findAppraiseBySchoolIdAndPeriodIdAndCode(schoolId, periodId, PK.PK_APPRAISE); Appraise appraise = appraiseRepository.findAppraiseBySchoolIdAndPeriodIdAndCode(schoolId, periodId, PK.PK_APPRAISE);
if (appraise != null) {
return this.buildTree(appraise);
}
// 如果传参 period 所在没有 tree 的话,则复制一份模板 tree 给他 (处理节点 id) // 如果传参 period 所在没有 tree 的话,则复制一份模板 tree 给他 (处理节点 id)
appraise = RepositoryUtil.findOne(appraiseRepository.findTemplateTree(), "获取模板评价树失败");
if (appraise == null) { if (appraise == null) {
throw new ServiceException(); appraise = RepositoryUtil.findOne(appraiseRepository.findTemplateTree(), "获取模板评价树失败");
if (appraise == null) {
throw new ServiceException();
}
// refresh
refreshAppraiseTree(appraise);
appraise.setPeriodId(periodId);
appraise.setSchoolId(schoolId);
appraise.setId(null);
appraise = appraiseRepository.save(appraise);
} }
// refresh
refreshAppraiseTree(appraise);
appraise.setPeriodId(periodId);
appraise.setSchoolId(schoolId);
appraise.setId(null);
appraise = appraiseRepository.save(appraise);
return this.buildTree(appraise); return this.buildTree(appraise);
} }
@ -141,6 +142,8 @@ public class EvaluationServiceImpl implements EvaluationService {
for (AppraiseTreeNode parent : parents) { for (AppraiseTreeNode parent : parents) {
buildChildren(parent, nodes); buildChildren(parent, nodes);
} }
// 排序
parents = parents.stream().sorted(Comparator.comparing(AppraiseTreeNode::getOrder)).collect(Collectors.toList());
appraise.setNodes(parents); appraise.setNodes(parents);
return appraise; return appraise;
} }

Loading…
Cancel
Save