Skip to content

Commit adc7121

Browse files
committed
refactor: API 명세에 맞게 응답 수정
1 parent 020f1cb commit adc7121

5 files changed

Lines changed: 32 additions & 27 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.example.solidconnection.mentor.dto;
22

33
public record MentoringCountResponse(
4-
int mentoringCount
4+
int uncheckedCount
55
) {
66

7-
public static MentoringCountResponse from(int mentoringCount) {
8-
return new MentoringCountResponse(mentoringCount);
7+
public static MentoringCountResponse from(int uncheckedCount) {
8+
return new MentoringCountResponse(uncheckedCount);
99
}
1010
}

src/main/java/com/example/solidconnection/mentor/dto/MentoringListResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import java.util.List;
44

55
public record MentoringListResponse(
6-
List<MentoringResponse> mentoringResponseList
6+
List<MentoringResponse> requests
77
) {
8-
public static MentoringListResponse from(List<MentoringResponse> mentoringResponseList) {
9-
return new MentoringListResponse(mentoringResponseList);
8+
public static MentoringListResponse from(List<MentoringResponse> requests) {
9+
return new MentoringListResponse(requests);
1010
}
1111
}
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
package com.example.solidconnection.mentor.dto;
22

3-
import com.example.solidconnection.common.VerifyStatus;
43
import com.example.solidconnection.mentor.domain.Mentoring;
4+
import com.example.solidconnection.siteuser.domain.SiteUser;
55

66
import java.time.ZonedDateTime;
77

88
public record MentoringResponse(
9-
long id,
10-
long mentorId,
11-
long menteeId,
12-
ZonedDateTime createdAt,
13-
ZonedDateTime confirmedAt,
14-
VerifyStatus verifyStatus,
15-
String rejectedReason
9+
long mentoringId,
10+
String profileImageUrl,
11+
String nickname,
12+
boolean isChecked,
13+
ZonedDateTime createAt
1614
) {
17-
public static MentoringResponse from(Mentoring mentoring) {
15+
public static MentoringResponse from(Mentoring mentoring, SiteUser mentee) {
1816
return new MentoringResponse(
1917
mentoring.getId(),
20-
mentoring.getMentorId(),
21-
mentoring.getMenteeId(),
22-
mentoring.getCreatedAt(),
23-
mentoring.getConfirmedAt(),
24-
mentoring.getVerifyStatus(),
25-
mentoring.getRejectedReason()
18+
mentee.getProfileImageUrl(),
19+
mentee.getNickname(),
20+
mentoring.getCheckedAt() != null,
21+
mentoring.getCreatedAt()
2622
);
2723
}
2824
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package com.example.solidconnection.mentor.service;
22

33
import com.example.solidconnection.common.exception.CustomException;
4+
import com.example.solidconnection.common.exception.ErrorCode;
45
import com.example.solidconnection.mentor.domain.Mentor;
56
import com.example.solidconnection.mentor.domain.Mentoring;
67
import com.example.solidconnection.mentor.dto.MentoringCountResponse;
78
import com.example.solidconnection.mentor.dto.MentoringListResponse;
89
import com.example.solidconnection.mentor.dto.MentoringResponse;
910
import com.example.solidconnection.mentor.repository.MentorRepository;
1011
import com.example.solidconnection.mentor.repository.MentoringRepository;
12+
import com.example.solidconnection.siteuser.domain.SiteUser;
13+
import com.example.solidconnection.siteuser.repository.SiteUserRepository;
1114
import lombok.RequiredArgsConstructor;
1215
import org.springframework.stereotype.Service;
1316
import org.springframework.transaction.annotation.Transactional;
@@ -22,6 +25,7 @@ public class MentoringQueryService {
2225

2326
private final MentoringRepository mentoringRepository;
2427
private final MentorRepository mentorRepository;
28+
private final SiteUserRepository siteUserRepository;
2529

2630
@Transactional(readOnly = true)
2731
public MentoringListResponse getMentorings(long siteUserId) {
@@ -30,7 +34,12 @@ public MentoringListResponse getMentorings(long siteUserId) {
3034

3135
List<Mentoring> mentorings = mentoringRepository.findAllByMentorId(mentor.getId());
3236
List<MentoringResponse> mentoringResponses = mentorings.stream()
33-
.map(MentoringResponse::from)
37+
.map(mentoring -> {
38+
SiteUser mentee = siteUserRepository.findById(mentoring.getMenteeId())
39+
.orElseThrow(() -> new CustomException(ErrorCode.USER_NOT_FOUND));
40+
41+
return MentoringResponse.from(mentoring, mentee);
42+
})
3443
.toList();
3544

3645
return MentoringListResponse.from(mentoringResponses);

src/test/java/com/example/solidconnection/mentor/service/MentoringQueryServiceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class 멘토링_목록_조회_테스트 {
6161

6262
// then
6363
assertAll(
64-
() -> assertThat(responses.mentoringResponseList()).hasSize(3),
65-
() -> assertThat(responses.mentoringResponseList()).extracting(MentoringResponse::id)
64+
() -> assertThat(responses.requests()).hasSize(3),
65+
() -> assertThat(responses.requests()).extracting(MentoringResponse::mentoringId)
6666
.containsExactlyInAnyOrder(
6767
mentoring1.getId(),
6868
mentoring2.getId(),
@@ -77,7 +77,7 @@ class 멘토링_목록_조회_테스트 {
7777
MentoringListResponse responses = mentoringQueryService.getMentorings(mentorUser.getId());
7878

7979
// then
80-
assertThat(responses.mentoringResponseList()).isEmpty();
80+
assertThat(responses.requests()).isEmpty();
8181
}
8282
}
8383

@@ -95,7 +95,7 @@ class 새_멘토링_개수_조회_테스트 {
9595
MentoringCountResponse response = mentoringQueryService.getNewMentoringsCount(mentorUser.getId());
9696

9797
// then
98-
assertThat(response.mentoringCount()).isEqualTo(2);
98+
assertThat(response.uncheckedCount()).isEqualTo(2);
9999
}
100100

101101
@Test
@@ -107,7 +107,7 @@ class 새_멘토링_개수_조회_테스트 {
107107
MentoringCountResponse response = mentoringQueryService.getNewMentoringsCount(mentorUser.getId());
108108

109109
// then
110-
assertThat(response.mentoringCount()).isZero();
110+
assertThat(response.uncheckedCount()).isZero();
111111
}
112112
}
113113
}

0 commit comments

Comments
 (0)