| | |
| | | import cc.mrbird.febs.common.core.entity.constant.StringConstant; |
| | | import cc.mrbird.febs.common.core.entity.system.Dept; |
| | | import cc.mrbird.febs.common.core.entity.system.DicItem; |
| | | import cc.mrbird.febs.common.core.entity.system.UserDataPermission; |
| | | import cc.mrbird.febs.common.core.utils.FebsUtil; |
| | | import cc.mrbird.febs.common.core.utils.SequenceUtil; |
| | | import cc.mrbird.febs.common.core.utils.SortUtil; |
| | |
| | | public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService { |
| | | private final RedisService redisService; |
| | | private final IUserDataPermissionService userDataPermissionService; |
| | | private final DeptMapper deptMapper; |
| | | |
| | | @Override |
| | | public Map<String, Object> findDepts(QueryRequest request, Dept dept) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createDept(Dept dept) { |
| | | dept.setDeptId(SequenceUtil.generateId(0L, ModuleCode.FRAM_SYSTEM)); |
| | | long deptId = SequenceUtil.generateId(0L, ModuleCode.FRAM_SYSTEM); |
| | | dept.setDeptId(deptId); |
| | | if (dept.getParentId() == null) { |
| | | dept.setParentId(Dept.TOP_DEPT_ID); |
| | | } |
| | | dept.setAllDeptName(createALlDeptName(dept)); |
| | | dept.setCreateTime(new Date()); |
| | | this.save(dept); |
| | | |
| | | UserDataPermission userDataPermission = new UserDataPermission(); |
| | | userDataPermission.setDeptId(deptId); |
| | | userDataPermission.setUserId(Long.parseLong(FebsUtil.getUserId())); |
| | | userDataPermissionService.save(userDataPermission); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (dept.getParentId() == null) { |
| | | dept.setParentId(Dept.TOP_DEPT_ID); |
| | | } |
| | | String oldAllName = dept.getAllDeptName(); |
| | | String newAllName = createALlDeptName(dept); |
| | | dept.setModifyTime(new Date()); |
| | | this.baseMapper.updateById(dept); |
| | | |
| | | deptMapper.changeAllDeptName(oldAllName,newAllName,oldAllName + "%"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | private String createALlDeptName(Dept dept){ |
| | | Dept parent = this.getById(dept.getParentId()); |
| | | return parent.getAllDeptName() + "/" + dept.getDeptName(); |
| | | } |
| | | } |