Files
sam-api/app/Swagger/v1/PopupApi.php
hskwon 8f1292f7c4 feat: Phase 6.2 팝업관리 API 구현
- popups 테이블 마이그레이션 생성
- Popup 모델 (BelongsToTenant, SoftDeletes)
- PopupService CRUD 구현
- FormRequest 검증 (Store/Update)
- PopupController 6개 엔드포인트
- Swagger 문서 (PopupApi.php)
- PROJECT_DEVELOPMENT_POLICY.md 정책 준수
2025-12-19 16:14:04 +09:00

247 lines
10 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Popup", description="팝업관리")
*
* @OA\Schema(
* schema="Popup",
*
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="tenant_id", type="integer", example=1),
* @OA\Property(property="target_type", type="string", enum={"all", "department"}, example="all", description="대상 유형"),
* @OA\Property(property="target_id", type="integer", nullable=true, example=null, description="대상 ID (부서 ID)"),
* @OA\Property(property="title", type="string", example="공지사항 팝업", description="제목"),
* @OA\Property(property="content", type="string", example="<p>팝업 내용입니다.</p>", description="내용 (HTML)"),
* @OA\Property(property="status", type="string", enum={"active", "inactive"}, example="active", description="상태"),
* @OA\Property(property="started_at", type="string", format="date-time", nullable=true, example="2025-01-01T00:00:00", description="노출 시작일"),
* @OA\Property(property="ended_at", type="string", format="date-time", nullable=true, example="2025-12-31T23:59:59", description="노출 종료일"),
* @OA\Property(property="options", type="object", nullable=true, description="확장 옵션"),
* @OA\Property(property="created_by", type="integer", nullable=true, example=1),
* @OA\Property(property="updated_by", type="integer", nullable=true),
* @OA\Property(property="created_at", type="string", format="date-time"),
* @OA\Property(property="updated_at", type="string", format="date-time"),
* @OA\Property(
* property="creator",
* type="object",
* nullable=true,
* @OA\Property(property="id", type="integer"),
* @OA\Property(property="name", type="string")
* ),
* @OA\Property(
* property="department",
* type="object",
* nullable=true,
* @OA\Property(property="id", type="integer"),
* @OA\Property(property="name", type="string")
* )
* )
*
* @OA\Schema(
* schema="PopupPagination",
* allOf={
* @OA\Schema(ref="#/components/schemas/PaginationMeta"),
* @OA\Schema(
*
* @OA\Property(
* property="data",
* type="array",
*
* @OA\Items(ref="#/components/schemas/Popup")
* )
* )
* }
* )
*
* @OA\Schema(
* schema="PopupCreateRequest",
* required={"title", "content"},
*
* @OA\Property(property="target_type", type="string", enum={"all", "department"}, example="all", description="대상 유형 (기본: all)"),
* @OA\Property(property="target_id", type="integer", nullable=true, example=null, description="대상 부서 ID (target_type=department 시 필수)"),
* @OA\Property(property="title", type="string", example="새 공지사항", maxLength=200, description="제목"),
* @OA\Property(property="content", type="string", example="<p>팝업 내용</p>", description="내용 (HTML)"),
* @OA\Property(property="status", type="string", enum={"active", "inactive"}, example="inactive", description="상태 (기본: inactive)"),
* @OA\Property(property="started_at", type="string", format="date", nullable=true, example="2025-01-01", description="노출 시작일"),
* @OA\Property(property="ended_at", type="string", format="date", nullable=true, example="2025-12-31", description="노출 종료일"),
* @OA\Property(property="options", type="object", nullable=true, description="확장 옵션")
* )
*
* @OA\Schema(
* schema="PopupUpdateRequest",
*
* @OA\Property(property="target_type", type="string", enum={"all", "department"}, example="department", description="대상 유형"),
* @OA\Property(property="target_id", type="integer", nullable=true, example=1, description="대상 부서 ID"),
* @OA\Property(property="title", type="string", example="수정된 공지사항", maxLength=200, description="제목"),
* @OA\Property(property="content", type="string", example="<p>수정된 내용</p>", description="내용 (HTML)"),
* @OA\Property(property="status", type="string", enum={"active", "inactive"}, example="active", description="상태"),
* @OA\Property(property="started_at", type="string", format="date", nullable=true, example="2025-01-01", description="노출 시작일"),
* @OA\Property(property="ended_at", type="string", format="date", nullable=true, example="2025-12-31", description="노출 종료일"),
* @OA\Property(property="options", type="object", nullable=true, description="확장 옵션")
* )
*/
class PopupApi
{
/**
* @OA\Get(
* path="/api/v1/popups",
* tags={"Popup"},
* summary="팝업 목록 조회 (관리자용)",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="target_type", in="query", @OA\Schema(type="string", enum={"all", "department"}), description="대상 유형"),
* @OA\Parameter(name="status", in="query", @OA\Schema(type="string", enum={"active", "inactive"}), description="상태"),
* @OA\Parameter(name="search", in="query", @OA\Schema(type="string"), description="검색어 (제목, 내용)"),
* @OA\Parameter(name="sort_by", in="query", @OA\Schema(type="string", default="created_at"), description="정렬 기준"),
* @OA\Parameter(name="sort_dir", in="query", @OA\Schema(type="string", enum={"asc", "desc"}, default="desc"), description="정렬 방향"),
* @OA\Parameter(name="per_page", in="query", @OA\Schema(type="integer", default=20), description="페이지당 항목 수"),
* @OA\Parameter(name="page", in="query", @OA\Schema(type="integer", default=1), description="페이지 번호"),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(ref="#/components/schemas/PopupPagination")
* )
* )
*/
public function index() {}
/**
* @OA\Get(
* path="/api/v1/popups/active",
* tags={"Popup"},
* summary="활성 팝업 목록 조회 (사용자용 - 로그인 후 노출)",
* description="현재 노출 중인 팝업 목록을 반환합니다. status=active이고 현재 시간이 started_at~ended_at 범위에 있는 팝업만 조회됩니다.",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="department_id", in="query", @OA\Schema(type="integer"), description="사용자의 부서 ID (해당 부서 대상 팝업 포함)"),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string"),
* @OA\Property(
* property="data",
* type="array",
*
* @OA\Items(ref="#/components/schemas/Popup")
* )
* )
* )
* )
*/
public function active() {}
/**
* @OA\Post(
* path="/api/v1/popups",
* tags={"Popup"},
* summary="팝업 등록",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/PopupCreateRequest")
* ),
*
* @OA\Response(
* response=201,
* description="생성 성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string"),
* @OA\Property(property="data", ref="#/components/schemas/Popup")
* )
* )
* )
*/
public function store() {}
/**
* @OA\Get(
* path="/api/v1/popups/{id}",
* tags={"Popup"},
* summary="팝업 상세 조회",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string"),
* @OA\Property(property="data", ref="#/components/schemas/Popup")
* )
* )
* )
*/
public function show() {}
/**
* @OA\Put(
* path="/api/v1/popups/{id}",
* tags={"Popup"},
* summary="팝업 수정",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/PopupUpdateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="수정 성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string"),
* @OA\Property(property="data", ref="#/components/schemas/Popup")
* )
* )
* )
*/
public function update() {}
/**
* @OA\Delete(
* path="/api/v1/popups/{id}",
* tags={"Popup"},
* summary="팝업 삭제",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="삭제 성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string"),
* @OA\Property(property="data", type="null")
* )
* )
* )
*/
public function destroy() {}
}