From a2d75a1c3dfffd9903906e596898ed0322bb9123 Mon Sep 17 00:00:00 2001 From: winter <2436197699@qq.com> Date: Wed, 29 Nov 2023 18:30:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E6=AC=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=84=E4=BB=B7=E6=97=B6=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=BE=97=E5=88=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/EvaluationServiceImpl.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java index 95c6611..c7bac1f 100644 --- a/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/EvaluationServiceImpl.java @@ -197,6 +197,11 @@ public class EvaluationServiceImpl implements EvaluationService { User loginUser = SecurityUtil.getLoginUser(); String schoolId = loginUser.getSchoolId(); + if (!targetType.equals(TARGET_STUDENT) && !targetType.equals(TARGET_CLASS)) { + throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不受支持的评价对象"); + } + + // 获取评价项节点 List nodes = appraiseRepository.findNodeById(PK.PK_APPRAISE, appraiseId); AppraiseTreeNode appraiseTreeNode = RepositoryUtil.findOne(nodes); @@ -230,21 +235,21 @@ public class EvaluationServiceImpl implements EvaluationService { record = new AppraiseRecord(); if (targetType.equals(TARGET_STUDENT)) { record.setTargetType(TARGET_STUDENT); - } else if (targetType.equals(TARGET_CLASS)){ - record.setTargetType(TARGET_CLASS); } else { - throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "不受支持的评价对象"); + record.setTargetType(TARGET_CLASS); } record.setTargetId(targetId); record.setAcademicYearId(academicYearId); - record.setPraiseCount(0); - record.setScore(0); + record.setPraiseCount(appraiseTreeNode.isPraise() ? 1 : -1); + record.setScore(ObjectUtils.isEmpty(appraiseTreeNode.getScore()) ? 0 : appraiseTreeNode.getScore()); record.setNodes(items); record.setCode(String.format(PK.PK_APPRAISE_RECORD, schoolId)); appraiseRecordRepository.save(record); } else { // 处理学校与学生的差异 -it + if (targetType.equals(TARGET_CLASS)){ + item.setSpread(spread); + } CosmosPatchOperations operations = CosmosPatchOperations.create(); operations.add("/nodes/0", item); // 表扬