|
@@ -2,6 +2,7 @@ package com.zhongzheng.modules.course.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.course.bo.*;
|
|
@@ -9,9 +10,7 @@ import com.zhongzheng.modules.course.domain.CourseEducationType;
|
|
|
import com.zhongzheng.modules.course.domain.MajorProject;
|
|
|
import com.zhongzheng.modules.course.service.IMajorLabelService;
|
|
|
import com.zhongzheng.modules.course.service.IMajorProjectService;
|
|
|
-import com.zhongzheng.modules.course.vo.CourseProjectTypeVo;
|
|
|
-import com.zhongzheng.modules.course.vo.MajorLabelVo;
|
|
|
-import com.zhongzheng.modules.course.vo.MajorProjectVo;
|
|
|
+import com.zhongzheng.modules.course.vo.*;
|
|
|
import com.zhongzheng.modules.user.bo.SchoolProjectAddBo;
|
|
|
import com.zhongzheng.modules.user.domain.SchoolProject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,7 +21,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.zhongzheng.modules.course.domain.Major;
|
|
|
import com.zhongzheng.modules.course.mapper.MajorMapper;
|
|
|
-import com.zhongzheng.modules.course.vo.MajorVo;
|
|
|
import com.zhongzheng.modules.course.service.IMajorService;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -103,6 +101,18 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
|
|
|
|
|
|
@Override
|
|
|
public Boolean insertByAddBo(MajorAddBo bo) {
|
|
|
+ //判断新增名字是否重复
|
|
|
+ LambdaQueryWrapper<Major> lqw = Wrappers.lambdaQuery();
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
+ status.add(1);
|
|
|
+ status.add(0);
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getCategoryName()), Major::getCategoryName, bo.getCategoryName());
|
|
|
+ lqw.in( Major::getStatus, status);
|
|
|
+ List<Major> list = this.list(lqw);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ throw new IllegalArgumentException("教育类型名称重复");
|
|
|
+ }
|
|
|
+
|
|
|
Major add = BeanUtil.toBean(bo, Major.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
@@ -121,6 +131,25 @@ public class MajorServiceImpl extends ServiceImpl<MajorMapper, Major> implements
|
|
|
|
|
|
@Override
|
|
|
public Boolean updateByEditBo(MajorEditBo bo) {
|
|
|
+
|
|
|
+ //修改判断名字是否重复
|
|
|
+ LambdaQueryWrapper<Major> lqwMajor = Wrappers.lambdaQuery();
|
|
|
+ lqwMajor.eq(StrUtil.isNotBlank(bo.getCategoryName()), Major::getCategoryName, bo.getCategoryName());
|
|
|
+ lqwMajor.eq(bo.getId()!= null, Major::getId, bo.getId());
|
|
|
+ List<Major> list = this.list(lqwMajor);
|
|
|
+ if (CollectionUtils.isEmpty(list)){
|
|
|
+ lqwMajor.clear();
|
|
|
+ lqwMajor.eq(StrUtil.isNotBlank(bo.getCategoryName()), Major::getCategoryName, bo.getCategoryName());
|
|
|
+ List<Integer> status = new ArrayList<>();
|
|
|
+ status.add(1);
|
|
|
+ status.add(0);
|
|
|
+ lqwMajor.in(bo.getStatus() != null, Major::getStatus, status);
|
|
|
+ List<Major> list1 = this.list(lqwMajor);
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)){
|
|
|
+ throw new IllegalArgumentException("专业名称重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Major update = BeanUtil.toBean(bo, Major.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|