1717import com .back .domain .post .post .repository .TagRepository ;
1818import com .back .domain .user .entity .User ;
1919import com .back .global .rq .Rq ;
20+ import com .back .domain .user .service .AbvScoreService ;
2021import java .util .List ;
2122import java .util .NoSuchElementException ;
2223import java .util .Optional ;
@@ -35,6 +36,7 @@ public class PostService {
3536 private final PostLikeRepository postLikeRepository ;
3637 private final NotificationService notificationService ;
3738 private final Rq rq ;
39+ private final AbvScoreService abvScoreService ;
3840
3941 // 게시글 작성 로직
4042 @ Transactional
@@ -58,7 +60,10 @@ public PostResponseDto createPost(PostCreateRequestDto reqBody) {
5860 addTag (tagNames , post );
5961 }
6062
61- return new PostResponseDto (postRepository .save (post ));
63+ Post saved = postRepository .save (post );
64+ // 활동 점수: 게시글 작성 +0.5
65+ abvScoreService .awardForPost (user .getId ());
66+ return new PostResponseDto (saved );
6267 }
6368
6469 // 게시글 다건 조회 로직
@@ -136,6 +141,8 @@ public void deletePost(Long postId) {
136141 .orElseThrow (() -> new NoSuchElementException ("해당 게시글을 찾을 수 없습니다. ID: " + postId ));
137142
138143 post .updateStatus (PostStatus .DELETED );
144+ // 활동 점수: 게시글 삭제 시 -0.5 (작성자 기준)
145+ abvScoreService .revokeForPost (post .getUser ().getId ());
139146
140147 // soft delete를 사용하기 위해 레포지토리 삭제 작업은 진행하지 않음.
141148// postRepository.delete(post);
@@ -156,6 +163,8 @@ public void toggleLike(Long postId) {
156163 existingLike .get ().updateStatus (PostLikeStatus .NONE );
157164 postLikeRepository .delete (existingLike .get ());
158165 post .decreaseLikeCount ();
166+ // 활동 점수: 추천 취소 시 -0.1
167+ abvScoreService .revokeForLike (user .getId ());
159168 } else {
160169 // 추천 추가
161170 PostLike postLike = PostLike .builder ()
@@ -165,6 +174,8 @@ public void toggleLike(Long postId) {
165174 .build ();
166175 postLikeRepository .save (postLike );
167176 post .increaseLikeCount ();
177+ // 활동 점수: 추천 추가 시 +0.1
178+ abvScoreService .awardForLike (user .getId ());
168179 }
169180
170181 // 게시글 작성자에게 알림 전송
0 commit comments