| | |
| | | import com.ruoyi.system.service.ISysPostService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.domain.vo.BranchUserQueryVO; |
| | | |
| | | /** |
| | | * 用户信息 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据分公司ID列表获取用户(POST方式) |
| | | */ |
| | | @PostMapping("/branch/users") |
| | | public AjaxResult listUsersByBranchDepts(@RequestBody BranchUserQueryVO queryVO) |
| | | { |
| | | List<Long> branchDeptIds = queryVO.getBranchDeptIds(); |
| | | |
| | | if (branchDeptIds == null || branchDeptIds.isEmpty()) { |
| | | return success(new java.util.ArrayList<>()); |
| | | } |
| | | |
| | | // 查询这些分公司及其所有子部门的用户 |
| | | List<SysUser> users = userService.selectUsersByBranchDeptIds(branchDeptIds); |
| | | |
| | | return success(users); |
| | | } |
| | | |
| | | /** |
| | | * 根据oaUserId查询用户信息 |
| | | */ |
| | | @GetMapping("/oa-user/{oaUserId}") |
| | |
| | | return error("未找到对应的用户信息"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新用户可管理分公司(通过oaOrderClass字段保存编码列表) |
| | | * 接收选中的分公司deptId列表,查询对应编码后合并写入oaOrderClass |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "用户管理-分公司配置", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/branch/{userId}") |
| | | public AjaxResult updateUserBranch(@PathVariable Long userId, @RequestBody java.util.List<Long> deptIds) |
| | | { |
| | | userService.checkUserDataScope(userId); |
| | | SysUser user = userService.selectUserById(userId); |
| | | if (user == null) { |
| | | return error("用户不存在"); |
| | | } |
| | | // 根据deptIds查询分公司信息,收集编码 |
| | | java.util.Set<String> codeSet = new java.util.LinkedHashSet<>(); |
| | | if (deptIds != null && !deptIds.isEmpty()) { |
| | | SysDept queryDept = new SysDept(); |
| | | queryDept.setParentId(100L); |
| | | List<SysDept> allBranches = deptService.selectDeptList(queryDept); |
| | | java.util.Map<Long, SysDept> deptMap = new java.util.HashMap<>(); |
| | | for (SysDept d : allBranches) { |
| | | deptMap.put(d.getDeptId(), d); |
| | | } |
| | | for (Long deptId : deptIds) { |
| | | SysDept dept = deptMap.get(deptId); |
| | | if (dept != null) { |
| | | if (StringUtils.isNotEmpty(dept.getServiceOrderClass())) { |
| | | codeSet.add(dept.getServiceOrderClass().trim()); |
| | | } |
| | | if (StringUtils.isNotEmpty(dept.getDispatchOrderClass())) { |
| | | codeSet.add(dept.getDispatchOrderClass().trim()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | String newOaOrderClass = String.join(",", codeSet); |
| | | SysUser updateUser = new SysUser(); |
| | | updateUser.setUserId(userId); |
| | | updateUser.setOaOrderClass(newOaOrderClass); |
| | | updateUser.setUpdateBy(getUsername()); |
| | | return toAjax(userService.updateUserProfile(updateUser)); |
| | | } |
| | | } |