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: 강좌 세부 조회 시 topword 필드 추가 #22

Merged
merged 1 commit into from
Jun 13, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package khu.bigdata.infou.business;

import khu.bigdata.infou.domain.LectureDetail;
import khu.bigdata.infou.domain.LectureTag;
import khu.bigdata.infou.domain.LectureUdemy;
import khu.bigdata.infou.domain.PlatformStudent;
import khu.bigdata.infou.web.dto.LectureResponseDTO;
Expand Down Expand Up @@ -62,7 +63,7 @@ public static LectureResponseDTO.KeywordRecommendLectureDto toKeywordRecommendLe
}

// 강좌 세부 조회
public static LectureResponseDTO.LectureDetailDto toLectureDetailDto(LectureUdemy lectureUdemy, LectureDetail lectureDetail) {
public static LectureResponseDTO.LectureDetailDto toLectureDetailDto(LectureUdemy lectureUdemy, LectureDetail lectureDetail, LectureTag lectureTag) {

return LectureResponseDTO.LectureDetailDto.builder()
.lectureId(lectureUdemy.getLectureId())
Expand All @@ -80,6 +81,11 @@ public static LectureResponseDTO.LectureDetailDto toLectureDetailDto(LectureUdem
.practice(lectureDetail.getPractice())
.rating(lectureDetail.getRating())
.level(lectureDetail.getLevel())
.topword1(lectureTag.getTopword1())
.topword2(lectureTag.getTopword2())
.topword3(lectureTag.getTopword3())
.topword4(lectureTag.getTopword4())
.topword5(lectureTag.getTopword5())
.build();
}

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

import khu.bigdata.infou.business.LectureConverter;
import khu.bigdata.infou.domain.LectureDetail;
import khu.bigdata.infou.domain.LectureInflearn;
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.domain.*;
import khu.bigdata.infou.repository.*;
import khu.bigdata.infou.web.dto.LectureResponseDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -27,6 +21,7 @@ public class LectureService {
private final LectureInflearnRepository lectureInflearnRepository;
private final LectureUdemyRepository lectureUdemyRepository;
private final LectureDetailRepository lectureDetailRepository;
private final LectureTagRepository lectureTagRepository;


/**
Expand Down Expand Up @@ -111,8 +106,10 @@ public LectureResponseDTO.LectureDetailDto findLectureDetail(Integer lectureId)
.orElseThrow(() -> new IllegalArgumentException("Lecture not found"));
LectureDetail lectureDetail = lectureDetailRepository.findByLectureUdemyId(lectureId)
.orElseThrow(() -> new IllegalArgumentException("Lecture detail not found"));
LectureTag lectureTag = lectureTagRepository.findByLectureUdemyId(lectureId)
.orElseThrow(() -> new IllegalArgumentException("Lecture tag not found"));

return LectureConverter.toLectureDetailDto(lectureUdemy, lectureDetail);
return LectureConverter.toLectureDetailDto(lectureUdemy, lectureDetail, lectureTag);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package khu.bigdata.infou.repository;

import khu.bigdata.infou.domain.LectureTag;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface LectureTagRepository extends JpaRepository<LectureTag, Long> {

Optional<LectureTag> findByLectureUdemyId(Integer lectureId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public static class CategoryRecommendLectureInfo {
private float price;
private String instructorName;

// todo: topword1 ~ 5까지 추가 -> lecture_tag 테이블에서 가져오기
private String topword1;
private String topword2;
private String topword3;
Expand Down Expand Up @@ -97,6 +96,11 @@ public static class LectureDetailDto {
private float rating;
private float level;

private String topword1;
private String topword2;
private String topword3;
private String topword4;
private String topword5;
}

@Builder
Expand Down
Loading