Skip to content

Commit e0fb829

Browse files
committed
feat: 댓글 작성 및 삭제 시 활동 점수 반영
1 parent 9b4d92e commit e0fb829

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/com/back/domain/post/comment/service/CommentService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.back.domain.post.post.repository.PostRepository;
1313
import com.back.domain.user.entity.User;
1414
import com.back.global.rq.Rq;
15+
import com.back.domain.user.service.AbvScoreService;
1516
import java.util.List;
1617
import lombok.RequiredArgsConstructor;
1718
import org.springframework.stereotype.Service;
@@ -25,6 +26,7 @@ public class CommentService {
2526
private final PostRepository postRepository;
2627
private final NotificationService notificationService;
2728
private final Rq rq;
29+
private final AbvScoreService abvScoreService;
2830

2931
// 댓글 작성 로직
3032
@Transactional
@@ -48,7 +50,10 @@ public CommentResponseDto createComment(Long postId, CommentCreateRequestDto req
4850
user.getNickname() + " 님이 댓글을 남겼습니다."
4951
);
5052

51-
return new CommentResponseDto(commentRepository.save(comment));
53+
Comment saved = commentRepository.save(comment);
54+
// 활동 점수: 댓글 작성 +0.2
55+
abvScoreService.awardForComment(user.getId());
56+
return new CommentResponseDto(saved);
5257
}
5358

5459
// 댓글 다건 조회 로직 (무한스크롤)
@@ -102,6 +107,8 @@ public void deleteComment(Long postId, Long commentId) {
102107
}
103108

104109
comment.updateStatus(CommentStatus.DELETED);
110+
// 활동 점수: 댓글 삭제 시 -0.2 (작성자 기준)
111+
abvScoreService.revokeForComment(user.getId());
105112

106113
// soft delete를 사용하기 위해 레포지토리 삭제 작업은 진행하지 않음.
107114
// commentRepository.delete(comment);

0 commit comments

Comments
 (0)