use of com.pig4cloud.pig.admin.api.entity.SysDeptRelation in project pig by pig-mesh.
the class SysDeptServiceImpl method updateDeptById.
/**
* 更新部门
* @param sysDept 部门信息
* @return 成功、失败
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateDeptById(SysDept sysDept) {
// 更新部门状态
this.updateById(sysDept);
// 更新部门关系
SysDeptRelation relation = new SysDeptRelation();
relation.setAncestor(sysDept.getParentId());
relation.setDescendant(sysDept.getDeptId());
sysDeptRelationService.updateDeptRelation(relation);
return Boolean.TRUE;
}
use of com.pig4cloud.pig.admin.api.entity.SysDeptRelation in project pig by pig-mesh.
the class SysDeptRelationServiceImpl method saveDeptRelation.
/**
* 维护部门关系
* @param sysDept 部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDeptRelation(SysDept sysDept) {
// 增加部门关系表
List<SysDeptRelation> relationList = sysDeptRelationMapper.selectList(Wrappers.<SysDeptRelation>query().lambda().eq(SysDeptRelation::getDescendant, sysDept.getParentId())).stream().map(relation -> {
relation.setDescendant(sysDept.getDeptId());
return relation;
}).collect(Collectors.toList());
if (CollUtil.isNotEmpty(relationList)) {
this.saveBatch(relationList);
}
// 自己也要维护到关系表中
SysDeptRelation own = new SysDeptRelation();
own.setDescendant(sysDept.getDeptId());
own.setAncestor(sysDept.getDeptId());
sysDeptRelationMapper.insert(own);
}
Aggregations