Skip to content

Commit 0b2cbe7

Browse files
committed
Feat: 멘토 슬롯 조회
1 parent ab6376f commit 0b2cbe7

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

back/src/main/java/com/back/domain/mentoring/slot/controller/MentorSlotController.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ public class MentorSlotController {
2222
private final MentorSlotService mentorSlotService;
2323
private final Rq rq;
2424

25+
@GetMapping("/{slotId}")
26+
@Operation(summary = "멘토 슬롯 조회", description = "특정 멘토 슬롯을 조회합니다.")
27+
public RsData<MentorSlotResponse> getMentorSlot(
28+
@PathVariable Long slotId
29+
) {
30+
MentorSlotResponse resDto = mentorSlotService.getMentorSlot(slotId);
31+
32+
return new RsData<>(
33+
"200",
34+
"멘토의 예약 가능 일정을 조회하였습니다.",
35+
resDto
36+
);
37+
}
38+
2539
@PostMapping
2640
@PreAuthorize("hasRole('MENTOR')")
2741
@Operation(summary = "멘토 슬롯 생성", description = "멘토 슬롯을 생성합니다. 로그인한 멘토만 생성할 수 있습니다.")
@@ -33,7 +47,7 @@ public RsData<MentorSlotResponse> createMentorSlot(
3347

3448
return new RsData<>(
3549
"201",
36-
"멘토링 예약 일정을 등록했습니다.",
50+
"멘토의 예약 가능 일정을 등록했습니다.",
3751
resDto
3852
);
3953
}
@@ -49,7 +63,7 @@ public RsData<MentorSlotResponse> updateMentorSlot(
4963

5064
return new RsData<>(
5165
"200",
52-
"멘토링 예약 일정이 수정되었습니다.",
66+
"멘토의 예약 가능 일정이 수정되었습니다.",
5367
resDto
5468
);
5569
}
@@ -64,8 +78,7 @@ public RsData<Void> deleteMentorSlot(
6478

6579
return new RsData<>(
6680
"200",
67-
"멘토링 예약 일정이 삭제되었습니다."
81+
"멘토의 예약 가능 일정이 삭제되었습니다."
6882
);
6983
}
70-
7184
}

