AppAchievementDemandController.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package com.goafanti.app.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.AchievementInterestService;
  7. import com.goafanti.achievement.service.AchievementService;
  8. import com.goafanti.activity.service.ActivityService;
  9. import com.goafanti.banners.service.BannersService;
  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.utils.StringUtils;
  14. import com.goafanti.core.shiro.token.TokenManager;
  15. import com.goafanti.demand.service.DemandService;
  16. import com.goafanti.news.service.NewsService;
  17. import com.goafanti.user.service.UserCareerService;
  18. import com.goafanti.user.service.UserIdentityService;
  19. import com.goafanti.user.service.UserInterestService;
  20. @RestController
  21. @RequestMapping(path = "/open/api/open/achievementDemand", method = RequestMethod.GET)
  22. public class AppAchievementDemandController extends BaseApiController {
  23. @Resource
  24. private BannersService bannersService;
  25. @Resource
  26. private ActivityService activityService;
  27. @Resource
  28. private NewsService newsService;
  29. @Resource
  30. private AchievementService achievementService;
  31. @Resource
  32. private DemandService demandService;
  33. @Resource
  34. private UserCareerService userCareerService;
  35. @Resource
  36. private UserInterestService userInterestService;
  37. @Resource
  38. private UserIdentityService userIdentityService;
  39. @Resource
  40. AchievementInterestService achievementInterestService;
  41. /**
  42. * 关注功能
  43. */
  44. @RequestMapping(value = "/interestAdd", method = RequestMethod.GET)
  45. public Result Addinterest( Integer type,String objectId,String interest) {
  46. Result res = new Result();
  47. if (null==type) {
  48. res.getError().add(buildError( "分类错误!", "分类错误"));
  49. return res;
  50. }
  51. String uid=null;
  52. if (StringUtils.isNotBlank(TokenManager.getUserId())) {
  53. uid=TokenManager.getUserId();
  54. }
  55. if (Integer.valueOf(interest)==0) {
  56. res.setData(achievementInterestService.saveInterest( uid, type, objectId,interest));
  57. }else {
  58. res.setData(achievementInterestService.deleteInterest( uid, type, objectId,interest));
  59. }
  60. return res;
  61. }
  62. /**
  63. * 我的成果
  64. */
  65. @RequestMapping(value = "/achievementList", method = RequestMethod.GET)
  66. private Result achievementList(String pageNo, String pageSize) {
  67. Result res = new Result();
  68. Integer pNo = 1;
  69. Integer pSize = 10;
  70. if (StringUtils.isNumeric(pageSize)) {
  71. pSize = Integer.parseInt(pageSize);
  72. }
  73. if (StringUtils.isNumeric(pageNo)) {
  74. pNo = Integer.parseInt(pageNo);
  75. }
  76. res.setData(achievementService.listAppMyAchievement(pNo, pSize));
  77. return res;
  78. }
  79. /**
  80. * 我的需求
  81. */
  82. @RequestMapping(value = "/demandList", method = RequestMethod.GET)
  83. public Result demandList(String pageNo, String pageSize) {
  84. Result res = new Result();
  85. Integer pNo = 1;
  86. Integer pSize = 10;
  87. if (StringUtils.isNumeric(pageSize)) {
  88. pSize = Integer.parseInt(pageSize);
  89. }
  90. if (StringUtils.isNumeric(pageNo)) {
  91. pNo = Integer.parseInt(pageNo);
  92. }
  93. res.setData(demandService.listMyDemand( pNo, pSize));
  94. return res;
  95. }
  96. /**
  97. * 关注列表
  98. */
  99. @RequestMapping(value = "/interestList", method = RequestMethod.GET)
  100. public Result interestList(Integer type,String pageNo, String pageSize) {
  101. Result res = new Result();
  102. Integer pNo = 1;
  103. Integer pSize = 10;
  104. if (null==type||type<0||type>5) {
  105. res.getError().add(buildError( "类型选择错误", "类型选择错误"));
  106. }
  107. if (StringUtils.isNumeric(pageSize)) {
  108. pSize = Integer.parseInt(pageSize);
  109. }
  110. if (StringUtils.isNumeric(pageNo)) {
  111. pNo = Integer.parseInt(pageNo);
  112. }
  113. res.setData(demandService.selectinterest(type, pNo, pSize));
  114. return res;
  115. }
  116. /**
  117. * 专家详情
  118. */
  119. @RequestMapping(value = "/expertsDetail", method = RequestMethod.GET)
  120. public Result expertsDetail(String uid) {
  121. Result res = new Result();
  122. if (StringUtils.isBlank(uid)) {
  123. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"专家必须指定","专家"));
  124. return res;
  125. }
  126. res.setData(userIdentityService.expertsDetail( uid));
  127. return res;
  128. }
  129. /**
  130. * 成果详情
  131. * @param id
  132. * @return
  133. */
  134. @RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
  135. private Result userDetail(String id ) {
  136. Result res = new Result();
  137. if (StringUtils.isBlank(id)) {
  138. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"成果必须指定","成果"));
  139. return res;
  140. }
  141. res.setData(achievementService.selectAppUserOwnerDetail(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,"需求必须指定","需求"));
  152. return res;
  153. }
  154. res.setData(demandService.selectDemandDetail( id));
  155. return res;
  156. }
  157. }