|
@@ -1,5 +1,10 @@
|
|
|
package org.dromara.backstage.basics.service.impl;
|
|
package org.dromara.backstage.basics.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
+import org.dromara.backstage.basics.domain.PtArea;
|
|
|
|
|
+import org.dromara.backstage.basics.domain.bo.PtAreaBo;
|
|
|
|
|
+import org.dromara.backstage.basics.domain.vo.PtAreaVo;
|
|
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
@@ -31,6 +36,8 @@ public class PtCampusServiceImpl implements IPtCampusService {
|
|
|
|
|
|
|
|
private final PtCampusMapper baseMapper;
|
|
private final PtCampusMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
+ private final PtAreaServiceImpl areaService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询校区信息
|
|
* 查询校区信息
|
|
|
*
|
|
*
|
|
@@ -89,6 +96,22 @@ public class PtCampusServiceImpl implements IPtCampusService {
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
if (flag) {
|
|
|
bo.setCampusId(add.getCampusId());
|
|
bo.setCampusId(add.getCampusId());
|
|
|
|
|
+ //校区作为学校的下一级数据,在创建校区时同步要在区域表中增加一条区域数据,区域Id就是校区Id,parent_id对应校区所属的school_id,区域类型固定为校区(见区域类型字典表)
|
|
|
|
|
+ // 一个租户就是一个学校,一个学校就是一个单位,区域的最大的父节点为学校,只会有一个,默认取一个即可
|
|
|
|
|
+ PtAreaBo ptArea = new PtAreaBo();
|
|
|
|
|
+ ptArea.setParentId(0L); // 根节点
|
|
|
|
|
+ ptArea.setAreaType("01"); //学校
|
|
|
|
|
+ List<PtAreaVo> ptAreaVos = areaService.queryList(ptArea);
|
|
|
|
|
+ if(ptAreaVos.size()>0){
|
|
|
|
|
+ PtAreaBo ptAreaBo = new PtAreaBo();
|
|
|
|
|
+ ptAreaBo.setAreaId(add.getCampusId());
|
|
|
|
|
+ ptAreaBo.setAreaName(add.getCampusName());
|
|
|
|
|
+ ptAreaBo.setAreaCode(ptAreaVos.get(0).getAreaCode()+"-"+add.getCampusCode());
|
|
|
|
|
+ ptAreaBo.setAncestors(0+","+add.getCampusId());
|
|
|
|
|
+ ptAreaBo.setAreaType("02");
|
|
|
|
|
+ areaService.insertByBo(ptAreaBo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
return flag;
|
|
return flag;
|
|
|
}
|
|
}
|
|
@@ -110,7 +133,14 @@ public class PtCampusServiceImpl implements IPtCampusService {
|
|
|
* 保存前的数据校验
|
|
* 保存前的数据校验
|
|
|
*/
|
|
*/
|
|
|
private void validEntityBeforeSave(PtCampus entity){
|
|
private void validEntityBeforeSave(PtCampus entity){
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
|
|
|
|
+ LambdaQueryWrapper<PtCampus> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
|
+ queryWrapper.eq(PtCampus::getSchoolId, entity.getSchoolId());
|
|
|
|
|
+ queryWrapper.eq(PtCampus::getCampusName, entity.getCampusName());
|
|
|
|
|
+ queryWrapper.ne(entity.getCampusId() !=null, PtCampus::getCampusId, entity.getCampusId());
|
|
|
|
|
+ if(baseMapper.exists(queryWrapper)){
|
|
|
|
|
+ throw new ServiceException("校区名称已存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -123,7 +153,13 @@ public class PtCampusServiceImpl implements IPtCampusService {
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
if(isValid){
|
|
if(isValid){
|
|
|
- //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
|
|
+ //查询校区下是否有区域数据,有区域数据,不允许删除
|
|
|
|
|
+ for (Long id : ids) {
|
|
|
|
|
+ PtAreaVo ptAreaVo = areaService.queryById(id);
|
|
|
|
|
+ if(ptAreaVo!=null){
|
|
|
|
|
+ throw new ServiceException("该校区有区域数据,请先删除区域数据后再操作");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
}
|