- 같은 날 같은 사용자의 기록이 있으면 업데이트, 없으면 생성 - 기존 Create Only 패턴에서 Upsert 패턴으로 변경 - Swagger 문서 업데이트 (409 응답 제거, 설명 변경) Co-Authored-By: Claude <noreply@anthropic.com>
422 lines
20 KiB
PHP
422 lines
20 KiB
PHP
<?php
|
|
|
|
namespace App\Swagger\v1;
|
|
|
|
/**
|
|
* @OA\Tag(name="Attendances", description="근태 관리 (HR)")
|
|
*
|
|
* @OA\Schema(
|
|
* schema="Attendance",
|
|
* 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="user_id", type="integer", example=10, description="사용자 ID"),
|
|
* @OA\Property(property="base_date", type="string", format="date", example="2024-01-15", description="기준일"),
|
|
* @OA\Property(property="status", type="string", enum={"onTime","late","absent","vacation","businessTrip","fieldWork","overtime","remote"}, example="onTime", description="근태 상태"),
|
|
* @OA\Property(property="remarks", type="string", example="외근으로 인한 지각", nullable=true, description="비고"),
|
|
* @OA\Property(property="check_in", type="string", example="09:00:00", nullable=true, description="출근 시간"),
|
|
* @OA\Property(property="check_out", type="string", example="18:00:00", nullable=true, description="퇴근 시간"),
|
|
* @OA\Property(property="work_minutes", type="integer", example=540, nullable=true, description="근무 시간(분)"),
|
|
* @OA\Property(property="overtime_minutes", type="integer", example=60, nullable=true, description="초과 근무 시간(분)"),
|
|
* @OA\Property(property="late_minutes", type="integer", example=15, nullable=true, description="지각 시간(분)"),
|
|
* @OA\Property(property="user", type="object", nullable=true, description="사용자 정보",
|
|
* @OA\Property(property="id", type="integer", example=10),
|
|
* @OA\Property(property="name", type="string", example="홍길동"),
|
|
* @OA\Property(property="email", type="string", example="hong@company.com")
|
|
* ),
|
|
* @OA\Property(property="created_at", type="string", format="date-time", example="2024-01-15T09:00:00Z"),
|
|
* @OA\Property(property="updated_at", type="string", format="date-time", example="2024-01-15T18:00:00Z")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="AttendanceCreateRequest",
|
|
* type="object",
|
|
* required={"user_id", "base_date"},
|
|
* description="근태 등록 요청",
|
|
*
|
|
* @OA\Property(property="user_id", type="integer", example=10, description="사용자 ID"),
|
|
* @OA\Property(property="base_date", type="string", format="date", example="2024-01-15", description="기준일"),
|
|
* @OA\Property(property="status", type="string", enum={"onTime","late","absent","vacation","businessTrip","fieldWork","overtime","remote"}, example="onTime", description="근태 상태"),
|
|
* @OA\Property(property="remarks", type="string", example="외근으로 인한 지각", description="비고"),
|
|
* @OA\Property(property="check_in", type="string", example="09:00:00", description="출근 시간"),
|
|
* @OA\Property(property="check_out", type="string", example="18:00:00", description="퇴근 시간"),
|
|
* @OA\Property(property="work_minutes", type="integer", example=540, description="근무 시간(분)"),
|
|
* @OA\Property(property="overtime_minutes", type="integer", example=60, description="초과 근무 시간(분)"),
|
|
* @OA\Property(property="vacation_type", type="string", example="annual", description="휴가 유형")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="AttendanceUpdateRequest",
|
|
* type="object",
|
|
* description="근태 수정 요청",
|
|
*
|
|
* @OA\Property(property="status", type="string", enum={"onTime","late","absent","vacation","businessTrip","fieldWork","overtime","remote"}, example="onTime", description="근태 상태"),
|
|
* @OA\Property(property="remarks", type="string", example="수정된 비고", description="비고"),
|
|
* @OA\Property(property="check_in", type="string", example="09:00:00", description="출근 시간"),
|
|
* @OA\Property(property="check_out", type="string", example="18:00:00", description="퇴근 시간"),
|
|
* @OA\Property(property="work_minutes", type="integer", example=540, description="근무 시간(분)")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="AttendanceMonthlyStats",
|
|
* type="object",
|
|
* description="월간 근태 통계",
|
|
*
|
|
* @OA\Property(property="year", type="integer", example=2024),
|
|
* @OA\Property(property="month", type="integer", example=1),
|
|
* @OA\Property(property="total_days", type="integer", example=22, description="총 기록 일수"),
|
|
* @OA\Property(property="by_status", type="object", description="상태별 일수",
|
|
* @OA\Property(property="onTime", type="integer", example=18),
|
|
* @OA\Property(property="late", type="integer", example=2),
|
|
* @OA\Property(property="absent", type="integer", example=0),
|
|
* @OA\Property(property="vacation", type="integer", example=2),
|
|
* @OA\Property(property="businessTrip", type="integer", example=0),
|
|
* @OA\Property(property="fieldWork", type="integer", example=0),
|
|
* @OA\Property(property="overtime", type="integer", example=0),
|
|
* @OA\Property(property="remote", type="integer", example=0)
|
|
* ),
|
|
* @OA\Property(property="total_work_minutes", type="integer", example=11880, description="총 근무 시간(분)"),
|
|
* @OA\Property(property="total_overtime_minutes", type="integer", example=300, description="총 초과 근무 시간(분)")
|
|
* )
|
|
*/
|
|
class AttendanceApi
|
|
{
|
|
/**
|
|
* @OA\Get(
|
|
* path="/api/v1/attendances",
|
|
* tags={"Attendances"},
|
|
* summary="근태 목록 조회",
|
|
* description="필터/검색/페이지네이션으로 근태 목록을 조회합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\Parameter(name="user_id", in="query", description="사용자 ID 필터", @OA\Schema(type="integer")),
|
|
* @OA\Parameter(name="date", in="query", description="특정 날짜 (YYYY-MM-DD)", @OA\Schema(type="string", format="date")),
|
|
* @OA\Parameter(name="date_from", in="query", description="시작 날짜", @OA\Schema(type="string", format="date")),
|
|
* @OA\Parameter(name="date_to", in="query", description="종료 날짜", @OA\Schema(type="string", format="date")),
|
|
* @OA\Parameter(name="status", in="query", description="근태 상태", @OA\Schema(type="string", enum={"onTime","late","absent","vacation","businessTrip","fieldWork","overtime","remote"})),
|
|
* @OA\Parameter(name="department_id", in="query", description="부서 ID 필터", @OA\Schema(type="integer")),
|
|
* @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"base_date","status","created_at"}, default="base_date")),
|
|
* @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/Attendance")),
|
|
* @OA\Property(property="per_page", type="integer", example=20),
|
|
* @OA\Property(property="total", type="integer", example=100)
|
|
* )
|
|
* )
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @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 index() {}
|
|
|
|
/**
|
|
* @OA\Get(
|
|
* path="/api/v1/attendances/monthly-stats",
|
|
* tags={"Attendances"},
|
|
* summary="월간 통계 조회",
|
|
* description="월간 근태 통계를 조회합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\Parameter(name="year", in="query", description="연도", @OA\Schema(type="integer", example=2024)),
|
|
* @OA\Parameter(name="month", in="query", description="월", @OA\Schema(type="integer", example=1, minimum=1, maximum=12)),
|
|
* @OA\Parameter(name="user_id", in="query", 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/AttendanceMonthlyStats"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
|
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
|
* )
|
|
*/
|
|
public function monthlyStats() {}
|
|
|
|
/**
|
|
* @OA\Post(
|
|
* path="/api/v1/attendances/check-in",
|
|
* tags={"Attendances"},
|
|
* summary="출근 기록 (체크인)",
|
|
* description="출근 시간을 기록합니다. 당일 기록이 없으면 새로 생성, 있으면 업데이트합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\RequestBody(
|
|
* required=false,
|
|
*
|
|
* @OA\JsonContent(
|
|
* type="object",
|
|
*
|
|
* @OA\Property(property="user_id", type="integer", example=10, description="사용자 ID (미지정시 본인)"),
|
|
* @OA\Property(property="check_in", type="string", example="09:00:00", description="출근 시간 (미지정시 현재 시간)"),
|
|
* @OA\Property(property="gps_data", type="object", description="GPS 데이터",
|
|
* @OA\Property(property="latitude", type="number", format="float", example=37.5665),
|
|
* @OA\Property(property="longitude", type="number", format="float", example=126.9780)
|
|
* )
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="출근 기록 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Attendance"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @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 checkIn() {}
|
|
|
|
/**
|
|
* @OA\Post(
|
|
* path="/api/v1/attendances/check-out",
|
|
* tags={"Attendances"},
|
|
* summary="퇴근 기록 (체크아웃)",
|
|
* description="퇴근 시간을 기록합니다. 출근 기록이 없으면 에러가 발생합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\RequestBody(
|
|
* required=false,
|
|
*
|
|
* @OA\JsonContent(
|
|
* type="object",
|
|
*
|
|
* @OA\Property(property="user_id", type="integer", example=10, description="사용자 ID (미지정시 본인)"),
|
|
* @OA\Property(property="check_out", type="string", example="18:00:00", description="퇴근 시간 (미지정시 현재 시간)"),
|
|
* @OA\Property(property="gps_data", type="object", description="GPS 데이터",
|
|
* @OA\Property(property="latitude", type="number", format="float", example=37.5665),
|
|
* @OA\Property(property="longitude", type="number", format="float", example=126.9780)
|
|
* )
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="퇴근 기록 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Attendance"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @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 checkOut() {}
|
|
|
|
/**
|
|
* @OA\Get(
|
|
* path="/api/v1/attendances/{id}",
|
|
* tags={"Attendances"},
|
|
* summary="근태 상세 조회",
|
|
* description="ID 기준 근태 상세 정보를 조회합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\Parameter(name="id", in="path", required=true, description="근태 ID", @OA\Schema(type="integer", example=1)),
|
|
*
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="조회 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Attendance"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @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\Post(
|
|
* path="/api/v1/attendances",
|
|
* tags={"Attendances"},
|
|
* summary="근태 등록 (Upsert)",
|
|
* description="근태 기록을 등록합니다. 같은 날 같은 사용자의 기록이 있으면 업데이트, 없으면 새로 생성합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\RequestBody(
|
|
* required=true,
|
|
*
|
|
* @OA\JsonContent(ref="#/components/schemas/AttendanceCreateRequest")
|
|
* ),
|
|
*
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="등록/수정 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Attendance"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @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\Patch(
|
|
* path="/api/v1/attendances/{id}",
|
|
* tags={"Attendances"},
|
|
* 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/AttendanceUpdateRequest")
|
|
* ),
|
|
*
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="수정 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Attendance"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @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/attendances/{id}",
|
|
* tags={"Attendances"},
|
|
* 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(
|
|
*
|
|
* @OA\Property(property="success", type="boolean", example=true),
|
|
* @OA\Property(property="message", type="string", example="삭제 완료"),
|
|
* @OA\Property(property="data", type="boolean", example=true)
|
|
* )
|
|
* ),
|
|
*
|
|
* @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\Post(
|
|
* path="/api/v1/attendances/bulk-delete",
|
|
* tags={"Attendances"},
|
|
* summary="근태 일괄 삭제",
|
|
* description="여러 근태 기록을 일괄 삭제합니다.",
|
|
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
|
*
|
|
* @OA\RequestBody(
|
|
* required=true,
|
|
*
|
|
* @OA\JsonContent(
|
|
* type="object",
|
|
* required={"ids"},
|
|
*
|
|
* @OA\Property(property="ids", type="array", @OA\Items(type="integer"), example={1, 2, 3}, description="삭제할 근태 ID 목록")
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(
|
|
* response=200,
|
|
* description="일괄 삭제 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
*
|
|
* @OA\Property(property="success", type="boolean", example=true),
|
|
* @OA\Property(property="message", type="string", example="일괄 삭제 완료"),
|
|
* @OA\Property(property="data", type="object",
|
|
* @OA\Property(property="deleted_count", type="integer", example=3)
|
|
* )
|
|
* )
|
|
* ),
|
|
*
|
|
* @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 bulkDelete() {}
|
|
}
|