Skip to content

Commit

Permalink
[#16] feat : 강의 관련 entity 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
sangminee committed May 17, 2023
1 parent 551d77c commit 79ca638
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
@NoArgsConstructor
Expand Down Expand Up @@ -40,6 +43,10 @@ public class Lecture extends BaseTimeEntity {
@Column(name = "lecture_description")
private String lectureDescription;

// 양방향 매핑
@OneToMany(mappedBy = "lecture")
private List<LectureQuestion> lectureQuestionList = new ArrayList<>();

@Builder
public Lecture(Curriculum curriculum, int lectureSequence, String lectureTitle,
int lectureTime, String lectureKey, String lectureDescription, String lectureInputKey){
Expand Down
Original file line number Diff line number Diff line change
@@ -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<LectureAnswerPhoto> lectureAnswerPhotoList = new ArrayList<>();

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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<LectureAnswer> lectureAnswerList = new ArrayList<>();

@OneToMany(mappedBy = "lectureQuestion")
private List<LectureQuestionPhoto> lectureQuestionPhotoList = new ArrayList<>();

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<LectureAnswerPhoto, Long> {

}
Original file line number Diff line number Diff line change
@@ -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<LectureAnswer, Long> {

}
Original file line number Diff line number Diff line change
@@ -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<LectureQuestionPhoto, Long> {

}
Original file line number Diff line number Diff line change
@@ -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<LectureQuestion, Long> {

}

0 comments on commit 79ca638

Please sign in to comment.