AdminOrganizationController.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package com.goafanti.organization.controller;
  2. import com.goafanti.common.bo.Result;
  3. import com.goafanti.common.constant.ErrorConstants;
  4. import com.goafanti.common.controller.BaseApiController;
  5. import com.goafanti.common.dao.DepartmentMapper;
  6. import com.goafanti.common.utils.StringUtils;
  7. import com.goafanti.organization.bo.OrganizationListOut;
  8. import com.goafanti.organization.service.OrganizationService;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.RequestMethod;
  12. import org.springframework.web.bind.annotation.RestController;
  13. import javax.annotation.Resource;
  14. @RestController
  15. @RequestMapping("/api/admin/organization")
  16. public class AdminOrganizationController extends BaseApiController{
  17. @Resource
  18. private OrganizationService organizationService;
  19. @Autowired
  20. private DepartmentMapper departmentMapper;
  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 = "/getAllDep" , method = RequestMethod.GET)
  31. public Result getAllDep(Integer hideSign){
  32. Result res = new Result();
  33. res.setData(organizationService.getAllDep(hideSign));
  34. return res;
  35. }
  36. /**获取所有部门 **/
  37. @RequestMapping(value = "/selectSuperId" , method = RequestMethod.GET)
  38. public Result selectSuperId(Integer hideSign){
  39. Result res = new Result();
  40. res.setData(organizationService.selectSuperId(hideSign));
  41. return res;
  42. }
  43. /**部门组织管理上级组织查询 **/
  44. @RequestMapping(value = "/selectSuperIdS" , method = RequestMethod.GET)
  45. public Result selectsuperIdS(){
  46. Result res = new Result();
  47. res.setData(organizationService.selectSuperId(1));
  48. return res;
  49. }
  50. /**部门组织管理新增**/
  51. @RequestMapping(value = "/addOrganization" , method = RequestMethod.POST)
  52. public Result addOrganization(String name, String managerId, String type, String superId, String remarks,
  53. Integer workingHoursType,Integer hideSign,String depNo) {
  54. Result res = new Result();
  55. if(StringUtils.isBlank(name) || StringUtils.isBlank(type) || StringUtils.isBlank(superId)||StringUtils.isBlank(depNo)){
  56. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"",""));
  57. return res;
  58. }
  59. String olo=departmentMapper.selectDepNoByName(name);
  60. if(olo!=null){
  61. res.getError().add(buildError("","部门已存在"));
  62. return res;
  63. }
  64. if (organizationService.checkDepNo(depNo,0)){
  65. res.getError().add(buildError("","部门编号已存在"));
  66. return res;
  67. }
  68. organizationService.addOrganization(name, managerId, type, superId, remarks,workingHoursType,hideSign,depNo);
  69. return res;
  70. }
  71. /**负责人自动补全查询**/
  72. @RequestMapping(value = "/selectName" , method = RequestMethod.POST)
  73. public Result selectName(String name){
  74. Result res = new Result();
  75. res.setData(organizationService.selectName(name));
  76. return res;
  77. }
  78. /**编辑页面数据读取**/
  79. @RequestMapping(value = "/selectAllById" , method = RequestMethod.POST)
  80. public Result selectAllById(String id){
  81. Result res = new Result();
  82. res.data(organizationService.selectAllById(id));
  83. return res;
  84. }
  85. /**
  86. * 修改部门信息
  87. **/
  88. @RequestMapping(value = "/updateOrganization" , method = RequestMethod.POST)
  89. public Result updateOrganization(String name, String type, String managerId, String superId, String status,Integer province,String retrialFinanceId,
  90. String remarks,String id,String abbreviation,String financeId,Integer workingHoursType,
  91. Integer hideSign,String depNo,Integer approval,String approvalAid){
  92. Result res = new Result();
  93. if(StringUtils.isBlank(name) || StringUtils.isBlank(type)
  94. || StringUtils.isBlank(managerId)|| StringUtils.isBlank(superId)
  95. || StringUtils.isBlank(status)|| StringUtils.isBlank(remarks)|| StringUtils.isBlank(depNo)){
  96. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"",""));
  97. return res;
  98. }
  99. if (id ==superId){
  100. res.getError().add(buildError("不能设置自己为上级"));
  101. return res;
  102. }
  103. if (organizationService.checkDepNo(depNo,1)){
  104. res.getError().add(buildError("","部门编号已存在"));
  105. return res;
  106. }
  107. if (approval==null||(approval==1&&StringUtils.isBlank(approvalAid))){
  108. res.getError().add(buildError("特批审核开启必须设置特批人"));
  109. return res;
  110. }
  111. int i=organizationService.updateOrganization(name, type, managerId, superId, status, province,
  112. retrialFinanceId,remarks,id, abbreviation,financeId,workingHoursType,hideSign,depNo, approval, approvalAid);
  113. return res.data(i);
  114. }
  115. /**删除列表信息**/
  116. @RequestMapping(value = "/deleteById" , method = RequestMethod.POST)
  117. public Result deleteById(String id){
  118. Result res = new Result();
  119. if(StringUtils.isBlank(id)){
  120. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "id"));
  121. return res;
  122. }
  123. /*OrganizationListOut olo=departmentMapper.selectAllById(id);
  124. String superId=olo.getName();*/
  125. int subordinate=departmentMapper.selectCountBySuperId(id);
  126. if(subordinate>0){
  127. res.getError().add(buildError("","存在下级组织不能删除"));
  128. return res;
  129. }
  130. int adminCount=departmentMapper.selectUserById(id);
  131. if(adminCount>0){
  132. res.getError().add(buildError("","部门被用户选定不能删除"));
  133. return res;
  134. }
  135. organizationService.deleteById(id);
  136. return res;
  137. }
  138. }