|
@@ -1,9 +1,12 @@
|
|
|
package com.zhongzheng.modules.exam.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSection;
|
|
|
import com.zhongzheng.modules.pay.domain.PayAisle;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -93,6 +96,24 @@ public class ExamPaperServiceImpl extends ServiceImpl<ExamPaperMapper, ExamPaper
|
|
|
*/
|
|
|
private void validEntityBeforeSave(ExamPaper entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ if(checkNameUnique(entity)){
|
|
|
+ throw new CustomException("节标题重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkNameUnique(ExamPaper entity) {
|
|
|
+ ExamPaper info = getOne(new LambdaQueryWrapper<ExamPaper>()
|
|
|
+ .eq(ExamPaper::getPaperName,entity.getPaperName()).ne(ExamPaper::getStatus,-1).last("limit 1"));
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
+ if(Validator.isNotEmpty(entity.getPaperId())){
|
|
|
+ if(entity.getPaperId().longValue() != info.getPaperId().longValue()){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Override
|