-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor : 좋아요 및 싫어요 테이블 추가에 따른 CommentRepository 코드 수정
- Loading branch information
Showing
4 changed files
with
212 additions
and
101 deletions.
There are no files selected for viewing
164 changes: 86 additions & 78 deletions
164
application/src/main/java/core/application/movies/repositories/CommentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,98 @@ | ||
package core.application.movies.repositories; | ||
|
||
|
||
import core.application.movies.models.entities.CommentEntity; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import core.application.movies.models.dto.CommentRespDTO; | ||
import core.application.movies.models.entities.CommentEntity; | ||
|
||
/** | ||
* {@code COMMENT_TABLE} 과 관련된 {@code Repository} | ||
*/ | ||
public interface CommentRepository { | ||
|
||
// CREATE | ||
|
||
/** | ||
* 특정 영화에 주어진 유저 ID 로 새로운 한줄평 댓글을 DB 에 등록 | ||
* | ||
* @param movieId 한줄평 댓글을 등록할 영화 ID | ||
* @param userId 댓글을 등록하는 유저 ID | ||
* @param comment 새로운 한줄평 댓글 | ||
* @return {@link CommentEntity} 등록된 정보 | ||
*/ | ||
CommentEntity saveNewComment(String movieId, UUID userId, CommentEntity comment); | ||
|
||
|
||
//<editor-fold desc="READ"> | ||
|
||
/** | ||
* 한줄평 댓글 ID 로 검색 | ||
* | ||
* @param commentId 댓글 ID | ||
* @return {@link Optional}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
Optional<CommentEntity> findByCommentId(Long commentId); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글들을 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
* @see #findByMovieIdOnDateDescend(String) | ||
* @see #findByMovieIdOnLikeDescend(String) | ||
* @see #findByMovieIdOnDislikeDescend(String) | ||
*/ | ||
List<CommentEntity> findByMovieId(String movieId); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글을 최신순으로 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentEntity> findByMovieIdOnDateDescend(String movieId); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글을 좋아요 순으로 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentEntity> findByMovieIdOnLikeDescend(String movieId); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글을 싫어요 순으로 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentEntity> findByMovieIdOnDislikeDescend(String movieId); | ||
|
||
/** | ||
* DB 의 모든 한줄평 댓글을 검색 | ||
* | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentEntity> selectAll(); | ||
//</editor-fold> | ||
|
||
|
||
// DELETE | ||
|
||
/** | ||
* 특정 한줄평 댓글을 삭제 | ||
* | ||
* @param commentId 삭제할 한줄평 댓글의 ID | ||
*/ | ||
void deleteComment(Long commentId); | ||
// CREATE | ||
|
||
/** | ||
* 특정 영화에 주어진 유저 ID 로 새로운 한줄평 댓글을 DB 에 등록 | ||
* | ||
* @param movieId 한줄평 댓글을 등록할 영화 ID | ||
* @param userId 댓글을 등록하는 유저 ID | ||
* @param comment 새로운 한줄평 댓글 | ||
* @return {@link CommentEntity} 등록된 정보 | ||
*/ | ||
CommentEntity saveNewComment(String movieId, UUID userId, CommentEntity comment); | ||
|
||
//<editor-fold desc="READ"> | ||
|
||
/** | ||
* 한줄평 댓글 ID 로 검색 | ||
* | ||
* @param commentId 댓글 ID | ||
* @return {@link Optional}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
Optional<CommentEntity> findByCommentId(Long commentId); | ||
|
||
Boolean existsByMovieIdAndUserId(String movieId, UUID userId); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글들을 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
* @see #findByMovieIdOnDateDescend(String, UUID, int) | ||
* @see #findByMovieIdOnLikeDescend(String, UUID, int) | ||
* @see #findByMovieIdOnDislikeDescend(String, UUID, int) | ||
*/ | ||
List<CommentRespDTO> findByMovieId(String movieId, UUID userId, int offset); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글을 최신순으로 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentRespDTO> findByMovieIdOnDateDescend(String movieId, UUID userId, int offset); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글을 좋아요 순으로 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentRespDTO> findByMovieIdOnLikeDescend(String movieId, UUID userId, int offset); | ||
|
||
/** | ||
* 특정 영화에 달린 한줄평 댓글을 싫어요 순으로 검색 | ||
* | ||
* @param movieId 검색할 영화 ID | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentRespDTO> findByMovieIdOnDislikeDescend(String movieId, UUID userId, int offset); | ||
|
||
/** | ||
* DB 의 모든 한줄평 댓글을 검색 | ||
* | ||
* @return {@link List}{@code <}{@link CommentEntity}{@code >} | ||
*/ | ||
List<CommentEntity> selectAll(); | ||
//</editor-fold> | ||
|
||
// UPDATE | ||
|
||
/** | ||
* 한줄평 내용 수정 | ||
* @param comment 수정할 한줄평 | ||
*/ | ||
public void update(CommentEntity comment); | ||
|
||
// DELETE | ||
|
||
/** | ||
* 특정 한줄평 댓글을 삭제 | ||
* | ||
* @param commentId 삭제할 한줄평 댓글의 ID | ||
*/ | ||
void deleteComment(Long commentId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.