back/src/main/java/com/back/domain/mentoring/slot/service/MentorSlotService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public class MentorSlotService {
2929
private final MentoringRepository mentoringRepository;
3030
private final ReservationRepository reservationRepository;
3131

32+
@Transactional(readOnly = true)
33+
public MentorSlotResponse getMentorSlot(Long slotId) {
34+
MentorSlot mentorSlot = findMentorSlot(slotId);
35+
Mentoring mentoring = findMentoring(mentorSlot.getMentor());
36+
37+
return MentorSlotResponse.from(mentorSlot, mentoring);
38+
}
39+
3240
@Transactional
3341
public MentorSlotResponse createMentorSlot(MentorSlotRequest reqDto, Member member) {
3442
Mentor mentor = findMentor(member);

back/src/test/java/com/back/domain/mentoring/slot/controller/MentorSlotControllerTest.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,35 @@ void setUp() {
7373
mentorSlots = mentoringFixture.createMentorSlots(mentor, baseDateTime, 2, 3);
7474
}
7575

76+
// ===== 슬롯 조회 =====
77+
@Test
78+
@DisplayName("멘토 슬롯 조회 성공")
79+
void getMentorSlotSuccess() throws Exception {
80+
MentorSlot mentorSlot = mentorSlots.getFirst();
81+
82+
ResultActions resultActions = mvc.perform(
83+
get(MENTOR_SLOT_URL + "/" + mentorSlot.getId())
84+
.cookie(new Cookie(TOKEN, mentorToken))
85+
)
86+
.andDo(print());
87+
88+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
89+
90+
resultActions
91+
.andExpect(status().isOk())
92+
.andExpect(handler().handlerType(MentorSlotController.class))
93+
.andExpect(handler().methodName("getMentorSlot"))
94+
.andExpect(jsonPath("$.resultCode").value("200"))
95+
.andExpect(jsonPath("$.msg").value("멘토의 예약 가능 일정을 조회하였습니다."))
96+
.andExpect(jsonPath("$.data.mentorSlotId").value(mentorSlot.getId()))
97+
.andExpect(jsonPath("$.data.mentorId").value(mentorSlot.getMentor().getId()))
98+
.andExpect(jsonPath("$.data.mentoringId").value(mentoring.getId()))
99+
.andExpect(jsonPath("$.data.mentoringTitle").value(mentoring.getTitle()))
100+
.andExpect(jsonPath("$.data.startDateTime").value(mentorSlot.getStartDateTime().format(formatter)))
101+
.andExpect(jsonPath("$.data.endDateTime").value(mentorSlot.getEndDateTime().format(formatter)))
102+
.andExpect(jsonPath("$.data.mentorSlotStatus").value(mentorSlot.getStatus().name()));
103+
}
104+
76105
// ===== 슬롯 생성 =====
77106

78107
@Test
@@ -84,7 +113,7 @@ void createMentorSlotSuccess() throws Exception {
84113
ResultActions resultActions = performCreateMentorSlot(mentor.getId(), mentorToken, startDateTime, endDateTime)
85114
.andExpect(status().isCreated())
86115
.andExpect(jsonPath("$.resultCode").value("201"))
87-
.andExpect(jsonPath("$.msg").value("멘토링 예약 일정을 등록했습니다."));
116+
.andExpect(jsonPath("$.msg").value("멘토의 예약 가능 일정을 등록했습니다."));
88117

89118
MentorSlot mentorSlot = mentorSlotRepository.findTopByOrderByIdDesc()
90119
.orElseThrow(() -> new ServiceException(MentorSlotErrorCode.NOT_FOUND_MENTOR_SLOT));
@@ -146,7 +175,7 @@ void updateMentorSlotSuccess() throws Exception {
146175
resultActions
147176
.andExpect(status().isOk())
148177
.andExpect(jsonPath("$.resultCode").value("200"))
149-
.andExpect(jsonPath("$.msg").value("멘토링 예약 일정이 수정되었습니다."))
178+
.andExpect(jsonPath("$.msg").value("멘토의 예약 가능 일정이 수정되었습니다."))
150179
.andExpect(jsonPath("$.data.mentorSlotId").value(mentorSlot.getId()))
151180
.andExpect(jsonPath("$.data.mentorId").value(mentorSlot.getMentor().getId()))
152181
.andExpect(jsonPath("$.data.mentoringId").value(mentoring.getId()))
@@ -176,7 +205,7 @@ void updateMentorSlotSuccessReserved() throws Exception {
176205
resultActions
177206
.andExpect(status().isOk())
178207
.andExpect(jsonPath("$.resultCode").value("200"))
179-
.andExpect(jsonPath("$.msg").value("멘토링 예약 일정이 수정되었습니다."))
208+
.andExpect(jsonPath("$.msg").value("멘토의 예약 가능 일정이 수정되었습니다."))
180209
.andExpect(jsonPath("$.data.mentorSlotId").value(mentorSlot.getId()))
181210
.andExpect(jsonPath("$.data.mentorId").value(mentorSlot.getMentor().getId()))
182211
.andExpect(jsonPath("$.data.mentoringId").value(mentoring.getId()))
@@ -249,7 +278,7 @@ void deleteMentorSlotSuccess() throws Exception {
249278
.andExpect(handler().handlerType(MentorSlotController.class))
250279
.andExpect(handler().methodName("deleteMentorSlot"))
251280
.andExpect(jsonPath("$.resultCode").value("200"))
252-
.andExpect(jsonPath("$.msg").value("멘토링 예약 일정이 삭제되었습니다."));
281+
.andExpect(jsonPath("$.msg").value("멘토의 예약 가능 일정이 삭제되었습니다."));
253282

254283
assertThat(afterCnt).isEqualTo(beforeCnt - 1);
255284
}

0 commit comments

Comments
 (0)