Skip to content

Commit

Permalink
refactor(InternalMeetingStatsService): orgId에 해당하는 유저가 없을 경우 승인된 스터디 …
Browse files Browse the repository at this point in the history
…신청 수를 0으로 반환하도록 변경
  • Loading branch information
hoonyworld committed Nov 21, 2024
1 parent 457056a commit f3799d6
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

0 comments on commit f3799d6

Please sign in to comment.