결재 템플릿 CRUD 화면과 컨트롤러 정식화

This commit is contained in:
JiWoong Sul
2025-09-25 00:42:25 +09:00
parent c3010965ad
commit 1fbed565b7
10 changed files with 1450 additions and 53 deletions

View File

@@ -7,6 +7,7 @@ class ApprovalTemplate {
required this.code,
required this.name,
this.description,
this.note,
required this.isActive,
this.createdBy,
this.createdAt,
@@ -18,11 +19,37 @@ class ApprovalTemplate {
final String code;
final String name;
final String? description;
final String? note;
final bool isActive;
final ApprovalTemplateAuthor? createdBy;
final DateTime? createdAt;
final DateTime? updatedAt;
final List<ApprovalTemplateStep> steps;
ApprovalTemplate copyWith({
String? code,
String? name,
String? description,
String? note,
bool? isActive,
ApprovalTemplateAuthor? createdBy,
DateTime? createdAt,
DateTime? updatedAt,
List<ApprovalTemplateStep>? steps,
}) {
return ApprovalTemplate(
id: id,
code: code ?? this.code,
name: name ?? this.name,
description: description ?? this.description,
note: note ?? this.note,
isActive: isActive ?? this.isActive,
createdBy: createdBy ?? this.createdBy,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
steps: steps ?? this.steps,
);
}
}
class ApprovalTemplateAuthor {
@@ -62,3 +89,73 @@ class ApprovalTemplateApprover {
final String employeeNo;
final String name;
}
/// 결재 템플릿 생성/수정 입력 모델
class ApprovalTemplateInput {
ApprovalTemplateInput({
this.code,
required this.name,
this.description,
this.note,
this.isActive = true,
this.createdById,
});
final String? code;
final String name;
final String? description;
final String? note;
final bool isActive;
final int? createdById;
Map<String, dynamic> toCreatePayload() {
return {
if (code != null) 'template_code': code,
'template_name': name,
if (description != null && description!.trim().isNotEmpty)
'description': description,
if (note != null && note!.trim().isNotEmpty) 'note': note,
'is_active': isActive,
if (createdById != null) 'created_by_id': createdById,
};
}
Map<String, dynamic> toUpdatePayload(int id) {
final payload = <String, dynamic>{
'id': id,
'template_name': name,
'is_active': isActive,
};
if (description != null && description!.trim().isNotEmpty) {
payload['description'] = description;
}
if (note != null && note!.trim().isNotEmpty) {
payload['note'] = note;
}
return payload;
}
}
/// 템플릿 단계 입력 모델
class ApprovalTemplateStepInput {
ApprovalTemplateStepInput({
this.id,
required this.stepOrder,
required this.approverId,
this.note,
});
final int? id;
final int stepOrder;
final int approverId;
final String? note;
Map<String, dynamic> toJson({bool includeId = true}) {
return {
if (includeId && id != null) 'id': id,
'step_order': stepOrder,
'approver_id': approverId,
if (note != null && note!.trim().isNotEmpty) 'note': note,
};
}
}