-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE-FEAT] 기술 관련 api 만들기 #360
Changes from 5 commits
ddb7dfa
a91d9f4
1b8c8a6
40d96f5
5429cb0
fc98812
f30a2bc
e38eb8d
90118fd
3c5aec2
bc4cc2f
ebca44a
7e8f81b
0602bf8
d6244a0
999d094
a08aa37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.pokerogue.helper.move.controller; | ||
|
||
import com.pokerogue.helper.move.dto.MoveDetailResponse; | ||
import com.pokerogue.helper.move.dto.MoveResponse; | ||
import com.pokerogue.helper.move.service.MoveService; | ||
import com.pokerogue.helper.util.dto.ApiResponse; | ||
|
@@ -18,6 +19,11 @@ public class MoveController { | |
|
||
private final MoveService moveService; | ||
|
||
@GetMapping("/api/v1/moves1") | ||
public ApiResponse<List<MoveResponse>> moveList() { | ||
return new ApiResponse<>("기술 리스트 불러오기에 성공했습니다.", moveService.findMoves()); | ||
} | ||
|
||
@GetMapping("/api/v1/moves") | ||
public ApiResponse<List<MoveResponse>> moveListByPokedexNumber(@RequestParam("pokedex-number") Integer pokedexNumber) { | ||
log.info( | ||
|
@@ -31,14 +37,26 @@ public ApiResponse<List<MoveResponse>> moveListByPokedexNumber(@RequestParam("po | |
} | ||
|
||
@GetMapping("/api/v1/move/{id}") | ||
public ApiResponse<MoveResponse> moveDetails(@PathVariable String id) { | ||
public ApiResponse<MoveResponse> moveDetailsByBattle(@PathVariable String id) { | ||
log.info( | ||
"---- URI : {}, Param : {}, ThreadName : {}", | ||
"/api/v1/move/{id}", | ||
id, | ||
Thread.currentThread().getName() | ||
); | ||
|
||
return new ApiResponse<>("포켓몬의 기술 불러오기에 성공했습니다.", moveService.findMove(id)); | ||
return new ApiResponse<>("기술 정보 불러오기에 성공했습니다.", moveService.findMoveByBattle(id)); | ||
} | ||
|
||
@GetMapping("/api/v1/move1/{id}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금 사용되고 있는 '기술 도감' 이어서 생각났어요! 배틀 관련 기술 api에 battle 붙이고 싶지만 하위호환성 때문에 그건 안될 거 같고.. 🥲 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수정했습니다! |
||
public ApiResponse<MoveDetailResponse> moveDetails(@PathVariable String id) { | ||
log.info( | ||
"---- URI : {}, Param : {}, ThreadName : {}", | ||
"/api/v1/move1/{id}", | ||
id, | ||
Thread.currentThread().getName() | ||
); | ||
|
||
return new ApiResponse<>("기술 정보 불러오기에 성공했습니다.", moveService.findMove(id)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.pokerogue.helper.move.dto; | ||
|
||
import com.pokerogue.helper.move.data.Move; | ||
import com.pokerogue.helper.move.data.MoveCategory; | ||
import com.pokerogue.helper.move.data.MoveFlag; | ||
import com.pokerogue.helper.type.data.Type; | ||
import java.util.List; | ||
|
||
public record MoveDetailResponse( | ||
String id, | ||
String name, | ||
String typeEngName, | ||
String typeLogo, | ||
String categoryEngName, | ||
String categoryLogo, | ||
String moveTarget, | ||
Integer power, | ||
Integer accuracy, | ||
Integer powerPoint, | ||
String effect, | ||
Integer effectChance, | ||
Integer priority, | ||
Integer generation, | ||
String released, | ||
List<String> flags, | ||
List<String> pokemonIdsWithLevelMove, | ||
List<String> pokemonIdsWithEggMove | ||
) { | ||
|
||
public static MoveDetailResponse from(Move move, List<String> levelMoveIdsContains, List<String> eggMoveIdsContains) { | ||
Type type = move.getType(); | ||
MoveCategory moveCategory = move.getMoveCategory(); | ||
List<String> moveFlags = move.getFlags().stream() | ||
.map(MoveFlag::getId) | ||
.toList(); | ||
|
||
return new MoveDetailResponse( | ||
move.getId(), | ||
move.getKoName(), | ||
type.getName(), | ||
type.getImage(), | ||
moveCategory.getEngName(), | ||
moveCategory.getImage(), | ||
move.getMoveTarget().getId(), | ||
move.getPower(), | ||
move.getAccuracy(), | ||
move.getPowerPoint(), | ||
move.getEffect(), | ||
move.getEffectChance(), | ||
move.getPriority(), | ||
move.getGeneration(), | ||
move.getReleased(), | ||
moveFlags, | ||
levelMoveIdsContains, | ||
eggMoveIdsContains | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 메소드들(서비스 메소드 포함)
moveDetailsInBattle
어때요 ?!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했습니다!☺️ ☺️