AdminAuditApiController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package com.goafanti.admin.controller;
  2. import javax.annotation.Resource;
  3. import org.springframework.web.bind.annotation.RequestMapping;
  4. import org.springframework.web.bind.annotation.RequestMethod;
  5. import org.springframework.web.bind.annotation.RestController;
  6. import com.goafanti.achievement.service.AchievementService;
  7. import com.goafanti.admin.service.AdminService;
  8. import com.goafanti.common.bo.Result;
  9. import com.goafanti.common.constant.ErrorConstants;
  10. import com.goafanti.common.controller.CertifyApiController;
  11. import com.goafanti.common.enums.AchievementAuditStatus;
  12. import com.goafanti.common.enums.DemandAuditStatus;
  13. import com.goafanti.common.model.Achievement;
  14. import com.goafanti.common.model.Demand;
  15. import com.goafanti.common.utils.StringUtils;
  16. import com.goafanti.demand.service.DemandService;
  17. @RestController
  18. @RequestMapping(value = "/api/admin/audit")
  19. public class AdminAuditApiController extends CertifyApiController {
  20. @Resource
  21. private AdminService adminService;
  22. @Resource
  23. private DemandService demandService;
  24. @Resource
  25. private AchievementService achievementService;
  26. /**
  27. * 获取技术经纪人下拉
  28. */
  29. @RequestMapping(value = "/techBroders", method = RequestMethod.GET)
  30. public Result getTechBroders() {
  31. Result res = new Result();
  32. res.setData(adminService.selectTechBroder());
  33. return res;
  34. }
  35. /**
  36. * 审核科技需求
  37. */
  38. @RequestMapping(value = "/demand", method = RequestMethod.POST)
  39. public Result demand(String id, String techBroderId, Integer auditStatus) {
  40. Result res = new Result();
  41. res = disposeDmandAchievement(res, "demand", id, techBroderId, auditStatus);
  42. if (!res.getError().isEmpty()) {
  43. return res;
  44. }
  45. Demand d = demandService.selectByPrimaryKey(id);
  46. if (null == d) {
  47. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  48. return res;
  49. }
  50. if (!DemandAuditStatus.INAUDIT.getCode().equals(d.getAuditStatus())) {
  51. res.getError().add(buildError("", "当前需求状态无法审核!"));
  52. return res;
  53. }
  54. res.setData(demandService.updateAuditDemand(d, techBroderId, auditStatus));
  55. return res;
  56. }
  57. /**
  58. * 审核科技成果
  59. */
  60. @RequestMapping(value = "/achievement", method = RequestMethod.POST)
  61. public Result achievement(String id, String techBroderId, Integer auditStatus) {
  62. Result res = new Result();
  63. res = disposeDmandAchievement(res, "achievement", id, techBroderId, auditStatus);
  64. if (!res.getError().isEmpty()) {
  65. return res;
  66. }
  67. Achievement a = achievementService.selectByPrimaryKey(id);
  68. if (null == a) {
  69. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "成果ID"));
  70. return res;
  71. }
  72. if (!AchievementAuditStatus.INAUDIT.getCode().equals(a.getAuditStatus())) {
  73. res.getError().add(buildError("", "当前成果状态无法审核!"));
  74. return res;
  75. }
  76. res.setData(achievementService.updateAuditAchievement(a, techBroderId, auditStatus));
  77. return res;
  78. }
  79. private Result disposeDmandAchievement(Result res, String sign, String id, String techBroderId,
  80. Integer auditStatus) {
  81. if (StringUtils.isBlank(id)) {
  82. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  83. return res;
  84. }
  85. if (null == auditStatus) {
  86. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到审核状态", "审核状态"));
  87. return res;
  88. }
  89. if (sign.equals("demand")) {
  90. if (!DemandAuditStatus.AUDITED.getCode().equals(auditStatus)
  91. && !DemandAuditStatus.UNAUDITED.getCode().equals(auditStatus)) {
  92. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "审核状态"));
  93. return res;
  94. }
  95. if (DemandAuditStatus.AUDITED.getCode().equals(auditStatus)) {
  96. if (StringUtils.isBlank(techBroderId)) {
  97. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到技术经纪人", "技术经纪人"));
  98. return res;
  99. }
  100. }
  101. } else {
  102. if (!AchievementAuditStatus.AUDITED.getCode().equals(auditStatus)
  103. && !AchievementAuditStatus.UNAUDITED.getCode().equals(auditStatus)) {
  104. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "审核状态"));
  105. return res;
  106. }
  107. if (AchievementAuditStatus.AUDITED.getCode().equals(auditStatus)) {
  108. if (StringUtils.isBlank(techBroderId)) {
  109. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到技术经纪人", "技术经纪人"));
  110. return res;
  111. }
  112. }
  113. }
  114. return res;
  115. }
  116. }