Skip to content

Commit 5e59344

Browse files
sso0omluckhee
authored andcommitted
Refactor: 멘토링 도메인에 멘토 닉네임 필드 반영 (#118)
* Refactor: name -> nickname 반영 * Refactor: 검증 수정 * Refactor: 반복 시작, 종료 검증 추가 * fix: 멘토 멘티 맴버 fetch join하여 조회 * Fix: StringListConverter에서 JSON 이중 인코딩 문제 해결
1 parent 3b7424b commit 5e59344

File tree

17 files changed

+197
-100
lines changed

17 files changed

+197
-100
lines changed

back/src/main/java/com/back/domain/member/member/service/MemberStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public Mentor findMentorByMember(Member member) {
2424
}
2525

2626
public Mentor findMentorByMemberId(Long memberId) {
27-
return mentorRepository.findByMemberId(memberId)
27+
return mentorRepository.findByMemberIdWithMember(memberId)
2828
.orElseThrow(() -> new ServiceException(MemberErrorCode.NOT_FOUND_MENTOR));
2929
}
3030

3131
public Mentee findMenteeByMember(Member member) {
32-
return menteeRepository.findByMemberId(member.getId())
32+
return menteeRepository.findByMemberIdWithMember(member.getId())
3333
.orElseThrow(() -> new ServiceException(MemberErrorCode.NOT_FOUND_MENTEE));
3434
}
3535

back/src/main/java/com/back/domain/member/mentee/dto/MenteeDto.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
public record MenteeDto(
77
@Schema(description = "멘티 ID")
88
Long menteeId,
9-
@Schema(description = "멘티명")
10-
String name
9+
@Schema(description = "멘티 닉네임")
10+
String nickname
1111
) {
1212
public static MenteeDto from(Mentee mentee) {
1313
return new MenteeDto(
1414
mentee.getId(),
15-
mentee.getMember().getName()
15+
mentee.getMember().getNickname()
1616
);
1717
}
1818
}

back/src/main/java/com/back/domain/member/mentee/repository/MenteeRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public interface MenteeRepository extends JpaRepository<Mentee, Long> {
1212
@Query("SELECT m FROM Mentee m WHERE m.member.id = :memberId AND m.isDeleted = false")
1313
Optional<Mentee> findByMemberId(@Param("memberId") Long memberId);
1414

15+
@Query("SELECT m FROM Mentee m JOIN FETCH m.member WHERE m.member.id = :memberId AND m.isDeleted = false")
16+
Optional<Mentee> findByMemberIdWithMember(@Param("memberId") Long memberId);
17+
1518
@Query("SELECT m FROM Mentee m WHERE m.id = :id AND m.isDeleted = false")
1619
Optional<Mentee> findById(@Param("id") Long id);
1720

back/src/main/java/com/back/domain/member/mentor/dto/MentorDetailDto.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
public record MentorDetailDto(
77
@Schema(description = "멘토 ID")
88
Long mentorId,
9-
@Schema(description = "멘토명")
10-
String name,
9+
@Schema(description = "멘토 닉네임")
10+
String nickname,
1111
@Schema(description = "평점")
1212
Double rate,
1313
// TODO: Job id, name
@@ -17,7 +17,7 @@ public record MentorDetailDto(
1717
public static MentorDetailDto from(Mentor mentor) {
1818
return new MentorDetailDto(
1919
mentor.getId(),
20-
mentor.getMember().getName(),
20+
mentor.getMember().getNickname(),
2121
mentor.getRate(),
2222
mentor.getCareerYears()
2323
);

back/src/main/java/com/back/domain/member/mentor/dto/MentorDto.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
public record MentorDto(
77
@Schema(description = "멘토 ID")
88
Long mentorId,
9-
@Schema(description = "멘토명")
10-
String name
9+
@Schema(description = "멘토 닉네임")
10+
String nickname
1111
) {
1212
public static MentorDto from(Mentor mentor) {
1313
return new MentorDto(
1414
mentor.getId(),
15-
mentor.getMember().getName()
15+
mentor.getMember().getNickname()
1616
);
1717
}
1818
}

back/src/main/java/com/back/domain/member/mentor/repository/MentorRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public interface MentorRepository extends JpaRepository<Mentor, Long> {
1212
@Query("SELECT m FROM Mentor m WHERE m.member.id = :memberId AND m.isDeleted = false")
1313
Optional<Mentor> findByMemberId(@Param("memberId") Long memberId);
1414

15+
@Query("SELECT m FROM Mentor m JOIN FETCH m.member WHERE m.member.id = :memberId AND m.isDeleted = false")
16+
Optional<Mentor> findByMemberIdWithMember(@Param("memberId") Long memberId);
17+
1518
@Query("SELECT m FROM Mentor m WHERE m.id = :id AND m.isDeleted = false")
1619
Optional<Mentor> findById(@Param("id") Long id);
1720

back/src/main/java/com/back/domain/mentoring/mentoring/repository/MentoringRepositoryImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public Page<Mentoring> searchMentorings(String keyword, Pageable pageable) {
2626

2727
BooleanBuilder builder = new BooleanBuilder();
2828

29-
// 제목, 멘토 이름 검색 조건
29+
// 제목, 멘토 닉네임 검색 조건
3030
if (keyword != null && !keyword.isBlank()) {
3131
builder.and(
3232
mentoring.title.containsIgnoreCase(keyword)
33-
.or(mentor.member.name.containsIgnoreCase(keyword))
33+
.or(mentor.member.nickname.containsIgnoreCase(keyword))
3434
);
3535
}
3636

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.back.domain.mentoring.slot.dto;
2+
3+
import com.back.domain.mentoring.slot.constant.MentorSlotStatus;
4+
import com.back.domain.mentoring.slot.entity.MentorSlot;
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
7+
import java.time.LocalDateTime;
8+
9+
public record MentorSlotDetailDto(
10+
@Schema(description = "멘토 슬롯 ID")
11+
Long mentorSlotId,
12+
@Schema(description = "시작 일시")
13+
LocalDateTime startDateTime,
14+
@Schema(description = "종료 일시")
15+
LocalDateTime endDateTime,
16+
@Schema(description = "멘토 슬롯 상태")
17+
MentorSlotStatus mentorSlotStatus,
18+
@Schema(description = "생성일")
19+
LocalDateTime createDate,
20+
@Schema(description = "수정일")
21+
LocalDateTime modifyDate
22+
) {
23+
public static MentorSlotDetailDto from(MentorSlot mentorSlot) {
24+
return new MentorSlotDetailDto(
25+
mentorSlot.getId(),
26+
mentorSlot.getStartDateTime(),
27+
mentorSlot.getEndDateTime(),
28+
mentorSlot.getStatus(),
29+
mentorSlot.getCreateDate(),
30+
mentorSlot.getModifyDate()
31+
);
32+
}
33+
}
Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,21 @@
11
package com.back.domain.mentoring.slot.dto.response;
22

3+
import com.back.domain.member.mentor.dto.MentorDto;
4+
import com.back.domain.mentoring.mentoring.dto.MentoringDto;
35
import com.back.domain.mentoring.mentoring.entity.Mentoring;
4-
import com.back.domain.mentoring.slot.constant.MentorSlotStatus;
6+
import com.back.domain.mentoring.slot.dto.MentorSlotDetailDto;
57
import com.back.domain.mentoring.slot.entity.MentorSlot;
6-
import io.swagger.v3.oas.annotations.media.Schema;
7-
8-
import java.time.LocalDateTime;
98

109
public record MentorSlotResponse(
11-
@Schema(description = "멘토 슬롯 ID")
12-
Long mentorSlotId,
13-
14-
@Schema(description = "멘토 ID")
15-
Long mentorId,
16-
17-
@Schema(description = "멘토링 ID")
18-
Long mentoringId,
19-
20-
@Schema(description = "멘토링 제목")
21-
String mentoringTitle,
22-
23-
@Schema(description = "시작 일시")
24-
LocalDateTime startDateTime,
25-
26-
@Schema(description = "종료 일시")
27-
LocalDateTime endDateTime,
28-
29-
@Schema(description = "멘토 슬롯 상태")
30-
MentorSlotStatus mentorSlotStatus,
31-
32-
@Schema(description = "생성일")
33-
LocalDateTime createDate,
34-
35-
@Schema(description = "수정일")
36-
LocalDateTime modifyDate
10+
MentorSlotDetailDto mentorSlot,
11+
MentorDto mentor,
12+
MentoringDto mentoring
3713
) {
3814
public static MentorSlotResponse from(MentorSlot mentorSlot, Mentoring mentoring) {
3915
return new MentorSlotResponse(
40-
mentorSlot.getId(),
41-
mentorSlot.getMentor().getId(),
42-
mentoring.getId(),
43-
mentoring.getTitle(),
44-
mentorSlot.getStartDateTime(),
45-
mentorSlot.getEndDateTime(),
46-
mentorSlot.getStatus(),
47-
mentorSlot.getCreateDate(),
48-
mentorSlot.getModifyDate()
16+
MentorSlotDetailDto.from(mentorSlot),
17+
MentorDto.from(mentorSlot.getMentor()),
18+
MentoringDto.from(mentoring)
4919
);
5020
}
5121
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.back.global.exception.ServiceException;
55

66
import java.time.Duration;
7+
import java.time.LocalDate;
78
import java.time.LocalDateTime;
9+
import java.time.LocalTime;
810

911
public class DateTimeValidator {
1012

@@ -50,4 +52,16 @@ public static void validateTimeSlot(LocalDateTime start, LocalDateTime end) {
5052
validateStartTimeNotInPast(start);
5153
validateMinimumDuration(start, end);
5254
}
55+
56+
public static void validateRepetitionSlot(LocalDate startDate, LocalTime startTime,
57+
LocalDate endDate, LocalTime endTime) {
58+
if (endDate.isBefore(startDate)) {
59+
throw new ServiceException(MentorSlotErrorCode.END_TIME_BEFORE_START);
60+
}
61+
62+
LocalDateTime startDateTime = LocalDateTime.of(startDate, startTime);
63+
LocalDateTime endDateTime = LocalDateTime.of(startDate, endTime);
64+
65+
validateTimeSlot(startDateTime, endDateTime);
66+
}
5367
}

0 commit comments

Comments
 (0)