Skip to content

Commit

Permalink
refactor: 로그인한 유저가 자신이 작성한 리뷰인지 확인하는 DTO 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
70825 committed Oct 6, 2023
1 parent 490482a commit 0c5b38c
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions backend/src/main/java/com/funeat/review/dto/SortingReviewDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ public class SortingReviewDto {
private final Long favoriteCount;
private final boolean favorite;
private final LocalDateTime createdAt;
private final boolean author;

public SortingReviewDto(final Long id, final String userName, final String profileImage, final String image,
final Long rating, final List<TagDto> tags,
final String content, final boolean rebuy, final Long favoriteCount, final boolean favorite,
final LocalDateTime createdAt) {
final Long rating, final List<TagDto> tags, final String content, final boolean rebuy,
final Long favoriteCount, final boolean favorite, final LocalDateTime createdAt,
final boolean author) {
this.id = id;
this.userName = userName;
this.profileImage = profileImage;
Expand All @@ -38,6 +39,7 @@ public SortingReviewDto(final Long id, final String userName, final String profi
this.favoriteCount = favoriteCount;
this.favorite = favorite;
this.createdAt = createdAt;
this.author = author;
}

public static SortingReviewDto toDto(final Review review, final Member member) {
Expand All @@ -52,7 +54,8 @@ public static SortingReviewDto toDto(final Review review, final Member member) {
review.getReBuy(),
review.getFavoriteCount(),
findReviewFavoriteChecked(review, member),
review.getCreatedAt()
review.getCreatedAt(),
findAuthorChecked(review, member)
);
}

Expand All @@ -73,6 +76,13 @@ private static boolean findReviewFavoriteChecked(final Review review, final Memb
.orElse(false);
}

private static boolean findAuthorChecked(final Review review, final Member member) {
final Long reviewMemberId = review.getMember().getId();
final Long loginMemberId = member.getId();

return reviewMemberId.equals(loginMemberId);
}

public Long getId() {
return id;
}
Expand Down Expand Up @@ -116,4 +126,8 @@ public boolean isFavorite() {
public LocalDateTime getCreatedAt() {
return createdAt;
}

public boolean isAuthor() {
return author;
}
}

0 comments on commit 0c5b38c

Please sign in to comment.