From 62ee2aee0d3445e68fe2fd32183b78c6cb77c92a Mon Sep 17 00:00:00 2001 From: yechan-kim <60172300+yechan-kim@users.noreply.github.com> Date: Sun, 17 Nov 2024 17:15:04 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=BA=90=EB=A6=AD=ED=84=B0=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20API=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=86=B5?= =?UTF-8?q?=EA=B3=84=20=EA=B3=84=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20-=20=EC=BA=90=EB=A6=AD=ED=84=B0=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EA=B0=B1=EC=8B=A0=20API(PATCH=20/update)=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20-=20=EC=BA=90=EB=A6=AD=ED=84=B0=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20API(GET=20/search)=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?-=20=EC=BA=90=EB=A6=AD=ED=84=B0=20=EB=A0=88=EB=B2=A8/=EC=9C=A0?= =?UTF-8?q?=EB=8B=88=EC=98=A8=20=EB=A0=88=EB=B2=A8/=EC=A0=84=ED=88=AC?= =?UTF-8?q?=EB=A0=A5=20=EB=9E=AD=ED=82=B9=20API(GET=20/ranking/{level/unio?= =?UTF-8?q?n/combat-power})=20=EC=B6=94=EA=B0=80=20-=20=EC=BA=90=EB=A6=AD?= =?UTF-8?q?=ED=84=B0=20=EB=A0=88=EB=B2=A8/=EC=9C=A0=EB=8B=88=EC=98=A8=20?= =?UTF-8?q?=EB=A0=88=EB=B2=A8/=EC=A0=84=ED=88=AC=EB=A0=A5=20=ED=8F=89?= =?UTF-8?q?=EA=B7=A0=20API(GET=20/ranking/{level/union/combat-power})=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/CharacterController.java | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 src/main/java/com/dpbr/dpbrbe/domain/character/presentation/CharacterController.java diff --git a/src/main/java/com/dpbr/dpbrbe/domain/character/presentation/CharacterController.java b/src/main/java/com/dpbr/dpbrbe/domain/character/presentation/CharacterController.java new file mode 100644 index 0000000..e615cd4 --- /dev/null +++ b/src/main/java/com/dpbr/dpbrbe/domain/character/presentation/CharacterController.java @@ -0,0 +1,154 @@ +package com.dpbr.dpbrbe.domain.character.presentation; + +import java.io.IOException; +import java.util.List; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.dpbr.dpbrbe.domain.character.presentation.dto.request.SearchRequest; +import com.dpbr.dpbrbe.domain.character.presentation.dto.request.UpdateRequest; +import com.dpbr.dpbrbe.domain.character.presentation.dto.response.AverageResponse; +import com.dpbr.dpbrbe.domain.character.presentation.dto.response.InfoResponse; +import com.dpbr.dpbrbe.domain.character.presentation.dto.response.RankingResponse; +import com.dpbr.dpbrbe.domain.character.usecase.AverageStatisticsService; +import com.dpbr.dpbrbe.domain.character.usecase.RankService; +import com.dpbr.dpbrbe.domain.character.usecase.SearchService; +import com.dpbr.dpbrbe.domain.character.usecase.UpdateInfoService; +import com.dpbr.dpbrbe.global.error.ErrorResponse; +import com.dpbr.dpbrbe.global.response.GlobalResponseDto; +import com.dpbr.dpbrbe.global.success.SuccessCode; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import lombok.RequiredArgsConstructor; + +@RestController +@RequestMapping("v1/character") +@RequiredArgsConstructor +public class CharacterController { + + private final RankService rankService; + private final SearchService searchService; + private final UpdateInfoService updateInfoService; + private final AverageStatisticsService averageStatisticsService; + + @Operation(summary = "캐릭터 정보 갱신", description = "사용자 캐릭터의 정보를 갱신합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @PatchMapping("/update") + public ResponseEntity> saveCharacter(UpdateRequest request) throws IOException { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(updateInfoService.execute(request))); + } + + @Operation(summary = "캐릭터 검색", description = "사용자 캐릭터의 정보를 검색합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/search") + public ResponseEntity> SearchCharacter(SearchRequest request) { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(searchService.execute(request), SuccessCode.SUCCESS)); + } + + @Operation(summary = "캐릭터 레벨 랭킹", description = "전체 캐릭터의 레벨 순위를 호출합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/ranking/level") + public ResponseEntity>> levelRanking() { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(rankService.level(), SuccessCode.SUCCESS)); + } + + @Operation(summary = "캐릭터 유니온 레벨 랭킹", description = "전체 캐릭터의 유니온 레벨 순위를 호출합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/ranking/union") + public ResponseEntity>> unionRanking() { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(rankService.unionLevel(), SuccessCode.SUCCESS)); + } + + @Operation(summary = "캐릭터 전투력 랭킹", description = "전체 캐릭터의 전투력 순위를 호출합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/ranking/combat-power") + public ResponseEntity>> combatPowerRanking() { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(rankService.combatPower(), SuccessCode.SUCCESS)); + } + + @Operation(summary = "캐릭터 레벨 평균", description = "전체 캐릭터의 레벨 평균을 호출합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/ranking/level") + public ResponseEntity> levelAverage() { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(averageStatisticsService.level(), SuccessCode.SUCCESS)); + } + + @Operation(summary = "캐릭터 유니온 레벨 평균", description = "전체 캐릭터의 유니온 레벨 평균을 호출합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/ranking/union") + public ResponseEntity> unionAverage() { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(averageStatisticsService.unionLevel(), SuccessCode.SUCCESS)); + } + + @Operation(summary = "캐릭터 전투력 평균", description = "전체 캐릭터의 전투력 평균을 호출합니다.") + @ApiResponses({ + @ApiResponse(responseCode = "200"), + @ApiResponse(responseCode = "401", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "403", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "404", content = @Content(schema = @Schema(implementation = ErrorResponse.class))), + @ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/ranking/combat-power") + public ResponseEntity> combatPowerAverage() { + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success(averageStatisticsService.combatPower(), SuccessCode.SUCCESS)); + } +}