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;
	}
	
}
最近下载更多
烟橙沐雨  LV1 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日
shen14755  LV3 2022年6月7日
testuser1234567  LV24 2022年5月23日
最近浏览更多
烟橙沐雨  LV1 3月21日
3334004690  LV3 3月6日
2890892945  LV2 2023年12月31日
空中飞尘  LV13 2023年11月25日
chenlie  LV2 2023年11月21日
微信网友_6743761691316224 2023年11月20日
暂无贡献等级
微信网友_6641066057273344  LV1 2023年10月27日
irivn007  LV15 2023年10月19日
新工艺  LV7 2023年6月12日
1455384106  LV2 2023年5月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友