use of com.pig4cloud.pig.admin.api.entity.SysDept 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);
}
use of com.pig4cloud.pig.admin.api.entity.SysDept in project pig by pig-mesh.
the class SysDeptServiceImpl method saveDept.
/**
* 添加信息部门
* @param dept 部门
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean saveDept(SysDept dept) {
SysDept sysDept = new SysDept();
BeanUtils.copyProperties(dept, sysDept);
this.save(sysDept);
sysDeptRelationService.saveDeptRelation(sysDept);
return Boolean.TRUE;
}
use of com.pig4cloud.pig.admin.api.entity.SysDept in project pig by pig-mesh.
the class DeptController method user.
/**
* 根据部门名查询部门信息
* @param deptname 部门名
* @return
*/
@GetMapping("/details/{deptname}")
public R<SysDept> user(@PathVariable String deptname) {
SysDept condition = new SysDept();
condition.setName(deptname);
return R.ok(sysDeptService.getOne(new QueryWrapper<>(condition)));
}
Aggregations