-
Notifications
You must be signed in to change notification settings - Fork 1
[release] 진행상황 Main 브랜치에 반영 #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fb0437f
633cf1c
dbac114
8fadc51
a798c93
9a04447
de642ba
75a7c98
22e3ed7
d0b6f8d
def26d2
7c53b70
482f59a
9e159a9
6b4fa94
2c32ec5
922edb0
6a80a37
7811fdf
73cee64
8f013ae
8b13e96
0778e07
29ab83d
632d878
fb1e4c8
5f599ef
2d0e790
5e1c71c
6555ebf
c51a3a8
20b6563
a9a3ef9
7b8d6fa
618212a
19801dd
ae634f9
475bdfc
04af9de
c7f79ff
0813926
d9be59d
7ee87ef
30b4c7a
35135ef
c2b8c9f
4517480
3d69dc3
4f1a31e
3581c05
321737d
204c949
59d2c31
bef0fef
882ac71
1c416d0
c2fbee4
664f789
bb47cea
54f1ee6
79f0b0f
71aa22c
7a67a62
302580e
31720d8
9fcb718
bf4756d
9f7c1e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.wayble.server.admin.dto; | ||
|
|
||
| import lombok.Builder; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Builder | ||
| public record DailyStatsDto( | ||
| LocalDate date, | ||
| long dailyRegistrationCount, | ||
| long dailyActiveUserCount, | ||
| long totalUserCount, | ||
| long totalWaybleZoneCount | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,12 +2,15 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import co.elastic.clients.elasticsearch.ElasticsearchClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import co.elastic.clients.elasticsearch.cluster.HealthResponse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.admin.dto.DailyStatsDto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.logging.service.UserActionLogService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import lombok.extern.slf4j.Slf4j; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.sql.DataSource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.sql.Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.time.LocalDate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Slf4j | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| @Service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,6 +19,9 @@ public class AdminSystemService { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final ElasticsearchClient elasticsearchClient; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final DataSource dataSource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final UserActionLogService userActionLogService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AdminUserService adminUserService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private final AdminWaybleZoneService adminWaybleZoneService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public boolean isElasticsearchHealthy() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -46,4 +52,42 @@ public boolean isFileStorageHealthy() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 파일 스토리지 상태 체크 (예: S3 연결 확인 등) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public DailyStatsDto getDailyStats() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LocalDate today = LocalDate.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 일일 가입자 수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| long dailyRegistrationCount = userActionLogService.getTodayUserRegistrationCount(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 일일 활성 유저 수 (방문자) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| long dailyActiveUserCount = userActionLogService.getTodayActiveUserCount(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 전체 유저 수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| long totalUserCount = adminUserService.getTotalUserCount(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 전체 웨이블존 수 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| long totalWaybleZoneCount = adminWaybleZoneService.getTotalWaybleZoneCounts(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return DailyStatsDto.builder() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .date(today) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dailyRegistrationCount(dailyRegistrationCount) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dailyActiveUserCount(dailyActiveUserCount) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .totalUserCount(totalUserCount) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .totalWaybleZoneCount(totalWaybleZoneCount) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log.error("Failed to get daily stats", e); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 에러 발생시 기본값 반환 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return DailyStatsDto.builder() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .date(LocalDate.now()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dailyRegistrationCount(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .dailyActiveUserCount(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .totalUserCount(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .totalWaybleZoneCount(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 일일 통계 메서드 개선사항 제안 기본적인 구현은 잘되어 있으나, 개별 통계 수집 실패 시에도 다른 통계는 정상 수집할 수 있도록 개선하면 좋겠습니다. 다음과 같이 개별 예외 처리를 추가하여 부분적인 실패에도 대응하도록 개선하세요: public DailyStatsDto getDailyStats() {
- try {
LocalDate today = LocalDate.now();
- // 일일 가입자 수
- long dailyRegistrationCount = userActionLogService.getTodayUserRegistrationCount();
+ // 개별 통계 수집 (실패해도 다른 통계는 계속 수집)
+ long dailyRegistrationCount = 0;
+ long dailyActiveUserCount = 0;
+ long totalUserCount = 0;
+ long totalWaybleZoneCount = 0;
- // 일일 활성 유저 수 (방문자)
- long dailyActiveUserCount = userActionLogService.getTodayActiveUserCount();
+ try {
+ dailyRegistrationCount = userActionLogService.getTodayUserRegistrationCount();
+ } catch (Exception e) {
+ log.warn("일일 가입자 수 조회 실패", e);
+ }
- // 전체 유저 수
- long totalUserCount = adminUserService.getTotalUserCount();
+ try {
+ dailyActiveUserCount = userActionLogService.getTodayActiveUserCount();
+ } catch (Exception e) {
+ log.warn("일일 활성 유저 수 조회 실패", e);
+ }
- // 전체 웨이블존 수
- long totalWaybleZoneCount = adminWaybleZoneService.getTotalWaybleZoneCounts();
+ try {
+ totalUserCount = adminUserService.getTotalUserCount();
+ } catch (Exception e) {
+ log.warn("전체 유저 수 조회 실패", e);
+ }
+
+ try {
+ totalWaybleZoneCount = adminWaybleZoneService.getTotalWaybleZoneCounts();
+ } catch (Exception e) {
+ log.warn("전체 웨이블존 수 조회 실패", e);
+ }
return DailyStatsDto.builder()
.date(today)
.dailyRegistrationCount(dailyRegistrationCount)
.dailyActiveUserCount(dailyActiveUserCount)
.totalUserCount(totalUserCount)
.totalWaybleZoneCount(totalWaybleZoneCount)
.build();
-
- } catch (Exception e) {
- log.error("Failed to get daily stats", e);
-
- // 에러 발생시 기본값 반환
- return DailyStatsDto.builder()
- .date(LocalDate.now())
- .dailyRegistrationCount(0)
- .dailyActiveUserCount(0)
- .totalUserCount(0)
- .totalWaybleZoneCount(0)
- .build();
- }
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.admin.dto.wayblezone.AdminWaybleZoneUpdateDto; | ||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.admin.exception.AdminErrorCase; | ||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.admin.repository.AdminWaybleZoneRepository; | ||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.aws.AmazonS3Manager; | ||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.common.exception.ApplicationException; | ||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.explore.service.WaybleZoneDocumentService; | ||||||||||||||||||||||||||||||||||||||||||||||
| import com.wayble.server.user.repository.UserPlaceWaybleZoneMappingRepository; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,6 +32,7 @@ public class AdminWaybleZoneService { | |||||||||||||||||||||||||||||||||||||||||||||
| private final WaybleZoneRepository waybleZoneRepository; | ||||||||||||||||||||||||||||||||||||||||||||||
| private final UserPlaceWaybleZoneMappingRepository userPlaceWaybleZoneMappingRepository; | ||||||||||||||||||||||||||||||||||||||||||||||
| private final WaybleZoneVisitLogRepository waybleZoneVisitLogRepository; | ||||||||||||||||||||||||||||||||||||||||||||||
| private final AmazonS3Manager amazonS3Manager; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| public long getTotalWaybleZoneCounts() { | ||||||||||||||||||||||||||||||||||||||||||||||
| return adminWaybleZoneRepository.count(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -87,6 +89,18 @@ public Long updateWaybleZone(AdminWaybleZoneUpdateDto updateDto) { | |||||||||||||||||||||||||||||||||||||||||||||
| WaybleZone waybleZone = waybleZoneRepository.findById(updateDto.id()) | ||||||||||||||||||||||||||||||||||||||||||||||
| .orElseThrow(() -> new ApplicationException(AdminErrorCase.WAYBLE_ZONE_NOT_FOUND)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 메인 이미지 변경 시 기존 이미지 S3에서 삭제 | ||||||||||||||||||||||||||||||||||||||||||||||
| String oldImageUrl = waybleZone.getMainImageUrl(); | ||||||||||||||||||||||||||||||||||||||||||||||
| String newImageUrl = updateDto.mainImageUrl(); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (oldImageUrl != null && !oldImageUrl.equals(newImageUrl)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| amazonS3Manager.deleteImageFileFromS3(oldImageUrl); | ||||||||||||||||||||||||||||||||||||||||||||||
| log.info("기존 메인 이미지 삭제 완료 - URL: {}", oldImageUrl); | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||||||||||||||
| log.warn("기존 메인 이미지 삭제 실패 - URL: {}, 오류: {}", oldImageUrl, e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+92
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion S3 이미지 삭제 로직을 별도 메서드로 분리하세요. updateWaybleZone과 deleteWaybleZone 메서드에서 S3 이미지 삭제 로직이 중복됩니다. 코드 중복을 제거하고 가독성을 향상시키기 위해 별도 메서드로 분리하는 것을 권장합니다. + private void deleteImageFromS3(String imageUrl, String context) {
+ if (imageUrl != null) {
+ try {
+ amazonS3Manager.deleteImageFileFromS3(imageUrl);
+ log.info("{} 이미지 삭제 완료 - URL: {}", context, imageUrl);
+ } catch (Exception e) {
+ log.warn("{} 이미지 삭제 실패 - URL: {}, 오류: {}", context, imageUrl, e.getMessage());
+ }
+ }
+ }그런 다음 중복된 코드를 이 메서드 호출로 대체하세요. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 주소 정보 업데이트 | ||||||||||||||||||||||||||||||||||||||||||||||
| com.wayble.server.common.entity.Address updatedAddress = com.wayble.server.common.entity.Address | ||||||||||||||||||||||||||||||||||||||||||||||
| .builder() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -135,6 +149,16 @@ public void deleteWaybleZone(Long waybleZoneId) { | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| log.info("웨이블존 삭제 시작 - ID: {}, 이름: {}", waybleZoneId, waybleZone.getZoneName()); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 메인 이미지 S3에서 삭제 | ||||||||||||||||||||||||||||||||||||||||||||||
| if (waybleZone.getMainImageUrl() != null) { | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| amazonS3Manager.deleteImageFileFromS3(waybleZone.getMainImageUrl()); | ||||||||||||||||||||||||||||||||||||||||||||||
| log.info("메인 이미지 삭제 완료 - URL: {}", waybleZone.getMainImageUrl()); | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||||||||||||||
| log.warn("메인 이미지 삭제 실패 - URL: {}, 오류: {}", waybleZone.getMainImageUrl(), e.getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+152
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 중복된 S3 삭제 로직을 통합된 메서드로 교체하세요. 위에서 제안한 - // 메인 이미지 S3에서 삭제
- if (waybleZone.getMainImageUrl() != null) {
- try {
- amazonS3Manager.deleteImageFileFromS3(waybleZone.getMainImageUrl());
- log.info("메인 이미지 삭제 완료 - URL: {}", waybleZone.getMainImageUrl());
- } catch (Exception e) {
- log.warn("메인 이미지 삭제 실패 - URL: {}, 오류: {}", waybleZone.getMainImageUrl(), e.getMessage());
- }
- }
+ // 메인 이미지 S3에서 삭제
+ deleteImageFromS3(waybleZone.getMainImageUrl(), "메인");📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 연관된 리뷰들 soft delete | ||||||||||||||||||||||||||||||||||||||||||||||
| waybleZone.getReviewList().forEach(review -> { | ||||||||||||||||||||||||||||||||||||||||||||||
| review.softDelete(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.wayble.server.common.config.security.jwt.JwtTokenProvider; | ||
| import com.wayble.server.common.exception.ApplicationException; | ||
| import com.wayble.server.logging.service.UserActionLogService; | ||
| import com.wayble.server.user.dto.KakaoLoginRequestDto; | ||
| import com.wayble.server.user.dto.KakaoLoginResponseDto; | ||
| import com.wayble.server.user.dto.KakaoUserInfoDto; | ||
|
|
@@ -26,6 +27,7 @@ public class KakaoLoginService { | |
| private final JwtTokenProvider jwtProvider; | ||
| private final ObjectMapper objectMapper; | ||
| private final WebClient webClient; | ||
| private final UserActionLogService userActionLogService; | ||
|
|
||
| private static final String KAKAO_USERINFO_URL = "https://kapi.kakao.com/v2/user/me"; | ||
|
|
||
|
|
@@ -66,6 +68,21 @@ public KakaoLoginResponseDto kakaoLogin(KakaoLoginRequestDto request) { | |
| ); | ||
| String refreshToken = jwtProvider.generateRefreshToken(user.getId()); | ||
|
|
||
| // 로그 저장 (비동기) | ||
| if (isNewUser) { | ||
| // 신규 가입 로그 | ||
| userActionLogService.logUserRegister( | ||
| user.getId(), | ||
| LoginType.KAKAO.name(), | ||
| user.getUserType() != null ? user.getUserType().name() : null | ||
| ); | ||
| } | ||
|
|
||
| // 모든 카카오 로그인시 활성 유저 로그 저장 (하루 1회만) | ||
| userActionLogService.logTokenRefresh( | ||
| user.getId(), | ||
| user.getUserType() != null ? user.getUserType().name() : null | ||
| ); | ||
|
Comment on lines
+71
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 로그 기록 로직을 별도 메서드로 분리하여 가독성을 개선하세요. 메인 로그인 로직과 로그 기록 로직이 섞여 있어 코드 가독성이 떨어집니다. 로그 기록을 별도 메서드로 분리하는 것을 권장합니다. // JWT 토큰 발급
String accessToken = jwtProvider.generateToken(
user.getId(),
user.getUserType() != null ? user.getUserType().name() : null
);
String refreshToken = jwtProvider.generateRefreshToken(user.getId());
- // 로그 저장 (비동기)
- if (isNewUser) {
- // 신규 가입 로그
- userActionLogService.logUserRegister(
- user.getId(),
- LoginType.KAKAO.name(),
- user.getUserType() != null ? user.getUserType().name() : null
- );
- }
-
- // 모든 카카오 로그인시 활성 유저 로그 저장 (하루 1회만)
- userActionLogService.logTokenRefresh(
- user.getId(),
- user.getUserType() != null ? user.getUserType().name() : null
- );
+ // 사용자 행동 로그 기록
+ logUserActions(user, isNewUser);
+ private void logUserActions(User user, boolean isNewUser) {
+ try {
+ if (isNewUser) {
+ userActionLogService.logUserRegister(
+ user.getId(),
+ LoginType.KAKAO.name(),
+ user.getUserType() != null ? user.getUserType().name() : null
+ );
+ }
+
+ userActionLogService.logTokenRefresh(
+ user.getId(),
+ user.getUserType() != null ? user.getUserType().name() : null
+ );
+ } catch (Exception e) {
+ log.warn("사용자 행동 로그 기록 실패 - 사용자 ID: {}", user.getId(), e);
+ }
+ }🤖 Prompt for AI Agents |
||
|
|
||
| return KakaoLoginResponseDto.builder() | ||
| .accessToken(accessToken) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
API 엔드포인트 개선사항 제안
새로운 일일 통계 API가 잘 구현되었으나 몇 가지 개선할 점이 있습니다:
다음과 같이 개선하세요:
📝 Committable suggestion
🤖 Prompt for AI Agents