Skip to content

Commit 6de4b0e

Browse files
authored
Merge pull request #137 from Team-Shaka/refactor/136
♻️ Refactor: 토큰 유효시간 증가와 활동량 로직 추가
2 parents fa3e3e3 + 8d17d3a commit 6de4b0e

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

src/main/java/treehouse/server/api/comment/business/CommentService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public CommentResponseDTO.CommentIdResponseDto createComment(User user, Long tre
167167
Comment comment = CommentMapper.toComment(writer, post, request.getContext(), CommentType.PARENT, -1L);
168168
Long commentId = commentCommandAdapter.createComment(comment).getId();
169169

170+
//활동량 증가
171+
user.increaseActiveRate(5);
172+
170173
//알림 생성
171174
NotificationRequestDTO.createNotification notificationRequest = new NotificationRequestDTO.createNotification();
172175
notificationRequest.setReceiverId(post.getWriter().getUser().getId()); // 여기서 receiver 설정 (예시)
@@ -228,6 +231,9 @@ public String reactToComment(User user, Long treehouseId, Long commentId, Commen
228231

229232
member.addReaction(savedReaction);
230233

234+
//활동량 증가
235+
user.increaseActiveRate(1);
236+
231237
//알림 생성
232238
NotificationRequestDTO.createNotification notificationRequest = new NotificationRequestDTO.createNotification();
233239
notificationRequest.setReceiverId(comment.getWriter().getId()); // 여기서 receiver 설정 (예시)

src/main/java/treehouse/server/api/post/business/PostService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ public PostResponseDTO.createPostResult createPost(User user, PostRequestDTO.cre
123123
List<PostImage> postImageList = PostMapper.toPostImageList(request);
124124
postImageList.forEach(postImage -> postImage.setPost(post));
125125
postImageCommandAdapter.savePostImageList(postImageList);
126+
127+
// 활동량 증가
128+
user.increaseActiveRate(5);
129+
126130
return PostMapper.toCreatePostResult(postCommandAdapter.savePost(post));
127131
}
128132

@@ -305,6 +309,9 @@ public String reactToPost(User user, Long treehouseId, Long postId, PostRequestD
305309

306310
member.addReaction(savedReaction);
307311

312+
// 활동량 증가
313+
user.increaseActiveRate(1);
314+
308315
//알림 생성
309316
NotificationRequestDTO.createNotification notificationRequest = new NotificationRequestDTO.createNotification();
310317
notificationRequest.setReceiverId(post.getWriter().getUser().getId()); // 여기서 receiver 설정 (예시)

src/main/java/treehouse/server/global/entity/User/User.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,18 @@ private void checkAndIncreaseInvitationCount() {
8989
this.invitationCreatedCount = 0; // 카운트 초기화
9090
}
9191
}
92+
93+
public void increaseActiveRate(int rate) {
94+
this.activeRate += rate;
95+
checkAndIncreaseInvitationCountByActiveRate(); // activeRate가 100 단위일 때 invitationCount 증가
96+
}
97+
98+
// activeRate가 100 단위일 때 invitationCount 증가
99+
private void checkAndIncreaseInvitationCountByActiveRate() {
100+
if (this.activeRate >= 100) {
101+
int additionalInvitations = this.activeRate / 100; // 100 단위마다 초대장 증가
102+
this.invitationCount += additionalInvitations; // 초대장 증가
103+
this.activeRate = this.activeRate % 100; // 남은 activeRate는 100 미만으로 유지
104+
}
105+
}
92106
}

src/main/resources/application.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ jwt:
7373
key: ${JWT_SECRET}
7474
# secret : ${JWT_SECRET}
7575
authorities-key: authoritiesKey
76-
access-token-validity-in-seconds: 600000 # 10 min
77-
refresh-token-validity-in-seconds: 3600000 # 1 hour
76+
access-token-validity-in-seconds: 7200000 # 2 hour
77+
refresh-token-validity-in-seconds: 2592000000 # 30 day
7878

7979
firebase:
8080
admin-sdk: ${FCM_KEY}
@@ -143,8 +143,8 @@ jwt:
143143
key: ${JWT_SECRET}
144144
# secret : ${JWT_SECRET}
145145
authorities-key: authoritiesKey
146-
access-token-validity-in-seconds: 2000000 # 30 m
147-
refresh-token-validity-in-seconds: 3000000 # 14 d
146+
access-token-validity-in-seconds: 7200000 # 2 hour
147+
refresh-token-validity-in-seconds: 2592000000 # 30 day
148148

149149
firebase:
150150
admin-sdk: ${FCM_KEY}

0 commit comments

Comments
 (0)