UserPartnerApiController.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package com.goafanti.user.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.common.bo.Result;
  8. import com.goafanti.common.constant.ErrorConstants;
  9. import com.goafanti.common.controller.CertifyApiController;
  10. import com.goafanti.common.enums.UserType;
  11. import com.goafanti.common.utils.StringUtils;
  12. import com.goafanti.demand.service.DemandService;
  13. import com.goafanti.user.service.UserService;
  14. @RestController
  15. @RequestMapping(value = "/api/user/partner")
  16. public class UserPartnerApiController extends CertifyApiController {
  17. @Resource
  18. private UserService userService;
  19. @Resource
  20. private DemandService demandService;
  21. @Resource
  22. private AchievementService achievementService;
  23. /**
  24. * "伙伴"主页详情
  25. */
  26. @RequestMapping(value = "/detail", method = RequestMethod.GET)
  27. public Result detail(String uid, Integer type) {
  28. Result res = new Result();
  29. if (StringUtils.isBlank(uid)) {
  30. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户ID"));
  31. return res;
  32. }
  33. if (null == type) {
  34. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "用户类型"));
  35. return res;
  36. }
  37. if (!UserType.PERSONAL.getCode().equals(type) && !UserType.ORGANIZATION.getCode().equals(type)) {
  38. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "用户类型"));
  39. return res;
  40. }
  41. if (UserType.PERSONAL.getCode().equals(type)) {
  42. res.setData(userService.findUserPartnerDetail(uid));
  43. } else {
  44. res.setData(userService.findOrgPartnerDetail(uid));
  45. }
  46. return res;
  47. }
  48. /**
  49. * "伙伴"主页--科技需求列表
  50. */
  51. @RequestMapping(value = "/demandList", method = RequestMethod.GET)
  52. public Result demandList(String employerId, String pageNo, String pageSize) {
  53. Result res = new Result();
  54. if (StringUtils.isBlank(employerId)){
  55. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "employerId"));
  56. return res;
  57. }
  58. Integer pNo = 1;
  59. Integer pSize = 10;
  60. if (StringUtils.isNumeric(pageSize)) {
  61. pSize = Integer.parseInt(pageSize);
  62. }
  63. if (StringUtils.isNumeric(pageNo)) {
  64. pNo = Integer.parseInt(pageNo);
  65. }
  66. res.setData(demandService.lisePartnerDemand(employerId, pNo, pSize));
  67. return res;
  68. }
  69. /**
  70. * "伙伴"主页--科技成果列表
  71. */
  72. @RequestMapping(value = "/achievementList", method = RequestMethod.GET)
  73. public Result achievementList(String ownerId, String pageNo, String pageSize){
  74. Result res = new Result();
  75. if (StringUtils.isBlank(ownerId)){
  76. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "ownerId"));
  77. return res;
  78. }
  79. Integer pNo = 1;
  80. Integer pSize = 10;
  81. if (StringUtils.isNumeric(pageSize)) {
  82. pSize = Integer.parseInt(pageSize);
  83. }
  84. if (StringUtils.isNumeric(pageNo)) {
  85. pNo = Integer.parseInt(pageNo);
  86. }
  87. res.setData(achievementService.listPartnerAchievement(ownerId, pNo, pSize));
  88. return res;
  89. }
  90. }