|
@@ -1,7 +1,9 @@
|
|
|
package com.zhongzheng.modules.base.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.base.bo.ApplyAreasAddBo;
|
|
@@ -11,6 +13,7 @@ import com.zhongzheng.modules.base.domain.ApplyAreas;
|
|
|
import com.zhongzheng.modules.base.mapper.ApplyAreasMapper;
|
|
|
import com.zhongzheng.modules.base.service.IApplyAreasService;
|
|
|
import com.zhongzheng.modules.base.vo.ApplyAreasVo;
|
|
|
+import com.zhongzheng.modules.course.domain.MajorCategory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -104,6 +107,9 @@ public class ApplyAreasServiceImpl extends ServiceImpl<ApplyAreasMapper, ApplyAr
|
|
|
*/
|
|
|
private void validEntityBeforeSave(ApplyAreas entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ if(checkNameUnique(entity)&&Validator.isEmpty(entity.getAreaId())){
|
|
|
+ throw new CustomException("地区名重复");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -113,4 +119,14 @@ public class ApplyAreasServiceImpl extends ServiceImpl<ApplyAreasMapper, ApplyAr
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ private boolean checkNameUnique(ApplyAreas entity) {
|
|
|
+ ApplyAreas info = getOne(new LambdaQueryWrapper<ApplyAreas>()
|
|
|
+ .eq(ApplyAreas::getAreaName,entity.getAreaName())
|
|
|
+ .last("limit 1"));
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|