PortalBussinessApiController.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package com.goafanti.portal.controller;
  2. import javax.annotation.Resource;
  3. import org.apache.commons.lang3.StringUtils;
  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.achievement.service.AchievementInterestService;
  8. import com.goafanti.achievement.service.AchievementService;
  9. import com.goafanti.common.bo.Result;
  10. import com.goafanti.common.constant.ErrorConstants;
  11. import com.goafanti.common.controller.CertifyApiController;
  12. import com.goafanti.common.enums.AchievementAuditStatus;
  13. import com.goafanti.common.enums.AchievementReleaseStatus;
  14. import com.goafanti.common.enums.DeleteStatus;
  15. import com.goafanti.common.enums.DemandAuditStatus;
  16. import com.goafanti.common.enums.DemandReleaseStatus;
  17. import com.goafanti.common.model.Achievement;
  18. import com.goafanti.common.model.AchievementInterest;
  19. import com.goafanti.common.model.Demand;
  20. import com.goafanti.common.model.DemandInterest;
  21. import com.goafanti.core.shiro.token.TokenManager;
  22. import com.goafanti.demand.service.DemandInterestService;
  23. import com.goafanti.demand.service.DemandService;
  24. @RestController
  25. @RequestMapping(value = "/api/user/portal")
  26. public class PortalBussinessApiController extends CertifyApiController{
  27. @Resource
  28. private AchievementService achievementService;
  29. @Resource
  30. private DemandService demandService;
  31. @Resource
  32. private AchievementInterestService achievementInterestService;
  33. @Resource
  34. private DemandInterestService demandInterestService;
  35. /**
  36. * 科技成果"感兴趣列表"
  37. */
  38. @RequestMapping(value = "/achievementInterestList", method = RequestMethod.GET)
  39. private Result achievementInterestList(String pageNo, String pageSize) {
  40. Result res = new Result();
  41. Integer pNo = 1;
  42. Integer pSize = 10;
  43. if (StringUtils.isNumeric(pageSize)) {
  44. pSize = Integer.parseInt(pageSize);
  45. }
  46. if (StringUtils.isNumeric(pageNo)) {
  47. pNo = Integer.parseInt(pageNo);
  48. }
  49. res.setData(achievementInterestService.listAchievementInterest(pNo, pSize));
  50. return res;
  51. }
  52. /**
  53. * 科技需求取消关注
  54. *
  55. */
  56. @RequestMapping(value = "/demandCancelInterest", method = RequestMethod.POST)
  57. public Result demandCancelInterest(String id) {
  58. Result res = new Result();
  59. if (StringUtils.isBlank(id)) {
  60. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  61. return res;
  62. }
  63. res.setData(demandInterestService.saveCancelDemandInterest(id));
  64. return res;
  65. }
  66. /**
  67. * 科技需求关注
  68. */
  69. @RequestMapping(value = "/demandInterest", method = RequestMethod.POST)
  70. public Result demandInterest(String id) {
  71. Result res = new Result();
  72. if (StringUtils.isBlank(id)) {
  73. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  74. return res;
  75. }
  76. DemandInterest di = demandInterestService.selectDemandInterestByUidAndDemandId(TokenManager.getUserId(), id);
  77. if (null != di) {
  78. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "当前科技科技需求已关注!"));
  79. return res;
  80. }
  81. Demand d = demandService.selectByPrimaryKey(id);
  82. if (null == d || d.getDeletedSign().equals(DeleteStatus.DELETED.getCode())
  83. || !d.getAuditStatus().equals(DemandAuditStatus.AUDITED.getCode())
  84. || !d.getReleaseStatus().equals(DemandReleaseStatus.RELEASED.getCode())) {
  85. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  86. return res;
  87. }
  88. demandInterestService.saveAchievementInterest(id);
  89. return res;
  90. }
  91. /**
  92. * 科技成果取消关注
  93. *
  94. */
  95. @RequestMapping(value = "/achievementCancelInterest", method = RequestMethod.POST)
  96. public Result achievementCancelInterest(String id) {
  97. Result res = new Result();
  98. if (StringUtils.isBlank(id)) {
  99. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
  100. return res;
  101. }
  102. res.setData(achievementInterestService.saveCancelAchievementInterest(id));
  103. return res;
  104. }
  105. /**
  106. * 科技成果关注
  107. */
  108. @RequestMapping(value = "/achievementInterest", method = RequestMethod.POST)
  109. public Result achievementInterest(String id) {
  110. Result res = new Result();
  111. if (StringUtils.isBlank(id)) {
  112. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "科技成果ID"));
  113. return res;
  114. }
  115. AchievementInterest ai = achievementInterestService
  116. .selectAchievementInterestByUidAndAchievementId(TokenManager.getUserId(), id);
  117. if (null != ai) {
  118. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "当前科技成果已关注!"));
  119. return res;
  120. }
  121. Achievement a = achievementService.selectByPrimaryKey(id);
  122. if (null == a || a.getDeletedSign().equals(DeleteStatus.DELETED.getCode())
  123. || !a.getAuditStatus().equals(AchievementAuditStatus.AUDITED.getCode())
  124. || !a.getReleaseStatus().equals(AchievementReleaseStatus.RELEASED.getCode())) {
  125. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "成果ID"));
  126. return res;
  127. }
  128. achievementInterestService.saveAchievementInterest(id);
  129. return res;
  130. }
  131. /**
  132. * 科技成果详情
  133. */
  134. @RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
  135. public Result achievementDetail(String id) {
  136. Result res = new Result();
  137. if (StringUtils.isBlank(id)) {
  138. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
  139. return res;
  140. }
  141. res.setData(achievementService.selectAchievementSearchDetail(TokenManager.getUserId(), id));
  142. return res;
  143. }
  144. /**
  145. * 科技需求详情
  146. */
  147. @RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
  148. public Result demandDetail(String id) {
  149. Result res = new Result();
  150. if (StringUtils.isBlank(id)) {
  151. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  152. return res;
  153. }
  154. res.setData(demandService.selectDemandSearchDetail(TokenManager.getUserId(), id));
  155. return res;
  156. }
  157. }