PortalSearchApiController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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.AchievementService;
  9. import com.goafanti.common.bo.Result;
  10. import com.goafanti.common.constant.ErrorConstants;
  11. import com.goafanti.common.controller.BaseApiController;
  12. import com.goafanti.common.enums.UserLevel;
  13. import com.goafanti.common.enums.UserType;
  14. import com.goafanti.demand.service.DemandService;
  15. import com.goafanti.user.service.OrganizationIdentityService;
  16. import com.goafanti.user.service.UserIdentityService;
  17. @RestController
  18. @RequestMapping(value = "/portal/search")
  19. public class PortalSearchApiController extends BaseApiController {
  20. @Resource
  21. private AchievementService achievementService;
  22. @Resource
  23. private DemandService demandService;
  24. @Resource
  25. private UserIdentityService userIdentityService;
  26. @Resource
  27. private OrganizationIdentityService organizationIdentityService;
  28. /**
  29. * 科技成果搜索
  30. */
  31. @RequestMapping(value = "/achievementList", method = RequestMethod.GET)
  32. public Result achievementSearchList(Integer bargainingMode, Integer category, Integer maturity,
  33. BigDecimal transferPriceLower, BigDecimal transferPriceUpper, Integer transferMode, String keyword,
  34. Integer fieldA, Integer fieldB, String pageNo, String pageSize) {
  35. Result res = new Result();
  36. Integer pNo = 1;
  37. Integer pSize = 20;
  38. if (StringUtils.isNumeric(pageSize)) {
  39. pSize = Integer.parseInt(pageSize);
  40. }
  41. if (StringUtils.isNumeric(pageNo)) {
  42. pNo = Integer.parseInt(pageNo);
  43. }
  44. res.setData(achievementService.listAchievementSearchList(bargainingMode, category, maturity, transferPriceLower,
  45. transferPriceUpper, transferMode, keyword, fieldA, fieldB, pNo, pSize));
  46. return res;
  47. }
  48. /**
  49. * 科技需求搜索
  50. */
  51. @RequestMapping(value = "/demandList", method = RequestMethod.GET)
  52. public Result demandSearchList(String keyword, Integer industryCategoryA, Integer industryCategoryB,
  53. Integer demandType, BigDecimal budgetCostLower, BigDecimal budgetCostUpper, String pageNo,
  54. String pageSize) {
  55. Result res = new Result();
  56. Integer pNo = 1;
  57. Integer pSize = 10;
  58. if (StringUtils.isNumeric(pageSize)) {
  59. pSize = Integer.parseInt(pageSize);
  60. }
  61. if (StringUtils.isNumeric(pageNo)) {
  62. pNo = Integer.parseInt(pageNo);
  63. }
  64. res.setData(demandService.listDemandSearchList(keyword, industryCategoryA, industryCategoryB, demandType,
  65. budgetCostLower, budgetCostUpper, pNo, pSize));
  66. return res;
  67. }
  68. /**
  69. * 用户搜索
  70. */
  71. @RequestMapping(value = "/subscriberList", method = RequestMethod.GET)
  72. public Result subscriberSearchList(String name, Integer level, Integer type, String field, Integer province, Integer city,
  73. Integer area, String pageNo, String pageSize) {
  74. Result res = new Result();
  75. if (null == type) {
  76. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户类型"));
  77. return res;
  78. }
  79. if (!UserType.PERSONAL.getCode().equals(type) && !UserType.ORGANIZATION.getCode().equals(type)) {
  80. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户类型"));
  81. return res;
  82. }
  83. if (null != level && !UserLevel.GENERAL.getCode().equals(level)
  84. && !UserLevel.CERTIFIED.getCode().equals(level)) {
  85. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户认证标记"));
  86. return res;
  87. }
  88. Integer pNo = 1;
  89. Integer pSize = 12;
  90. if (StringUtils.isNumeric(pageSize)) {
  91. pSize = Integer.parseInt(pageSize);
  92. }
  93. if (StringUtils.isNumeric(pageNo)) {
  94. pNo = Integer.parseInt(pageNo);
  95. }
  96. if (UserType.PERSONAL.getCode().equals(type)) {
  97. res.setData(userIdentityService.listSubscriber(name, level, field, province, city, area, pNo, pSize));
  98. } else {
  99. res.setData(organizationIdentityService.listSubscriber(name, level, field, province, city, area, pNo, pSize));
  100. }
  101. return res;
  102. }
  103. }