PortalSearchApiController.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. package com.goafanti.portal.controller;
  2. import java.math.BigDecimal;
  3. import javax.annotation.Resource;
  4. import org.apache.commons.lang3.StringUtils;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestMethod;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.goafanti.achievement.service.AchievementInterestService;
  9. import com.goafanti.achievement.service.AchievementService;
  10. import com.goafanti.common.bo.Result;
  11. import com.goafanti.common.constant.ErrorConstants;
  12. import com.goafanti.common.controller.BaseApiController;
  13. import com.goafanti.common.enums.AchievementAuditStatus;
  14. import com.goafanti.common.enums.AchievementReleaseStatus;
  15. import com.goafanti.common.enums.DeleteStatus;
  16. import com.goafanti.common.enums.DemandAuditStatus;
  17. import com.goafanti.common.enums.DemandReleaseStatus;
  18. import com.goafanti.common.model.Achievement;
  19. import com.goafanti.common.model.AchievementInterest;
  20. import com.goafanti.common.model.Demand;
  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 = "/portal/search")
  26. public class PortalSearchApiController extends BaseApiController {
  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. Demand d = demandService.selectByPrimaryKey(id);
  77. if (null == d || d.getDeletedSign().equals(DeleteStatus.DELETED.getCode())
  78. || !d.getAuditStatus().equals(DemandAuditStatus.AUDITED.getCode())
  79. || !d.getReleaseStatus().equals(DemandReleaseStatus.UNRELEASE.getCode())) {
  80. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
  81. return res;
  82. }
  83. demandInterestService.saveAchievementInterest(id);
  84. return res;
  85. }
  86. /**
  87. * 科技成果取消关注
  88. *
  89. */
  90. @RequestMapping(value = "/achievementCancelInterest", method = RequestMethod.POST)
  91. public Result achievementCancelInterest(String id) {
  92. Result res = new Result();
  93. if (StringUtils.isBlank(id)) {
  94. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
  95. return res;
  96. }
  97. res.setData(achievementInterestService.saveCancelAchievementInterest(id));
  98. return res;
  99. }
  100. /**
  101. * 科技成果关注
  102. */
  103. @RequestMapping(value = "/achievementInterest", method = RequestMethod.POST)
  104. public Result achievementInterest(String id) {
  105. Result res = new Result();
  106. if (StringUtils.isBlank(id)) {
  107. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "科技成果ID"));
  108. return res;
  109. }
  110. Achievement a = achievementService.selectByPrimaryKey(id);
  111. if (null == a || a.getDeletedSign().equals(DeleteStatus.DELETED.getCode())
  112. || !a.getAuditStatus().equals(AchievementAuditStatus.AUDITED.getCode())
  113. || !a.getReleaseStatus().equals(AchievementReleaseStatus.RELEASED.getCode())) {
  114. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "成果ID"));
  115. return res;
  116. }
  117. AchievementInterest ai = achievementInterestService
  118. .selectAchievementInterestByUidAndAchievementId(TokenManager.getUserId(), id);
  119. if (null != ai){
  120. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "当前科技成果已关注!"));
  121. return res;
  122. }
  123. achievementInterestService.saveAchievementInterest(id);
  124. return res;
  125. }
  126. /**
  127. * 科技成果搜索
  128. */
  129. @RequestMapping(value = "/achievementList", method = RequestMethod.GET)
  130. public Result achievementSearchList(Integer bargainingMode, Integer category, Integer maturity,
  131. BigDecimal transferPriceLower, BigDecimal transferPriceUpper, Integer transferMode, String keyword,
  132. Integer fieldA, Integer fieldB, String pageNo, String pageSize) {
  133. Result res = new Result();
  134. Integer pNo = 1;
  135. Integer pSize = 10;
  136. if (StringUtils.isNumeric(pageSize)) {
  137. pSize = Integer.parseInt(pageSize);
  138. }
  139. if (StringUtils.isNumeric(pageNo)) {
  140. pNo = Integer.parseInt(pageNo);
  141. }
  142. res.setData(achievementService.listAchievementSearchList(bargainingMode, category, maturity, transferPriceLower,
  143. transferPriceUpper, transferMode, keyword, fieldA, fieldB, pNo, pSize));
  144. return res;
  145. }
  146. /**
  147. * 科技需求搜索
  148. */
  149. @RequestMapping(value = "/demandList", method = RequestMethod.GET)
  150. public Result demandSerarchList(String keyword, Integer industryCategoryA, Integer industryCategoryB,
  151. Integer demandType, BigDecimal budgetCostLower, BigDecimal budgetCostUpper, String pageNo,
  152. String pageSize) {
  153. Result res = new Result();
  154. Integer pNo = 1;
  155. Integer pSize = 10;
  156. if (StringUtils.isNumeric(pageSize)) {
  157. pSize = Integer.parseInt(pageSize);
  158. }
  159. if (StringUtils.isNumeric(pageNo)) {
  160. pNo = Integer.parseInt(pageNo);
  161. }
  162. res.setData(demandService.listDemandSearchList(keyword, industryCategoryA, industryCategoryB, demandType,
  163. budgetCostLower, budgetCostUpper, pNo, pSize));
  164. return res;
  165. }
  166. /**
  167. * 科技成果详情
  168. */
  169. @RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
  170. public Result achievementDetail(String id) {
  171. Result res = new Result();
  172. if (StringUtils.isBlank(id)) {
  173. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
  174. return res;
  175. }
  176. res.setData(achievementService.selectAchievementSearchDetail(TokenManager.getUserId(), id));
  177. return res;
  178. }
  179. /**
  180. * 科技需求详情
  181. */
  182. @RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
  183. public Result demandDetail(String id) {
  184. Result res = new Result();
  185. if (StringUtils.isBlank(id)) {
  186. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  187. return res;
  188. }
  189. res.setData(demandService.selectDemandSearchDetail(TokenManager.getUserId(), id));
  190. return res;
  191. }
  192. }