Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ public MentoringResponse createMentoring(CreateMentoringRequest request, Long me
.orElseThrow(() -> new CustomRuntimeException(MentorErrorCode.MENTOR_NOT_FOUND));
Mentee mentee = menteeRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomRuntimeException(MenteeErrorCode.MENTEE_NOT_FOUND));
final Mentoring mentoring = Mentoring.of(MentoringStatus.WAITING, request.topic(), request.applyTimes(), request.mentoringMessage(), mentor, mentee);
final Mentoring mentoring = Mentoring.of(
MentoringStatus.WAITING,
request.topic(),
request.applyTimes(),
request.mentoringMessage(),
mentor,
mentee);

mentee.addMentoring(mentoring);
mentor.addMentoring(mentoring);

return MentoringResponse.from(mentoringRepository.save(mentoring));

}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/es/princip/ringus/domain/mentee/Mentee.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import es.princip.ringus.domain.bookmark.Bookmark;
import es.princip.ringus.domain.common.Education;
import es.princip.ringus.domain.mentoring.Mentoring;
import es.princip.ringus.infra.storage.domain.ProfileImage;
import es.princip.ringus.presentation.mentee.dto.EditMenteeRequest;
import jakarta.persistence.*;
Expand Down Expand Up @@ -46,6 +47,9 @@ public class Mentee {
@OneToMany(mappedBy = "mentee", cascade = CascadeType.ALL ,orphanRemoval = true, fetch = FetchType.LAZY)
private List<Bookmark> bookmarks = new ArrayList<>();

@OneToMany(mappedBy = "mentee", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private List<Mentoring> mentorings = new ArrayList<>();

@Builder
public Mentee(
final String nickname,
Expand Down Expand Up @@ -75,4 +79,13 @@ public void addBookmark(Bookmark bookmark){
public void deleteBookmark(Bookmark bookmark){
bookmarks.remove(bookmark);
}

public void addMentoring(Mentoring mentoring){
mentorings.add(mentoring);
}

public void deleteMentoring(Mentoring mentoring){
mentorings.remove(mentoring);
}

}
13 changes: 13 additions & 0 deletions src/main/java/es/princip/ringus/domain/mentor/Mentor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import es.princip.ringus.domain.common.Education;
import es.princip.ringus.domain.mentor.vo.*;
import es.princip.ringus.domain.mentoring.Mentoring;
import es.princip.ringus.infra.storage.domain.ProfileImage;
import es.princip.ringus.presentation.mentor.dto.EditMentorRequest;
import jakarta.persistence.*;
Expand All @@ -10,6 +11,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -57,6 +59,9 @@ public class Mentor {
@CollectionTable(name = "mentor_hashtags", joinColumns = @JoinColumn(name = "mentor_id"))
private List<Hashtag> hashtags;

@OneToMany(mappedBy = "mentor", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private List<Mentoring> mentorings = new ArrayList<>();

// 멘티에게 전하는 말
@Column(name = "message", length = 50)
private String message;
Expand Down Expand Up @@ -109,4 +114,12 @@ public void edit(final EditMentorRequest request) {
this.message = request.message();
this.portfolio = request.portfolio().toEntity();
}

public void addMentoring(Mentoring mentoring){
mentorings.add(mentoring);
}

public void deleteMentoring(Mentoring mentoring){
mentorings.remove(mentoring);
}
}
10 changes: 6 additions & 4 deletions src/main/java/es/princip/ringus/domain/mentoring/Mentoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public class Mentoring extends BaseTimeEntity {
private Long id;

@Enumerated(EnumType.STRING)
private MentoringStatus status;
@Column(name = "mentoring_status")
private MentoringStatus mentoringStatus;

@Enumerated(EnumType.STRING)
private MentoringTopic topic;
@Column(name = "mentoring_topic")
private MentoringTopic mentoringTopic;

@Convert(converter = MentoringTimeConverter.class)
@Column(length = 500, nullable = false) // 500자 이내
Expand Down Expand Up @@ -62,8 +64,8 @@ public Mentoring(
if (applyTimes.size() > 5) {
throw new CustomRuntimeException(MentoringErrorCode.MENTORING_TIME_ERROR);
}
this.status = status;
this.topic = topic;
this.mentoringStatus = status;
this.mentoringTopic = topic;
this.applyTimes = applyTimes;
this.mentoringMessage = mentoringMessage;
this.mentor = mentor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public static MentoringResponse from(
) {
return new MentoringResponse(
mentoring.getId(),
mentoring.getStatus(),
mentoring.getTopic(),
mentoring.getMentoringStatus(),
mentoring.getMentoringTopic(),
mentoring.getApplyTimes(),
mentoring.getMentoringMessage(),
mentoring.getMentor().getNickname(),
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ spring:
flyway:
enabled: true
baseline-on-migrate: true

servlet:
multipart:
max-file-size: ${MAX_FILE_SIZE}
max-request-size: ${MAX_REQUEST_SIZE}
jpa:
show-sql: true
hibernate:
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/db/migration/V3__add_mentoring.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE mentoring (

mentoring_id BIGINT NOT NULL AUTO_INCREMENT,
created_at DATETIME(6),
updated_at DATETIME(6),
mentoring_status ENUM ('WAITING', 'ACCEPTED', 'REJECTED') NOT NULL,
mentoring_topic ENUM ('STUDY', 'INDUSTRY_TRENDS', 'INTERVIEW', 'JOB_PREP') NOT NULL,

apply_times VARCHAR(500) NOT NULL CHECK (JSON_VALID(apply_times)),
mentoring_message VARCHAR(500) NOT NULL,

mentee_id BIGINT NOT NULL,
mentor_id BIGINT NOT NULL,

PRIMARY KEY (mentoring_id),

CONSTRAINT fk_mentoring_mentee FOREIGN KEY (mentee_id) REFERENCES mentee (mentee_id) ON DELETE CASCADE,
CONSTRAINT fk_mentoring_mentor FOREIGN KEY (mentor_id) REFERENCES mentor (mentor_id) ON DELETE CASCADE
);