Files
sam-api/app/Swagger/v1/BankAccountApi.php
hskwon e1b0c99d5d feat: 2.3 카드/계좌 관리 API 구현
- cards, bank_accounts 테이블 마이그레이션
- Card, BankAccount 모델 (카드번호 암호화)
- CardService, BankAccountService
- CardController, BankAccountController + FormRequest 4개
- API 엔드포인트 15개 (카드 7개, 계좌 8개)
- Swagger 문서 (CardApi.php, BankAccountApi.php)
2025-12-17 21:02:20 +09:00

354 lines
16 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="BankAccounts", description="계좌 관리")
*
* @OA\Schema(
* schema="BankAccount",
* type="object",
* description="계좌 정보",
*
* @OA\Property(property="id", type="integer", example=1, description="계좌 ID"),
* @OA\Property(property="tenant_id", type="integer", example=1, description="테넌트 ID"),
* @OA\Property(property="bank_code", type="string", example="088", description="은행 코드"),
* @OA\Property(property="bank_name", type="string", example="신한은행", description="은행명"),
* @OA\Property(property="account_number", type="string", example="110-123-456789", description="계좌번호"),
* @OA\Property(property="account_holder", type="string", example="주식회사 샘", description="예금주"),
* @OA\Property(property="account_name", type="string", example="운영계좌", description="계좌 별칭"),
* @OA\Property(property="status", type="string", enum={"active","inactive"}, example="active", description="상태"),
* @OA\Property(property="assigned_user_id", type="integer", example=1, nullable=true, description="담당자 ID"),
* @OA\Property(property="assigned_user", type="object", nullable=true,
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="홍길동"),
* description="담당자 정보"
* ),
* @OA\Property(property="is_primary", type="boolean", example=true, description="대표계좌 여부"),
* @OA\Property(property="created_by", type="integer", example=1, nullable=true, description="생성자 ID"),
* @OA\Property(property="updated_by", type="integer", example=1, nullable=true, description="수정자 ID"),
* @OA\Property(property="created_at", type="string", format="date-time"),
* @OA\Property(property="updated_at", type="string", format="date-time")
* )
*
* @OA\Schema(
* schema="BankAccountCreateRequest",
* type="object",
* required={"bank_code","bank_name","account_number","account_holder","account_name"},
* description="계좌 등록 요청",
*
* @OA\Property(property="bank_code", type="string", example="088", maxLength=10, description="은행 코드"),
* @OA\Property(property="bank_name", type="string", example="신한은행", maxLength=50, description="은행명"),
* @OA\Property(property="account_number", type="string", example="110-123-456789", maxLength=30, description="계좌번호"),
* @OA\Property(property="account_holder", type="string", example="주식회사 샘", maxLength=50, description="예금주"),
* @OA\Property(property="account_name", type="string", example="운영계좌", maxLength=100, description="계좌 별칭"),
* @OA\Property(property="status", type="string", enum={"active","inactive"}, example="active", description="상태"),
* @OA\Property(property="assigned_user_id", type="integer", example=1, nullable=true, description="담당자 ID"),
* @OA\Property(property="is_primary", type="boolean", example=false, description="대표계좌 여부")
* )
*
* @OA\Schema(
* schema="BankAccountUpdateRequest",
* type="object",
* description="계좌 수정 요청",
*
* @OA\Property(property="bank_code", type="string", example="088", maxLength=10, description="은행 코드"),
* @OA\Property(property="bank_name", type="string", example="신한은행", maxLength=50, description="은행명"),
* @OA\Property(property="account_number", type="string", example="110-123-456789", maxLength=30, description="계좌번호"),
* @OA\Property(property="account_holder", type="string", example="주식회사 샘", maxLength=50, description="예금주"),
* @OA\Property(property="account_name", type="string", example="운영계좌", maxLength=100, description="계좌 별칭"),
* @OA\Property(property="status", type="string", enum={"active","inactive"}, example="active", description="상태"),
* @OA\Property(property="assigned_user_id", type="integer", example=1, nullable=true, description="담당자 ID")
* )
*
* @OA\Schema(
* schema="BankAccountListItem",
* type="object",
* description="계좌 목록 아이템 (셀렉트박스용)",
*
* @OA\Property(property="id", type="integer", example=1, description="계좌 ID"),
* @OA\Property(property="account_name", type="string", example="운영계좌", description="계좌 별칭"),
* @OA\Property(property="bank_name", type="string", example="신한은행", description="은행명"),
* @OA\Property(property="display_number", type="string", example="*****6789", description="마스킹된 계좌번호"),
* @OA\Property(property="is_primary", type="boolean", example=true, description="대표계좌 여부")
* )
*/
class BankAccountApi
{
/**
* @OA\Get(
* path="/api/v1/bank-accounts",
* tags={"BankAccounts"},
* summary="계좌 목록 조회",
* description="계좌 목록을 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="search", in="query", description="검색어 (계좌명, 은행명, 예금주, 계좌번호)", @OA\Schema(type="string")),
* @OA\Parameter(name="status", in="query", description="상태 필터", @OA\Schema(type="string", enum={"active","inactive"})),
* @OA\Parameter(name="assigned_user_id", in="query", description="담당자 ID", @OA\Schema(type="integer")),
* @OA\Parameter(name="is_primary", in="query", description="대표계좌만", @OA\Schema(type="boolean")),
* @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"account_name","bank_name","created_at"}, default="created_at")),
* @OA\Parameter(name="sort_dir", in="query", description="정렬 방향", @OA\Schema(type="string", enum={"asc","desc"}, default="desc")),
* @OA\Parameter(ref="#/components/parameters/Page"),
* @OA\Parameter(ref="#/components/parameters/Size"),
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(
* property="data",
* type="object",
* @OA\Property(property="current_page", type="integer", example=1),
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/BankAccount")),
* @OA\Property(property="per_page", type="integer", example=20),
* @OA\Property(property="total", type="integer", example=10)
* )
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function index() {}
/**
* @OA\Post(
* path="/api/v1/bank-accounts",
* tags={"BankAccounts"},
* summary="계좌 등록",
* description="새로운 계좌를 등록합니다. 첫 번째 계좌는 자동으로 대표계좌로 설정됩니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/BankAccountCreateRequest")
* ),
*
* @OA\Response(
* response=201,
* description="등록 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/BankAccount")
* )
* }
* )
* ),
*
* @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function store() {}
/**
* @OA\Get(
* path="/api/v1/bank-accounts/active",
* tags={"BankAccounts"},
* summary="활성 계좌 목록 (셀렉트박스용)",
* description="활성 상태의 계좌 목록을 간단한 형태로 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/BankAccountListItem"))
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function active() {}
/**
* @OA\Get(
* path="/api/v1/bank-accounts/{id}",
* tags={"BankAccounts"},
* summary="계좌 상세 조회",
* description="계좌 상세 정보를 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="계좌 ID", @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/BankAccount")
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="계좌 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function show() {}
/**
* @OA\Put(
* path="/api/v1/bank-accounts/{id}",
* tags={"BankAccounts"},
* summary="계좌 수정",
* description="계좌 정보를 수정합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="계좌 ID", @OA\Schema(type="integer")),
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/BankAccountUpdateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="수정 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/BankAccount")
* )
* }
* )
* ),
*
* @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="계좌 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function update() {}
/**
* @OA\Delete(
* path="/api/v1/bank-accounts/{id}",
* tags={"BankAccounts"},
* summary="계좌 삭제",
* description="계좌를 삭제합니다. (Soft Delete) 대표계좌 삭제 시 다른 활성 계좌가 대표계좌로 자동 설정됩니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="계좌 ID", @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="삭제 성공",
*
* @OA\JsonContent(ref="#/components/schemas/ApiResponse")
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="계좌 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function destroy() {}
/**
* @OA\Patch(
* path="/api/v1/bank-accounts/{id}/toggle",
* tags={"BankAccounts"},
* summary="계좌 상태 토글",
* description="계좌의 상태를 토글합니다. (active ↔ inactive)",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="계좌 ID", @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="토글 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/BankAccount")
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="계좌 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function toggle() {}
/**
* @OA\Patch(
* path="/api/v1/bank-accounts/{id}/set-primary",
* tags={"BankAccounts"},
* summary="대표계좌 설정",
* description="해당 계좌를 대표계좌로 설정합니다. 기존 대표계좌는 자동으로 해제됩니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="계좌 ID", @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="설정 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/BankAccount")
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="계좌 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function setPrimary() {}
}