Skip to content

Commit 8f04ea2

Browse files
authored
Merge pull request #65 from Kusitms-29th-Kobaco-A/fix/top-view-ad
fix : 최근 인기있는 영상 정렬을 조회수 기반으로 변경
2 parents 6f07fb5 + 923ce7f commit 8f04ea2

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

kobaco/kobaco/src/main/java/core/kobaco/application/advertise/service/AdvertiseService.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ public Page<AdvertiseSimpleResponse> getSaveAdvertiseList(Pageable pageable) {
7676
}
7777

7878
public Page<AdvertiseSimpleResponse> getLikeAdvertiseList(Pageable pageable, List<String> keywordList) {
79-
List<AdvertiseSimpleResponse> advertiseSimpleResponses =
80-
advertiseLikeReader.getLikeAdvertiseIdList(pageable, keywordList).stream()
81-
.map(advertiseReader::getAdvertise)
82-
.map(this::convertSimpleResponse)
83-
.toList();
84-
return new PageImpl<>(advertiseSimpleResponses, pageable, advertiseSimpleResponses.size());
79+
return advertiseReader.getAllTopViewAdvertiseList(pageable, keywordList)
80+
.map(this::convertSimpleResponse);
8581
}
8682

8783
public Page<AdvertiseSimpleResponse> getAdvertiseList(Pageable pageable, List<String> keywordList, OrderType orderType) {
@@ -117,7 +113,6 @@ public void trendAdvertise(Long advertiseId, AdvertiseTrendCreateRequest request
117113

118114
private AdvertiseSimpleResponse convertSimpleResponse(Advertisement advertise) {
119115
List<String> advertiseKeywordList = getKeywordList(advertise);
120-
121116
return AdvertiseSimpleResponse.of(advertise, advertiseKeywordList);
122117
}
123118

kobaco/kobaco/src/main/java/core/kobaco/domain/advertise/AdvertisementRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ public interface AdvertisementRepository {
2222
Page<Advertisement> findAllByMakerCompanyAndAdvertiseId(Pageable pageable, String makerCompany, Long advertiseId);
2323

2424
void upViewCount(Long advertiseId);
25+
26+
Page<Advertisement> findAllOrderByViewCount(Pageable pageable, List<String> keywordList);
2527
}

kobaco/kobaco/src/main/java/core/kobaco/domain/advertise/service/AdvertiseReader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public Page<Advertisement> getAllAdvertiseList(Pageable pageable,
3838
return advertisementRepository.findAllWithKeyword(pageable, keywordList, orderType);
3939
}
4040

41+
public Page<Advertisement> getAllTopViewAdvertiseList(Pageable pageable, List<String> keywordList) {
42+
return advertisementRepository.findAllOrderByViewCount(pageable, keywordList);
43+
}
44+
4145
public Page<Advertisement> getSaveAdvertiseList(Long requestUserId, Pageable pageable) {
4246
return advertisementRepository.findSavedAllByUserId(pageable, requestUserId);
4347
}

kobaco/kobaco/src/main/java/core/kobaco/infra/jpa/advertisement/AdvertisementRepositoryImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,14 @@ public Page<Advertisement> findAllByMakerCompanyAndAdvertiseId(Pageable pageable
8585
public void upViewCount(Long advertiseId) {
8686
advertisementJpaRepository.updateViewCount(advertiseId);
8787
}
88+
89+
@Override
90+
public Page<Advertisement> findAllOrderByViewCount(Pageable pageable, List<String> keywordList) {
91+
if(Objects.isNull(keywordList)||keywordList.isEmpty()){
92+
return advertisementJpaRepository.findAllOrderByViewCount(pageable)
93+
.map(advertiseMapper::toDomain);
94+
}
95+
return advertisementJpaRepository.findAllWithKeywordOrderByViewCount(pageable, keywordList, (long) keywordList.size())
96+
.map(advertiseMapper::toDomain);
97+
}
8898
}

0 commit comments

Comments
 (0)