-
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.
Browse files
Browse the repository at this point in the history
[REFACTOR] 전술 복사 API 요청 시, response 내용 수정
- Loading branch information
Showing
5 changed files
with
84 additions
and
4 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
59 changes: 59 additions & 0 deletions
59
src/main/java/com/capstone/BnagFer/domain/tactic/dto/CopyTacticResponse.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,59 @@ | ||
package com.capstone.BnagFer.domain.tactic.dto; | ||
|
||
import com.capstone.BnagFer.domain.tactic.entity.Position; | ||
import com.capstone.BnagFer.domain.tactic.entity.Tactic; | ||
import com.capstone.BnagFer.domain.tactic.entity.TacticPositionDetail; | ||
import lombok.Builder; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Builder | ||
public record CopyTacticResponse( | ||
Long tacticId, | ||
Long userId, | ||
String nickname, | ||
String tacticName, | ||
Boolean anonymous, | ||
String mainFormation, | ||
List<TacticDetailResponse.DetailList> positionDetail, | ||
String tacticDetails, | ||
String subTactic, | ||
LocalDateTime createdAt, | ||
LocalDateTime updatedAt) { | ||
public static CopyTacticResponse from(Tactic tactic) { | ||
|
||
return CopyTacticResponse.builder() | ||
.tacticId(tactic.getTacticId()) | ||
.userId(tactic.getUser().getId()) | ||
.nickname(tactic.getUser().getProfile().getNickname()) | ||
.tacticName(tactic.getTacticName()) | ||
.anonymous(tactic.isAnonymous()) | ||
.mainFormation(tactic.getMainFormation()) | ||
.positionDetail(CopyTacticResponse.DetailList.from(tactic.getTacticPositionDetails())) | ||
.tacticDetails(tactic.getTacticDetails()) | ||
.subTactic(tactic.getSubTactic()) | ||
.createdAt(tactic.getCreatedAt()) | ||
.updatedAt(tactic.getUpdatedAt()) | ||
.build(); | ||
} | ||
|
||
@Builder | ||
public record DetailList( | ||
Long detailId, | ||
Position position, | ||
String positionDescription | ||
){ | ||
public static TacticDetailResponse.DetailList from(TacticPositionDetail tacticPositionDetail){ | ||
return TacticDetailResponse.DetailList.builder() | ||
.detailId(tacticPositionDetail.getDetailId()) | ||
.position(tacticPositionDetail.getPosition()) | ||
.positionDescription(tacticPositionDetail.getPositionDescription()) | ||
.build(); | ||
} | ||
public static List<TacticDetailResponse.DetailList> from(List<TacticPositionDetail> positions){ | ||
return positions.stream().map(TacticDetailResponse.DetailList::from).toList(); | ||
} | ||
} | ||
} |
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