|
| 1 | +package org.umc.valuedi.domain.asset.controller; |
| 2 | + |
| 3 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 4 | +import lombok.RequiredArgsConstructor; |
| 5 | +import org.springframework.web.bind.annotation.GetMapping; |
| 6 | +import org.springframework.web.bind.annotation.PathVariable; |
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 8 | +import org.springframework.web.bind.annotation.RestController; |
| 9 | +import org.umc.valuedi.domain.asset.dto.res.AssetResDTO; |
| 10 | +import org.umc.valuedi.domain.asset.dto.res.BankResDTO; |
| 11 | +import org.umc.valuedi.domain.asset.dto.res.CardResDTO; |
| 12 | +import org.umc.valuedi.domain.asset.service.AssetQueryService; |
| 13 | +import org.umc.valuedi.domain.connection.service.ConnectionQueryService; |
| 14 | +import org.umc.valuedi.global.apiPayload.ApiResponse; |
| 15 | +import org.umc.valuedi.global.apiPayload.code.GeneralSuccessCode; |
| 16 | +import org.umc.valuedi.global.security.annotation.CurrentMember; |
| 17 | + |
| 18 | +import java.util.List; |
| 19 | + |
| 20 | +@RestController |
| 21 | +@RequiredArgsConstructor |
| 22 | +@RequestMapping("/api/assets") |
| 23 | +@Tag(name = "Asset", description = "자산 관련 조회 API") |
| 24 | +public class AssetController implements AssetControllerDocs { |
| 25 | + |
| 26 | + private final ConnectionQueryService connectionQueryService; |
| 27 | + private final AssetQueryService assetQueryService; |
| 28 | + |
| 29 | + |
| 30 | + @GetMapping("/cards") |
| 31 | + public ApiResponse<CardResDTO.CardListDTO> getCards( |
| 32 | + @CurrentMember Long memberId |
| 33 | + ) { |
| 34 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, assetQueryService.getAllCards(memberId)); |
| 35 | + } |
| 36 | + |
| 37 | + @GetMapping("/cardIssuers") |
| 38 | + public ApiResponse<List<CardResDTO.CardIssuerConnection>> getCardIssuers( |
| 39 | + @CurrentMember Long memberId |
| 40 | + ) { |
| 41 | + List<CardResDTO.CardIssuerConnection> cardIssuers = connectionQueryService.getConnectedCardIssuers(memberId); |
| 42 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, cardIssuers); |
| 43 | + } |
| 44 | + |
| 45 | + @GetMapping("/cardIssuers/{issuerCode}/cards") |
| 46 | + public ApiResponse<CardResDTO.CardListDTO> getCardsByIssuer( |
| 47 | + @PathVariable String issuerCode, |
| 48 | + @CurrentMember Long memberId |
| 49 | + ) { |
| 50 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, assetQueryService.getCardsByIssuer(memberId, issuerCode)); |
| 51 | + } |
| 52 | + |
| 53 | + @GetMapping("/banks") |
| 54 | + public ApiResponse<List<BankResDTO.BankConnection>> getBanks( // TODO: List 객체 래핑으로 변경 |
| 55 | + @CurrentMember Long memberId |
| 56 | + ) { |
| 57 | + List<BankResDTO.BankConnection> banks = connectionQueryService.getConnectedBanks(memberId); |
| 58 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, banks); |
| 59 | + } |
| 60 | + |
| 61 | + @GetMapping("/accounts") |
| 62 | + public ApiResponse<BankResDTO.BankAccountListDTO> getAllBankAccounts( |
| 63 | + @CurrentMember Long memberId |
| 64 | + ) { |
| 65 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, assetQueryService.getAllBankAccounts(memberId)); |
| 66 | + } |
| 67 | + |
| 68 | + @GetMapping("/banks/{bankCode}/accounts") |
| 69 | + public ApiResponse<BankResDTO.BankAccountListDTO> getAccountsByBank( |
| 70 | + @PathVariable String bankCode, |
| 71 | + @CurrentMember Long memberId |
| 72 | + ) { |
| 73 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, assetQueryService.getBankAccountsByOrganization(memberId, bankCode)); |
| 74 | + } |
| 75 | + |
| 76 | + @GetMapping("/summary") |
| 77 | + public ApiResponse<AssetResDTO.AssetSummaryCountDTO> getAssetCount( |
| 78 | + @CurrentMember Long memberId |
| 79 | + ) { |
| 80 | + return ApiResponse.onSuccess(GeneralSuccessCode.OK, assetQueryService.getAssetSummaryCount(memberId)); |
| 81 | + } |
| 82 | +} |
0 commit comments