Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 다른 수강생 커리큘럼 조회 API 구현 #18

Merged
merged 16 commits into from
Jun 12, 2024
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
28 changes: 26 additions & 2 deletions src/main/java/khu/bigdata/infou/business/LectureConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import khu.bigdata.infou.domain.LectureDetail;
import khu.bigdata.infou.domain.LectureUdemy;
import khu.bigdata.infou.domain.PlatformStudent;
import khu.bigdata.infou.web.dto.LectureResponseDTO;

import java.util.List;
Expand Down Expand Up @@ -79,8 +80,31 @@ public static LectureResponseDTO.LectureDetailDto toLectureDetailDto(LectureUdem
.practice(lectureDetail.getPractice())
.rating(lectureDetail.getRating())
.level(lectureDetail.getLevel())
.topword1(lectureUdemy.getTopic())
.topword2(lectureUdemy.getSubcategory())
.build();
}

public static LectureResponseDTO.OtherStudentsListInfo toOtherStudentInfo(PlatformStudent student) {

return LectureResponseDTO.OtherStudentsListInfo.builder()
.inflearnUserId(Long.valueOf(student.getInflearnUserId()))
.udemyUserId(Long.valueOf(student.getUdemyUserId()))
.name(student.getName())
.topword1(student.getTopword1())
.topword2(student.getTopword2())
.topword3(student.getTopword3())
.topword4(student.getTopword4())
.topword5(student.getTopword5())
.build();
}

public static LectureResponseDTO.OtherStudentsDto toOtherStudentsDto(List<PlatformStudent> students) {

List<LectureResponseDTO.OtherStudentsListInfo> studentInfos = students.stream()
.map(LectureConverter::toOtherStudentInfo)
.collect(Collectors.toList());

return LectureResponseDTO.OtherStudentsDto.builder()
.studentList(studentInfos)
.build();
}
}
25 changes: 11 additions & 14 deletions src/main/java/khu/bigdata/infou/domain/LectureDetail.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package khu.bigdata.infou.domain;

import jakarta.persistence.*;
import khu.bigdata.infou.domain.enums.LectureType;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;

Expand All @@ -11,16 +10,18 @@
@DynamicInsert
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED) // 생성 로직 규정
@Table(name = "lecture_detail", indexes = {
@Index(name = "idx_lecture_id", columnList = "lectureId")})
@Table(name = "lecture_detail")
public class LectureDetail {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@Column(name = "lecture_id", nullable = false)
private Integer lectureId;
@Column(name = "lecture_udemy_id", nullable = false)
private Integer lectureUdemyId;

@Column(name = "lecture_inflearn_id", nullable = false)
private Integer lectureInflearnId;

@Column(name = "good", nullable = false)
private Integer good;
Expand All @@ -43,13 +44,9 @@ public class LectureDetail {
@Column(name = "level", nullable = false)
private Float level;

@Enumerated(EnumType.STRING)
@Column(name = "lecture_type", nullable = false)
private LectureType lectureType;

@OneToOne(fetch = FetchType.LAZY)
private LectureInflearn lectureInflearn;

@OneToOne(fetch = FetchType.LAZY)
private LectureUdemy lectureUdemy;
// @OneToOne(fetch = FetchType.LAZY)
// private LectureInflearn lectureInflearn;
//
// @OneToOne(fetch = FetchType.LAZY)
// private LectureUdemy lectureUdemy;
}
82 changes: 39 additions & 43 deletions src/main/java/khu/bigdata/infou/domain/LectureInflearn.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,66 @@ public class LectureInflearn {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "lecture_inflearn_id")
private int lectureInflearnId;
@Column(name = "id")
private int id;

@Column(name = "slug", columnDefinition = "TEXT")
private String slug;

@Column(name = "thumbnailUrl", columnDefinition = "TEXT")
private String thumbnailUrl;

@Column(name = "title", columnDefinition = "TEXT")
private String title;
@Column(name = "lecture_id", nullable = false)
private int lectureId;

@Column(name = "description", columnDefinition = "TEXT")
private String description;

@Column(name = "reviewCount")
private int reviewCount;
@Column(name = "instructor_id")
private int instructorId;

@Column(name = "studentCount")
private int studentCount;
@Column(name = "instructor_name", length = 50)
private String instructorName;

@Column(name = "likeCount")
private int likeCount;
@Column(name = "review_count")
private int reviewCount;

@Column(name = "star")
private float star;

@Column(name = "isExclusive")
private boolean isExclusive;
@Column(name = "level", length = 20)
private String level;

@Column(name = "isNew")
private boolean isNew;
@Column(name = "first_category", length = 255)
private String firstCategory;

@Column(name = "isUpdated")
private boolean isUpdated;
@Column(name = "second_category", length = 255)
private String secondCategory;

@Column(name = "updatedAt")
@Temporal(TemporalType.DATE)
private Date updatedAt;
@Column(name = "skill_tag", length = 255)
private String skillTag;

@Column(name = "publishedAt")
@Temporal(TemporalType.DATE)
private Date publishedAt;
@Column(name = "price")
private int price;

@Column(name = "metadata", columnDefinition = "JSON")
private String metadata;
@Column(name = "student_count")
private int studentCount;

@Column(name = "instructor_id")
private int instructorId;
@Column(name = "thumbnail_url", columnDefinition = "TEXT")
private String thumbnailUrl;

@Column(name = "instructor_name", length = 50)
private String instructorName;
@Column(name = "title", columnDefinition = "TEXT")
private String title;

@Column(name = "updated_at")
@Temporal(TemporalType.DATE)
private Date updatedAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "platform_student_lecture_id")
private PlatformStudentLecture platformStudentLecture;
// @ManyToOne(fetch = FetchType.LAZY)
// @JoinColumn(name = "platform_student_lecture_id")
// private PlatformStudentLecture platformStudentLecture;


