|
@@ -1,13 +1,16 @@
|
|
package com.zhongzheng.modules.course.service.impl;
|
|
package com.zhongzheng.modules.course.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
|
|
|
|
+import com.zhongzheng.modules.course.domain.Course;
|
|
import com.zhongzheng.modules.course.domain.CourseSection;
|
|
import com.zhongzheng.modules.course.domain.CourseSection;
|
|
import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
|
|
import com.zhongzheng.modules.course.domain.CourseSectionBusiness;
|
|
import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
@@ -133,6 +136,9 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
*/
|
|
*/
|
|
private void validEntityBeforeSave(CourseSection entity){
|
|
private void validEntityBeforeSave(CourseSection entity){
|
|
//TODO 做一些数据校验,如唯一约束
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
|
+ if(checkNameUnique(entity)){
|
|
|
|
+ throw new CustomException("名称重复");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -142,4 +148,19 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
}
|
|
}
|
|
return this.removeByIds(ids);
|
|
return this.removeByIds(ids);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private boolean checkNameUnique(CourseSection entity) {
|
|
|
|
+ CourseSection info = getOne(new LambdaQueryWrapper<CourseSection>()
|
|
|
|
+ .eq(CourseSection::getPrefixName,entity.getPrefixName()).eq(CourseSection::getName,entity.getName()).last("limit 1"));
|
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
|
+ if(Validator.isNotEmpty(entity.getSectionId())){
|
|
|
|
+ if(entity.getSectionId() != info.getSectionId()){
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|