package com.lvwang.osf.control;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.lvwang.osf.model.Event;
import com.lvwang.osf.model.Tag;
import com.lvwang.osf.model.User;
import com.lvwang.osf.service.EventService;
import com.lvwang.osf.service.FeedService;
import com.lvwang.osf.service.FollowService;
import com.lvwang.osf.service.InterestService;
import com.lvwang.osf.service.TagService;
import com.lvwang.osf.service.UserService;
import com.lvwang.osf.util.Dic;
import com.lvwang.osf.util.Property;

@Controller
@RequestMapping("/explore")
public class ExploreController {
	
	@Autowired
	@Qualifier("interestService")
	private InterestService interestService;
	
	@Autowired
	@Qualifier("tagService")
	private TagService tagService;
	
	@Autowired
	@Qualifier("feedService")
	private FeedService feedService;
	
	@Autowired
	@Qualifier("eventService")
	private EventService eventService;
	
	@Autowired
	@Qualifier("userService")
	private UserService userService;
	
	@Autowired
	@Qualifier("followService")
	private FollowService followService;
	
	@RequestMapping("")
	public ModelAndView explore(HttpSession session){
		ModelAndView mav = new ModelAndView();
		mav.setViewName("explore");
		
		User user = (User) session.getAttribute("user");
		
		mav.addObject("events", feedService.getRecommendFeeds(user==null?0:user.getId()));
		
		List<Tag> tags_recommend = tagService.getRecommendTags(user==null?0:user.getId());
		mav.addObject("tags", tags_recommend);
		mav.addObject("isInterests", interestService.hasInterestInTags(user==null?0:user.getId(), tags_recommend));
		
		List<User> rec_users = userService.getRecommendUsers(user==null?0:user.getId(), 4);
		mav.addObject("isFollowings", followService.isFollowing(user==null?0:user.getId(), rec_users));
		
		Map<User, List<Event>> feeds = new HashMap<User, List<Event>>();
		for(User rec_user: rec_users){
			feeds.put(rec_user, eventService.getEventsOfUser(rec_user.getId(), 4));
		}
		mav.addObject("feeds", feeds);
		mav.addObject("dic", new Dic());
		return mav;
	}
	
}
最近下载更多
微笑刺客  LV21 2024年11月24日
goccgoccgocc  LV4 2024年5月23日
烟橙沐雨  LV1 2024年3月21日
hosinvm  LV7 2022年11月18日
dfsfvsr  LV2 2022年11月8日
疯子庭  LV8 2022年10月10日
1140215796  LV6 2022年8月28日
是anan呀  LV2 2022年7月7日
wbg_TS  LV1 2022年7月7日
wei_471416461  LV1 2022年6月25日
最近浏览更多
Daima000  LV4 2024年12月3日
微笑刺客  LV21 2024年11月24日
1481421104  LV3 2024年11月14日
dongandmin  LV8 2024年11月13日
goccgoccgocc  LV4 2024年5月9日
2860615178  LV4 2024年5月2日
烟橙沐雨  LV1 2024年3月21日
3334004690  LV10 2024年3月6日
2890892945  LV2 2023年12月31日
空中飞尘  LV13 2023年11月25日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友