-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 탐색 페이지 트랜딩 리스트 조회 API 구현 (#74)
* style: 패키지 구조 변경 (#74) * feat: 탐색 페이지 트랜딩 리스트 조회 API 구현 (#74) * refactor: 트랜딩에 ownerId 추가 및 정렬 기준 변경 (#74) * style: 패키지 구조 변경 (#74) * refactor: 비지니스로직 부분 service 단에서 처리하도록 변경 (#74)
- Loading branch information
Showing
13 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tion/dto/response/ListCreateResponse.java → ...tion/dto/response/ListCreateResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/listywave/list/application/dto/response/ListTrandingResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.listywave.list.application.dto.response; | ||
|
||
import com.listywave.list.application.domain.Lists; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ListTrandingResponse( | ||
Long id, | ||
Long ownerId, | ||
String title, | ||
String description, | ||
String itemImageUrl, | ||
String backgroundColor | ||
) { | ||
public static ListTrandingResponse of(Lists list, String imageUrlTopRankItem) { | ||
return ListTrandingResponse.builder() | ||
.id(list.getId()) | ||
.ownerId(list.getUser().getId()) | ||
.title(list.getTitle()) | ||
.description(list.getDescription()) | ||
.itemImageUrl(imageUrlTopRankItem) | ||
.backgroundColor(list.getBackgroundColor()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/listywave/list/presentation/controller/CategoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...ywave/list/repository/ListRepository.java → .../list/repository/list/ListRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/com/listywave/list/repository/list/custom/CustomListRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.listywave.list.repository.list.custom; | ||
|
||
import com.listywave.list.application.domain.Lists; | ||
import java.util.List; | ||
|
||
public interface CustomListRepository { | ||
|
||
List<Lists> findTrandingLists(); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/listywave/list/repository/list/custom/impl/CustomListRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.listywave.list.repository.list.custom.impl; | ||
|
||
import static com.listywave.list.application.domain.QItem.item; | ||
import static com.listywave.list.application.domain.QLists.lists; | ||
|
||
import com.listywave.list.application.domain.Item; | ||
import com.listywave.list.application.domain.Lists; | ||
import com.listywave.list.repository.list.custom.CustomListRepository; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class CustomListRepositoryImpl implements CustomListRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Lists> findTrandingLists() { | ||
List<Lists> fetch = queryFactory | ||
.selectFrom(lists) | ||
.leftJoin(lists.items, item) | ||
.distinct() | ||
.limit(10) | ||
.orderBy(lists.collectCount.desc(), lists.viewCount.desc()) | ||
.fetch(); | ||
|
||
fetch.forEach( | ||
list -> list.getItems() | ||
.sort(Comparator.comparing(Item::getRanking)) | ||
); | ||
return fetch; | ||
} | ||
} |