passo_mobile_app/lib/model/profile/assigned_area.dart

75 lines
2.2 KiB
Dart

import 'package:unit2/model/rbac/rbac.dart';
import '../roles/pass_check/assign_role_area_type.dart';
class UserAssignedArea {
final int id;
final AssignedRole? assignedRole;
final AssignRoleAreaType? assignedRoleAreaType;
final dynamic assignedArea;
UserAssignedArea({
required this.id,
required this.assignedRole,
required this.assignedRoleAreaType,
required this.assignedArea,
});
factory UserAssignedArea.fromJson(Map<String, dynamic> json) => UserAssignedArea(
id: json["id"],
assignedRole: json['assigned_role'] == null? null: AssignedRole.fromJson(json["assigned_role"]),
assignedRoleAreaType: json['assigned_role_area_type'] == null? null : AssignRoleAreaType.fromJson(json["assigned_role_area_type"]),
assignedArea: json["assigned_area"],
);
Map<String, dynamic> toJson() => {
"id": id,
"assigned_role": assignedRole?.toJson(),
"assigned_role_area_type": assignedRoleAreaType?.toJson(),
"assigned_area": assignedArea,
};
}
class AssignedRole {
final int id;
final RBAC? role;
final CreatedBy? user;
final DateTime? createdAt;
final DateTime? updatedAt;
final CreatedBy? createdBy;
final CreatedBy? updatedBy;
AssignedRole({
required this.id,
required this.role,
required this.user,
required this.createdAt,
required this.updatedAt,
required this.createdBy,
required this.updatedBy,
});
factory AssignedRole.fromJson(Map<String, dynamic> json) => AssignedRole(
id: json["id"],
role: RBAC.fromJson(json["role"]),
user: CreatedBy.fromJson(json["user"]),
createdAt: DateTime.parse(json["created_at"]),
updatedAt: DateTime.parse(json["updated_at"]),
createdBy: CreatedBy.fromJson(json["created_by"]),
updatedBy: CreatedBy.fromJson(json["updated_by"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"role": role?.toJson(),
"user": user?.toJson(),
"created_at": createdAt?.toIso8601String(),
"updated_at": updatedAt?.toIso8601String(),
"created_by": createdBy?.toJson(),
"updated_by": updatedBy?.toJson(),
};
}