Skip to content

Commit 4d09fb5

Browse files
authored
Merge pull request #20 from prgrms-web-devcourse-final-project/chore#12
[Chore] 멘토링 관련 엔티티 구현
2 parents 00fc988 + 4f4a7e5 commit 4d09fb5

File tree

10 files changed

+178
-0
lines changed

10 files changed

+178
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.back.domain.mentoring.mentoring.entity;
2+
3+
import com.back.domain.member.mentor.entity.Mentor;
4+
import com.back.global.jpa.BaseEntity;
5+
import jakarta.persistence.Column;
6+
import jakarta.persistence.Entity;
7+
import jakarta.persistence.JoinColumn;
8+
import jakarta.persistence.ManyToOne;
9+
import lombok.Getter;
10+
11+
@Entity
12+
@Getter
13+
public class Mentoring extends BaseEntity {
14+
@ManyToOne
15+
@JoinColumn(name = "mentor_id")
16+
private Mentor mentor;
17+
18+
@Column(length = 100)
19+
private String title;
20+
21+
@Column(columnDefinition = "TEXT")
22+
private String bio;
23+
24+
@Column(columnDefinition = "JSON")
25+
private String tags;
26+
27+
@Column(length = 255)
28+
private String thumb;
29+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.back.domain.mentoring.mentoring.entity;
2+
3+
import com.back.domain.mentoring.reservation.entity.Reservation;
4+
import com.back.global.jpa.BaseEntity;
5+
import jakarta.persistence.*;
6+
import lombok.Getter;
7+
8+
@Entity
9+
@Getter
10+
public class Review extends BaseEntity {
11+
@ManyToOne(fetch = FetchType.LAZY)
12+
@JoinColumn(name = "reservation_id", nullable = false)
13+
private Reservation reservation;
14+
15+
@Column(nullable = false)
16+
private double rating;
17+
18+
@Column(columnDefinition = "TEXT")
19+
private String content;
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.back.domain.mentoring.mentoring.repository;
2+
3+
import com.back.domain.mentoring.mentoring.entity.Mentoring;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface MentoRepository extends JpaRepository<Mentoring, Long> {
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.back.domain.mentoring.mentoring.repository;
2+
3+
import com.back.domain.mentoring.mentoring.entity.Review;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface ReviewRepository extends JpaRepository<Review, Long> {
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.back.domain.mentoring.reservation.constant;
2+
3+
public enum ReservationStatus {
4+
PENDING, // 예약 승인 대기
5+
APPROVED, // 승인됨
6+
REJECTED, // 거절됨
7+
CANCELED, // 취소됨
8+
COMPLETED // 완료됨
9+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.back.domain.mentoring.reservation.entity;
2+
3+
import com.back.domain.member.mentee.entity.Mentee;
4+
import com.back.domain.member.mentor.entity.Mentor;
5+
import com.back.domain.mentoring.mentoring.entity.Mentoring;
6+
import com.back.domain.mentoring.reservation.constant.ReservationStatus;
7+
import com.back.domain.mentoring.slot.entity.MentorSlot;
8+
import com.back.global.jpa.BaseEntity;
9+
import jakarta.persistence.*;
10+
import lombok.Getter;
11+
12+
@Entity
13+
@Getter
14+
public class Reservation extends BaseEntity {
15+
@ManyToOne(fetch = FetchType.LAZY)
16+
@JoinColumn(name = "mentoring_id", nullable = false)
17+
private Mentoring mentoring;
18+
19+
@ManyToOne(fetch = FetchType.LAZY)
20+
@JoinColumn(name = "mentor_id", nullable = false)
21+
private Mentor mentor;
22+
23+
@ManyToOne(fetch = FetchType.LAZY)
24+
@JoinColumn(name = "mentee_id", nullable = false)
25+
private Mentee mentee;
26+
27+
@OneToOne(fetch = FetchType.LAZY)
28+
@JoinColumn(name = "mentor_slot_id", nullable = false)
29+
private MentorSlot mentorSlot;
30+
31+
@Column(columnDefinition = "TEXT")
32+
private String preQuestion;
33+
34+
@Enumerated(EnumType.STRING)
35+
@Column(nullable = false)
36+
private ReservationStatus status;
37+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.back.domain.mentoring.reservation.repository;
2+
3+
import com.back.domain.mentoring.reservation.entity.Reservation;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface ReservationRepository extends JpaRepository<Reservation, Long> {
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.back.domain.mentoring.slot.constant;
2+
3+
public enum MentorSlotStatus {
4+
AVAILABLE, // 예약 가능
5+
PENDING, // 예약 승인 대기
6+
APPROVED, // 예약 승인됨(확정)
7+
COMPLETED // 멘토링 완료
8+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.back.domain.mentoring.slot.entity;
2+
3+
import com.back.domain.member.mentor.entity.Mentor;
4+
import com.back.domain.mentoring.reservation.constant.ReservationStatus;
5+
import com.back.domain.mentoring.reservation.entity.Reservation;
6+
import com.back.domain.mentoring.slot.constant.MentorSlotStatus;
7+
import com.back.global.jpa.BaseEntity;
8+
import jakarta.persistence.*;
9+
import lombok.Getter;
10+
11+
import java.time.LocalDateTime;
12+
13+
@Entity
14+
@Getter
15+
public class MentorSlot extends BaseEntity {
16+
@ManyToOne(fetch = FetchType.LAZY)
17+
@JoinColumn(name = "mentor_id", nullable = false)
18+
private Mentor mentor;
19+
20+
@Column(nullable = false)
21+
private LocalDateTime startDateTime;
22+
23+
@Column(nullable = false)
24+
private LocalDateTime endDateTime;
25+
26+
@OneToOne(mappedBy = "mentorSlot")
27+
private Reservation reservation;
28+
29+
public MentorSlotStatus getStatus() {
30+
if (reservation == null) {
31+
return MentorSlotStatus.AVAILABLE;
32+
}
33+
34+
return switch (reservation.getStatus()) {
35+
case PENDING -> MentorSlotStatus.PENDING;
36+
case APPROVED -> MentorSlotStatus.APPROVED;
37+
case COMPLETED -> MentorSlotStatus.COMPLETED;
38+
default -> MentorSlotStatus.AVAILABLE;
39+
};
40+
}
41+
42+
public boolean isAvailable() {
43+
return reservation == null ||
44+
reservation.getStatus().equals(ReservationStatus.REJECTED) ||
45+
reservation.getStatus().equals(ReservationStatus.CANCELED);
46+
}
47+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.back.domain.mentoring.slot.repository;
2+
3+
import com.back.domain.mentoring.slot.entity.MentorSlot;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface MentorSlotRepository extends JpaRepository<MentorSlot, Long> {
7+
}

0 commit comments

Comments
 (0)