feat: G-1 작업지시 관리 API 구현
- 작업지시 테이블 마이그레이션 (work_orders, work_order_items, work_order_bending_details, work_order_issues)
- 작업지시 모델 4개 (WorkOrder, WorkOrderItem, WorkOrderBendingDetail, WorkOrderIssue)
- WorkOrderService 비즈니스 로직 구현
- WorkOrderController REST API 엔드포인트 11개
- FormRequest 검증 클래스 5개
- Swagger API 문서화 완료
API Endpoints:
- GET /work-orders (목록)
- GET /work-orders/stats (통계)
- POST /work-orders (등록)
- GET /work-orders/{id} (상세)
- PUT /work-orders/{id} (수정)
- DELETE /work-orders/{id} (삭제)
- PATCH /work-orders/{id}/status (상태변경)
- PATCH /work-orders/{id}/assign (담당자배정)
- PATCH /work-orders/{id}/bending/toggle (벤딩토글)
- POST /work-orders/{id}/issues (이슈등록)
- PATCH /work-orders/{id}/issues/{issueId}/resolve (이슈해결)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
161
app/Models/Production/WorkOrderIssue.php
Normal file
161
app/Models/Production/WorkOrderIssue.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Production;
|
||||
|
||||
use App\Models\Members\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 작업지시 이슈 모델
|
||||
*
|
||||
* 작업지시 진행 중 발생한 이슈를 기록하고 추적
|
||||
*/
|
||||
class WorkOrderIssue extends Model
|
||||
{
|
||||
protected $table = 'work_order_issues';
|
||||
|
||||
protected $fillable = [
|
||||
'work_order_id',
|
||||
'title',
|
||||
'description',
|
||||
'priority',
|
||||
'status',
|
||||
'reported_by',
|
||||
'resolved_by',
|
||||
'resolved_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'resolved_at' => 'datetime',
|
||||
];
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
// 상수
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 우선순위
|
||||
*/
|
||||
public const PRIORITY_HIGH = 'high';
|
||||
|
||||
public const PRIORITY_MEDIUM = 'medium';
|
||||
|
||||
public const PRIORITY_LOW = 'low';
|
||||
|
||||
public const PRIORITIES = [
|
||||
self::PRIORITY_HIGH,
|
||||
self::PRIORITY_MEDIUM,
|
||||
self::PRIORITY_LOW,
|
||||
];
|
||||
|
||||
/**
|
||||
* 상태
|
||||
*/
|
||||
public const STATUS_OPEN = 'open';
|
||||
|
||||
public const STATUS_IN_PROGRESS = 'in_progress';
|
||||
|
||||
public const STATUS_RESOLVED = 'resolved';
|
||||
|
||||
public const STATUSES = [
|
||||
self::STATUS_OPEN,
|
||||
self::STATUS_IN_PROGRESS,
|
||||
self::STATUS_RESOLVED,
|
||||
];
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
// 관계
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 작업지시
|
||||
*/
|
||||
public function workOrder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(WorkOrder::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 보고자
|
||||
*/
|
||||
public function reporter(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'reported_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 해결자
|
||||
*/
|
||||
public function resolver(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'resolved_by');
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
// 스코프
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 열린 이슈
|
||||
*/
|
||||
public function scopeOpen($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 미해결 이슈 (open + in_progress)
|
||||
*/
|
||||
public function scopeUnresolved($query)
|
||||
{
|
||||
return $query->whereIn('status', [self::STATUS_OPEN, self::STATUS_IN_PROGRESS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 해결된 이슈
|
||||
*/
|
||||
public function scopeResolved($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_RESOLVED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 우선순위별
|
||||
*/
|
||||
public function scopePriority($query, string $priority)
|
||||
{
|
||||
return $query->where('priority', $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* 높은 우선순위
|
||||
*/
|
||||
public function scopeHighPriority($query)
|
||||
{
|
||||
return $query->where('priority', self::PRIORITY_HIGH);
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
// 헬퍼 메서드
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 해결되었는지 확인
|
||||
*/
|
||||
public function isResolved(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_RESOLVED;
|
||||
}
|
||||
|
||||
/**
|
||||
* 이슈 해결 처리
|
||||
*/
|
||||
public function resolve(int $userId): void
|
||||
{
|
||||
$this->status = self::STATUS_RESOLVED;
|
||||
$this->resolved_by = $userId;
|
||||
$this->resolved_at = now();
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user