결재 템플릿 단계 적용 구현
- ApprovalTemplate 엔티티·DTO·원격 리포지토리 추가 - ApprovalController에 템플릿 로딩/적용 상태와 assignSteps 호출 연동 - ApprovalPage 단계 탭에 템플릿 선택 UI 및 적용 확인 다이얼로그 구현 - 템플릿 적용 단위 테스트와 IMPLEMENTATION_TASKS 현황 갱신
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
|
||||
import '../../domain/entities/group_permission.dart';
|
||||
|
||||
class GroupPermissionDto {
|
||||
GroupPermissionDto({
|
||||
this.id,
|
||||
required this.group,
|
||||
required this.menu,
|
||||
this.canCreate = false,
|
||||
this.canRead = true,
|
||||
this.canUpdate = false,
|
||||
this.canDelete = false,
|
||||
this.isActive = true,
|
||||
this.isDeleted = false,
|
||||
this.note,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final GroupPermissionGroupDto group;
|
||||
final GroupPermissionMenuDto menu;
|
||||
final bool canCreate;
|
||||
final bool canRead;
|
||||
final bool canUpdate;
|
||||
final bool canDelete;
|
||||
final bool isActive;
|
||||
final bool isDeleted;
|
||||
final String? note;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
factory GroupPermissionDto.fromJson(Map<String, dynamic> json) {
|
||||
return GroupPermissionDto(
|
||||
id: json['id'] as int?,
|
||||
group: GroupPermissionGroupDto.fromJson(
|
||||
(json['group'] as Map<String, dynamic>? ?? const {}),
|
||||
),
|
||||
menu: GroupPermissionMenuDto.fromJson(
|
||||
(json['menu'] as Map<String, dynamic>? ?? const {}),
|
||||
),
|
||||
canCreate: (json['can_create'] as bool?) ?? false,
|
||||
canRead: (json['can_read'] as bool?) ?? true,
|
||||
canUpdate: (json['can_update'] as bool?) ?? false,
|
||||
canDelete: (json['can_delete'] as bool?) ?? false,
|
||||
isActive: (json['is_active'] as bool?) ?? true,
|
||||
isDeleted: (json['is_deleted'] as bool?) ?? false,
|
||||
note: json['note'] as String?,
|
||||
createdAt: _parseDate(json['created_at']),
|
||||
updatedAt: _parseDate(json['updated_at']),
|
||||
);
|
||||
}
|
||||
|
||||
GroupPermission toEntity() => GroupPermission(
|
||||
id: id,
|
||||
group: group.toEntity(),
|
||||
menu: menu.toEntity(),
|
||||
canCreate: canCreate,
|
||||
canRead: canRead,
|
||||
canUpdate: canUpdate,
|
||||
canDelete: canDelete,
|
||||
isActive: isActive,
|
||||
isDeleted: isDeleted,
|
||||
note: note,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
);
|
||||
|
||||
static PaginatedResult<GroupPermission> parsePaginated(
|
||||
Map<String, dynamic>? json,
|
||||
) {
|
||||
final items = (json?['items'] as List<dynamic>? ?? [])
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(GroupPermissionDto.fromJson)
|
||||
.map((dto) => dto.toEntity())
|
||||
.toList();
|
||||
return PaginatedResult<GroupPermission>(
|
||||
items: items,
|
||||
page: json?['page'] as int? ?? 1,
|
||||
pageSize: json?['page_size'] as int? ?? items.length,
|
||||
total: json?['total'] as int? ?? items.length,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class GroupPermissionGroupDto {
|
||||
GroupPermissionGroupDto({required this.id, required this.groupName});
|
||||
|
||||
final int id;
|
||||
final String groupName;
|
||||
|
||||
factory GroupPermissionGroupDto.fromJson(Map<String, dynamic> json) {
|
||||
return GroupPermissionGroupDto(
|
||||
id: json['id'] as int? ?? json['group_id'] as int,
|
||||
groupName:
|
||||
json['group_name'] as String? ?? json['name'] as String? ?? '-',
|
||||
);
|
||||
}
|
||||
|
||||
GroupPermissionGroup toEntity() =>
|
||||
GroupPermissionGroup(id: id, groupName: groupName);
|
||||
}
|
||||
|
||||
class GroupPermissionMenuDto {
|
||||
GroupPermissionMenuDto({required this.id, required this.menuName});
|
||||
|
||||
final int id;
|
||||
final String menuName;
|
||||
|
||||
factory GroupPermissionMenuDto.fromJson(Map<String, dynamic> json) {
|
||||
return GroupPermissionMenuDto(
|
||||
id: json['id'] as int? ?? json['menu_id'] as int,
|
||||
menuName: json['menu_name'] as String? ?? json['name'] as String? ?? '-',
|
||||
);
|
||||
}
|
||||
|
||||
GroupPermissionMenu toEntity() =>
|
||||
GroupPermissionMenu(id: id, menuName: menuName);
|
||||
}
|
||||
|
||||
DateTime? _parseDate(Object? value) {
|
||||
if (value == null) return null;
|
||||
if (value is DateTime) return value;
|
||||
if (value is String) return DateTime.tryParse(value);
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user