-
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 #170 from Gamegoo-repo/feat/161
[Feat/161] λ΄κ° μμ±ν κ²μν κΈ λͺ©λ‘ μ‘°ν API
- Loading branch information
Showing
6 changed files
with
109 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
src/main/java/com/gamegoo/gamegoo_v2/content/board/dto/response/MyBoardListResponse.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,39 @@ | ||
package com.gamegoo.gamegoo_v2.content.board.dto.response; | ||
|
||
import com.gamegoo.gamegoo_v2.account.member.domain.Member; | ||
import com.gamegoo.gamegoo_v2.account.member.domain.Tier; | ||
import com.gamegoo.gamegoo_v2.content.board.domain.Board; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Builder | ||
public class MyBoardListResponse { | ||
|
||
long boardId; | ||
long memberId; | ||
Integer profileImage; | ||
String gameName; | ||
String tag; | ||
Tier tier; | ||
int rank; | ||
String contents; | ||
LocalDateTime createdAt; | ||
|
||
public static MyBoardListResponse of(Board board) { | ||
Member member = board.getMember(); | ||
return MyBoardListResponse.builder() | ||
.boardId(board.getId()) | ||
.memberId(member.getId()) | ||
.profileImage(board.getBoardProfileImage()) | ||
.gameName(member.getGameName()) | ||
.tag(member.getTag()) | ||
.tier(member.getTier()) | ||
.rank(member.getGameRank()) | ||
.createdAt(board.getCreatedAt()) | ||
.build(); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/gamegoo/gamegoo_v2/content/board/dto/response/MyBoardResponse.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,37 @@ | ||
package com.gamegoo.gamegoo_v2.content.board.dto.response; | ||
|
||
import com.gamegoo.gamegoo_v2.content.board.domain.Board; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Getter | ||
@Builder | ||
public class MyBoardResponse { | ||
|
||
Integer totalPage; | ||
Integer totalCount; | ||
List<MyBoardListResponse> myBoards; | ||
|
||
public static MyBoardResponse of(Page<Board> boardPage) { | ||
// μ 체 νμ΄μ§/κ°μ μΆμΆ | ||
int totalCount = (int) boardPage.getTotalElements(); | ||
int totalPage = (boardPage.getTotalPages() == 0) ? 1 : boardPage.getTotalPages(); | ||
|
||
// Board -> MyBoardListResponse λ³ν | ||
List<MyBoardListResponse> boardList = boardPage.getContent().stream() | ||
.map(MyBoardListResponse::of) | ||
.collect(Collectors.toList()); | ||
|
||
// DTO μμ± | ||
return MyBoardResponse.builder() | ||
.totalPage(totalPage) | ||
.totalCount(totalCount) | ||
.myBoards(boardList) | ||
.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