결재 템플릿 CRUD 화면과 컨트롤러 정식화
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
|
||||
import '../entities/approval_template.dart';
|
||||
|
||||
abstract class ApprovalTemplateRepository {
|
||||
Future<List<ApprovalTemplate>> list({bool activeOnly = true});
|
||||
Future<PaginatedResult<ApprovalTemplate>> list({
|
||||
int page = 1,
|
||||
int pageSize = 20,
|
||||
String? query,
|
||||
bool? isActive,
|
||||
});
|
||||
|
||||
Future<ApprovalTemplate> fetchDetail(int id, {bool includeSteps = true});
|
||||
|
||||
Future<ApprovalTemplate> create(
|
||||
ApprovalTemplateInput input, {
|
||||
List<ApprovalTemplateStepInput> steps = const [],
|
||||
});
|
||||
|
||||
Future<ApprovalTemplate> update(
|
||||
int id,
|
||||
ApprovalTemplateInput input, {
|
||||
List<ApprovalTemplateStepInput>? steps,
|
||||
});
|
||||
|
||||
Future<void> delete(int id);
|
||||
|
||||
Future<ApprovalTemplate> restore(int id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user