|
|
|
/// 登录请求模型
|
|
|
|
class LoginRequest {
|
|
|
|
final String username;
|
|
|
|
final String password;
|
|
|
|
final String wechatJsCode;
|
|
|
|
|
|
|
|
LoginRequest({
|
|
|
|
required this.username,
|
|
|
|
required this.password,
|
|
|
|
this.wechatJsCode = "",
|
|
|
|
});
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
return {
|
|
|
|
'username': username,
|
|
|
|
'password': password,
|
|
|
|
'wechatJsCode': wechatJsCode,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// 从 Map 创建 LoginRequest 对象
|
|
|
|
factory LoginRequest.fromJson(Map<String, dynamic> json) {
|
|
|
|
return LoginRequest(
|
|
|
|
username: json['username'] as String,
|
|
|
|
password: json['password'] as String,
|
|
|
|
wechatJsCode: json['wechatJsCode'] as String,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 登录响应模型
|
|
|
|
class LoginResponse {
|
|
|
|
final String token;
|
|
|
|
final String refreshToken;
|
|
|
|
final int expires;
|
|
|
|
final String name;
|
|
|
|
|
|
|
|
LoginResponse({
|
|
|
|
required this.token,
|
|
|
|
required this.refreshToken,
|
|
|
|
required this.expires,
|
|
|
|
required this.name,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory LoginResponse.fromJson(Map<String, dynamic> json) {
|
|
|
|
return LoginResponse(
|
|
|
|
token: json['token'] ?? '',
|
|
|
|
refreshToken: json['refresh_token'] ?? '',
|
|
|
|
expires: json['expires'] ?? '',
|
|
|
|
name: json['name'] ?? '',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Profile {
|
|
|
|
final String id;
|
|
|
|
final String name;
|
|
|
|
final String? email;
|
|
|
|
final String? signatureImage;
|
|
|
|
|
|
|
|
Profile({
|
|
|
|
required this.id,
|
|
|
|
required this.name,
|
|
|
|
this.email,
|
|
|
|
this.signatureImage,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory Profile.fromJson(Map<String, dynamic> json) {
|
|
|
|
return Profile(
|
|
|
|
id: json['id'] as String,
|
|
|
|
name: json['name'] as String,
|
|
|
|
email: json['email'] as String?,
|
|
|
|
signatureImage: json['signatureImage'] as String?,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|