설계된 엔티티(Movie)를 통해 더미 데이터를 넣고, 메인페이지를 제작 했습니다.
-- Movie 테이블 더미 데이터 삽입
insert into movie_tb (movie_nm, prdt_year, open_dt, nation_nm, genre_nm, director, company, runtime, rating_grade, vod_url, plot, actor_nm, api_id)
values
('Interstellar', '2014', '2014-11-07', 'USA', 'Sci-Fi', 'Christopher Nolan', 'Warner Bros.', 169, '12세', 'https://www.kmdb.or.kr/trailer/trailerPlayPop?pFileNm=MK034919_P02.mp4', 'A team of explorers travel through a wormhole in space in an attempt to ensure humanity''s survival.', 'Matthew McConaughey, Anne Hathaway', 1),
('Parasite', '2019', '2019-05-30', 'South Korea', 'Drama', 'Bong Joon Ho', 'Barunson E&A', 132, '15세', 'https://www.kmdb.or.kr/trailer/trailerPlayPop?pFileNm=MK041673_P02.mp4', 'Greed and class discrimination threaten the newly formed symbiotic relationship between the wealthy Park family and the destitute Kim clan.', 'Song Kang-ho, Lee Sun-kyun', 2),
('The Godfather', '1972', '1972-03-24', 'USA', 'Crime, Drama', 'Francis Ford Coppola', 'Paramount Pictures', 175, '15세', 'https://www.kmdb.or.kr/trailer/trailerPlayPop?pFileNm=MK013841_P03.mp4', 'The aging patriarch of an organized crime dynasty transfers control of his clandestine empire to his reluctant son.', 'Marlon Brando, Al Pacino', 3),
('Your Name', '2016', '2016-08-26', 'Japan', 'Animation, Fantasy, Romance', 'Makoto Shinkai', 'CoMix Wave Films', 112, '12세', 'https://www.kmdb.or.kr/trailer/trailerPlayPop?pFileNm=MK039884_P02.mp4', 'Two teenagers share a profound, magical connection upon discovering they are swapping bodies.', 'Ryunosuke Kamiki, Mone Kamishiraishi', 4),
('Spirited Away', '2001', '2001-07-20', 'Japan', 'Animation, Fantasy, Adventure', 'Hayao Miyazaki', 'Studio Ghibli', 125, 'All ages', 'https://www.kmdb.or.kr/trailer/trailerPlayPop?pFileNm=MK035672_P02.mp4', 'A young girl, Chihiro, becomes trapped in a mysterious and magical world of spirits, where she must work to free herself and her parents.', 'Rumi Hiiragi, Miyu Irino', 5);
MovieRepository에서
메인 페이지의 경우 엔티티상 OneToMany로 엮인 엔티티 중 PosterUrls 테이블의 값만을 필요로 하고, LazyLoading 전략을 사용하고 있기에 db에 가져올 데이터의 쿼리문을 join fetch로 한번에 가져오게끔 메서드를 생성하였습니다.

MovieServie에서
메인페이지는 현재상영작 top5 를 보여주는 창으로 5개의 영화만을 전송해야하기에 가져온 영화리스트에서 5개만을 넣어 리턴 하도록 만들었습니다. (추후 누적관람객 or 결제순 등으로 변경예정)

ResponseDTO는 Movie 객체를 받아 메인페이지에서 필요한 정보만을 DTO에 담는 생성자를 생성하였습니다.

MovieController에선
MovieList를 DTO로 리턴받고 세션에 넣어 보내기만 해줍니다.

view.mustache에서 models컬렉션을 돌며 해당 정보들을 뿌려줍니다.

이렇게 하고 실행을 시키면

메인페이지 제작을 완료했습니다.
Share article