Skip to content

Commit

Permalink
Merge pull request #14 from khu-bigdata-project-team-5/feat/10
Browse files Browse the repository at this point in the history
Feat/10(#10) (#1)
  • Loading branch information
yxhwxn authored Jun 10, 2024
2 parents 18ff8bb + 365b347 commit 4939977
Show file tree
Hide file tree
Showing 18 changed files with 717 additions and 89 deletions.
70 changes: 70 additions & 0 deletions src/main/java/khu/bigdata/infou/business/LectureConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package khu.bigdata.infou.business;

import khu.bigdata.infou.domain.LectureTag;
import khu.bigdata.infou.domain.LectureUdemy;
import khu.bigdata.infou.web.dto.LectureResponseDTO;

import java.util.List;
import java.util.stream.Collectors;

public class LectureConverter {


public static LectureResponseDTO.CategoryRecommendLectureInfo toCategoryRecommendLectureInfo(LectureUdemy lectureUdemy) {

LectureTag lectureTag = lectureUdemy.getLectureTag();

return LectureResponseDTO.CategoryRecommendLectureInfo.builder()
.lectureId(lectureUdemy.getLectureId())
.title(lectureUdemy.getTitle())
.price(lectureUdemy.getPrice())
.avgRating(lectureUdemy.getAvgRating())
.thumbnail(lectureUdemy.getThumbnail())
.topword1(lectureTag.getTopword1())
.topword2(lectureTag.getTopword2())
.topword3(lectureTag.getTopword3())
.topword4(lectureTag.getTopword4())
.topword5(lectureTag.getTopword5())
.build();
}

public static LectureResponseDTO.CategoryRecommendLectureDto toCategoryRecommendLectureDto(List<LectureUdemy> list) {

List<LectureResponseDTO.CategoryRecommendLectureInfo> infoList = list.stream().map(lecture -> toCategoryRecommendLectureInfo(lecture)).toList();

return LectureResponseDTO.CategoryRecommendLectureDto.builder()
.lectureList(infoList)
.build();
}


// 키워드별 추천 강좌 조회
public static LectureResponseDTO.KeywordRecommendLectureInfo toKeywordRecommendLectureInfo(LectureUdemy lectureUdemy) {
LectureTag lectureTag = lectureUdemy.getLectureTag();

return LectureResponseDTO.KeywordRecommendLectureInfo.builder()
.lectureId(lectureUdemy.getLectureId())
.title(lectureUdemy.getTitle())
.price(lectureUdemy.getPrice())
.avgRating(lectureUdemy.getAvgRating())
.thumbnail(lectureUdemy.getThumbnail())
.topword1(lectureTag.getTopword1())
.topword2(lectureTag.getTopword2())
.topword3(lectureTag.getTopword3())
.topword4(lectureTag.getTopword4())
.topword5(lectureTag.getTopword5())
.build();
}

public static LectureResponseDTO.KeywordRecommendLectureDto toKeywordRecommendLectureDto(List<LectureUdemy> lectureUdemyList) {

List<LectureResponseDTO.KeywordRecommendLectureInfo> lectureInfos = lectureUdemyList.stream()
.map(LectureConverter::toKeywordRecommendLectureInfo)
.collect(Collectors.toList());

return LectureResponseDTO.KeywordRecommendLectureDto.builder()
.lectureList(lectureInfos)
.build();
}

}
48 changes: 0 additions & 48 deletions src/main/java/khu/bigdata/infou/domain/Lecture.java

This file was deleted.

54 changes: 54 additions & 0 deletions src/main/java/khu/bigdata/infou/domain/LectureDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package khu.bigdata.infou.domain;

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

@Entity
@Getter
@Builder
@DynamicInsert
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED) // 생성 로직 규정
@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 = "good", nullable = false)
private Integer good;

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

@Column(name = "teaching_quality", nullable = false)
private Float teachingQuality;

@Column(name = "reference", nullable = false)
private Float reference;

@Column(name = "practice", nullable = false)
private Float practice;

@Column(name = "rating", nullable = false)
private Float rating;

@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;
}
86 changes: 86 additions & 0 deletions src/main/java/khu/bigdata/infou/domain/LectureInflearn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package khu.bigdata.infou.domain;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;

import java.util.Date;

@Entity
@Getter
@Builder
@DynamicInsert
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED) // 생성 로직 규정
@Table(name = "lecture_inflearn")
public class LectureInflearn {

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

@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 = "description", columnDefinition = "TEXT")
private String description;

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

@Column(name = "studentCount")
private int studentCount;

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

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

@Column(name = "isExclusive")
private boolean isExclusive;

@Column(name = "isNew")
private boolean isNew;

@Column(name = "isUpdated")
private boolean isUpdated;

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

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

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

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

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

@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;
}
// getters and setters
}

40 changes: 28 additions & 12 deletions src/main/java/khu/bigdata/infou/domain/LectureTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,45 @@

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;

@Entity
@Table(name = "lecture_tag")
@Getter
@Builder
@DynamicInsert
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED) // 생성 로직 규정
@Table(name = "lecture_tag")
public class LectureTag {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "lecture_tag_id")
private Long id;
private Integer id;

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "lecture_id")
private Lecture lecture;
@Column(name = "lecture_udemy_id", nullable = false)
private Integer lectureUdemyId;

@Id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id")
private Tag tag;
@Column(name = "lecture_inflearn_id", nullable = false)
private Integer lectureInflearnId;

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

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

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

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

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

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

// Getters and Setters
@OneToOne(fetch = FetchType.LAZY)
private LectureUdemy lectureUdemy;
}
Loading

0 comments on commit 4939977

Please sign in to comment.