AppApiController.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.goafanti.app.controller;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. import javax.annotation.Resource;
  5. import javax.servlet.http.HttpServletRequest;
  6. import org.apache.commons.lang3.StringUtils;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestMethod;
  9. import org.springframework.web.bind.annotation.RestController;
  10. import com.goafanti.achievement.service.AchievementService;
  11. import com.goafanti.activity.service.ActivityService;
  12. import com.goafanti.banners.enums.BannersType;
  13. import com.goafanti.banners.service.BannersService;
  14. import com.goafanti.common.bo.Result;
  15. import com.goafanti.common.constant.ErrorConstants;
  16. import com.goafanti.common.controller.BaseApiController;
  17. import com.goafanti.demand.service.DemandService;
  18. import com.goafanti.news.enums.NewsType;
  19. import com.goafanti.news.service.NewsService;
  20. @RestController
  21. @RequestMapping(path = "/api/open/app", method = RequestMethod.GET)
  22. public class AppApiController 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. @RequestMapping(value = "/index", method = RequestMethod.GET)
  34. public Result index(HttpServletRequest request) {
  35. Map<String, Object> result = new HashMap<>();
  36. String domainName = request.getServerName();
  37. result.put("banners", bannersService.findPortalBanners(BannersType.APP.getKey()));
  38. result.put("activities", activityService.findPortalList(0, 3, null));
  39. result.put("policies", newsService.findNewsList(0, NewsType.GJZC.getCode(), 3, domainName, true));
  40. result.put("news", newsService.findNewsList(0, NewsType.JTDT.getCode(), 5, domainName, true));
  41. return res().data(result);
  42. }
  43. /**
  44. * 科技成果详情
  45. */
  46. @RequestMapping(value = "/achievementDetail", method = RequestMethod.GET)
  47. public Result achievementDetail(String id) {
  48. Result res = new Result();
  49. if (StringUtils.isBlank(id)) {
  50. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到成果ID", "成果ID"));
  51. return res;
  52. }
  53. res.setData(achievementService.selectAchievementDetail(id));
  54. return res;
  55. }
  56. /**
  57. * 科技需求详情
  58. */
  59. @RequestMapping(value = "/demandDetail", method = RequestMethod.GET)
  60. public Result demandDetail(String id) {
  61. Result res = new Result();
  62. if (StringUtils.isBlank(id)) {
  63. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
  64. return res;
  65. }
  66. res.setData(demandService.selectDemandDetail(id));
  67. return res;
  68. }
  69. }