AuthUserInfoController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.dragoninfo.dcuc.authweb.restcontroller.sub;
  2. import com.dragoninfo.dcuc.auth.sub.dto.AuthUserDTO;
  3. import com.dragoninfo.dcuc.auth.sub.enumresource.JobTypeEnum;
  4. import com.dragoninfo.dcuc.auth.sub.facade.IAuthUserInfoFacade;
  5. import com.dragoninfo.dcuc.auth.sub.vo.AuthUserVo;
  6. import com.dragoninfo.duceap.core.response.Result;
  7. import com.dragonsoft.duceap.base.entity.search.SearchDTO;
  8. import com.dragonsoft.duceap.core.search.Searchable;
  9. import com.dragonsoft.duceap.core.search.enums.SearchOperator;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiImplicitParam;
  12. import io.swagger.annotations.ApiOperation;
  13. import org.springframework.beans.BeanUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.data.domain.Page;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.List;
  18. import java.util.stream.Collectors;
  19. /**
  20. * @author wangrs
  21. * @date 2021-04-27
  22. */
  23. @Api(tags = {"授权管理-主客体管理-用户信息"})
  24. @RestController
  25. @RequestMapping(value = "authsvr/v2/authuserinfo")
  26. public class AuthUserInfoController {
  27. @Autowired
  28. private IAuthUserInfoFacade authUserInfoFacade;
  29. /**
  30. * 同角色授权-人员视图列表
  31. * @param searchDTO
  32. * @return
  33. */
  34. @RequestMapping("/page")
  35. @ApiImplicitParam(name = "searchable", value = "查询条件")
  36. @ApiOperation(value = "分页查询用户信息")
  37. public Page<AuthUserDTO> page(SearchDTO searchDTO) {
  38. //职位状态只查询在职、挂职、借调
  39. Searchable searchable = getUserQuerySearchable(searchDTO);
  40. return authUserInfoFacade.roleAuthUserViewPage(searchable.toSearchDTO());
  41. }
  42. private Searchable getUserQuerySearchable(SearchDTO searchDTO) {
  43. Searchable searchable = Searchable.toSearchable(searchDTO);
  44. String[] jobTypes = new String[]{JobTypeEnum.ZZ.getValue(), JobTypeEnum.GZ.getValue(), JobTypeEnum.JD.getValue()};
  45. searchable.addSearchFilter("relStatus", SearchOperator.in, jobTypes);
  46. return searchable;
  47. }
  48. @ApiOperation(value = "用户信息详情")
  49. @ApiImplicitParam(name = "id", value = "id")
  50. @GetMapping(value = "/detail/{id}")
  51. public AuthUserVo detail(@PathVariable(value = "id") String id) {
  52. AuthUserDTO authUserInfo = authUserInfoFacade.get(id);
  53. AuthUserVo authUserVo = new AuthUserVo();
  54. BeanUtils.copyProperties(authUserInfo,authUserVo);
  55. return authUserVo;
  56. }
  57. @ApiOperation(value = "用户信息删除")
  58. @ApiImplicitParam(name = "id", value = "id")
  59. @DeleteMapping(value = "/delete/{id}")
  60. public Result delete(@PathVariable(value = "id") String id) {
  61. authUserInfoFacade.delete(id);
  62. return Result.success();
  63. }
  64. @ApiOperation(value = "机构下未添加白名单的人员")
  65. @ApiImplicitParam(name = "searchable", value = "searchable 查询条件:orgId:= ; name:like; idcard:like")
  66. @PostMapping("notInWhiteListUserPage")
  67. public Result notInWhiteListUserPage(Searchable searchable) {
  68. Page<AuthUserDTO> userPage = authUserInfoFacade.notInWhiteListUserPage(searchable.toSearchDTO());
  69. List<AuthUserDTO> content = userPage.getContent();
  70. List<AuthUserVo> voList = content.stream().map(item -> {
  71. AuthUserVo vo = new AuthUserVo();
  72. BeanUtils.copyProperties(item, vo);
  73. return vo;
  74. }).collect(Collectors.toList());
  75. return Result.success(userPage.getTotalElements(), voList);
  76. }
  77. }