Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,8 @@ public void delete() {
this.isDeleted = true;
this.description = "삭제된 댓글입니다.";
}

public void changeType(CommentType type) {
this.commentType = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface CommentRepository extends JpaRepository<Comment, Long> {

List<Comment> findByFeedIdOrderByCreatedAtAsc(Long feedId);

List<Comment> findByParentIdOrderByCreatedAtAsc(Long parentId);

Optional<Comment> findByParticipationId(Long participationId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,13 @@ public void deleteComment(Long commentId, Long memberId) {

comment.delete();
}

// 참가 승인, 거절에 따른 댓글 상태변환
public void updateEventComment(Long participationId, CommentType type) {

Comment comment = commentRepository.findByParticipationId(participationId)
.orElseThrow(() -> new IllegalArgumentException("댓글이 존재하지 않습니다."));

comment.changeType(type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,8 @@ public void approve(Long participationId, Member writer) {
Member applicant = participation.getApplicant();
Feed feed = participation.getFeed();

String message = applicant.getNickname() + "님의 참가가 승인되었습니다.";

commentService.createEventComment(
feed.getId(),
commentService.updateEventComment(
participation.getId(),
message,
CommentType.APPROVE
);

Expand All @@ -125,12 +121,8 @@ public void reject(Long participationId, Member writer) {
Member applicant = participation.getApplicant();
Feed feed = participation.getFeed();

String message = applicant.getNickname() + "님의 참가가 거절되었습니다.";

commentService.createEventComment(
feed.getId(),
commentService.updateEventComment(
participation.getId(),
message,
CommentType.REJECT
);

Expand Down