88 lines
2.0 KiB
Dart
88 lines
2.0 KiB
Dart
class LoginResponseDto {
|
|
final int statusCode;
|
|
final bool isSuccess;
|
|
final String message;
|
|
final LoginDataDto? data;
|
|
|
|
LoginResponseDto({
|
|
required this.statusCode,
|
|
required this.isSuccess,
|
|
required this.message,
|
|
this.data,
|
|
});
|
|
|
|
factory LoginResponseDto.fromJson(Map<String, dynamic> json) {
|
|
return LoginResponseDto(
|
|
statusCode: json['statusCode'] ?? 0,
|
|
isSuccess: json['isSuccess'] ?? false,
|
|
message: json['message'] ?? '',
|
|
data: json['data'] != null ? LoginDataDto.fromJson(json['data']) : null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'statusCode': statusCode,
|
|
'isSuccess': isSuccess,
|
|
'message': message,
|
|
'data': data?.toJson(),
|
|
};
|
|
}
|
|
}
|
|
|
|
class LoginDataDto {
|
|
final String? token;
|
|
final String? id;
|
|
final String? employeeId;
|
|
final String? username;
|
|
final String? fullName;
|
|
final String? role;
|
|
final String? email;
|
|
final String? phoneNumber;
|
|
final List<String>? permissions;
|
|
|
|
LoginDataDto({
|
|
this.token,
|
|
this.id,
|
|
this.employeeId,
|
|
this.username,
|
|
this.fullName,
|
|
this.role,
|
|
this.email,
|
|
this.phoneNumber,
|
|
this.permissions,
|
|
});
|
|
|
|
factory LoginDataDto.fromJson(Map<String, dynamic> json) {
|
|
return LoginDataDto(
|
|
token: json['token'],
|
|
id: json['id'],
|
|
employeeId:
|
|
json['employeeId'] ?? json['EmployeeId'] ?? json['employee_id'],
|
|
username: json['username'],
|
|
fullName: json['fullName'],
|
|
role: json['role'],
|
|
email: json['email'],
|
|
phoneNumber: json['phoneNumber'],
|
|
permissions:
|
|
json['permissions'] != null
|
|
? List<String>.from(json['permissions'])
|
|
: null,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'token': token,
|
|
'id': id,
|
|
'employeeId': employeeId,
|
|
'username': username,
|
|
'fullName': fullName,
|
|
'role': role,
|
|
'email': email,
|
|
'phoneNumber': phoneNumber,
|
|
'permissions': permissions,
|
|
};
|
|
}
|
|
}
|