|
@@ -3,7 +3,6 @@ package com.example.cinema.blImpl.management.movie;
|
|
|
import com.example.cinema.bl.management.MovieService;
|
|
import com.example.cinema.bl.management.MovieService;
|
|
|
import com.example.cinema.blImpl.management.schedule.MovieServiceForBl;
|
|
import com.example.cinema.blImpl.management.schedule.MovieServiceForBl;
|
|
|
import com.example.cinema.blImpl.management.schedule.ScheduleServiceForBl;
|
|
import com.example.cinema.blImpl.management.schedule.ScheduleServiceForBl;
|
|
|
-import com.example.cinema.data.statistics.MovieLikeMapper;
|
|
|
|
|
import com.example.cinema.data.management.MovieMapper;
|
|
import com.example.cinema.data.management.MovieMapper;
|
|
|
import com.example.cinema.vo.*;
|
|
import com.example.cinema.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,17 +18,11 @@ import java.util.List;
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
-
|
|
|
|
|
- private static final String ALREADY_LIKE_ERROR_MESSAGE = "用户已标记该电影为想看";
|
|
|
|
|
- private static final String UNLIKE_ERROR_MESSAGE = "用户未标记该电影为想看";
|
|
|
|
|
- private static final String MOVIE_NOT_EXIST_ERROR_MESSAGE = "电影不存在";
|
|
|
|
|
private static final String SCHEDULE_ERROR_MESSAGE = "有电影后续仍有排片或已有观众购票且未使用";
|
|
private static final String SCHEDULE_ERROR_MESSAGE = "有电影后续仍有排片或已有观众购票且未使用";
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MovieMapper movieMapper;
|
|
private MovieMapper movieMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private MovieLikeMapper movieLikeMapper;
|
|
|
|
|
- @Autowired
|
|
|
|
|
private ScheduleServiceForBl scheduleServiceForBl;
|
|
private ScheduleServiceForBl scheduleServiceForBl;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -74,48 +67,11 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public ResponseVO likeMovie(int userId, int movieId) {
|
|
|
|
|
|
|
|
|
|
- //todo: user 判空
|
|
|
|
|
- if (userLikeTheMovie(userId, movieId)) {
|
|
|
|
|
- return ResponseVO.buildFailure(ALREADY_LIKE_ERROR_MESSAGE);
|
|
|
|
|
- } else if (movieMapper.selectMovieById(movieId) == null) {
|
|
|
|
|
- return ResponseVO.buildFailure(MOVIE_NOT_EXIST_ERROR_MESSAGE);
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- return ResponseVO.buildSuccess(movieLikeMapper.insertOneLike(movieId, userId));
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- return ResponseVO.buildFailure("失败");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public ResponseVO unLikeMovie(int userId, int movieId) {
|
|
|
|
|
- if (!userLikeTheMovie(userId, movieId)) {
|
|
|
|
|
- return ResponseVO.buildFailure(UNLIKE_ERROR_MESSAGE);
|
|
|
|
|
- } else if (movieMapper.selectMovieById(movieId) == null) {
|
|
|
|
|
- return ResponseVO.buildFailure(MOVIE_NOT_EXIST_ERROR_MESSAGE);
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- return ResponseVO.buildSuccess(movieLikeMapper.deleteOneLike(movieId, userId));
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- return ResponseVO.buildFailure("失败");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public ResponseVO getCountOfLikes(int movieId) {
|
|
|
|
|
- try {
|
|
|
|
|
- return ResponseVO.buildSuccess(movieLikeMapper.selectLikeNums(movieId));
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- return ResponseVO.buildFailure("失败");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ResponseVO getMovieByKeyword(String keyword) {
|
|
public ResponseVO getMovieByKeyword(String keyword) {
|
|
@@ -125,15 +81,7 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
return ResponseVO.buildSuccess(movieMapper.selectMovieByKeyword(keyword));
|
|
return ResponseVO.buildSuccess(movieMapper.selectMovieByKeyword(keyword));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public ResponseVO getLikeNumsGroupByDate(int movieId) {
|
|
|
|
|
- try {
|
|
|
|
|
- return ResponseVO.buildSuccess(movieLikeMapper.getDateLikeNum(movieId));
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- return ResponseVO.buildFailure("失败");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ResponseVO pullOfBatchOfMovie(MovieBatchOffForm movieBatchOffForm) {
|
|
public ResponseVO pullOfBatchOfMovie(MovieBatchOffForm movieBatchOffForm) {
|
|
@@ -197,9 +145,7 @@ public class MovieServiceImpl implements MovieService, MovieServiceForBl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- private boolean userLikeTheMovie(int userId, int movieId) {
|
|
|
|
|
- return movieLikeMapper.selectLikeMovie(movieId, userId) == 0 ? false : true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|