From b610194f300fb2ff14290b05976f0ed6b4f7db0f Mon Sep 17 00:00:00 2001 From: winter <2436197699@qq.com> Date: Mon, 11 Dec 2023 17:11:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=AF=84=E4=BB=B7?= =?UTF-8?q?=E9=A1=B9=20path=20=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/teammodel/model/dto/Appraise/InsertNodeDto.java | 1 + .../java/cn/teammodel/model/dto/Appraise/UpdateNodeDto.java | 1 + .../cn/teammodel/model/entity/appraise/AppraiseTreeNode.java | 1 + .../java/cn/teammodel/service/impl/EvaluationServiceImpl.java | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/cn/teammodel/model/dto/Appraise/InsertNodeDto.java b/src/main/java/cn/teammodel/model/dto/Appraise/InsertNodeDto.java index 0b33ea5..37d430a 100644 --- a/src/main/java/cn/teammodel/model/dto/Appraise/InsertNodeDto.java +++ b/src/main/java/cn/teammodel/model/dto/Appraise/InsertNodeDto.java @@ -18,6 +18,7 @@ public class InsertNodeDto { @ApiModelProperty(value = "父亲节点,不传则为根节点", required = true) @NotBlank(message = "name 不能为空") String name; + String[] path; String logo; Integer order = 0; Integer score = 0; diff --git a/src/main/java/cn/teammodel/model/dto/Appraise/UpdateNodeDto.java b/src/main/java/cn/teammodel/model/dto/Appraise/UpdateNodeDto.java index cf5073a..832b8a3 100644 --- a/src/main/java/cn/teammodel/model/dto/Appraise/UpdateNodeDto.java +++ b/src/main/java/cn/teammodel/model/dto/Appraise/UpdateNodeDto.java @@ -14,6 +14,7 @@ public class UpdateNodeDto { @ApiModelProperty(value = "评价项节点的 id") String id; String name; + String[] path; String logo; Integer order; boolean isPraise; diff --git a/src/main/java/cn/teammodel/model/entity/appraise/AppraiseTreeNode.java b/src/main/java/cn/teammodel/model/entity/appraise/AppraiseTreeNode.java index f6387e6..02f7bbf 100644 --- a/src/main/java/cn/teammodel/model/entity/appraise/AppraiseTreeNode.java +++ b/src/main/java/cn/teammodel/model/entity/appraise/AppraiseTreeNode.java @@ -12,6 +12,7 @@ public class AppraiseTreeNode { String id; String pid; String name; + String[] path; String logo; String creator; String creatorId; diff --git a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java index d6ed5e4..9a241f2 100644 --- a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java @@ -176,7 +176,6 @@ public class EvaluationServiceImpl implements EvaluationService { throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "父节点不存在"); } } - // todo: 可不可以添加默认值 order ? newNode.setId(UUID.randomUUID().toString()); newNode.setCreatorId(loginUser.getId()); newNode.setCreator(loginUser.getName()); @@ -199,6 +198,7 @@ public class EvaluationServiceImpl implements EvaluationService { .orElseThrow(() -> new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "更新节点不存在")); // 更新字段,考虑直接 copy properties updateNode.setName(updateNodeDto.getName()); + updateNode.setPath(updateNodeDto.getPath()); updateNode.setLogo(updateNodeDto.getLogo()); updateNode.setOrder(updateNodeDto.getOrder()); updateNode.setPraise(updateNodeDto.isPraise()); @@ -386,7 +386,7 @@ public class EvaluationServiceImpl implements EvaluationService { .filter(item -> nodeId.equals(item.getId())) .findFirst().orElseThrow(() -> new ServiceException("该记录节点不存在")); // 鉴权(不是创建老师不能撤回) - if (!userId.equals(record.getCreatorId())) { + if (!userId.equals(record.getCreatorId()) || !loginUser.getRoles().contains("admin")) { throw new ServiceException(ErrorCode.NO_AUTH_ERROR.getCode(), "您不是创建老师,不能撤回"); } // 删除评价项并且恢复评分