From 7f72a369eff0f149632ce270e93f3afd3f22e4d0 Mon Sep 17 00:00:00 2001 From: mingeun0507 Date: Fri, 26 May 2023 01:01:46 +0900 Subject: [PATCH] =?UTF-8?q?Fix(#171):=20=EC=98=A4=EB=A5=98=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20log.info()=20=EC=B6=9C=EB=A0=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seesaw/service/auth/SignupService.java | 3 +++ .../seesaw/service/battery/BatteryService.java | 15 ++++++++++++++- .../seesaw/service/charge/ChargeService.java | 5 ++++- .../seesaw/service/project/ProjectService.java | 9 +++++++-- .../seesaw/service/user/UserServiceImpl.java | 3 +++ .../seesaw/service/value/ValueService.java | 6 ++++-- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/_8attery/seesaw/service/auth/SignupService.java b/src/main/java/com/_8attery/seesaw/service/auth/SignupService.java index 7cf9ed7..5442fc3 100644 --- a/src/main/java/com/_8attery/seesaw/service/auth/SignupService.java +++ b/src/main/java/com/_8attery/seesaw/service/auth/SignupService.java @@ -5,12 +5,14 @@ import com._8attery.seesaw.exception.BaseException; import com._8attery.seesaw.exception.BaseResponseStatus; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.List; +@Slf4j @Service @Transactional(readOnly = true) @RequiredArgsConstructor @@ -53,6 +55,7 @@ public SignupResponseDto userSignup(Boolean agreeMarketing, String email, String return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(BaseResponseStatus.DATABASE_ERROR); } diff --git a/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java b/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java index 7f919a9..451076d 100644 --- a/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java +++ b/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java @@ -6,15 +6,19 @@ import com._8attery.seesaw.dto.api.response.*; import com._8attery.seesaw.exception.BaseException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import static com._8attery.seesaw.exception.BaseResponseStatus.DATABASE_ERROR; +@Slf4j @Service @Transactional(readOnly = true) @RequiredArgsConstructor @@ -31,6 +35,7 @@ public Integer setUserActivityGoal(Long userId, Integer req) throws BaseExceptio return batteryRepository.findUserActivityGoal(userId); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -45,6 +50,7 @@ public Integer setUserSleepGoal(Long userId, Integer req) throws BaseException { return batteryRepository.findUserSleepGoal(userId); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -59,6 +65,7 @@ public Integer setUserCurActivity(Long userId, Integer req) throws BaseException return batteryRepository.findUserCurActivity(userId); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -97,6 +104,7 @@ public Integer setUserCurSleep(Long userId, Integer req) throws BaseException { return batteryRepository.findUserCurSleep(userId); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -112,6 +120,7 @@ public List getUserBatteryHistory(Long userId) throws return batteryRepository.findUserBatteryHistory(userId, startDate, endDate); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -155,6 +164,7 @@ public List getUserBatteryData(Long userId) throws return combinedData; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -221,6 +231,7 @@ public List getUserActivity(Long userId, Integer year, Inte return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -299,6 +310,7 @@ public List getUserSleep(Long userId, Integer year, Integer mo return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -334,6 +346,7 @@ public BatteryResponseDto getUserBattery(Long userId) throws BaseException { return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } diff --git a/src/main/java/com/_8attery/seesaw/service/charge/ChargeService.java b/src/main/java/com/_8attery/seesaw/service/charge/ChargeService.java index 8ee473b..76f5406 100644 --- a/src/main/java/com/_8attery/seesaw/service/charge/ChargeService.java +++ b/src/main/java/com/_8attery/seesaw/service/charge/ChargeService.java @@ -5,15 +5,16 @@ import com._8attery.seesaw.dto.api.response.ChargeResponseDto; import com._8attery.seesaw.exception.BaseException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Optional; import static com._8attery.seesaw.exception.BaseResponseStatus.DATABASE_ERROR; +@Slf4j @Service @Transactional(readOnly = true) @RequiredArgsConstructor @@ -49,6 +50,7 @@ public ChargeResponseDto setUserCharge(Long userId, Long valueId, String chargeN return chargeResponseDto.orElse(new ChargeResponseDto(0L, null, null)); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -60,6 +62,7 @@ public ChargeResponseDto getUserCharge(Long userId) throws BaseException { return chargeRepository.findTodayCharge(userId); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } diff --git a/src/main/java/com/_8attery/seesaw/service/project/ProjectService.java b/src/main/java/com/_8attery/seesaw/service/project/ProjectService.java index d687946..e11de5a 100644 --- a/src/main/java/com/_8attery/seesaw/service/project/ProjectService.java +++ b/src/main/java/com/_8attery/seesaw/service/project/ProjectService.java @@ -98,7 +98,7 @@ public ProjectResponseDto addUserProject(Long userId, Long valueId, String proje // return projectResponseDto.orElse(new ProjectResponseDto(0L, null, null, null, null, null, false)); // // } catch (Exception exception) { -// exception.printStackTrace(); +// log.info(exception.getMessage());exception.printStackTrace(); // throw new BaseException(DATABASE_ERROR); // } @@ -139,6 +139,7 @@ public ProjectResponseDto updateUserProject(Long projectId, Long userId, Long va return projectResponseDto.orElse(new ProjectResponseDto(0L, null, null, null, null, null, false)); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -151,6 +152,7 @@ public Long retrieveUserId(Long projectId) throws BaseException { throw new BaseException(POSTS_EMPTY_POST_ID); return userId; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -164,7 +166,7 @@ public void deleteUserProject(Long projectId) throws BaseException { // if (result == 0) // throw new BaseException(DELETE_FAIL_POST); // } catch (Exception exception) { -// exception.printStackTrace(); +// log.info(exception.getMessage());exception.printStackTrace(); // throw new BaseException(DATABASE_ERROR); // } Project retrievedProject = serviceUtils.retrieveProjectById(projectId); @@ -176,6 +178,7 @@ public List getProgressProjectList(Long userId) throws B List list = projectRepository.findProgressProjectList(userId); return list; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -186,6 +189,7 @@ public List getCompleteProjectList(Long userId) throws B List list = projectRepository.findCompleteProjectList(userId); return list; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -200,6 +204,7 @@ public ProjectCountResponseDto getUserProjectCount(Long userId) throws BaseExcep ProjectCountResponseDto res = new ProjectCountResponseDto(progressCount, completeCount); return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } diff --git a/src/main/java/com/_8attery/seesaw/service/user/UserServiceImpl.java b/src/main/java/com/_8attery/seesaw/service/user/UserServiceImpl.java index c809790..86a32b7 100644 --- a/src/main/java/com/_8attery/seesaw/service/user/UserServiceImpl.java +++ b/src/main/java/com/_8attery/seesaw/service/user/UserServiceImpl.java @@ -40,6 +40,7 @@ public void updateNickname(Long userId, NicknameRequestDto nicknameRequestDto) t userRepository.updateUserNickname(userId, nicknameRequestDto.getNickName()); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -52,6 +53,7 @@ public String getUserNickname(Long userId) throws BaseException { return userRepository.findUserNickname(userId); } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -78,6 +80,7 @@ public UserHistoryResponseDto getUserHistory(Long userId) throws BaseException { return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } diff --git a/src/main/java/com/_8attery/seesaw/service/value/ValueService.java b/src/main/java/com/_8attery/seesaw/service/value/ValueService.java index 846cc38..2a806e3 100644 --- a/src/main/java/com/_8attery/seesaw/service/value/ValueService.java +++ b/src/main/java/com/_8attery/seesaw/service/value/ValueService.java @@ -2,13 +2,13 @@ import com._8attery.seesaw.domain.project.Project; import com._8attery.seesaw.domain.value.ValueRepository; -import com._8attery.seesaw.dto.api.response.UserHistoryResponseDto; import com._8attery.seesaw.dto.api.response.ValueInfoResponseDto; import com._8attery.seesaw.dto.api.response.ValueResponseDto; import com._8attery.seesaw.dto.api.response.ValueYearResponseDto; import com._8attery.seesaw.exception.BaseException; import com._8attery.seesaw.exception.BaseResponseStatus; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -19,8 +19,8 @@ import java.util.List; import static com._8attery.seesaw.exception.BaseResponseStatus.DATABASE_ERROR; -import static java.time.temporal.ChronoUnit.DAYS; +@Slf4j @Service @Transactional(readOnly = true) @RequiredArgsConstructor @@ -103,6 +103,7 @@ public ValueInfoResponseDto getUserValueInfo(Long userId, Long valueId) throws B return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); } @@ -142,6 +143,7 @@ public ValueYearResponseDto getUserValueYear(Long userId) throws BaseException { return res; } catch (Exception exception) { + log.info(exception.getMessage()); exception.printStackTrace(); throw new BaseException(DATABASE_ERROR); }