Skip to content

Commit

Permalink
[Refactor] : 브랜딩 상세페이지 키워드 추출 로직 변경
Browse files Browse the repository at this point in the history
[Refactor] : 브랜딩 상세페이지 키워드 추출 로직 변경
  • Loading branch information
emilywin825 authored May 23, 2024
2 parents eb8c7bc + eb599ea commit 5cc2b48
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ public class ProgramController {

//자기이해 조회 - 전체
@GetMapping("/main/self-understanding")
public ResponseEntity<ApiResponse<List<ProgrmsMainResponsetDto>>> findMainSelfUnderstanding() {
public ResponseEntity<ApiResponse<List<ProgramsMainResponseDto>>> findMainSelfUnderstanding() {
return ApiResponse.onSuccess(SuccessStatus._OK, programService.getMainSelfUnderstanding());
}

//브랜딩 조회 - 전체
@GetMapping("/main/branding")
public ResponseEntity<ApiResponse<List<ProgrmsMainResponsetDto>>> findMainBranding(@RequestHeader("Authorization") String authorizationHeader) {
public ResponseEntity<ApiResponse<List<ProgramsMainResponseDto>>> findMainBranding(@RequestHeader("Authorization") String authorizationHeader) {
return ApiResponse.onSuccess(SuccessStatus._OK, programService.getMainBranding(authorizationHeader));
}

//자기이해 조회 - 필터링
@PostMapping("/more/self-understanding")
private ResponseEntity<ApiResponse<List<ProgrmsMainResponsetDto>>> findMoreSelfUnderstanding(@RequestBody ProgramSelfUnderstandingRequestDto requestDto) {
private ResponseEntity<ApiResponse<List<ProgramsMainResponseDto>>> findMoreSelfUnderstanding(@RequestBody ProgramSelfUnderstandingRequestDto requestDto) {
return ApiResponse.onSuccess(SuccessStatus._OK, programService.getMoreSelfUnderstanding(requestDto));
}

//브랜딩 조회 - 필터링
@PostMapping("/more/branding")
private ResponseEntity<ApiResponse<List<ProgrmsMainResponsetDto>>> findMoreSelfUnderstanding(@RequestHeader("Authorization") String authorizationHeader,@RequestBody ProgramBrandingRequestDto requestDto) {
private ResponseEntity<ApiResponse<List<ProgramsMainResponseDto>>> findMoreSelfUnderstanding(@RequestHeader("Authorization") String authorizationHeader, @RequestBody ProgramBrandingRequestDto requestDto) {
return ApiResponse.onSuccess(SuccessStatus._OK, programService.getMoreBranding(authorizationHeader,requestDto));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import java.util.List;

public interface ProgramService {
List<ProgramDto.ProgrmsMainResponsetDto> getMainSelfUnderstanding();
List<ProgramDto.ProgramsMainResponseDto> getMainSelfUnderstanding();

List<ProgramDto.ProgrmsMainResponsetDto> getMainBranding(String authorizationHeader);
List<ProgramDto.ProgramsMainResponseDto> getMainBranding(String authorizationHeader);

List<ProgramDto.ProgrmsMainResponsetDto> getMoreSelfUnderstanding(ProgramDto.ProgramSelfUnderstandingRequestDto requestDto);
List<ProgramDto.ProgramsMainResponseDto> getMoreSelfUnderstanding(ProgramDto.ProgramSelfUnderstandingRequestDto requestDto);

List<ProgramDto.ProgrmsMainResponsetDto> getMoreBranding(String authorizationHeader,ProgramDto.ProgramBrandingRequestDto requestDto);
List<ProgramDto.ProgramsMainResponseDto> getMoreBranding(String authorizationHeader, ProgramDto.ProgramBrandingRequestDto requestDto);

ProgramDetailDto.ProgramDetailResponseDto getDetailProgram(String authorizationHeader, Long programId, String type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ public class ProgramServiceImpl implements ProgramService {
private final ProgramParticipantsRepository programParticipantsRepository;

@Override
public List<ProgramDto.ProgrmsMainResponsetDto> getMainSelfUnderstanding() {
return selfUnderstandingsRepository.findTop9ByOrderByCreatedDateDesc().stream().map(ProgramDto.ProgrmsMainResponsetDto::of).collect(Collectors.toList());
public List<ProgramDto.ProgramsMainResponseDto> getMainSelfUnderstanding() {
return selfUnderstandingsRepository.findTop9ByOrderByCreatedDateDesc().stream().map(ProgramDto.ProgramsMainResponseDto::of).collect(Collectors.toList());
}

@Override
public List<ProgramDto.ProgrmsMainResponsetDto> getMainBranding(String authorizationHeader) {
public List<ProgramDto.ProgramsMainResponseDto> getMainBranding(String authorizationHeader) {
//브랜딩 프로그램에서 유저의 관심분야와 키워드
return findAllBrandingByUsersKeywordsAndInterests(authorizationHeader).stream().limit(9).map(ProgramDto.ProgrmsMainResponsetDto::of).collect(Collectors.toList());
return findAllBrandingByUsersKeywordsAndInterests(authorizationHeader).stream().limit(9).map(ProgramDto.ProgramsMainResponseDto::of).collect(Collectors.toList());
}


@Override
public List<ProgramDto.ProgrmsMainResponsetDto> getMoreSelfUnderstanding(ProgramDto.ProgramSelfUnderstandingRequestDto requestDto) {
public List<ProgramDto.ProgramsMainResponseDto> getMoreSelfUnderstanding(ProgramDto.ProgramSelfUnderstandingRequestDto requestDto) {
int maxPrice = selfUnderstandingsRepository.findTopByOrderByPriceDesc().getPrice();

return findSelfUnderstandingByFilter(requestDto, maxPrice).stream().map(v -> ProgramDto.ProgrmsMainResponsetDto.of(v, maxPrice)).collect(Collectors.toList());
return findSelfUnderstandingByFilter(requestDto, maxPrice).stream().map(v -> ProgramDto.ProgramsMainResponseDto.of(v, maxPrice)).collect(Collectors.toList());
}


@Override
public List<ProgramDto.ProgrmsMainResponsetDto> getMoreBranding(String authorizationHeader, ProgramDto.ProgramBrandingRequestDto requestDto) {
public List<ProgramDto.ProgramsMainResponseDto> getMoreBranding(String authorizationHeader, ProgramDto.ProgramBrandingRequestDto requestDto) {
List<Branding> brandings = findBrandingsByFilter(authorizationHeader, requestDto);
return brandings.stream().map(ProgramDto.ProgrmsMainResponsetDto::of).collect(Collectors.toList());
return brandings.stream().map(ProgramDto.ProgramsMainResponseDto::of).collect(Collectors.toList());
}

@Override
Expand All @@ -78,7 +78,7 @@ public ProgramDetailDto.ProgramDetailResponseDto getDetailProgram(String authori
return ProgramDetailDto.ProgramDetailResponseDto.of(findSelfUnderStandingById(programId), findAllUserKeyword(user), participants, isApply);
} else if (type.equals("branding")) {
participants = findBrandingById(programId).getProgramParticipants().size();
return ProgramDetailDto.ProgramDetailResponseDto.of(findBrandingById(programId), findAllUserKeyword(user), participants, isApply);
return ProgramDetailDto.ProgramDetailResponseDto.of(findBrandingById(programId), participants, isApply);
} else throw new ProgramException(NOT_FOUND_PROGRAM);
}

Expand Down Expand Up @@ -148,7 +148,7 @@ private List<SelfUnderstanding> findSelfUnderstandingByFilter(ProgramDto.Program

if (requestDto.getForm() == null || requestDto.getForm().equals("온오프라인")) {
return selfUnderstandingsRepository.findByPriceBetween(requestDto.getStartPrice(), endPrice);
} else if(requestDto.getForm().equals("온라인")||requestDto.getForm().equals("오프라인"))
} else if (requestDto.getForm().equals("온라인") || requestDto.getForm().equals("오프라인"))
return selfUnderstandingsRepository.findByPriceBetweenAndForm(requestDto.getStartPrice(), endPrice, FORM.ofCode(requestDto.getForm()));
else throw new ProgramException(PROGRAM_ENUM_NOT_FOUND);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.NoArgsConstructor;

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

public class ProgramDetailDto {

Expand Down Expand Up @@ -55,14 +56,14 @@ public static ProgramDetailResponseDto of(SelfUnderstanding selfUnderstandings,
}

// 브랜딩
public static ProgramDetailResponseDto of(Branding branding, List<String> userKeywords, int participants, boolean isApply) {
public static ProgramDetailResponseDto of(Branding branding, int participants, boolean isApply) {
return ProgramDetailResponseDto.builder()
.imageUrl(branding.getBrandingUrl())
.name(branding.getName())
.oneLineDescription(branding.getOneLineDescription())
.descriptionUrl(branding.getDescriptionUrl())
.link(branding.getLink())
.keywords(userKeywords)
.keywords(branding.getProgramsImageKeywords().stream().map(v->v.getKeyword().getName()).collect(Collectors.toList()))
.providerImage(branding.getProgramProvider().getProviderImage())
.providerName(branding.getProgramProvider().getProviderName())
.providerJob(branding.getProgramProvider().getProviderJob())
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/kusitms/jangkku/domain/program/dto/ProgramDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ProgramDto {
@NoArgsConstructor
@AllArgsConstructor
@Getter
public static class ProgrmsMainResponsetDto {
public static class ProgramsMainResponseDto {
private String selfUnderstandingUrl; //썸네일 이미지
private String name;//제목
private String link;
Expand All @@ -25,8 +25,8 @@ public static class ProgrmsMainResponsetDto {
private String form;
private int price;

public static ProgrmsMainResponsetDto of(SelfUnderstanding selfUnderstandings) {
return ProgrmsMainResponsetDto.builder()
public static ProgramsMainResponseDto of(SelfUnderstanding selfUnderstandings) {
return ProgramsMainResponseDto.builder()
.selfUnderstandingUrl(selfUnderstandings.getSelfUnderstandingUrl())
.name(selfUnderstandings.getName())
.link(selfUnderstandings.getLink())
Expand All @@ -35,8 +35,8 @@ public static ProgrmsMainResponsetDto of(SelfUnderstanding selfUnderstandings) {
.build();
}

public static ProgrmsMainResponsetDto of(SelfUnderstanding selfUnderstandings,int maxPrice) {
return ProgrmsMainResponsetDto.builder()
public static ProgramsMainResponseDto of(SelfUnderstanding selfUnderstandings, int maxPrice) {
return ProgramsMainResponseDto.builder()
.selfUnderstandingUrl(selfUnderstandings.getSelfUnderstandingUrl())
.name(selfUnderstandings.getName())
.link(selfUnderstandings.getLink())
Expand All @@ -48,8 +48,8 @@ public static ProgrmsMainResponsetDto of(SelfUnderstanding selfUnderstandings,in
.build();
}

public static ProgrmsMainResponsetDto of(Branding branding) {
return ProgrmsMainResponsetDto.builder()
public static ProgramsMainResponseDto of(Branding branding) {
return ProgramsMainResponseDto.builder()
.selfUnderstandingUrl(branding.getBrandingUrl())
.name(branding.getName())
.link(branding.getLink())
Expand Down

0 comments on commit 5cc2b48

Please sign in to comment.