diff --git a/src/main/java/com/project/task/domain/service/impl/SaveOrUpdateTaskDomainServiceImpl.java b/src/main/java/com/project/task/domain/service/impl/SaveOrUpdateTaskDomainServiceImpl.java index 0eb8101..d51ef9d 100644 --- a/src/main/java/com/project/task/domain/service/impl/SaveOrUpdateTaskDomainServiceImpl.java +++ b/src/main/java/com/project/task/domain/service/impl/SaveOrUpdateTaskDomainServiceImpl.java @@ -126,6 +126,12 @@ public class SaveOrUpdateTaskDomainServiceImpl implements SaveOrUpdateTaskDomain if (StrUtil.isBlank(dto.getName())) { throw new BusinessErrorException("考试任务名称不能为空"); } + //校验考试名称是否存在 + long count = taskBaseService.count(new LambdaQueryWrapper().eq(TaskEntity::getName, dto.getName())); + if (count > 0){ + throw new BusinessErrorException("考试任务名称已存在"); + } + if (StrUtil.length(dto.getName()) > 10) { throw new BusinessErrorException("考试任务名称过长"); }