feat: 근태관리/직원관리 API 구현
- AttendanceController, AttendanceService 추가 - EmployeeController, EmployeeService 추가 - Attendance 모델 및 마이그레이션 추가 - TenantUserProfile에 employee_status 컬럼 추가 - DepartmentService 트리 조회 기능 개선 - Swagger 문서 추가 (AttendanceApi, EmployeeApi) - API 라우트 등록
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('tenant_user_profiles', function (Blueprint $table) {
|
||||
// 인덱싱 필요한 필드만 컬럼으로 추가
|
||||
$table->enum('employee_status', ['active', 'leave', 'resigned'])
|
||||
->default('active')
|
||||
->after('employment_type_key')
|
||||
->comment('고용상태: active(재직), leave(휴직), resigned(퇴직)');
|
||||
|
||||
// 복합 인덱스 추가
|
||||
$table->index(['tenant_id', 'employee_status'], 'idx_tenant_employee_status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenant_user_profiles', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_tenant_employee_status');
|
||||
$table->dropColumn('employee_status');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('attendances', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// 인덱싱 필요 필드 (컬럼)
|
||||
$table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
|
||||
$table->unsignedBigInteger('user_id')->comment('사용자 ID');
|
||||
$table->date('base_date')->comment('기준일');
|
||||
$table->enum('status', [
|
||||
'onTime', // 정시 출근
|
||||
'late', // 지각
|
||||
'absent', // 결근
|
||||
'vacation', // 휴가
|
||||
'businessTrip', // 출장
|
||||
'fieldWork', // 외근
|
||||
'overtime', // 야근
|
||||
'remote', // 재택
|
||||
])->default('onTime')->comment('근태 상태');
|
||||
|
||||
// 확장 가능한 상세 정보 (JSON)
|
||||
// {
|
||||
// "check_in": "09:00:00",
|
||||
// "check_out": "18:00:00",
|
||||
// "break_time": "01:00",
|
||||
// "overtime_hours": "02:00",
|
||||
// "reason": { "type": "vacationRequest", "label": "연차", "document_id": "DOC-001" },
|
||||
// "gps_data": { "check_in_location": {...}, "check_out_location": {...}, "is_auto_checked": true },
|
||||
// "external_work": { "type": "dispatch", "location": "협력사 A", "company": "ABC Corp" },
|
||||
// "multiple_entries": [{ "in": "09:00", "out": "12:00" }, { "in": "13:00", "out": "18:00" }]
|
||||
// }
|
||||
$table->json('json_details')->nullable()->comment('출퇴근 상세 정보 (JSON)');
|
||||
|
||||
// 감사 로그
|
||||
$table->unsignedBigInteger('created_by')->nullable()->comment('생성자 ID');
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->comment('수정자 ID');
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자 ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
// 외래 키
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('cascade');
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
|
||||
// 유니크 제약: 같은 테넌트/사용자/날짜에 하나의 근태 레코드만 허용
|
||||
$table->unique(['tenant_id', 'user_id', 'base_date'], 'uq_attendance_user_date');
|
||||
|
||||
// 인덱스
|
||||
$table->index(['tenant_id', 'base_date', 'status'], 'idx_attendance_tenant_date_status');
|
||||
$table->index(['tenant_id', 'user_id'], 'idx_attendance_tenant_user');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('attendances');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('attendances', function (Blueprint $table) {
|
||||
$table->string('remarks', 500)->nullable()->after('json_details')->comment('비고');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('attendances', function (Blueprint $table) {
|
||||
$table->dropColumn('remarks');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user