use of com.po.Movie in project Movie by batsqd.
the class MovieController method getRecommendedMoviesByOurAlgorithm.
/////////////////////////////////////////////////////
@RequestMapping("getRecommendedMoviesByOurAlgorithm.action")
public ModelAndView getRecommendedMoviesByOurAlgorithm(HttpSession session) throws Exception {
User user = (User) session.getAttribute("user");
int user_id = user.getUserid();
int recommend_movie_num = Configs.recommend_movie_num;
ApplicationContext ac = ApplicationContextUtil.getApplicationContext();
WatchMovieMapper watchMovieMapper = (WatchMovieMapper) ac.getBean("watchMovieMapper");
int numsOfRatedMoviesByUserId = watchMovieMapper.numsOfRatedMoviesByUserId(user_id);
ModelAndView modelAndView = new ModelAndView();
if (numsOfRatedMoviesByUserId < 5) {
modelAndView.addObject("numsOfRatedMoviesByUserId", numsOfRatedMoviesByUserId);
modelAndView.setViewName("/WEB-INF/jsp/guessYouLike.jsp");
return modelAndView;
} else {
//超过5人评价,才做预测
ImproveSlopeOne improveSlopeOne = new ImproveSlopeOne();
List<RecommendedMovie> recommendedMovieslist = improveSlopeOne.getPredictMovies(user_id, recommend_movie_num);
//System.out.println("=========================================");
//System.out.println("推荐电影的数量:"+recommendedMovieslist.size());
//System.out.println(recommendedMovieslist.toString());
//System.out.println("==========================================");
MovieMapper movieMapper = (MovieMapper) ac.getBean("movieMapper");
RecommendMapper recommendMapper = (RecommendMapper) ac.getBean("recommendMapper");
ArrayList<Movie> moviesList = new ArrayList<Movie>();
for (int i = 0; i < recommendedMovieslist.size(); i++) {
double movie_recommend_value = recommendedMovieslist.get(i).getRecommend_vale();
int recommendedMovie_id = recommendedMovieslist.get(i).getMovie_id();
HashMap<String, Object> parameter = new HashMap<String, Object>();
parameter.put("movie_id", recommendedMovie_id);
parameter.put("user_id", user_id);
parameter.put("recommend_value", movie_recommend_value);
//最好处理下异常
//只是保存user_id movie_id recommend_value timestamp
recommendMapper.saveRecommendedMovies(parameter);
Movie movie = movieMapper.selectMovieById(recommendedMovie_id);
if (movie != null) {
moviesList.add(movie);
}
}
modelAndView.addObject("moviesList", moviesList);
modelAndView.setViewName("/WEB-INF/jsp/guessYouLike.jsp");
return modelAndView;
}
}
use of com.po.Movie in project Movie by batsqd.
the class MovieController method queryMovies.
@RequestMapping("/queryMovies.action")
public ModelAndView queryMovies() {
ArrayList<Movie> moviesList = new ArrayList<Movie>();
ApplicationContext ac = ApplicationContextUtil.getApplicationContext();
MovieMapper movieMapper = (MovieMapper) ac.getBean("movieMapper");
Movie movie = movieMapper.selectMovieById(1);
moviesList.add(movie);
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("moviesList", moviesList);
modelAndView.setViewName("/WEB-INF/jsp/movie.jsp");
return modelAndView;
}
use of com.po.Movie in project Movie by batsqd.
the class SearchMovieController method showSearchContent.
@RequestMapping("/showSearchContent.action")
public ModelAndView showSearchContent(String keyWord) throws UnsupportedEncodingException {
//防止中文乱码
String decode_keyWord = URLDecoder.decode(keyWord, "UTF-8");
System.out.println("decode_keyWord" + decode_keyWord);
System.out.println("keyWord" + keyWord);
ModelAndView modelAndView = new ModelAndView();
MovieInfoService movieInfoService = new MovieInfoService();
ArrayList<Movie> moviesList = new ArrayList<Movie>();
int pageCount = 0;
if (decode_keyWord != null) {
//search box提交的请求
moviesList = movieInfoService.getMoviesBySearchKeyWordToPage(decode_keyWord, 0, 12);
pageCount = movieInfoService.getPageCountByKeyWord(12, decode_keyWord);
}
if (pageCount > 1) {
//此时有下一页
modelAndView.addObject("navigation", "<a href='http://yuanzhiyuan-pc:8080/Movie/getSearchMovieByPage.action?pageNow=1&keyWord=" + URLEncoder.encode(URLEncoder.encode(decode_keyWord, "UTF-8"), "UTF-8") + "'>下一页</a>" + " 共" + pageCount + "页!");
}
modelAndView.addObject("moviesList", moviesList);
modelAndView.setViewName("/WEB-INF/jsp/ShowSearchResult.jsp");
return modelAndView;
}
use of com.po.Movie in project Movie by batsqd.
the class SearchMovieController method getSearchMovieByPage.
@RequestMapping("/getSearchMovieByPage.action")
public ModelAndView getSearchMovieByPage(int pageNow, String keyWord) throws UnsupportedEncodingException {
int pageSize = 12;
int pageCount = 1;
int begain = 0;
int end = 5;
begain = (pageNow) * pageSize;
end = begain + pageSize;
//防止中文乱码
String decode_keyWord = URLDecoder.decode(keyWord, "UTF-8");
MovieInfoService movieInfoService = new MovieInfoService();
ArrayList<Movie> moviesList = movieInfoService.getMoviesBySearchKeyWordToPage(decode_keyWord, begain, end);
pageCount = movieInfoService.getPageCountByKeyWord(pageSize, decode_keyWord);
ModelAndView modelAndView = new ModelAndView();
String navigationUrlPre = "";
String navigationUrlNext = "";
if (pageNow < 1) {
//没有上一页;
navigationUrlPre = "";
} else {
//有上一页
navigationUrlPre = "<a href='http://yuanzhiyuan-pc:8080/Movie/getSearchMovieByPage.action?pageNow=" + (pageNow - 1) + "&keyWord=" + URLEncoder.encode(URLEncoder.encode(decode_keyWord, "UTF-8"), "UTF-8") + "'>上一页</a>";
}
if (pageNow + 1 < pageCount) {
//有下一页
navigationUrlNext = "<a href='http://yuanzhiyuan-pc:8080/Movie/getSearchMovieByPage.action?pageNow=" + (pageNow + 1) + "&keyWord=" + URLEncoder.encode(URLEncoder.encode(decode_keyWord, "UTF-8"), "UTF-8") + "'>下一页</a>";
} else {
//没有下一页
navigationUrlNext = "";
}
modelAndView.addObject("moviesList", moviesList);
modelAndView.addObject("navigation", "当前为第" + (pageNow + 1) + "页 " + navigationUrlPre + " " + navigationUrlNext + " " + " 共" + pageCount + "页!");
modelAndView.setViewName("/WEB-INF/jsp/ShowSearchResult.jsp");
return modelAndView;
}
use of com.po.Movie in project Movie by batsqd.
the class FrameController method showRomance.
@RequestMapping("/romance.action")
public ModelAndView showRomance(String type, String genres) {
//type指的是按照流派,按照发行时间,按照评分
ModelAndView modelAndView = new ModelAndView();
MovieInfoService movieInfoService = new MovieInfoService();
ArrayList<Movie> moviesList = new ArrayList<Movie>();
int pageCount = 0;
if ("byGenres".equals(type)) {
moviesList = movieInfoService.getMoviesByGenresToPage(genres, 0, 12);
pageCount = movieInfoService.getPageCountByGenres(12, genres);
} else if ("byReleaseTime".equals(type)) {
//此处按发布时间指的是按照Romance类别中电影的发布时间顺序
moviesList = movieInfoService.getMoviesOrderByReleaseTimeToPage(genres, 0, 12);
pageCount = movieInfoService.getPageCountByGenres(12, genres);
} else if ("byRating".equals(type)) {
moviesList = movieInfoService.getMoviesOrderByRatingToPage(genres, 0, 12);
pageCount = movieInfoService.getPageCountByGenres(12, genres);
}
if (pageCount > 1) {
//此时有下一页
modelAndView.addObject("navigation", "<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow=1&type=" + type + "&genres=" + genres + "'>下一页</a>" + " 共" + pageCount + "页!");
}
modelAndView.addObject("genres", genres);
modelAndView.addObject("moviesList", moviesList);
//genres=romance,所有的类型都可以调到同一个页面
modelAndView.setViewName("/WEB-INF/jsp/romance.jsp");
return modelAndView;
}
Aggregations