Search in sources :

Example 11 with Movie

use of com.po.Movie in project Movie by batsqd.

the class MovieController method getMovieDetail.

@RequestMapping("getMovieDetail.action")
public ModelAndView getMovieDetail(int movie_id, HttpSession session) {
    ArrayList<Movie> moviesList = new ArrayList<Movie>();
    ApplicationContext ac = ApplicationContextUtil.getApplicationContext();
    MovieMapper movieMapper = (MovieMapper) ac.getBean("movieMapper");
    Movie movie = movieMapper.selectMovieById(movie_id);
    ModelAndView modelAndView = new ModelAndView();
    session.setAttribute("movieDetail", movie);
    //modelAndView.addObject("movieDetail", movie);
    modelAndView.setViewName("/WEB-INF/jsp/movieDetail.jsp");
    return modelAndView;
}
Also used : RecommendedMovie(com.po.RecommendedMovie) Movie(com.po.Movie) ApplicationContext(org.springframework.context.ApplicationContext) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) MovieMapper(com.mapper.MovieMapper) WatchMovieMapper(com.mapper.WatchMovieMapper) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with Movie

use of com.po.Movie in project Movie by batsqd.

the class TestMybatis method main.

public static void main(String[] args) throws IOException {
    // TODO Auto-generated method stub
    String resource = "SqlMapConfig.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
    SqlSession sqlSession = sqlSessionFactory.openSession();
    MovieMapper movieMapper = sqlSession.getMapper(MovieMapper.class);
    Movie movie = movieMapper.selectMovieById(3);
    System.out.println(movie.toString());
}
Also used : Movie(com.po.Movie) SqlSession(org.apache.ibatis.session.SqlSession) InputStream(java.io.InputStream) SqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) MovieMapper(com.mapper.MovieMapper)

Example 13 with Movie

use of com.po.Movie in project Movie by batsqd.

the class TestSpring method main.

public static void main(String[] args) {
    // TODO Auto-generated method stub
    ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
    Movie movie = (Movie) ac.getBean("movie");
    System.out.println("电影名:" + movie.getMovie_name());
}
Also used : Movie(com.po.Movie) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Example 14 with Movie

use of com.po.Movie in project Movie by batsqd.

the class MovieInfoService method getMoviesOrderByRatingToPage.

public ArrayList<Movie> getMoviesOrderByRatingToPage(String movie_genres, int begain, int end) {
    ApplicationContext ac = ApplicationContextUtil.getApplicationContext();
    MovieMapper movieMapper = (MovieMapper) ac.getBean("movieMapper");
    HashMap<String, Object> parameter = new HashMap<String, Object>();
    parameter.put("movie_genres", "%" + movie_genres + "%");
    parameter.put("begain", begain);
    parameter.put("end", end);
    ArrayList<Movie> moviesList = movieMapper.selectMoviesByRatingLimit(parameter);
    return moviesList;
}
Also used : Movie(com.po.Movie) ApplicationContext(org.springframework.context.ApplicationContext) HashMap(java.util.HashMap) MovieMapper(com.mapper.MovieMapper)

Example 15 with Movie

use of com.po.Movie in project Movie by batsqd.

the class FenyeController method getMoviesByPage.

@RequestMapping("/getMoviesByPage.action")
public ModelAndView getMoviesByPage(int pageNow, String type, String genres) {
    //pageNow是指用户从所看到的页面的那页
    int pageSize = 12;
    int pageCount = 1;
    int begain = 0;
    int end = 5;
    begain = (pageNow) * pageSize;
    end = begain + pageSize;
    ArrayList<Movie> moviesList = new ArrayList<Movie>();
    MovieInfoService movieInfoService = new MovieInfoService();
    if ("byGenres".equals(type)) {
        moviesList = movieInfoService.getMoviesByGenresToPage(genres, begain, end);
        pageCount = movieInfoService.getPageCountByGenres(pageSize, genres);
    } else if ("byReleaseTime".equals(type)) {
        moviesList = movieInfoService.getMoviesOrderByReleaseTimeToPage(genres, begain, end);
        pageCount = movieInfoService.getPageCountByGenres(pageSize, genres);
    } else if ("byRating".equals(type)) {
        moviesList = movieInfoService.getMoviesOrderByRatingToPage(genres, begain, end);
        pageCount = movieInfoService.getPageCountByGenres(pageSize, genres);
    }
    ModelAndView modelAndView = new ModelAndView();
    String navigationUrlPre = "";
    String navigationUrlNext = "";
    if (pageNow < 1) {
        //没有上一页;
        navigationUrlPre = "";
    } else {
        //有上一页
        /*http://121.42.174.147:8080
	    	navigationUrlPre="<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow="+(pageNow-1)+"&type="+type+"&genres="+genres+"'>上一页</a>";
	        */
        navigationUrlPre = "<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow=" + (pageNow - 1) + "&type=" + type + "&genres=" + genres + "'>上一页</a>";
    }
    if (pageNow + 1 < pageCount) {
        //有下一页
        navigationUrlNext = "<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow=" + (pageNow + 1) + "&type=" + type + "&genres=" + genres + "'>下一页</a>";
    } else {
        //没有下一页
        navigationUrlNext = "";
    }
    modelAndView.addObject("genres", genres);
    modelAndView.addObject("moviesList", moviesList);
    modelAndView.addObject("navigation", "当前为第" + (pageNow + 1) + "页&nbsp;&nbsp;" + navigationUrlPre + "  " + navigationUrlNext + " " + "&nbsp;&nbsp;共" + pageCount + "页!");
    modelAndView.setViewName("/WEB-INF/jsp/romance.jsp");
    return modelAndView;
}
Also used : Movie(com.po.Movie) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) MovieInfoService(com.service.MovieInfoService) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Movie (com.po.Movie)15 MovieMapper (com.mapper.MovieMapper)10 ApplicationContext (org.springframework.context.ApplicationContext)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ModelAndView (org.springframework.web.servlet.ModelAndView)9 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 WatchMovieMapper (com.mapper.WatchMovieMapper)5 RecommendedMovie (com.po.RecommendedMovie)5 MovieInfoService (com.service.MovieInfoService)4 RecommendMapper (com.mapper.RecommendMapper)1 User (com.po.User)1 ImproveSlopeOne (com.recommender.ImproveSlopeOne)1 InputStream (java.io.InputStream)1 Date (java.sql.Date)1 SimpleDateFormat (java.text.SimpleDateFormat)1 SqlSession (org.apache.ibatis.session.SqlSession)1 SqlSessionFactory (org.apache.ibatis.session.SqlSessionFactory)1 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1