|
@@ -1,14 +1,13 @@
|
|
|
package com.zhongzheng.modules.course.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.bo.*;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseChapter;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseChapterBusiness;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseChapterSection;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
|
|
|
+import com.zhongzheng.modules.course.domain.*;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseChapterMapper;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
|
import com.zhongzheng.modules.course.service.ICourseChapterBusinessService;
|
|
@@ -167,6 +166,9 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
|
|
|
*/
|
|
|
private void validEntityBeforeSave(CourseChapter entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ if(checkNameUnique(entity)){
|
|
|
+ throw new CustomException("名称重复");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -176,4 +178,19 @@ public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, C
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ private boolean checkNameUnique(CourseChapter entity) {
|
|
|
+ CourseChapter info = getOne(new LambdaQueryWrapper<CourseChapter>()
|
|
|
+ .eq(CourseChapter::getPrefixName,entity.getPrefixName()).eq(CourseChapter::getName,entity.getName()).last("limit 1"));
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
+ if(Validator.isNotEmpty(entity.getChapterId())){
|
|
|
+ if(entity.getChapterId() != info.getChapterId()){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|