|
|
@@ -4,10 +4,13 @@ import com.example.cinema.bl.management.MovieService;
|
|
|
import com.example.cinema.blImpl.management.schedule.MovieServiceForBl;
|
|
|
import com.example.cinema.blImpl.management.schedule.ScheduleServiceForBl;
|
|
|
import com.example.cinema.data.management.MovieMapper;
|
|
|
+import com.example.cinema.po.Movie;
|
|
|
+import com.example.cinema.po.ScheduleItem;
|
|
|
import com.example.cinema.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -39,7 +42,7 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
@Override
|
|
|
public ResponseVO searchOneMovieByIdAndUserId(int id, int userId) {
|
|
|
try {
|
|
|
- return ResponseVO.buildSuccess(movieMapper.selectMovieByIdAndUserId(id, userId));
|
|
|
+ return ResponseVO.buildSuccess(movie2MovieVO(movieMapper.selectMovieByIdAndUserId(id, userId)));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseVO.buildFailure("失败");
|
|
|
@@ -50,7 +53,7 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
@Override
|
|
|
public ResponseVO searchAllMovie() {
|
|
|
try {
|
|
|
- return ResponseVO.buildSuccess(movieMapper.selectAllMovie());
|
|
|
+ return ResponseVO.buildSuccess(movieList2MovieVOList(movieMapper.selectAllMovie()));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseVO.buildFailure("失败");
|
|
|
@@ -60,25 +63,19 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
@Override
|
|
|
public ResponseVO searchOtherMoviesExcludeOff() {
|
|
|
try {
|
|
|
- return ResponseVO.buildSuccess(movieMapper.selectOtherMoviesExcludeOff());
|
|
|
+ return ResponseVO.buildSuccess(movieList2MovieVOList(movieMapper.selectOtherMoviesExcludeOff()));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResponseVO.buildFailure("失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public ResponseVO getMovieByKeyword(String keyword) {
|
|
|
if (keyword==null||keyword.equals("")){
|
|
|
- return ResponseVO.buildSuccess(movieMapper.selectAllMovie());
|
|
|
+ return ResponseVO.buildSuccess(movieList2MovieVOList(movieMapper.selectAllMovie()));
|
|
|
}
|
|
|
- return ResponseVO.buildSuccess(movieMapper.selectMovieByKeyword(keyword));
|
|
|
+ return ResponseVO.buildSuccess(movieList2MovieVOList(movieMapper.selectMovieByKeyword(keyword)));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -116,7 +113,7 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MovieVO getMovieById(int id) {
|
|
|
+ public Movie getMovieById(int id) {
|
|
|
try {
|
|
|
return movieMapper.selectMovieById(id);
|
|
|
}catch (Exception e){
|
|
|
@@ -145,7 +142,35 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private MovieVO movie2MovieVO(Movie movie){
|
|
|
+ if(movie != null){
|
|
|
+ MovieVO movieVO = new MovieVO();
|
|
|
+ movieVO.setId(movie.getId());
|
|
|
+ movieVO.setName(movie.getName());
|
|
|
+ movieVO.setPosterUrl(movie.getPosterUrl());
|
|
|
+ movieVO.setDirector(movie.getDirector());
|
|
|
+ movieVO.setScreenWriter(movie.getScreenWriter());
|
|
|
+ movieVO.setStarring(movie.getStarring());
|
|
|
+ movieVO.setType(movie.getType());
|
|
|
+ movieVO.setCountry(movie.getCountry());
|
|
|
+ movieVO.setLanguage(movie.getLanguage());
|
|
|
+ movieVO.setStartDate(movie.getStartDate());
|
|
|
+ movieVO.setLength(movie.getLength());
|
|
|
+ movieVO.setDescription(movie.getDescription());
|
|
|
+ movieVO.setStatus(movie.getStatus());
|
|
|
+ movieVO.setIslike(movie.getIslike());
|
|
|
+ movieVO.setLikeCount(movie.getLikeCount());
|
|
|
+ return movieVO;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ private List<MovieVO> movieList2MovieVOList(List<Movie> movieList){
|
|
|
+ List<MovieVO> movieVOList = new ArrayList<>();
|
|
|
+ for(Movie movie : movieList){
|
|
|
+ movieVOList.add(movie2MovieVO(movie));
|
|
|
+ }
|
|
|
+ return movieVOList;
|
|
|
+ }
|
|
|
|
|
|
}
|