use of com.albedo.java.modules.sys.domain.DeptRelationDo in project albedo by somowhere.
the class DeptServiceImpl method saveOrUpdate.
/**
* 添加信息部门
*
* @param deptDto 部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(DeptDto deptDto) {
boolean add = ObjectUtil.isEmpty(deptDto.getId());
super.saveOrUpdate(deptDto);
if (add) {
deptRelationService.saveDeptRelation(deptDto);
} else {
// 更新部门关系
DeptRelationDo relation = new DeptRelationDo();
relation.setAncestor(deptDto.getParentId());
relation.setDescendant(deptDto.getId());
deptRelationService.updateDeptRelation(relation);
}
SysCacheUtil.delDeptCaches(deptDto.getId());
}
use of com.albedo.java.modules.sys.domain.DeptRelationDo in project albedo by somowhere.
the class DeptRelationServiceImpl method saveDeptRelation.
/**
* 维护部门关系
*
* @param deptDto 部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDeptRelation(DeptDto deptDto) {
// 增加部门关系表
DeptRelationDo condition = new DeptRelationDo();
condition.setDescendant(deptDto.getParentId());
List<DeptRelationDo> relationList = deptRelationRepository.selectList(Wrappers.<DeptRelationDo>query().lambda().eq(DeptRelationDo::getDescendant, deptDto.getParentId())).stream().map(relation -> {
relation.setDescendant(deptDto.getId());
return relation;
}).collect(Collectors.toList());
if (CollUtil.isNotEmpty(relationList)) {
this.saveBatch(relationList);
}
// 自己也要维护到关系表中
DeptRelationDo own = new DeptRelationDo();
own.setDescendant(deptDto.getId());
own.setAncestor(deptDto.getId());
deptRelationRepository.insert(own);
}
Aggregations