|
|
@@ -1,15 +1,12 @@
|
|
|
package com.zhongzheng.modules.user.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.modules.user.bo.SchoolAddBo;
|
|
|
import com.zhongzheng.modules.user.bo.SchoolEditBo;
|
|
|
import com.zhongzheng.modules.user.bo.SchoolQueryBo;
|
|
|
import com.zhongzheng.modules.user.domain.School;
|
|
|
-import com.zhongzheng.modules.user.domain.SchoolType;
|
|
|
import com.zhongzheng.modules.user.mapper.SchoolMapper;
|
|
|
import com.zhongzheng.modules.user.service.ISchoolService;
|
|
|
import com.zhongzheng.modules.user.vo.SchoolVo;
|
|
|
@@ -28,7 +25,7 @@ import java.util.stream.Collectors;
|
|
|
* 高校Service业务层处理
|
|
|
*
|
|
|
* @author hjl
|
|
|
- * @date 2021-05-19
|
|
|
+ * @date 2021-05-21
|
|
|
*/
|
|
|
@Service
|
|
|
public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> implements ISchoolService {
|
|
|
@@ -47,6 +44,11 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> impleme
|
|
|
lqw.eq(bo.getStatus() != null, School::getStatus, bo.getStatus());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getIntroduction()), School::getIntroduction, bo.getIntroduction());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getSchoolCity()), School::getSchoolCity, bo.getSchoolCity());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getAdvantageSpecialty()), School::getAdvantageSpecialty, bo.getAdvantageSpecialty());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getContact()), School::getContact, bo.getContact());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getPhone()), School::getPhone, bo.getPhone());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getAddress()), School::getAddress, bo.getAddress());
|
|
|
+ lqw.eq(bo.getDictCode() != null, School::getDictCode, bo.getDictCode());
|
|
|
return entity2Vo(this.list(lqw));
|
|
|
}
|
|
|
|
|
|
@@ -83,6 +85,7 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> impleme
|
|
|
public Boolean updateByEditBo(SchoolEditBo bo) {
|
|
|
School update = BeanUtil.toBean(bo, School.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
return this.updateById(update);
|
|
|
}
|
|
|
|
|
|
@@ -93,9 +96,6 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> impleme
|
|
|
*/
|
|
|
private void validEntityBeforeSave(School entity){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
- if(checkNameUnique(entity)){
|
|
|
- throw new CustomException("名称已存在");
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -105,14 +105,4 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> impleme
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
-
|
|
|
- private boolean checkNameUnique(School entity) {
|
|
|
- School info = getOne(new LambdaQueryWrapper<School>()
|
|
|
- .eq(School::getSchoolName,entity.getSchoolName())
|
|
|
- .last("limit 1"));
|
|
|
- if (Validator.isNotNull(info)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
}
|