diff --git a/src/main/java/com/mju/course/domain/model/lecture/Lecture.java b/src/main/java/com/mju/course/domain/model/lecture/Lecture.java index 2adde26..9f4a21a 100644 --- a/src/main/java/com/mju/course/domain/model/lecture/Lecture.java +++ b/src/main/java/com/mju/course/domain/model/lecture/Lecture.java @@ -8,6 +8,9 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; + @Entity @Getter @NoArgsConstructor @@ -40,6 +43,10 @@ public class Lecture extends BaseTimeEntity { @Column(name = "lecture_description") private String lectureDescription; + // 양방향 매핑 + @OneToMany(mappedBy = "lecture") + private List lectureQuestionList = new ArrayList<>(); + @Builder public Lecture(Curriculum curriculum, int lectureSequence, String lectureTitle, int lectureTime, String lectureKey, String lectureDescription, String lectureInputKey){ diff --git a/src/main/java/com/mju/course/domain/model/lecture/LectureAnswer.java b/src/main/java/com/mju/course/domain/model/lecture/LectureAnswer.java new file mode 100644 index 0000000..d9f1ce7 --- /dev/null +++ b/src/main/java/com/mju/course/domain/model/lecture/LectureAnswer.java @@ -0,0 +1,37 @@ +package com.mju.course.domain.model.lecture; + +import com.mju.course.domain.model.BaseTimeEntity; +import com.mju.course.domain.model.User; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@NoArgsConstructor +public class LectureAnswer extends BaseTimeEntity { + + @Id + @Column(name = "lecture_answer_index") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name="lecture_question_index") + private LectureQuestion lectureQuestion; + + @ManyToOne + @JoinColumn(name = "user_index") + private User user; + + @Column(name = "lecture_answer") + private String lectureAnswer; + + // 양방향 매핑 + @OneToMany(mappedBy = "lectureAnswer") + private List lectureAnswerPhotoList = new ArrayList<>(); + +} diff --git a/src/main/java/com/mju/course/domain/model/lecture/LectureAnswerPhoto.java b/src/main/java/com/mju/course/domain/model/lecture/LectureAnswerPhoto.java new file mode 100644 index 0000000..8105d10 --- /dev/null +++ b/src/main/java/com/mju/course/domain/model/lecture/LectureAnswerPhoto.java @@ -0,0 +1,26 @@ +package com.mju.course.domain.model.lecture; + +import com.mju.course.domain.model.BaseTimeEntity; +import com.mju.course.domain.model.User; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class LectureAnswerPhoto extends BaseTimeEntity { + + @Id + @Column(name = "lecture_answer_photo_index") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name="lecture_answer_index") + private LectureAnswer lectureAnswer; + + @Column(name = "lecture_answer_photo_key") + private String lectureAnswerPhotoKey; + +} diff --git a/src/main/java/com/mju/course/domain/model/lecture/LectureQuestion.java b/src/main/java/com/mju/course/domain/model/lecture/LectureQuestion.java new file mode 100644 index 0000000..0b3c72d --- /dev/null +++ b/src/main/java/com/mju/course/domain/model/lecture/LectureQuestion.java @@ -0,0 +1,42 @@ +package com.mju.course.domain.model.lecture; + +import com.mju.course.domain.model.BaseTimeEntity; +import com.mju.course.domain.model.User; +import com.mju.course.domain.model.course.Course; +import com.mju.course.domain.model.course.Skill; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@NoArgsConstructor +public class LectureQuestion extends BaseTimeEntity { + + @Id + @Column(name = "lecture_question_index") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name="lecture_index") + private Lecture lecture; + + @ManyToOne + @JoinColumn(name = "user_index") + private User user; + + @Column(name = "lecture_question") + private String lectureQuestion; + + // 양방향 매핑 + @OneToMany(mappedBy = "lectureQuestion") + private List lectureAnswerList = new ArrayList<>(); + + @OneToMany(mappedBy = "lectureQuestion") + private List lectureQuestionPhotoList = new ArrayList<>(); + +} diff --git a/src/main/java/com/mju/course/domain/model/lecture/LectureQuestionPhoto.java b/src/main/java/com/mju/course/domain/model/lecture/LectureQuestionPhoto.java new file mode 100644 index 0000000..a46b9bb --- /dev/null +++ b/src/main/java/com/mju/course/domain/model/lecture/LectureQuestionPhoto.java @@ -0,0 +1,25 @@ +package com.mju.course.domain.model.lecture; + +import com.mju.course.domain.model.BaseTimeEntity; +import jakarta.persistence.*; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class LectureQuestionPhoto extends BaseTimeEntity { + + @Id + @Column(name = "lecture_question_photo_index") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name="lecture_question_index") + private LectureQuestion lectureQuestion; + + @Column(name = "lecture_question_photo_key") + private String lectureQuestionPhotoKey; + +} diff --git a/src/main/java/com/mju/course/domain/repository/course/CourseRepositoryImpl.java b/src/main/java/com/mju/course/domain/repository/course/CourseRepositoryImpl.java index aa46560..399a28c 100644 --- a/src/main/java/com/mju/course/domain/repository/course/CourseRepositoryImpl.java +++ b/src/main/java/com/mju/course/domain/repository/course/CourseRepositoryImpl.java @@ -1,11 +1,11 @@ package com.mju.course.domain.repository.course; import com.mju.course.domain.model.course.Course; -import com.mju.course.domain.model.QCourseLike; +import com.mju.course.domain.model.course.QCourseLike; import com.querydsl.core.types.Projections; import java.util.ArrayList; -import com.mju.course.domain.model.QCourse; +import com.mju.course.domain.model.course.QCourse; import com.mju.course.domain.model.enums.CourseState; import com.mju.course.presentation.dto.response.CoursesReadDto; import com.mju.course.presentation.dto.response.admin.AdminReadCoursesDto; diff --git a/src/main/java/com/mju/course/domain/repository/lecture/LectureAnswerPhotoRepository.java b/src/main/java/com/mju/course/domain/repository/lecture/LectureAnswerPhotoRepository.java new file mode 100644 index 0000000..8ab6551 --- /dev/null +++ b/src/main/java/com/mju/course/domain/repository/lecture/LectureAnswerPhotoRepository.java @@ -0,0 +1,10 @@ +package com.mju.course.domain.repository.lecture; + +import com.mju.course.domain.model.lecture.LectureAnswerPhoto; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface LectureAnswerPhotoRepository extends JpaRepository { + +} diff --git a/src/main/java/com/mju/course/domain/repository/lecture/LectureAnswerRepository.java b/src/main/java/com/mju/course/domain/repository/lecture/LectureAnswerRepository.java new file mode 100644 index 0000000..172cbc8 --- /dev/null +++ b/src/main/java/com/mju/course/domain/repository/lecture/LectureAnswerRepository.java @@ -0,0 +1,10 @@ +package com.mju.course.domain.repository.lecture; + +import com.mju.course.domain.model.lecture.LectureAnswer; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface LectureAnswerRepository extends JpaRepository { + +} diff --git a/src/main/java/com/mju/course/domain/repository/lecture/LectureQuestionPhotoRepository.java b/src/main/java/com/mju/course/domain/repository/lecture/LectureQuestionPhotoRepository.java new file mode 100644 index 0000000..fd1e939 --- /dev/null +++ b/src/main/java/com/mju/course/domain/repository/lecture/LectureQuestionPhotoRepository.java @@ -0,0 +1,10 @@ +package com.mju.course.domain.repository.lecture; + +import com.mju.course.domain.model.lecture.LectureQuestionPhoto; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface LectureQuestionPhotoRepository extends JpaRepository { + +} diff --git a/src/main/java/com/mju/course/domain/repository/lecture/LectureQuestionRepository.java b/src/main/java/com/mju/course/domain/repository/lecture/LectureQuestionRepository.java new file mode 100644 index 0000000..e617f4c --- /dev/null +++ b/src/main/java/com/mju/course/domain/repository/lecture/LectureQuestionRepository.java @@ -0,0 +1,10 @@ +package com.mju.course.domain.repository.lecture; + +import com.mju.course.domain.model.lecture.LectureQuestion; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface LectureQuestionRepository extends JpaRepository { + +}