You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
2 weeks ago
|
/// 登录请求模型
|
||
|
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'] ?? '',
|
||
|
);
|
||
|
}
|
||
|
}
|