考核评估 新增考试添加判断通过分数不能大于总分数

This commit is contained in:
xusd 2024-05-14 17:04:52 +08:00
parent 2caa0da8c6
commit 0964d803bc

View File

@ -4,6 +4,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import com.inspur.common.exception.ServiceException;
import com.inspur.common.utils.DateUtils;
import com.inspur.common.utils.SecurityUtils;
import com.inspur.common.utils.StringUtils;
@ -63,6 +64,11 @@ public class ExamInfoServiceImpl implements IExamInfoService {
*/
@Override
public int insertExamInfo(ExamInfo examInfo) {
if(Objects.nonNull(examInfo.getTotalScore()) && Objects.nonNull(examInfo.getPassScore())){
if (examInfo.getTotalScore().compareTo(examInfo.getPassScore()) < 0){
throw new ServiceException("通过分数不能大于总分数");
}
}
examInfo.setId(IdUtils.fastSimpleUUID());
examInfo.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
examInfo.setCreateTime(DateUtils.getNowDate());
@ -77,6 +83,11 @@ public class ExamInfoServiceImpl implements IExamInfoService {
*/
@Override
public int updateExamInfo(ExamInfo examInfo) {
if(Objects.nonNull(examInfo.getTotalScore()) && Objects.nonNull(examInfo.getPassScore())){
if (examInfo.getTotalScore().compareTo(examInfo.getPassScore()) < 0){
throw new ServiceException("通过分数不能大于总分数");
}
}
examInfo.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
examInfo.setUpdateTime(DateUtils.getNowDate());
return examInfoMapper.updateExamInfo(examInfo);