public void setPlatformStudentLecture(PlatformStudentLecture platformStudentLecture) {
if (this.platformStudentLecture != null) {
this.platformStudentLecture.getLectureInflearnList().remove(this);
}
this.platformStudentLecture = platformStudentLecture;
}
// public void setPlatformStudentLecture(PlatformStudentLecture platformStudentLecture) {
// if (this.platformStudentLecture != null) {
// this.platformStudentLecture.getLectureInflearnList().remove(this);
// }
// this.platformStudentLecture = platformStudentLecture;
// }
// getters and setters
}

10 changes: 5 additions & 5 deletions src/main/java/khu/bigdata/infou/domain/LectureTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class LectureTag {
@Column(name = "topword5", length = 20)
private String topword5;

@OneToOne(fetch = FetchType.LAZY)
private LectureInflearn lectureInflearn;

@OneToOne(fetch = FetchType.LAZY)
private LectureUdemy lectureUdemy;
// @OneToOne(fetch = FetchType.LAZY)
// private LectureInflearn lectureInflearn;
//
// @OneToOne(fetch = FetchType.LAZY)
// private LectureUdemy lectureUdemy;
}
22 changes: 11 additions & 11 deletions src/main/java/khu/bigdata/infou/domain/LectureUdemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class LectureUdemy {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "lecture_udemy_id")
@Column(name = "id")
private int id;

@Column(name = "lecture_id", nullable = false)
Expand Down Expand Up @@ -73,18 +73,18 @@ public class LectureUdemy {
@Column(name = "thumbnail", columnDefinition = "TEXT")
private String thumbnail;

@ManyToOne(fetch = FetchType.LAZY)
private PlatformStudentLecture platformStudentLecture;
// @ManyToOne(fetch = FetchType.LAZY)
// private PlatformStudentLecture platformStudentLecture;

@OneToOne(mappedBy = "lectureUdemy")
private LectureTag lectureTag;
// @OneToOne(mappedBy = "lectureUdemy")
// private LectureTag lectureTag;

public void setPlatformStudentLecture(PlatformStudentLecture platformStudentLecture) {
if (this.platformStudentLecture != null) {
this.platformStudentLecture.getLectureUdemyList().remove(this);
}
this.platformStudentLecture = platformStudentLecture;
}
// public void setPlatformStudentLecture(PlatformStudentLecture platformStudentLecture) {
// if (this.platformStudentLecture != null) {
// this.platformStudentLecture.getLectureUdemyList().remove(this);
// }
// this.platformStudentLecture = platformStudentLecture;
// }

// getters and setters

Expand Down
14 changes: 6 additions & 8 deletions src/main/java/khu/bigdata/infou/domain/PlatformStudent.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package khu.bigdata.infou.domain;

import jakarta.persistence.*;
import khu.bigdata.infou.domain.enums.UserType;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;

Expand All @@ -18,10 +17,13 @@ public class PlatformStudent {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@Column(name = "user_id", nullable = false)
private Integer userId;
@Column(name = "udemy_user_id", nullable = false)
private Integer udemyUserId;

@Column(name = "name", length = 30, nullable = false)
@Column(name = "inflearn_user_id", nullable = false)
private Integer inflearnUserId;

@Column(name = "name", length = 50, nullable = false)
private String name;

@Column(name = "topword1", length = 20)
Expand All @@ -38,8 +40,4 @@ public class PlatformStudent {

@Column(name = "topword5", length = 20)
private String topword5;

@Enumerated(EnumType.STRING)
@Column(name = "user_type", nullable = false)
private UserType userType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import lombok.*;
import org.hibernate.annotations.DynamicInsert;

import java.util.List;

@Entity
@Getter
@Builder
Expand All @@ -23,14 +21,16 @@ public class PlatformStudentLecture {
@Column(name = "user_id", nullable = false)
private Integer userId;

@Column(name = "lecture_id", nullable = false)
private Integer lectureId;

@Enumerated(EnumType.STRING)
@Column(name = "user_type", nullable = false)
private UserType userType;

@OneToMany(mappedBy = "platformStudentLecture")
private List<LectureInflearn> lectureInflearnList;
private UserType platForm;

@OneToMany(mappedBy = "platformStudentLecture")
private List<LectureUdemy> lectureUdemyList;
// @OneToMany(mappedBy = "platformStudentLecture")
// private List<LectureInflearn> lectureInflearnList;
//
// @OneToMany(mappedBy = "platformStudentLecture")
// private List<LectureUdemy> lectureUdemyList;
}
Loading
Loading