Skip to content

Commit 37fce94

Browse files
committed
feat: 멘토링 신규 신청 건수 조회 구현
1 parent 1e31b51 commit 37fce94

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/main/java/com/example/solidconnection/mentor/controller/MentoringController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.example.solidconnection.mentor.dto.MentoringCheckResponse;
77
import com.example.solidconnection.mentor.dto.MentoringConfirmRequest;
88
import com.example.solidconnection.mentor.dto.MentoringConfirmResponse;
9+
import com.example.solidconnection.mentor.dto.MentoringCountResponse;
910
import com.example.solidconnection.mentor.dto.MentoringResponse;
1011
import com.example.solidconnection.mentor.service.MentoringCommandService;
1112
import com.example.solidconnection.mentor.service.MentoringQueryService;
@@ -70,4 +71,12 @@ public ResponseEntity<MentoringCheckResponse> checkMentoring(
7071
MentoringCheckResponse response = mentoringCommandService.checkMentoring(siteUser.getId(), mentoringId);
7172
return ResponseEntity.ok(response);
7273
}
74+
75+
@GetMapping("/check")
76+
public ResponseEntity<MentoringCountResponse> getNewMentoringsCount(
77+
@AuthorizedUser SiteUser siteUser
78+
) {
79+
MentoringCountResponse responses = mentoringQueryService.getNewMentoringsCount(siteUser.getId());
80+
return ResponseEntity.ok(responses);
81+
}
7382
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.solidconnection.mentor.dto;
2+
3+
public record MentoringCountResponse(
4+
int mentoringCount
5+
) {
6+
7+
public static MentoringCountResponse from(int mentoringCount) {
8+
return new MentoringCountResponse(mentoringCount);
9+
}
10+
}

src/main/java/com/example/solidconnection/mentor/repository/MentoringRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
public interface MentoringRepository extends JpaRepository<Mentoring, Long> {
99

1010
List<Mentoring> findAllByMentorId(Long mentorId);
11+
int countByMentorIdAndCheckedAtIsNull(Long mentorId);
1112
}

src/main/java/com/example/solidconnection/mentor/service/MentoringQueryService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.example.solidconnection.common.exception.CustomException;
44
import com.example.solidconnection.mentor.domain.Mentor;
55
import com.example.solidconnection.mentor.domain.Mentoring;
6+
import com.example.solidconnection.mentor.dto.MentoringCountResponse;
67
import com.example.solidconnection.mentor.dto.MentoringResponse;
78
import com.example.solidconnection.mentor.repository.MentorRepository;
89
import com.example.solidconnection.mentor.repository.MentoringRepository;
@@ -33,4 +34,14 @@ public List<MentoringResponse> getMentorings(Long siteUserId) {
3334
.map(MentoringResponse::from)
3435
.collect(Collectors.toList());
3536
}
37+
38+
@Transactional(readOnly = true)
39+
public MentoringCountResponse getNewMentoringsCount(Long siteUserId) {
40+
Mentor mentor = mentorRepository.findBySiteUserId(siteUserId)
41+
.orElseThrow(() -> new CustomException(MENTOR_NOT_FOUND));
42+
43+
int count = mentoringRepository.countByMentorIdAndCheckedAtIsNull(mentor.getId());
44+
45+
return MentoringCountResponse.from(count);
46+
}
3647
}

0 commit comments

Comments
 (0)