From eef46a79d520eae9216d2a2a9639a610b7ba7a0f Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Wed, 12 Jun 2024 21:01:23 +0900 Subject: [PATCH 01/16] =?UTF-8?q?:sparkles:=20Feat:=20LectureInflearn=20?= =?UTF-8?q?=EC=8A=A4=ED=82=A4=EB=A7=88=20=EC=9E=AC=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigdata/infou/domain/LectureInflearn.java | 62 +++++++++---------- .../repository/LectureInflearnRepository.java | 3 + 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java b/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java index 2eed125..67bb863 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java @@ -20,55 +20,51 @@ public class LectureInflearn { @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 = "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 = "lecture_id") + private int lectureId; - @Column(name = "isNew") - private boolean isNew; + @Column(name = "level", length = 20) + private String level; - @Column(name = "isUpdated") - private boolean isUpdated; + @Column(name = "first_category", length = 255) + private String firstCategory; - @Column(name = "updatedAt") - @Temporal(TemporalType.DATE) - private Date updatedAt; + @Column(name = "second_category", length = 255) + private String secondCategory; - @Column(name = "publishedAt") - @Temporal(TemporalType.DATE) - private Date publishedAt; + @Column(name = "skill_tag", length = 255) + private String skillTag; - @Column(name = "metadata", columnDefinition = "JSON") - private String metadata; + @Column(name = "price") + private int price; - @Column(name = "instructor_id") - private int instructorId; + @Column(name = "student_count") + private int studentCount; - @Column(name = "instructor_name", length = 50) - private String instructorName; + @Column(name = "thumbnail_url", columnDefinition = "TEXT") + private String thumbnailUrl; + + @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") diff --git a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java index 76cebdc..8254e2a 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java @@ -3,6 +3,9 @@ import khu.bigdata.infou.domain.LectureInflearn; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface LectureInflearnRepository extends JpaRepository { + Optional findByLectureId(Long lectureId); } From 988318880aa490b9628dcfa82c731a62ee1e73ab Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Wed, 12 Jun 2024 21:06:10 +0900 Subject: [PATCH 02/16] =?UTF-8?q?:sparkles:=20Feat:=20=EC=B6=94=EC=B2=9C?= =?UTF-8?q?=20=EA=B0=95=EC=A2=8C=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C,=20respo?= =?UTF-8?q?nse=20list=20=EA=B0=9C=EC=88=98=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/khu/bigdata/infou/implement/LectureService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/khu/bigdata/infou/implement/LectureService.java b/src/main/java/khu/bigdata/infou/implement/LectureService.java index d8ab677..2d583ac 100644 --- a/src/main/java/khu/bigdata/infou/implement/LectureService.java +++ b/src/main/java/khu/bigdata/infou/implement/LectureService.java @@ -37,6 +37,7 @@ public LectureResponseDTO.CategoryRecommendLectureDto findRecommendedLectureByCa // 일단 가져오고 상위 값 추출 List sortedList = lectureUdemyList.stream() .sorted(Comparator.comparingDouble((LectureUdemy lecture) -> lecture.getAvgRating() * lecture.getNumReviews()).reversed()) + .limit(1000) // 1000개로 제한 .collect(Collectors.toList()); return LectureConverter.toCategoryRecommendLectureDto(sortedList); @@ -55,6 +56,7 @@ public LectureResponseDTO.KeywordRecommendLectureDto findRecommendedLectureByKey // 조회된 강의 목록을 AvgRating과 NumReviews의 값을 곱한 값으로 내림차순 정렬 List sortedList = lectureUdemyList.stream() .sorted(Comparator.comparingDouble((LectureUdemy lecture) -> lecture.getAvgRating() * lecture.getNumReviews()).reversed()) + .limit(1000) // 1000개로 제한 .collect(Collectors.toList()); // 조회된 강의 목록을 DTO로 변환하여 반환 From 28156a45816761512a2178396064e24a7b8e20a4 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Wed, 12 Jun 2024 21:08:54 +0900 Subject: [PATCH 03/16] =?UTF-8?q?:memo:=20swagger=20=EB=AA=85=EC=84=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../khu/bigdata/infou/web/controller/MainServiceController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java b/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java index f36ebd6..3b44f43 100644 --- a/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java +++ b/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java @@ -17,7 +17,7 @@ public class MainServiceController { private final LectureService lectureService; @GetMapping("/lectures/categories") - @Operation(summary = "카테고리별 추천 강좌 조회 API", description = "카테고리: Programming Language, Web Development, Game Development, Mobile Development, Data Science") + @Operation(summary = "카테고리별 추천 강좌 조회 API", description = "카테고리: Programming Languages, Web Development, Game Development, Mobile Development, Data Science") public ResponseEntity getRecommendedLectureByCategory( @RequestParam(name = "category") String category ) { From 85f5c802061d5b2c3a0ebceb9c08bd0794e07c00 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 01:56:37 +0900 Subject: [PATCH 04/16] =?UTF-8?q?:recycle:=20Refactor:=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EB=A7=A4=ED=95=91=20=EC=88=98=EC=A0=95(?= =?UTF-8?q?=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20=EC=A0=9C=EA=B1=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigdata/infou/domain/LectureDetail.java | 24 +++++++++---------- .../bigdata/infou/domain/LectureInflearn.java | 22 ++++++++--------- .../khu/bigdata/infou/domain/LectureTag.java | 10 ++++---- .../bigdata/infou/domain/LectureUdemy.java | 22 ++++++++--------- .../bigdata/infou/domain/PlatformStudent.java | 14 +++++------ .../infou/domain/PlatformStudentLecture.java | 16 ++++++------- src/main/resources/application.yml | 2 +- 7 files changed, 53 insertions(+), 57 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/domain/LectureDetail.java b/src/main/java/khu/bigdata/infou/domain/LectureDetail.java index 02b278d..80816c8 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureDetail.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureDetail.java @@ -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; @@ -12,15 +11,18 @@ @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) // 생성 로직 규정 @Table(name = "lecture_detail", indexes = { - @Index(name = "idx_lecture_id", columnList = "lectureId")}) + @Index(name = "idx_lecture_id", columnList = "lectureUdemyId")}) 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; @@ -43,13 +45,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; } diff --git a/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java b/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java index 67bb863..06d45f0 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java @@ -17,8 +17,8 @@ public class LectureInflearn { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "lecture_inflearn_id") - private int lectureInflearnId; + @Column(name = "id") + private int id; @Column(name = "description", columnDefinition = "TEXT") private String description; @@ -66,17 +66,17 @@ public class LectureInflearn { @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 } diff --git a/src/main/java/khu/bigdata/infou/domain/LectureTag.java b/src/main/java/khu/bigdata/infou/domain/LectureTag.java index 8d3626d..aee67c6 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureTag.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureTag.java @@ -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; } diff --git a/src/main/java/khu/bigdata/infou/domain/LectureUdemy.java b/src/main/java/khu/bigdata/infou/domain/LectureUdemy.java index 3954ee2..24840df 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureUdemy.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureUdemy.java @@ -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) @@ -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 diff --git a/src/main/java/khu/bigdata/infou/domain/PlatformStudent.java b/src/main/java/khu/bigdata/infou/domain/PlatformStudent.java index 2923f89..7945c39 100644 --- a/src/main/java/khu/bigdata/infou/domain/PlatformStudent.java +++ b/src/main/java/khu/bigdata/infou/domain/PlatformStudent.java @@ -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; @@ -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) @@ -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; } diff --git a/src/main/java/khu/bigdata/infou/domain/PlatformStudentLecture.java b/src/main/java/khu/bigdata/infou/domain/PlatformStudentLecture.java index 59cdf0f..b289682 100644 --- a/src/main/java/khu/bigdata/infou/domain/PlatformStudentLecture.java +++ b/src/main/java/khu/bigdata/infou/domain/PlatformStudentLecture.java @@ -5,8 +5,6 @@ import lombok.*; import org.hibernate.annotations.DynamicInsert; -import java.util.List; - @Entity @Getter @Builder @@ -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 lectureInflearnList; + private UserType platForm; - @OneToMany(mappedBy = "platformStudentLecture") - private List lectureUdemyList; +// @OneToMany(mappedBy = "platformStudentLecture") +// private List lectureInflearnList; +// +// @OneToMany(mappedBy = "platformStudentLecture") +// private List lectureUdemyList; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 71b3b34..90971ea 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,7 +6,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: - ddl-auto: update + ddl-auto: none properties: hibernate: dialect: org.hibernate.dialect.MySQL8Dialect From 5b90c314031fe6649e1e2dc93dc2af765634f62d Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 02:29:14 +0900 Subject: [PATCH 05/16] =?UTF-8?q?:recycle:=20Refactor:=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/khu/bigdata/infou/domain/LectureDetail.java | 3 +-- src/main/java/khu/bigdata/infou/domain/LectureInflearn.java | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/domain/LectureDetail.java b/src/main/java/khu/bigdata/infou/domain/LectureDetail.java index 80816c8..7c180e0 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureDetail.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureDetail.java @@ -10,8 +10,7 @@ @DynamicInsert @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) // 생성 로직 규정 -@Table(name = "lecture_detail", indexes = { - @Index(name = "idx_lecture_id", columnList = "lectureUdemyId")}) +@Table(name = "lecture_detail") public class LectureDetail { @Id diff --git a/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java b/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java index 06d45f0..d1c5aeb 100644 --- a/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java +++ b/src/main/java/khu/bigdata/infou/domain/LectureInflearn.java @@ -20,6 +20,9 @@ public class LectureInflearn { @Column(name = "id") private int id; + @Column(name = "lecture_id", nullable = false) + private int lectureId; + @Column(name = "description", columnDefinition = "TEXT") private String description; @@ -35,9 +38,6 @@ public class LectureInflearn { @Column(name = "star") private float star; - @Column(name = "lecture_id") - private int lectureId; - @Column(name = "level", length = 20) private String level; From ea6b797660a38fd13865b69702f77f549f997662 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 02:29:35 +0900 Subject: [PATCH 06/16] =?UTF-8?q?:recycle:=20Refactor:=20repository=20?= =?UTF-8?q?=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigdata/infou/repository/LectureDetailRepository.java | 5 ++--- .../bigdata/infou/repository/LectureInflearnRepository.java | 5 +++++ .../khu/bigdata/infou/repository/LectureUdemyRepository.java | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java index 90d1105..5d05e10 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java @@ -1,14 +1,13 @@ package khu.bigdata.infou.repository; import khu.bigdata.infou.domain.LectureDetail; -import khu.bigdata.infou.domain.LectureUdemy; import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; public interface LectureDetailRepository extends JpaRepository { - Optional findByLectureUdemy(LectureUdemy lectureUdemy); + Optional findByLectureUdemyId(Long lectureId); - Optional findByLectureId(Long lectureId); + Optional findByLectureInflearnId(Long lectureId); } diff --git a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java index 8254e2a..33e3890 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java @@ -3,9 +3,14 @@ import khu.bigdata.infou.domain.LectureInflearn; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; import java.util.Optional; public interface LectureInflearnRepository extends JpaRepository { + List findAllBySubcategory(String subcategory); + + List findAllByTopic(String topic); + Optional findByLectureId(Long lectureId); } diff --git a/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java index 82eb4e7..677113a 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java @@ -2,7 +2,6 @@ import khu.bigdata.infou.domain.LectureUdemy; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import java.util.List; import java.util.Optional; @@ -10,7 +9,6 @@ public interface LectureUdemyRepository extends JpaRepository { - @Query("select l from LectureUdemy l left join fetch l.lectureTag where l.subcategory = :subcategory") List findAllBySubcategory(String subcategory); List findAllByTopic(String topic); From c547cb1d57d2a960e47094989ba40fd4baa9ea66 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 02:30:33 +0900 Subject: [PATCH 07/16] =?UTF-8?q?:recycle:=20Refactor:=20=EA=B0=95?= =?UTF-8?q?=EC=A2=8C=20=EC=84=B8=EB=B6=80=EC=A1=B0=ED=9A=8C=20API=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/khu/bigdata/infou/implement/LectureService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/khu/bigdata/infou/implement/LectureService.java b/src/main/java/khu/bigdata/infou/implement/LectureService.java index 2d583ac..1ea95a2 100644 --- a/src/main/java/khu/bigdata/infou/implement/LectureService.java +++ b/src/main/java/khu/bigdata/infou/implement/LectureService.java @@ -73,7 +73,7 @@ public LectureResponseDTO.LectureDetailDto findLectureDetail(Integer lectureId) LectureUdemy lectureUdemy = lectureUdemyRepository.findByLectureId(Long.valueOf(lectureId)) .orElseThrow(() -> new IllegalArgumentException("Lecture not found")); - LectureDetail lectureDetail = lectureDetailRepository.findByLectureId(Long.valueOf(lectureId)) + LectureDetail lectureDetail = lectureDetailRepository.findByLectureUdemyId(Long.valueOf(lectureId)) .orElseThrow(() -> new IllegalArgumentException("Lecture detail not found")); return LectureConverter.toLectureDetailDto(lectureUdemy, lectureDetail); From 8f90637926f7a61e2318ab637ea68896f2620a17 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 03:27:03 +0900 Subject: [PATCH 08/16] =?UTF-8?q?:sparkles:=20Feat:=20converter=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infou/business/LectureConverter.java | 26 +++++++++++++++++++ .../web/controller/MainServiceController.java | 5 +--- .../infou/web/dto/LectureResponseDTO.java | 22 ++++++++++++---- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/business/LectureConverter.java b/src/main/java/khu/bigdata/infou/business/LectureConverter.java index e3a6ee1..7a06c93 100644 --- a/src/main/java/khu/bigdata/infou/business/LectureConverter.java +++ b/src/main/java/khu/bigdata/infou/business/LectureConverter.java @@ -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; @@ -83,4 +84,29 @@ public static LectureResponseDTO.LectureDetailDto toLectureDetailDto(LectureUdem .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 students) { + + List studentInfos = students.stream() + .map(LectureConverter::toOtherStudentInfo) + .collect(Collectors.toList()); + + return LectureResponseDTO.OtherStudentsDto.builder() + .lectureList(studentInfos) + .build(); + } } diff --git a/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java b/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java index 3b44f43..867232f 100644 --- a/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java +++ b/src/main/java/khu/bigdata/infou/web/controller/MainServiceController.java @@ -42,11 +42,8 @@ public ResponseEntity getLectureDetail( return ResponseEntity.ok(lectureService.findLectureDetail(lectureId)); } - /** - * TODO - */ @GetMapping("/others") - @Operation(summary = "다른 수강생들의 커리큘럼 전체 조회 API") + @Operation(summary = "다른 수강생들의 커리큘럼 전체 조회 API", description = "다른 수강생들의 커리큘럼을 조회합니다.") public ResponseEntity getOtherStudents() { return ResponseEntity.ok(lectureService.findOtherStudents()); } diff --git a/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java b/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java index 202f6ca..a9bdbea 100644 --- a/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java +++ b/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java @@ -98,14 +98,26 @@ public static class LectureDetailDto { @Getter @NoArgsConstructor @AllArgsConstructor - public static class OtherStudentsDto { + public static class OtherStudentsListInfo { - private String userId; + private Long inflearnUserId; + private Long udemyUserId; private String name; - private String topword1; // topic - private String topword2; // subcategory - private String topword3; // (title + description) 가장 많이 나오는 단어 + private String topword1; + private String topword2; + private String topword3; + private String topword4; + private String topword5; + } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class OtherStudentsDto { + + List lectureList; } @Builder From 4ab82957918f441f5d080cbff133465ae9a948bd Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 03:35:44 +0900 Subject: [PATCH 09/16] =?UTF-8?q?:sparkles:=20Feat:=20userId=EC=9D=98=20co?= =?UTF-8?q?unt=20=EA=B0=92=EC=9D=84=20=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=88=98=EA=B0=95=EC=83=9D=20=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/PlatformStudentRepository.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java b/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java index 121fc7c..a375fe5 100644 --- a/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java @@ -2,6 +2,20 @@ import khu.bigdata.infou.domain.PlatformStudent; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; public interface PlatformStudentRepository extends JpaRepository { + + @Query("SELECT p.inflearnUserId, COUNT(p) FROM PlatformStudent p WHERE p.inflearnUserId IS NOT NULL GROUP BY p.inflearnUserId ORDER BY COUNT(p) DESC") + List countInflearnUserId(); + + @Query("SELECT p.udemyUserId, COUNT(p) FROM PlatformStudent p WHERE p.udemyUserId IS NOT NULL GROUP BY p.udemyUserId ORDER BY COUNT(p) DESC") + List countUdemyUserId(); + + List findByInflearnUserId(Long inflearnUserId); + + List findByUdemyUserId(Long udemyUserId); } + From 39b4d511008dbb4c1f993da8f804c0e5d78a8e19 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 03:36:26 +0900 Subject: [PATCH 10/16] =?UTF-8?q?:sparkles:=20Feat:=20=EB=8B=A4=EB=A5=B8?= =?UTF-8?q?=20=EC=82=AC=EB=9E=8C=EC=9D=98=20=EC=B6=94=EC=B2=9C=20=EC=BB=A4?= =?UTF-8?q?=EB=A6=AC=ED=81=98=EB=9F=BC=20=EB=B0=8F=20topword=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infou/implement/LectureService.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/implement/LectureService.java b/src/main/java/khu/bigdata/infou/implement/LectureService.java index 1ea95a2..f036514 100644 --- a/src/main/java/khu/bigdata/infou/implement/LectureService.java +++ b/src/main/java/khu/bigdata/infou/implement/LectureService.java @@ -3,16 +3,17 @@ import khu.bigdata.infou.business.LectureConverter; import khu.bigdata.infou.domain.LectureDetail; import khu.bigdata.infou.domain.LectureUdemy; +import khu.bigdata.infou.domain.PlatformStudent; import khu.bigdata.infou.repository.LectureDetailRepository; import khu.bigdata.infou.repository.LectureInflearnRepository; import khu.bigdata.infou.repository.LectureUdemyRepository; +import khu.bigdata.infou.repository.PlatformStudentRepository; import khu.bigdata.infou.web.dto.LectureResponseDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @RequiredArgsConstructor @@ -20,6 +21,7 @@ @Slf4j public class LectureService { + private final PlatformStudentRepository platformStudentRepository; private final LectureInflearnRepository lectureInflearnRepository; private final LectureUdemyRepository lectureUdemyRepository; private final LectureDetailRepository lectureDetailRepository; @@ -80,7 +82,30 @@ public LectureResponseDTO.LectureDetailDto findLectureDetail(Integer lectureId) } public LectureResponseDTO.OtherStudentsDto findOtherStudents() { - return null; + // inflearn_user_id의 개수를 세고 내림차순으로 정렬하여 상위 1000개 선택 + List inflearnUserCounts = platformStudentRepository.countInflearnUserId(); + List topInflearnStudents = inflearnUserCounts.stream() + .limit(1000) + .map(obj -> (Long) obj[0]) + .flatMap(id -> platformStudentRepository.findByInflearnUserId(id).stream()) + .collect(Collectors.toList()); + + // udemy_user_id의 개수를 세고 내림차순으로 정렬하여 상위 1000개 선택 + List udemyUserCounts = platformStudentRepository.countUdemyUserId(); + List topUdemyStudents = udemyUserCounts.stream() + .limit(1000) + .map(obj -> (Long) obj[0]) + .flatMap(id -> platformStudentRepository.findByUdemyUserId(id).stream()) + .collect(Collectors.toList()); + + // 두 리스트를 합치고 중복을 제거하여 최종 리스트 생성 + Set topStudentsSet = new HashSet<>(); + topStudentsSet.addAll(topInflearnStudents); + topStudentsSet.addAll(topUdemyStudents); + + List topStudents = new ArrayList<>(topStudentsSet); + + return LectureConverter.toOtherStudentsDto(topStudents); } public LectureResponseDTO.OtherLectureListDto findOtherLectureList() { From d4387f0082f9237328920ec9b934b9aa2e6dc74d Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 04:01:06 +0900 Subject: [PATCH 11/16] =?UTF-8?q?:sparkles:=20Feat:=20topword=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infou/web/dto/LectureResponseDTO.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java b/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java index a9bdbea..ecaf0d9 100644 --- a/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java +++ b/src/main/java/khu/bigdata/infou/web/dto/LectureResponseDTO.java @@ -24,8 +24,12 @@ public static class CategoryRecommendLectureInfo { private float price; private String instructorName; + // todo: topword1 ~ 5까지 추가 -> lecture_tag 테이블에서 가져오기 private String topword1; private String topword2; + private String topword3; + private String topword4; + private String topword5; } @@ -53,8 +57,12 @@ public static class KeywordRecommendLectureInfo { private float price; private String instructorName; + // todo: topword1 ~ 5까지 추가 -> lecture_tag 테이블에서 가져오기 private String topword1; private String topword2; + private String topword3; + private String topword4; + private String topword5; } @@ -81,7 +89,6 @@ public static class LectureDetailDto { private String instructorName; private String category; private String subcategory; - private Integer good; private Integer bad; private float teaching_quality; @@ -90,8 +97,6 @@ public static class LectureDetailDto { private float rating; private float level; - private String topword1; // topic - private String topword2; // subcategory } @Builder @@ -117,7 +122,7 @@ public static class OtherStudentsListInfo { @AllArgsConstructor public static class OtherStudentsDto { - List lectureList; + List studentList; } @Builder @@ -136,6 +141,8 @@ public static class OtherLectureListInfo { private String topword1; private String topword2; private String topword3; + private String topword4; + private String topword5; } @Builder @@ -150,6 +157,8 @@ public static class OtherLectureListDto { private String topword1; private String topword2; private String topword3; + private String topword4; + private String topword5; private List lectureList; // 강의 정보 관련 } From 8c48ee317e112ecebc1b4362e277a2b019712c4b Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 04:14:42 +0900 Subject: [PATCH 12/16] =?UTF-8?q?:recycle:=20Refactor:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=ED=95=84=EB=93=9C=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../khu/bigdata/infou/business/LectureConverter.java | 4 +--- .../khu/bigdata/infou/web/dto/LectureResponseDTO.java | 11 +---------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/business/LectureConverter.java b/src/main/java/khu/bigdata/infou/business/LectureConverter.java index 7a06c93..55206b2 100644 --- a/src/main/java/khu/bigdata/infou/business/LectureConverter.java +++ b/src/main/java/khu/bigdata/infou/business/LectureConverter.java @@ -80,8 +80,6 @@ public static LectureResponseDTO.LectureDetailDto toLectureDetailDto(LectureUdem .practice(lectureDetail.getPractice()) .rating(lectureDetail.getRating()) .level(lectureDetail.getLevel()) - .topword1(lectureUdemy.getTopic()) - .topword2(lectureUdemy.getSubcategory()) .build(); } @@ -106,7 +104,7 @@ public static LectureResponseDTO.OtherStudentsDto toOtherStudentsDto(List lectureList; // 강의 정보 관련 + private List otherLectureList; // 강의 정보 관련 } From e7dc2580c626c7ab585cf27da45987ed149fc5a0 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 04:15:13 +0900 Subject: [PATCH 13/16] =?UTF-8?q?:recycle:=20Refactor:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20DB=20=EC=A0=91=EA=B7=BC=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigdata/infou/repository/LectureInflearnRepository.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java index 33e3890..8254e2a 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java @@ -3,14 +3,9 @@ import khu.bigdata.infou.domain.LectureInflearn; import org.springframework.data.jpa.repository.JpaRepository; -import java.util.List; import java.util.Optional; public interface LectureInflearnRepository extends JpaRepository { - List findAllBySubcategory(String subcategory); - - List findAllByTopic(String topic); - Optional findByLectureId(Long lectureId); } From a39a1bab0a03004b1a5812b199ca71bb44d197cd Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 04:31:27 +0900 Subject: [PATCH 14/16] =?UTF-8?q?:recycle:=20Refactor:=20Long=20->=20Integ?= =?UTF-8?q?er=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infou/implement/LectureService.java | 53 ++++++++++--------- .../repository/LectureDetailRepository.java | 4 +- .../repository/LectureInflearnRepository.java | 2 +- .../repository/LectureUdemyRepository.java | 2 +- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/implement/LectureService.java b/src/main/java/khu/bigdata/infou/implement/LectureService.java index f036514..bf53fdb 100644 --- a/src/main/java/khu/bigdata/infou/implement/LectureService.java +++ b/src/main/java/khu/bigdata/infou/implement/LectureService.java @@ -11,9 +11,13 @@ import khu.bigdata.infou.web.dto.LectureResponseDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; import java.util.stream.Collectors; @RequiredArgsConstructor @@ -73,39 +77,38 @@ public LectureResponseDTO.LectureDetailDto findLectureDetail(Integer lectureId) throw new IllegalArgumentException("LectureId must not be null"); } - LectureUdemy lectureUdemy = lectureUdemyRepository.findByLectureId(Long.valueOf(lectureId)) + LectureUdemy lectureUdemy = lectureUdemyRepository.findByLectureId(lectureId) .orElseThrow(() -> new IllegalArgumentException("Lecture not found")); - LectureDetail lectureDetail = lectureDetailRepository.findByLectureUdemyId(Long.valueOf(lectureId)) + LectureDetail lectureDetail = lectureDetailRepository.findByLectureUdemyId(lectureId) .orElseThrow(() -> new IllegalArgumentException("Lecture detail not found")); return LectureConverter.toLectureDetailDto(lectureUdemy, lectureDetail); } public LectureResponseDTO.OtherStudentsDto findOtherStudents() { - // inflearn_user_id의 개수를 세고 내림차순으로 정렬하여 상위 1000개 선택 - List inflearnUserCounts = platformStudentRepository.countInflearnUserId(); - List topInflearnStudents = inflearnUserCounts.stream() - .limit(1000) - .map(obj -> (Long) obj[0]) - .flatMap(id -> platformStudentRepository.findByInflearnUserId(id).stream()) - .collect(Collectors.toList()); - - // udemy_user_id의 개수를 세고 내림차순으로 정렬하여 상위 1000개 선택 - List udemyUserCounts = platformStudentRepository.countUdemyUserId(); - List topUdemyStudents = udemyUserCounts.stream() - .limit(1000) - .map(obj -> (Long) obj[0]) - .flatMap(id -> platformStudentRepository.findByUdemyUserId(id).stream()) - .collect(Collectors.toList()); - // 두 리스트를 합치고 중복을 제거하여 최종 리스트 생성 - Set topStudentsSet = new HashSet<>(); - topStudentsSet.addAll(topInflearnStudents); - topStudentsSet.addAll(topUdemyStudents); - - List topStudents = new ArrayList<>(topStudentsSet); + Pageable pageable = PageRequest.of(0, 1000); + + // 쿼리 실행 + List topStudents = platformStudentRepository.findTopStudents(pageable); + + // 조회된 데이터를 List로 변환 + List studentList = new ArrayList<>(); + for (Object[] result : topStudents) { + Integer userId = (Integer) result[0]; + List students; + if (userId != null) { + students = platformStudentRepository.findByInflearnUserId(userId); + if (students.isEmpty()) { + students = platformStudentRepository.findByUdemyUserId(userId); + } + } else { + students = new ArrayList<>(); + } + studentList.addAll(students); + } - return LectureConverter.toOtherStudentsDto(topStudents); + return LectureConverter.toOtherStudentsDto(studentList); } public LectureResponseDTO.OtherLectureListDto findOtherLectureList() { diff --git a/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java index 5d05e10..a70ccdc 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureDetailRepository.java @@ -7,7 +7,7 @@ public interface LectureDetailRepository extends JpaRepository { - Optional findByLectureUdemyId(Long lectureId); + Optional findByLectureUdemyId(Integer lectureId); - Optional findByLectureInflearnId(Long lectureId); + Optional findByLectureInflearnId(Integer lectureId); } diff --git a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java index 8254e2a..fd4353f 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureInflearnRepository.java @@ -7,5 +7,5 @@ public interface LectureInflearnRepository extends JpaRepository { - Optional findByLectureId(Long lectureId); + Optional findByLectureId(Integer lectureId); } diff --git a/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java b/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java index 677113a..ef9ab89 100644 --- a/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/LectureUdemyRepository.java @@ -13,6 +13,6 @@ public interface LectureUdemyRepository extends JpaRepository findAllByTopic(String topic); - Optional findByLectureId(Long lectureId); + Optional findByLectureId(Integer lectureId); } From 571f1642b3f6627d79efc86fbb9d5954bd04e320 Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 04:36:21 +0900 Subject: [PATCH 15/16] =?UTF-8?q?:sparkles:=20Feat:=20=EB=8B=A4=EB=A5=B8?= =?UTF-8?q?=20=EC=88=98=EA=B0=95=EC=83=9D=EB=93=A4=EC=9D=98=20=EC=BB=A4?= =?UTF-8?q?=EB=A6=AC=ED=81=98=EB=9F=BC=20=EC=A0=84=EC=B2=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigdata/infou/implement/LectureService.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/implement/LectureService.java b/src/main/java/khu/bigdata/infou/implement/LectureService.java index bf53fdb..d087aae 100644 --- a/src/main/java/khu/bigdata/infou/implement/LectureService.java +++ b/src/main/java/khu/bigdata/infou/implement/LectureService.java @@ -31,7 +31,9 @@ public class LectureService { private final LectureDetailRepository lectureDetailRepository; - // 카테고리별 추천 강좌 조회 + /** + * 카테고리별 추천 강좌 조회 + */ public LectureResponseDTO.CategoryRecommendLectureDto findRecommendedLectureByCategory(String category) { if (category == null) { @@ -49,7 +51,9 @@ public LectureResponseDTO.CategoryRecommendLectureDto findRecommendedLectureByCa return LectureConverter.toCategoryRecommendLectureDto(sortedList); } - // 선택된 키워드별 추천 강좌 조회 + /** + * 선택된 키워드별 추천 강좌 조회 + */ public LectureResponseDTO.KeywordRecommendLectureDto findRecommendedLectureByKeyword(String keyword) { // 키워드가 null이거나 빈 문자열인 경우에 대한 예외 처리 if (keyword == null || keyword.trim().isEmpty()) { @@ -69,7 +73,9 @@ public LectureResponseDTO.KeywordRecommendLectureDto findRecommendedLectureByKey return LectureConverter.toKeywordRecommendLectureDto(sortedList); } - // 강좌 세부 조회 + /** + * 강좌 세부 조회 + */ public LectureResponseDTO.LectureDetailDto findLectureDetail(Integer lectureId) { // lectureId가 null인 경우에 대한 예외 처리 @@ -85,6 +91,9 @@ public LectureResponseDTO.LectureDetailDto findLectureDetail(Integer lectureId) return LectureConverter.toLectureDetailDto(lectureUdemy, lectureDetail); } + /** + * 다른 수강생들의 커리큘럼 전체 조회 + */ public LectureResponseDTO.OtherStudentsDto findOtherStudents() { Pageable pageable = PageRequest.of(0, 1000); From ba20e5e7e058c84f813f6bf464d56b9234018d4e Mon Sep 17 00:00:00 2001 From: yxhwxn Date: Thu, 13 Jun 2024 04:37:06 +0900 Subject: [PATCH 16/16] =?UTF-8?q?:recycle:=20Refactor:=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20=ED=83=80=EC=9E=85=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/PlatformStudentRepository.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java b/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java index a375fe5..392eef6 100644 --- a/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java +++ b/src/main/java/khu/bigdata/infou/repository/PlatformStudentRepository.java @@ -1,6 +1,7 @@ package khu.bigdata.infou.repository; import khu.bigdata.infou.domain.PlatformStudent; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -8,14 +9,14 @@ public interface PlatformStudentRepository extends JpaRepository { - @Query("SELECT p.inflearnUserId, COUNT(p) FROM PlatformStudent p WHERE p.inflearnUserId IS NOT NULL GROUP BY p.inflearnUserId ORDER BY COUNT(p) DESC") - List countInflearnUserId(); + @Query("SELECT p.inflearnUserId AS userId, COUNT(p) AS cnt FROM PlatformStudent p WHERE p.inflearnUserId IS NOT NULL GROUP BY p.inflearnUserId " + + "UNION " + + "SELECT p.udemyUserId AS userId, COUNT(p) AS cnt FROM PlatformStudent p WHERE p.udemyUserId IS NOT NULL GROUP BY p.udemyUserId " + + "ORDER BY cnt DESC") + List findTopStudents(Pageable pageable); - @Query("SELECT p.udemyUserId, COUNT(p) FROM PlatformStudent p WHERE p.udemyUserId IS NOT NULL GROUP BY p.udemyUserId ORDER BY COUNT(p) DESC") - List countUdemyUserId(); + List findByInflearnUserId(Integer userId); - List findByInflearnUserId(Long inflearnUserId); - - List findByUdemyUserId(Long udemyUserId); + List findByUdemyUserId(Integer userId); }