From f3799d6a9ddc7a6d64fee20e4113b422d6efb3e0 Mon Sep 17 00:00:00 2001 From: DongHoon Lee Date: Thu, 21 Nov 2024 16:17:15 +0900 Subject: [PATCH] =?UTF-8?q?refactor(InternalMeetingStatsService):=20orgId?= =?UTF-8?q?=EC=97=90=20=ED=95=B4=EB=8B=B9=ED=95=98=EB=8A=94=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EA=B0=80=20=EC=97=86=EC=9D=84=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?=EC=8A=B9=EC=9D=B8=EB=90=9C=20=EC=8A=A4=ED=84=B0=EB=94=94=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=20=EC=88=98=EB=A5=BC=200=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/InternalMeetingStatsService.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main/src/main/java/org/sopt/makers/crew/main/internal/service/InternalMeetingStatsService.java b/main/src/main/java/org/sopt/makers/crew/main/internal/service/InternalMeetingStatsService.java index af286b12..5a2c4320 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/internal/service/InternalMeetingStatsService.java +++ b/main/src/main/java/org/sopt/makers/crew/main/internal/service/InternalMeetingStatsService.java @@ -5,8 +5,6 @@ import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory; import org.sopt.makers.crew.main.entity.user.User; import org.sopt.makers.crew.main.entity.user.UserRepository; -import org.sopt.makers.crew.main.global.exception.ErrorStatus; -import org.sopt.makers.crew.main.global.exception.NotFoundException; import org.sopt.makers.crew.main.internal.dto.ApprovedStudyCountResponseDto; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,12 +19,15 @@ public class InternalMeetingStatsService { private final UserRepository userRepository; public ApprovedStudyCountResponseDto getApprovedStudyCountByOrgId(Integer orgId) { - User user = userRepository.findByOrgId(orgId) - .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_USER.getErrorCode())); + User user = userRepository.findByOrgId(orgId).orElse(null); - Long approvedStudyCount = applyRepository.findApprovedStudyCountByOrgId( - MeetingCategory.STUDY, EnApplyStatus.APPROVE, user.getOrgId()); + if (user == null) { + return ApprovedStudyCountResponseDto.of(orgId, 0L); + } - return ApprovedStudyCountResponseDto.of(user.getOrgId(), approvedStudyCount); + Long approvedStudyCount = applyRepository.findApprovedStudyCountByOrgId(MeetingCategory.STUDY, + EnApplyStatus.APPROVE, user.getOrgId()); + + return ApprovedStudyCountResponseDto.of(orgId, approvedStudyCount); } }