Files
sam-api/app/Swagger/v1/EmployeeApi.php
hskwon f1f4c52c31 feat: 근태관리/직원관리 API 구현
- AttendanceController, AttendanceService 추가
- EmployeeController, EmployeeService 추가
- Attendance 모델 및 마이그레이션 추가
- TenantUserProfile에 employee_status 컬럼 추가
- DepartmentService 트리 조회 기능 개선
- Swagger 문서 추가 (AttendanceApi, EmployeeApi)
- API 라우트 등록
2025-12-09 20:27:44 +09:00

434 lines
24 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Employees", description="사원 관리 (HR)")
*
* @OA\Schema(
* schema="Employee",
* 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="name", type="string", example="홍길동", description="이름"),
* @OA\Property(property="email", type="string", example="hong@company.com", description="이메일"),
* @OA\Property(property="phone", type="string", example="010-1234-5678", description="연락처"),
* @OA\Property(property="department_id", type="integer", example=5, nullable=true, description="부서 ID"),
* @OA\Property(property="department_name", type="string", example="개발팀", nullable=true, description="부서명"),
* @OA\Property(property="position_key", type="string", example="manager", nullable=true, description="직급 키"),
* @OA\Property(property="job_title_key", type="string", example="developer", nullable=true, description="직책 키"),
* @OA\Property(property="work_location_key", type="string", example="seoul_hq", nullable=true, description="근무지 키"),
* @OA\Property(property="employment_type_key", type="string", example="fulltime", nullable=true, description="고용형태 키"),
* @OA\Property(property="employee_status", type="string", enum={"active", "leave", "resigned"}, example="active", description="고용상태"),
* @OA\Property(property="manager_user_id", type="integer", example=5, nullable=true, description="상급자 ID"),
* @OA\Property(property="display_name", type="string", example="홍길동 매니저", nullable=true, description="표시명"),
* @OA\Property(property="profile_photo_path", type="string", example="/photos/hong.jpg", nullable=true, description="프로필 사진 경로"),
* @OA\Property(property="employee_code", type="string", example="EMP-001", nullable=true, description="사원번호"),
* @OA\Property(property="hire_date", type="string", format="date", example="2020-03-15", nullable=true, description="입사일"),
* @OA\Property(property="rank", type="string", example="G3", nullable=true, description="호봉"),
* @OA\Property(property="work_type", type="string", enum={"regular", "daily", "temporary", "external"}, example="regular", nullable=true, description="근무형태"),
* @OA\Property(property="has_account", type="boolean", example=true, description="시스템 계정 보유 여부"),
* @OA\Property(property="is_active", type="boolean", example=true, description="활성 상태"),
* @OA\Property(property="created_at", type="string", format="date-time", example="2020-03-15T09:00:00Z"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2024-01-10T14:30:00Z")
* )
*
* @OA\Schema(
* schema="EmployeeCreateRequest",
* type="object",
* required={"name", "email"},
* description="사원 등록 요청",
*
* @OA\Property(property="user_id", type="string", example="hong001", description="사용자 ID (로그인 ID)"),
* @OA\Property(property="name", type="string", example="홍길동", description="이름"),
* @OA\Property(property="email", type="string", format="email", example="hong@company.com", description="이메일"),
* @OA\Property(property="phone", type="string", example="010-1234-5678", description="연락처"),
* @OA\Property(property="password", type="string", example="Password123!", description="초기 비밀번호 (미입력시 계정 미생성)"),
* @OA\Property(property="is_active", type="boolean", example=true, description="활성 상태"),
* @OA\Property(property="department_id", type="integer", example=5, description="부서 ID"),
* @OA\Property(property="position_key", type="string", example="manager", description="직급 키"),
* @OA\Property(property="job_title_key", type="string", example="developer", description="직책 키"),
* @OA\Property(property="work_location_key", type="string", example="seoul_hq", description="근무지 키"),
* @OA\Property(property="employment_type_key", type="string", example="fulltime", description="고용형태 키"),
* @OA\Property(property="employee_status", type="string", enum={"active", "leave", "resigned"}, example="active", description="고용상태"),
* @OA\Property(property="manager_user_id", type="integer", example=5, description="상급자 ID"),
* @OA\Property(property="display_name", type="string", example="홍길동 매니저", description="표시명"),
* @OA\Property(property="employee_code", type="string", example="EMP-001", description="사원번호"),
* @OA\Property(property="resident_number", type="string", example="encrypted_value", description="주민번호 (암호화)"),
* @OA\Property(property="gender", type="string", enum={"male", "female"}, example="male", description="성별"),
* @OA\Property(
* property="address",
* type="object",
* @OA\Property(property="zipCode", type="string", example="06234"),
* @OA\Property(property="address1", type="string", example="서울시 강남구 테헤란로 123"),
* @OA\Property(property="address2", type="string", example="10층 1001호")
* ),
* @OA\Property(property="salary", type="number", format="float", example=50000000, description="연봉"),
* @OA\Property(property="hire_date", type="string", format="date", example="2020-03-15", description="입사일"),
* @OA\Property(property="rank", type="string", example="G3", description="호봉"),
* @OA\Property(
* property="bank_account",
* type="object",
* @OA\Property(property="bankName", type="string", example="국민은행"),
* @OA\Property(property="accountNumber", type="string", example="123-456-789012"),
* @OA\Property(property="accountHolder", type="string", example="홍길동")
* ),
* @OA\Property(property="work_type", type="string", enum={"regular", "daily", "temporary", "external"}, example="regular", description="근무형태"),
* @OA\Property(
* property="contract_info",
* type="object",
* @OA\Property(property="start_date", type="string", format="date", example="2024-01-01"),
* @OA\Property(property="end_date", type="string", format="date", example="2024-12-31"),
* @OA\Property(property="external_company", type="string", example="파트너사")
* )
* )
*
* @OA\Schema(
* schema="EmployeeUpdateRequest",
* type="object",
* description="사원 수정 요청",
*
* @OA\Property(property="name", type="string", example="홍길동"),
* @OA\Property(property="email", type="string", format="email", example="hong@company.com"),
* @OA\Property(property="phone", type="string", example="010-1234-5678"),
* @OA\Property(property="is_active", type="boolean", example=true),
* @OA\Property(property="department_id", type="integer", example=5),
* @OA\Property(property="position_key", type="string", example="manager"),
* @OA\Property(property="job_title_key", type="string", example="developer"),
* @OA\Property(property="work_location_key", type="string", example="seoul_hq"),
* @OA\Property(property="employment_type_key", type="string", example="fulltime"),
* @OA\Property(property="employee_status", type="string", enum={"active", "leave", "resigned"}, example="active"),
* @OA\Property(property="manager_user_id", type="integer", example=5),
* @OA\Property(property="display_name", type="string", example="홍길동 매니저"),
* @OA\Property(property="employee_code", type="string", example="EMP-001"),
* @OA\Property(property="hire_date", type="string", format="date", example="2020-03-15"),
* @OA\Property(property="rank", type="string", example="G3"),
* @OA\Property(property="work_type", type="string", enum={"regular", "daily", "temporary", "external"}, example="regular")
* )
*
* @OA\Schema(
* schema="EmployeeStats",
* type="object",
* description="사원 통계",
*
* @OA\Property(property="total", type="integer", example=150, description="전체 사원 수"),
* @OA\Property(property="active", type="integer", example=140, description="재직 중"),
* @OA\Property(property="leave", type="integer", example=5, description="휴직 중"),
* @OA\Property(property="resigned", type="integer", example=5, description="퇴직"),
* @OA\Property(property="has_account", type="integer", example=130, description="시스템 계정 보유"),
* @OA\Property(property="no_account", type="integer", example=20, description="시스템 계정 미보유")
* )
*/
class EmployeeApi
{
/**
* @OA\Get(
* path="/api/v1/employees",
* tags={"Employees"},
* summary="사원 목록 조회",
* description="필터/검색/페이지네이션으로 사원 목록을 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="q", in="query", description="이름/이메일/사원번호 검색어", @OA\Schema(type="string")),
* @OA\Parameter(name="status", in="query", description="고용상태 필터", @OA\Schema(type="string", enum={"active", "leave", "resigned"})),
* @OA\Parameter(name="department_id", in="query", description="부서 ID 필터", @OA\Schema(type="integer", example=5)),
* @OA\Parameter(name="has_account", in="query", description="시스템 계정 보유 여부", @OA\Schema(type="string", enum={"0", "1", "true", "false"})),
* @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"created_at", "name", "employee_status", "department_id"}, 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/Employee")),
* @OA\Property(property="first_page_url", type="string", example="/api/v1/employees?page=1"),
* @OA\Property(property="from", type="integer", example=1),
* @OA\Property(property="last_page", type="integer", example=8),
* @OA\Property(property="last_page_url", type="string", example="/api/v1/employees?page=8"),
* @OA\Property(property="next_page_url", type="string", nullable=true, example="/api/v1/employees?page=2"),
* @OA\Property(property="path", type="string", example="/api/v1/employees"),
* @OA\Property(property="per_page", type="integer", example=20),
* @OA\Property(property="prev_page_url", type="string", nullable=true, example=null),
* @OA\Property(property="to", type="integer", example=20),
* @OA\Property(property="total", type="integer", example=150)
* )
* )
* }
* )
* ),
*
* @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=403, 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/employees/stats",
* tags={"Employees"},
* 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", ref="#/components/schemas/EmployeeStats"))
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function stats() {}
/**
* @OA\Get(
* path="/api/v1/employees/{id}",
* tags={"Employees"},
* 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/Employee"))
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, 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/employees",
* tags={"Employees"},
* summary="사원 등록",
* description="새 사원을 등록합니다. password를 입력하면 시스템 계정도 함께 생성됩니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/EmployeeCreateRequest")
* ),
*
* @OA\Response(
* response=201,
* description="등록 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Employee"))
* }
* )
* ),
*
* @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=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=409, 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/employees/{id}",
* tags={"Employees"},
* 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/EmployeeUpdateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="수정 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Employee"))
* }
* )
* ),
*
* @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=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="사원을 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=409, 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/employees/{id}",
* tags={"Employees"},
* summary="사원 삭제 (퇴직 처리)",
* description="사원을 퇴직 처리합니다. employee_status가 'resigned'로 변경되고 소프트 삭제됩니다.",
* 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=403, 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/employees/bulk-delete",
* tags={"Employees"},
* 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=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function bulkDelete() {}
/**
* @OA\Post(
* path="/api/v1/employees/{id}/create-account",
* tags={"Employees"},
* 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(
* type="object",
* required={"password"},
*
* @OA\Property(property="password", type="string", minLength=8, example="Password123!", description="계정 비밀번호")
* )
* ),
*
* @OA\Response(
* response=200,
* description="계정 생성 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Employee"))
* }
* )
* ),
*
* @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=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="사원을 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=409, description="이미 계정이 존재함", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function createAccount() {}
}