diff --git a/src/main/java/treehouse/server/api/comment/business/CommentService.java b/src/main/java/treehouse/server/api/comment/business/CommentService.java index 50e9199..5b4097b 100644 --- a/src/main/java/treehouse/server/api/comment/business/CommentService.java +++ b/src/main/java/treehouse/server/api/comment/business/CommentService.java @@ -167,6 +167,9 @@ public CommentResponseDTO.CommentIdResponseDto createComment(User user, Long tre Comment comment = CommentMapper.toComment(writer, post, request.getContext(), CommentType.PARENT, -1L); Long commentId = commentCommandAdapter.createComment(comment).getId(); + //활동량 증가 + user.increaseActiveRate(5); + //알림 생성 NotificationRequestDTO.createNotification notificationRequest = new NotificationRequestDTO.createNotification(); notificationRequest.setReceiverId(post.getWriter().getUser().getId()); // 여기서 receiver 설정 (예시) @@ -228,6 +231,9 @@ public String reactToComment(User user, Long treehouseId, Long commentId, Commen member.addReaction(savedReaction); + //활동량 증가 + user.increaseActiveRate(1); + //알림 생성 NotificationRequestDTO.createNotification notificationRequest = new NotificationRequestDTO.createNotification(); notificationRequest.setReceiverId(comment.getWriter().getId()); // 여기서 receiver 설정 (예시) diff --git a/src/main/java/treehouse/server/api/post/business/PostService.java b/src/main/java/treehouse/server/api/post/business/PostService.java index 3b2eec9..5293865 100644 --- a/src/main/java/treehouse/server/api/post/business/PostService.java +++ b/src/main/java/treehouse/server/api/post/business/PostService.java @@ -123,6 +123,10 @@ public PostResponseDTO.createPostResult createPost(User user, PostRequestDTO.cre List postImageList = PostMapper.toPostImageList(request); postImageList.forEach(postImage -> postImage.setPost(post)); postImageCommandAdapter.savePostImageList(postImageList); + + // 활동량 증가 + user.increaseActiveRate(5); + return PostMapper.toCreatePostResult(postCommandAdapter.savePost(post)); } @@ -305,6 +309,9 @@ public String reactToPost(User user, Long treehouseId, Long postId, PostRequestD member.addReaction(savedReaction); + // 활동량 증가 + user.increaseActiveRate(1); + //알림 생성 NotificationRequestDTO.createNotification notificationRequest = new NotificationRequestDTO.createNotification(); notificationRequest.setReceiverId(post.getWriter().getUser().getId()); // 여기서 receiver 설정 (예시) diff --git a/src/main/java/treehouse/server/global/entity/User/User.java b/src/main/java/treehouse/server/global/entity/User/User.java index 1e9bb7b..5c7409c 100644 --- a/src/main/java/treehouse/server/global/entity/User/User.java +++ b/src/main/java/treehouse/server/global/entity/User/User.java @@ -89,4 +89,18 @@ private void checkAndIncreaseInvitationCount() { this.invitationCreatedCount = 0; // 카운트 초기화 } } + + public void increaseActiveRate(int rate) { + this.activeRate += rate; + checkAndIncreaseInvitationCountByActiveRate(); // activeRate가 100 단위일 때 invitationCount 증가 + } + + // activeRate가 100 단위일 때 invitationCount 증가 + private void checkAndIncreaseInvitationCountByActiveRate() { + if (this.activeRate >= 100) { + int additionalInvitations = this.activeRate / 100; // 100 단위마다 초대장 증가 + this.invitationCount += additionalInvitations; // 초대장 증가 + this.activeRate = this.activeRate % 100; // 남은 activeRate는 100 미만으로 유지 + } + } } \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b9a9df4..caa2534 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -73,8 +73,8 @@ jwt: key: ${JWT_SECRET} # secret : ${JWT_SECRET} authorities-key: authoritiesKey - access-token-validity-in-seconds: 600000 # 10 min - refresh-token-validity-in-seconds: 3600000 # 1 hour + access-token-validity-in-seconds: 7200000 # 2 hour + refresh-token-validity-in-seconds: 2592000000 # 30 day firebase: admin-sdk: ${FCM_KEY} @@ -143,8 +143,8 @@ jwt: key: ${JWT_SECRET} # secret : ${JWT_SECRET} authorities-key: authoritiesKey - access-token-validity-in-seconds: 2000000 # 30 m - refresh-token-validity-in-seconds: 3000000 # 14 d + access-token-validity-in-seconds: 7200000 # 2 hour + refresh-token-validity-in-seconds: 2592000000 # 30 day firebase: admin-sdk: ${FCM_KEY}