-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from syyling/feat/11
[feat] 랭킹 조회 기능 추가
- Loading branch information
Showing
7 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...in/java/com/mookive/mookive_backend/ranking/applicaiton/dto/response/RankingResponse.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,24 @@ | ||
package com.mookive.mookive_backend.ranking.applicaiton.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class RankingResponse { | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public static class RankingInfoResponse { | ||
|
||
private int rankingNumber; | ||
private String poster; | ||
private String title; | ||
|
||
@Builder | ||
public RankingInfoResponse(int rankingNumber, String poster, String title) { | ||
this.rankingNumber = rankingNumber; | ||
this.poster = poster; | ||
this.title = title; | ||
} | ||
} | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/mookive/mookive_backend/ranking/applicaiton/service/RankingGetService.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,40 @@ | ||
package com.mookive.mookive_backend.ranking.applicaiton.service; | ||
|
||
import com.mookive.mookive_backend.ranking.applicaiton.dto.response.RankingResponse; | ||
import com.mookive.mookive_backend.ranking.applicaiton.mapper.RankingMapper; | ||
import com.mookive.mookive_backend.ranking.domain.entity.Ranking; | ||
import com.mookive.mookive_backend.ranking.domain.service.RankingQueryService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RankingGetService { | ||
|
||
private final RankingQueryService rankingQueryService; | ||
|
||
public List<RankingResponse.RankingInfoResponse> getRanking(Long userId) { | ||
List<Ranking> rankingList = rankingQueryService.findByUserId(userId); | ||
Collections.sort(rankingList, new Comparator<Ranking>() { | ||
@Override | ||
public int compare(Ranking o1, Ranking o2) { | ||
return o1.getRankingNumber()-o2.getRankingNumber(); | ||
} | ||
}); | ||
|
||
List<RankingResponse.RankingInfoResponse> rankingInfoResponseList = rankingList.stream().map(ranking -> { | ||
RankingResponse.RankingInfoResponse rankingInfoResponse = RankingMapper.mapToRankingInfoResponse(ranking); | ||
return rankingInfoResponse; | ||
}).collect(Collectors.toList()); | ||
|
||
return rankingInfoResponseList; | ||
} | ||
|
||
|
||
|
||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/mookive/mookive_backend/ranking/domain/service/RankingQueryService.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,19 @@ | ||
package com.mookive.mookive_backend.ranking.domain.service; | ||
|
||
import com.mookive.mookive_backend.ranking.domain.entity.Ranking; | ||
import com.mookive.mookive_backend.ranking.domain.respository.RankingRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RankingQueryService { | ||
|
||
private final RankingRepository rankingRepository; | ||
|
||
public List<Ranking> findByUserId(Long userId) { | ||
return rankingRepository.findByUserId(userId); | ||
} | ||
} |
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