OrganizationStructureController.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. package com.ims.eval.controller;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.ims.eval.entity.OrganizationStructure;
  5. import com.ims.eval.entity.dto.result.R;
  6. import com.ims.eval.service.IOrganizationStructureService;
  7. import com.ims.eval.service.custom.PostService;
  8. import com.ims.eval.service.custom.PostUserService;
  9. import io.swagger.annotations.ApiOperation;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.*;
  12. import javax.servlet.http.HttpServletRequest;
  13. import java.util.List;
  14. /**
  15. * <p>
  16. * 前端控制器
  17. * </p>
  18. *
  19. * @author wang
  20. * @since 2023-03-01
  21. */
  22. @RestController
  23. @RequestMapping("//organization-structure")
  24. public class OrganizationStructureController {
  25. @Autowired
  26. private HttpServletRequest request;
  27. @Autowired
  28. private IOrganizationStructureService organizationStructureService;
  29. @Autowired
  30. private PostService postService;
  31. @Autowired
  32. private PostUserService postUserService;
  33. /**
  34. * 添加
  35. *
  36. * @param evaluateRuleInfo
  37. * @return
  38. */
  39. //@ImsPreAuth("eval:dataDictionary:edit")
  40. @PostMapping(value = "/save")
  41. @ApiOperation(value = "新增(修改)", notes = "新增(修改)")
  42. public R addAll(@RequestBody List<OrganizationStructure> evaluateRuleInfo) {
  43. boolean b = organizationStructureService.saveBatch(evaluateRuleInfo);
  44. if (b) {
  45. return R.ok().data(b);
  46. } else {
  47. return R.error().data("保存失败!");
  48. }
  49. }
  50. @GetMapping(value = "getTree")
  51. public R getTree(
  52. @RequestParam(value = "id", required = false) String id,
  53. @RequestParam(value = "num", required = false) Integer num,
  54. @RequestParam(value = "type", required = false) String type) {
  55. List<OrganizationStructure> list = organizationStructureService.getTree(id,num,type);
  56. return R.ok().data(list);
  57. }
  58. @GetMapping(value = "getList2")
  59. public R getList2(
  60. @RequestParam(value = "id", required = false) String id,
  61. @RequestParam(value = "num", required = false) Integer num,
  62. @RequestParam(value = "type", required = false) String type) {
  63. List<OrganizationStructure> list = organizationStructureService.getList2(id,num,type);
  64. return R.ok().data(list);
  65. }
  66. @GetMapping(value = "getList")
  67. public R getList(
  68. @RequestParam(value = "likeParentId", required = false) String id,
  69. @RequestParam(value = "parentId", required = false) String num,
  70. @RequestParam(value = "name", required = false) String name,
  71. @RequestParam(value = "type", required = false) String type) {
  72. List<OrganizationStructure> list = organizationStructureService.getList(id,num,name,type, request);
  73. return R.ok().data(list);
  74. }
  75. /**
  76. * 根据组织获取岗位
  77. * @param current
  78. * @param size
  79. * @param orgId
  80. * @return
  81. */
  82. @GetMapping(value = "getPostList")
  83. public R getPostList(
  84. @RequestParam(value = "current", required = false) Integer current,
  85. @RequestParam(value = "size", required = false) Integer size,
  86. @RequestParam(value = "orgId", required = false) String orgId) {
  87. try {
  88. Object list = postService.getPostList(current,size,orgId, request);
  89. if(null !=list){
  90. return R.ok().data(list);
  91. }
  92. return R.customError("失败");
  93. } catch (Exception e) {
  94. return R.customError("失败");
  95. }
  96. }
  97. /**
  98. * 根据岗位获取人员
  99. * @param current
  100. * @param size
  101. * @param posId
  102. * @return
  103. */
  104. @GetMapping(value = "getPostUserList")
  105. public R getPostUserList(
  106. @RequestParam(value = "current", required = false) Integer current,
  107. @RequestParam(value = "size", required = false) Integer size,
  108. @RequestParam(value = "posId", required = false) String posId) {
  109. try {
  110. Object list = postUserService.getPostUserList(current,size,posId, request);
  111. if(null !=list){
  112. return R.ok().data(list);
  113. }
  114. return R.customError("失败");
  115. } catch (Exception e) {
  116. e.printStackTrace();
  117. return R.customError("失败");
  118. }
  119. }
  120. /**
  121. * 更具人员获取岗位
  122. * @param current
  123. * @param size
  124. * @param userId
  125. * @return
  126. */
  127. @GetMapping(value = "getUserPostList")
  128. public R getUserPostList(
  129. @RequestParam(value = "current", required = false) Integer current,
  130. @RequestParam(value = "size", required = false) Integer size,
  131. @RequestParam(value = "userId", required = false) String userId) {
  132. try {
  133. Object list = postUserService.getUserPostList(current,size,userId, request);
  134. if(null !=list){
  135. return R.ok().data(list);
  136. }
  137. return R.customError("失败");
  138. } catch (Exception e) {
  139. return R.customError("失败");
  140. }
  141. }
  142. }