baseproject
This commit is contained in:
57
base_project/lib/model/user/logged_in_user.dart
Normal file
57
base_project/lib/model/user/logged_in_user.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class LoggedUserModel {
|
||||
final String token;
|
||||
final String userId;
|
||||
final String fullname;
|
||||
final String? username;
|
||||
final String email;
|
||||
final String firstName;
|
||||
final List<String> roles;
|
||||
|
||||
LoggedUserModel({
|
||||
required this.token,
|
||||
required this.userId,
|
||||
required this.fullname,
|
||||
this.username,
|
||||
required this.email,
|
||||
required this.firstName,
|
||||
required this.roles,
|
||||
});
|
||||
|
||||
// Factory constructor to create a UserModel from a JSON map
|
||||
factory LoggedUserModel.fromJson(Map<String, dynamic> json) {
|
||||
return LoggedUserModel(
|
||||
token: json['token'] as String,
|
||||
userId: json['userId'] as String,
|
||||
fullname: json['fullname'] as String,
|
||||
username: json['username'] as String?,
|
||||
email: json['email'] as String,
|
||||
firstName: json['firstName'] as String,
|
||||
roles: List<String>.from(json['roles'] as List<dynamic>),
|
||||
);
|
||||
}
|
||||
|
||||
// Method to convert UserModel to JSON map
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'token': token,
|
||||
'userId': userId,
|
||||
'fullname': fullname,
|
||||
'username': username,
|
||||
'email': email,
|
||||
'firstName': firstName,
|
||||
'roles': roles,
|
||||
};
|
||||
}
|
||||
|
||||
// Method to convert UserModel to a JSON string
|
||||
String toJsonString() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
// Factory constructor to create a UserModel from a JSON string
|
||||
factory LoggedUserModel.fromJsonString(String jsonString) {
|
||||
return LoggedUserModel.fromJson(json.decode(jsonString));
|
||||
}
|
||||
}
|
||||
49
base_project/lib/model/user/user_model_admin.dart
Normal file
49
base_project/lib/model/user/user_model_admin.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
class UserModelAdmin {
|
||||
final String id;
|
||||
final String userId;
|
||||
final String userName;
|
||||
final String fullName;
|
||||
final String email;
|
||||
final bool isPunchIn;
|
||||
final bool isPunchOut;
|
||||
final bool onBreak;
|
||||
|
||||
UserModelAdmin({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.userName,
|
||||
required this.fullName,
|
||||
required this.email,
|
||||
required this.isPunchIn,
|
||||
required this.isPunchOut,
|
||||
required this.onBreak,
|
||||
});
|
||||
|
||||
// Factory method to create a User from JSON
|
||||
factory UserModelAdmin.fromJson(Map<String, dynamic> json) {
|
||||
return UserModelAdmin(
|
||||
id: json['id'].toString(),
|
||||
userId: json['userId'].toString(),
|
||||
userName: json['userName'] ?? '',
|
||||
fullName: json['fullName'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
isPunchIn: json['isPunchIn'] ?? false,
|
||||
isPunchOut: json['isPunchOut'] ?? false,
|
||||
onBreak: json['onBreak'] ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
// Convert User to JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'userId': userId,
|
||||
'userName': userName,
|
||||
'fullName': fullName,
|
||||
'email': email,
|
||||
'isPunchIn': isPunchIn,
|
||||
'isPunchOut': isPunchOut,
|
||||
'onBreak': onBreak,
|
||||
};
|
||||
}
|
||||
}
|
||||
26
base_project/lib/model/user/user_profile.dart
Normal file
26
base_project/lib/model/user/user_profile.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
class UserProfile {
|
||||
final dynamic userId;
|
||||
final String username;
|
||||
final String email;
|
||||
final dynamic mobNo;
|
||||
final String fullName;
|
||||
|
||||
UserProfile({
|
||||
required this.userId,
|
||||
required this.username,
|
||||
required this.email,
|
||||
required this.mobNo,
|
||||
required this.fullName,
|
||||
});
|
||||
|
||||
factory UserProfile.fromJson(Map<String, dynamic> json) {
|
||||
return UserProfile(
|
||||
userId: json['userId'],
|
||||
username: json['username'],
|
||||
email: json['email'],
|
||||
mobNo: json['mob_no'],
|
||||
fullName: json['fullName'],
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user