|
| 1 | +package fitfit.domain.account.controller; |
| 2 | + |
| 3 | +import fitfit.domain.account.dto.AccountRequestDTO.RegisterOrUpdateRequest; |
| 4 | +import fitfit.domain.account.dto.AccountResponseDTO.AccountInfoResponse; |
| 5 | +import fitfit.domain.account.service.command.AccountCommandService; |
| 6 | +import fitfit.domain.account.service.query.AccountQueryService; |
| 7 | +import fitfit.global.apiPayload.ApiResponse; |
| 8 | +import io.swagger.v3.oas.annotations.Operation; |
| 9 | +import io.swagger.v3.oas.annotations.media.Content; |
| 10 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 11 | +import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 13 | +import jakarta.validation.Valid; |
| 14 | +import lombok.RequiredArgsConstructor; |
| 15 | +import lombok.extern.slf4j.Slf4j; |
| 16 | +import org.springframework.web.bind.annotation.*; |
| 17 | +import org.springframework.http.ResponseEntity; |
| 18 | + |
| 19 | +@Slf4j |
| 20 | +@RestController |
| 21 | +@RequestMapping("/api/accounts") |
| 22 | +@RequiredArgsConstructor |
| 23 | +@Tag(name = "Account", description = "계좌 관련 API") |
| 24 | +public class AccountRestController { |
| 25 | + |
| 26 | + private final AccountQueryService accountQueryService; |
| 27 | + private final AccountCommandService accountCommandService; |
| 28 | + |
| 29 | + @PutMapping |
| 30 | + @Operation(summary = "내 계좌 등록 및 수정 API", description = "로그인된 회원의 계좌 정보를 등록하거나 기존 정보를 수정하는 API입니다.") |
| 31 | + @ApiResponses({ |
| 32 | + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "OK, 성공"), |
| 33 | + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "유효성 검사 실패 또는 JWT 오류.", content = @Content(schema = @Schema(implementation = ApiResponse.class))), |
| 34 | + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "존재하지 않는 회원입니다.", content = @Content(schema = @Schema(implementation = ApiResponse.class))), |
| 35 | + }) |
| 36 | + public ApiResponse<AccountInfoResponse> registerOrUpdateAccount( |
| 37 | + @RequestHeader(value = "Authorization") String authorization, |
| 38 | + @Valid @RequestBody RegisterOrUpdateRequest request) { |
| 39 | + |
| 40 | + AccountInfoResponse response = accountCommandService.registerOrUpdateAccount(authorization, request); |
| 41 | + return ApiResponse.onSuccess(response); |
| 42 | + } |
| 43 | + |
| 44 | + @GetMapping |
| 45 | + @Operation(summary = "내 계좌 정보 조회 API", description = "로그인된 회원의 현재 등록된 계좌 정보를 조회하는 API입니다.") |
| 46 | + @ApiResponses({ |
| 47 | + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "OK, 성공", content = @Content(schema = @Schema(implementation = AccountInfoResponse.class))), |
| 48 | + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "존재하지 않는 회원이거나 계좌 정보가 없습니다.", content = @Content(schema = @Schema(implementation = ApiResponse.class))), |
| 49 | + }) |
| 50 | + public ResponseEntity<ApiResponse<AccountInfoResponse>> getAccountInfo( |
| 51 | + @RequestHeader(value = "Authorization") String authorization) { |
| 52 | + |
| 53 | + AccountInfoResponse response = accountQueryService.getAccountInfo(authorization); |
| 54 | + return ResponseEntity.ok(ApiResponse.onSuccess(response)); |
| 55 | + } |
| 56 | +} |
0 commit comments