OrganizationManagementController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.goafanti.organization.controller;
  2. import javax.annotation.Resource;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import com.goafanti.common.bo.Result;
  8. import com.goafanti.common.constant.ErrorConstants;
  9. import com.goafanti.common.controller.BaseApiController;
  10. import com.goafanti.common.dao.OrganizationManagementMapper;
  11. import com.goafanti.common.utils.StringUtils;
  12. import com.goafanti.organization.bo.OrganizationListOut;
  13. import com.goafanti.organization.service.OrganizationService;
  14. @RestController
  15. @RequestMapping("api/admin/organization")
  16. public class OrganizationManagementController extends BaseApiController{
  17. @Resource
  18. private OrganizationService organizationService;
  19. @Autowired
  20. private OrganizationManagementMapper organizationManagementMapper;
  21. /**部门组织管理列表 **/
  22. @RequestMapping(value = "/listOrganizationManagement" , method = RequestMethod.POST)
  23. public Result listOrganizationManagement(OrganizationListOut olo, Integer pageNo,
  24. Integer pageSize){
  25. Result res = new Result();
  26. res.setData(organizationService.listOrganizationManagement(olo, pageNo, pageSize));
  27. return res;
  28. }
  29. /**部门组织管理上级组织查询 **/
  30. @RequestMapping(value = "/selectSuperId" , method = RequestMethod.POST)
  31. public Result selectsuperId(){
  32. Result res = new Result();
  33. res.setData(organizationService.selectSuperId());
  34. return res;
  35. }
  36. /**部门组织管理新增**/
  37. @RequestMapping(value = "/addOrganization" , method = RequestMethod.POST)
  38. public Result addOrganization(String name, String managerId, String type, String superId, String remarks) throws Exception{
  39. Result res = new Result();
  40. if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
  41. || StringUtils.isBlank(superId)){
  42. res.getError().add(buildError("","组织名称、组织类型、上级组织不能为空"));
  43. return res;
  44. }
  45. String olo=organizationManagementMapper.selectDepNoByName(name);
  46. if(olo!=null){
  47. res.getError().add(buildError("","部门已存在"));
  48. return res;
  49. }
  50. organizationService.addOrganization(name, managerId, type, superId, remarks);
  51. return res;
  52. }
  53. /**负责人自动补全查询**/
  54. @RequestMapping(value = "/selectName" , method = RequestMethod.POST)
  55. public Result selectName(String name){
  56. Result res = new Result();
  57. res.setData(organizationService.selectName(name));
  58. return res;
  59. }
  60. /**编辑页面数据读取**/
  61. @RequestMapping(value = "/selectAllById" , method = RequestMethod.POST)
  62. public OrganizationListOut selectAllById(String id){
  63. OrganizationListOut res = organizationService.selectAllById(id);
  64. return res;
  65. }
  66. /**修改信息**/
  67. @RequestMapping(value = "/updateOrganization" , method = RequestMethod.POST)
  68. public Result updateOrganization(String name, String type, String managerId, String superId, String status,
  69. String remarks,String id){
  70. Result res = new Result();
  71. if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
  72. || StringUtils.isBlank(managerId)|| StringUtils.isBlank(superId)
  73. || StringUtils.isBlank(status)|| StringUtils.isBlank(remarks)){
  74. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,""));
  75. return res;
  76. }
  77. organizationService.updateOrganization(name, type, managerId, superId, status, remarks,id);
  78. return res;
  79. }
  80. /**删除列表信息**/
  81. @RequestMapping(value = "/deleteById" , method = RequestMethod.POST)
  82. public Result deleteById(String id){
  83. Result res = new Result();
  84. if(StringUtils.isBlank(id)){
  85. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "id"));
  86. return res;
  87. }
  88. OrganizationListOut olo=organizationManagementMapper.selectAllById(id);
  89. String superId=olo.getName();
  90. int subordinate=organizationManagementMapper.selectCountBySuperId(superId);
  91. if(subordinate>0){
  92. res.getError().add(buildError("","存在下级组织不能删除"));
  93. return res;
  94. }
  95. organizationService.deleteById(id);
  96. return res;
  97. }
  98. }