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 @@ -92,17 +92,18 @@ public static Comment createUserComment(
.build();
}

// SYSTEM 댓글 생성
public static Comment createSystemComment(
// SYSTEMEVENT 댓글 생성
public static Comment createEventComment(
String description,
Feed feed,
Long participationId
Long participationId,
CommentType type
) {
return Comment.builder()
.description(description)
.parentId(null)
.depth(0)
.commentType(CommentType.SYSTEM)
.commentType(type)
.member(null)
.feed(feed)
.participationId(participationId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

public enum CommentType {
USER,
SYSTEM
APPLY,
APPROVE,
REJECT,
CANCEL
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,23 @@ public List<CommentResponse> getComments(Long feedId) {
}

// 시스템 댓글 생성
public void createSystemComment(Long feedId, String message, Long participationId) {
public void createEventComment(
Long feedId,
Long participationId,
String message,
CommentType type
) {

Feed feed = feedRepository.findById(feedId)
.orElseThrow(() -> new IllegalArgumentException("피드가 존재하지 않습니다."));

Comment comment = Comment.createSystemComment(message, feed, participationId);
Comment comment = Comment.createEventComment(
message,
feed,
participationId,
type
);

commentRepository.save(comment);
}

Expand All @@ -97,8 +109,8 @@ public void deleteComment(Long commentId, Long memberId) {
Comment comment = commentRepository.findById(commentId)
.orElseThrow(() -> new IllegalArgumentException("댓글이 존재하지 않습니다."));

if (comment.getCommentType() == CommentType.SYSTEM) {
throw new IllegalArgumentException("SYSTEM 댓글은 삭제할 수 없습니다.");
if (comment.getCommentType() != CommentType.USER) {
throw new IllegalArgumentException("이벤트 댓글은 삭제할 수 없습니다.");
}

if (!comment.getMember().getId().equals(memberId)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Mua.Mua_backend.domain.participation.service;

import Mua.Mua_backend.domain.comment.entity.CommentType;
import Mua.Mua_backend.domain.comment.service.CommentService;
import Mua.Mua_backend.domain.feed.entity.Feed;
import Mua.Mua_backend.domain.feed.repository.FeedRepository;
Expand Down Expand Up @@ -56,7 +57,12 @@ public void apply(Long feedId, Member member) {
participationRepository.save(participation);

String message = member.getNickname() + "님이 참가 신청했습니다.";
commentService.createSystemComment(feed.getId(), message, participation.getId());
commentService.createEventComment(
feed.getId(),
participation.getId(),
message,
CommentType.APPLY
);
}

// 참가자 전체 조회
Expand Down Expand Up @@ -89,6 +95,15 @@ public void approve(Long participationId, Member writer) {
Member applicant = participation.getApplicant();
Feed feed = participation.getFeed();

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

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

notificationService.sendNotification(
applicant,
NotificationType.PARTICIPATION_APPROVED,
Expand All @@ -110,6 +125,15 @@ public void reject(Long participationId, Member writer) {
Member applicant = participation.getApplicant();
Feed feed = participation.getFeed();

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

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

notificationService.sendNotification(
applicant,
NotificationType.PARTICIPATION_REJECTED,
Expand Down