| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.annotation.AnonymousAccess; |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.config.RsaProperties; |
| | | import me.zhengjie.modules.project.service.dto.ProjectQueryCriteria; |
| | | import me.zhengjie.modules.system.domain.Dept; |
| | | import me.zhengjie.modules.system.service.DataService; |
| | | import me.zhengjie.modules.system.domain.User; |
| | |
| | | import me.zhengjie.modules.system.domain.vo.UserPassVo; |
| | | import me.zhengjie.modules.system.service.DeptService; |
| | | import me.zhengjie.modules.system.service.RoleService; |
| | | import me.zhengjie.modules.system.service.dto.DeptDto; |
| | | import me.zhengjie.modules.system.service.dto.DeptUserNodeDto; |
| | | import me.zhengjie.modules.system.service.dto.RoleSmallDto; |
| | | import me.zhengjie.modules.system.service.dto.UserDto; |
| | | import me.zhengjie.modules.system.service.dto.UserQueryCriteria; |
| | |
| | | import me.zhengjie.utils.*; |
| | | import me.zhengjie.modules.system.service.UserService; |
| | | import me.zhengjie.utils.enums.CodeEnum; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | public void exportUser(HttpServletResponse response, UserQueryCriteria criteria) throws IOException { |
| | | userService.download(userService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping(value = "/dept/{deptId}") |
| | | @AnonymousAccess |
| | | public ResponseEntity<Object> queryDeptUserByDeptId(@PathVariable Long deptId) { |
| | | return new ResponseEntity<>(userService.queryDeptUserByDeptId(deptId), HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询用户") |
| | | @ApiOperation("查询用户") |
| | | @PreAuthorize("@el.check('user:list')") |
| | | public ResponseEntity<Object> queryUserAll(UserQueryCriteria criteria){ |
| | | return new ResponseEntity<>(userService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/approval") |
| | | @Log("查询用户") |
| | | @ApiOperation("查询用户") |
| | | @PreAuthorize("@el.check('user:list')") |
| | | public ResponseEntity<Object> queryApprovalUser(UserQueryCriteria criteria) { |
| | | // 当前用户 |
| | | UserDto user = userService.findByName(SecurityUtils.getCurrentUsername()); |
| | | List<Long> deptList = new ArrayList<Long>(); |
| | | // 当前部门 |
| | | DeptDto deptDto = deptService.findById(user.getDept().getId()); |
| | | // 然后把父节点的ID都加入到集合中 |
| | | deptList.addAll(deptService.getSuperior(deptDto, new ArrayList<Dept>()).stream().map(dept -> dept.getId()).collect(Collectors.toList())); |
| | | // 父部门加入检索条件 |
| | | criteria.getDeptIds().addAll(deptList); |
| | | |
| | | RoleSmallDto role = user.getRoles().stream().findFirst().orElseGet(RoleSmallDto::new); |
| | | // 数据权限是全体的场合,包含自己,否则不包含自己 |
| | | if ("全部".equals(role.getDataScope())) { |
| | | criteria.setLevel(role.getLevel()); |
| | | } else { |
| | | criteria.setLevelNq(role.getLevel()); |
| | | } |
| | | return new ResponseEntity<>(userService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | |
| | | } |
| | | // 数据权限 |
| | | List<Long> dataScopes = dataService.getDeptIds(userService.findByName(SecurityUtils.getCurrentUsername())); |
| | | List<Long> totalScopes = new ArrayList<Long>(dataScopes); |
| | | for (Long dataScope : dataScopes) { |
| | | // 先查找是否存在子节点 |
| | | List<Dept> data = deptService.findByPid(dataScope); |
| | | // 然后把子节点的ID都加入到集合中 |
| | | totalScopes.addAll(deptService.getDeptChildren(data)); |
| | | } |
| | | // criteria.getDeptIds() 不为空并且数据权限不为空则取交集 |
| | | if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)){ |
| | | if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(totalScopes)){ |
| | | // 取交集 |
| | | criteria.getDeptIds().retainAll(dataScopes); |
| | | criteria.getDeptIds().retainAll(totalScopes); |
| | | if(!CollectionUtil.isEmpty(criteria.getDeptIds())){ |
| | | return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | } else { |
| | | // 否则取并集 |
| | | criteria.getDeptIds().addAll(dataScopes); |
| | | criteria.getDeptIds().addAll(totalScopes); |
| | | return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | return new ResponseEntity<>(PageUtil.toPage(null,0),HttpStatus.OK); |
| | | } |
| | | |
| | | @Log("新增用户") |
| | | // @Log("新增用户") |
| | | @ApiOperation("新增用户") |
| | | @PostMapping |
| | | @PreAuthorize("@el.check('user:add')") |
| | |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @ApiOperation("重置密码") |
| | | @PostMapping(value = "/resetPass") |
| | | public ResponseEntity<Object> resetUserPass(@RequestBody User passVo) throws Exception { |
| | | UserDto user = userService.findByName(passVo.getUsername()); |
| | | userService.updatePass(user.getUsername(),passwordEncoder.encode("123456")); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @ApiOperation("修改头像") |
| | | @PostMapping(value = "/updateAvatar") |
| | | public ResponseEntity<Object> updateUserAvatar(@RequestParam MultipartFile avatar){ |
| | |
| | | return new ResponseEntity<>(userService.getUserCalendarInfo(month), HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/getUserBaseInfo") |
| | | @GetMapping(value = "/getUserBaseInfo/{yearMonth}") |
| | | @Log("获取用户基础信息") |
| | | @ApiOperation("获取用户日历信息") |
| | | public ResponseEntity<Object> getUserBaseInfo() throws ParseException { |
| | | return new ResponseEntity<>(userService.getUserBaseInfo(), HttpStatus.OK); |
| | | public ResponseEntity<Object> getUserBaseInfo(@PathVariable Date yearMonth) throws ParseException { |
| | | return new ResponseEntity<>(userService.getUserBaseInfo(yearMonth), HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/getProjectUser") |
| | | public ResponseEntity<Object> getUserByTaskId(String taskId){ |
| | | return new ResponseEntity<>(userService.getUserByTaskId(taskId),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/getAllUser") |
| | | public ResponseEntity<Object> getAllUserByTaskId(String taskId){ |
| | | return new ResponseEntity<>(userService.getAllUserByTaskId(taskId),HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getUserDept") |
| | | public ResponseEntity<Object> getAllUserDetail(){ |
| | | return new ResponseEntity<>(userService.getUserDept(),HttpStatus.OK); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/getUserPidDept") |
| | | public ResponseEntity<Object> getUserPidDept(Long[] ids) { |
| | | List<Long[]> result = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | result.add(userService.getUserPidDept(id)); |
| | | } |
| | | return new ResponseEntity<>(result,HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/getPerformanceDetail") |
| | | public ResponseEntity<Object> getPerformanceDetail(Long nextMonth) throws ParseException { |
| | | return new ResponseEntity<>(HttpStatus.OK); // userService.getPerformanceDetail(nextMonth), |
| | | |
| | | } |
| | | |
| | | @GetMapping(value = "/getUserInfose") |
| | | @Log("查询用户信息") |
| | | @ApiOperation("查询用户信息") |
| | | public ResponseEntity<Object> getUserInfos() { |
| | | return new ResponseEntity<>(userService.getUserInfose(), HttpStatus.OK); |
| | | } |
| | | } |