PortalBigShotController.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.goafanti.portal.controller;
  2. import java.util.List;
  3. import javax.annotation.Resource;
  4. import org.apache.commons.lang3.StringUtils;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RequestMethod;
  8. import org.springframework.web.bind.annotation.ResponseBody;
  9. import org.springframework.web.servlet.ModelAndView;
  10. import com.goafanti.banners.enums.BannersType;
  11. import com.goafanti.banners.service.BannersService;
  12. import com.goafanti.common.bo.Result;
  13. import com.goafanti.common.constant.AFTConstants;
  14. import com.goafanti.common.controller.BaseController;
  15. import com.goafanti.common.model.Banners;
  16. import com.goafanti.common.model.User;
  17. import com.goafanti.core.shiro.token.TokenManager;
  18. import com.goafanti.star.bo.BigShotStarListBo;
  19. import com.goafanti.star.service.StarService;
  20. import com.goafanti.user.service.UserInterestService;
  21. /**
  22. * 大咖说
  23. */
  24. @Controller
  25. public class PortalBigShotController extends BaseController {
  26. @Resource
  27. private StarService starService;
  28. @Resource
  29. private UserInterestService userInterestService;
  30. @Resource
  31. private BannersService bannersService;
  32. @RequestMapping(value = "/portal/scienceTechnology/bigShot", method = RequestMethod.GET)
  33. public ModelAndView bigShot() {
  34. ModelAndView mv = new ModelAndView();
  35. List<BigShotStarListBo> starList = starService.listBigShotStar(AFTConstants.BIG_SHOT_STAR_CACHE_KEY);
  36. if (null != starList && starList.size() > 0) {
  37. for (BigShotStarListBo bo : starList) {
  38. if (StringUtils.isNotBlank(bo.getUid())) {
  39. bo.setFansNum(userInterestService.countByToUid(bo.getUid()));
  40. }
  41. if (StringUtils.isNotBlank(bo.getEngagedField())) {
  42. String engagedField = "";
  43. String[] arr = bo.getEngagedField().split(",|,");
  44. if (null != arr && arr.length > 0) {
  45. for (String s : arr) {
  46. if (StringUtils.isNumeric(s)) {
  47. /*engagedField += engagedFieldGlossoryService.selectByPrimaryKey(Integer.parseInt(s))
  48. .getName();*/
  49. }
  50. }
  51. }
  52. bo.setEngagedField(engagedField);
  53. }
  54. }
  55. mv.addObject("starList", starList);
  56. }
  57. handleBanners(mv, BannersType.DA_KA_SHUO_1, "banners");
  58. handleBanners(mv, BannersType.DA_KA_SHUO_2, "starBanners");
  59. handleBanners(mv, BannersType.DA_KA_SHUO_3, "actBanners");
  60. mv.setViewName("/portal/scienceTechnology/bigShot");
  61. return mv;
  62. }
  63. /**
  64. * 关注状态
  65. */
  66. @RequestMapping(value = "/portal/scienceTechnology/bigShot/interestStatus", method = RequestMethod.GET)
  67. @ResponseBody
  68. public Result interestStatus() {
  69. Result res = new Result();
  70. if (TokenManager.getToken() instanceof User) {
  71. res.setData(starService.findBigShotInterestStatus(TokenManager.getUserId()));
  72. }
  73. return res;
  74. }
  75. private void handleBanners(ModelAndView modelview, BannersType bannersType, String name) {
  76. List<Banners> banners = bannersService.findPortalBanners(bannersType.getKey());
  77. if (!banners.isEmpty()) {
  78. modelview.addObject(name, banners);
  79. }
  80. }
  81. }