| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import 'package:json_annotation/json_annotation.dart';
- part 'auth_model.g.dart';
- /// 机构信息模型
- @JsonSerializable()
- class InstitutionInfo {
- final int id;
- final String uuid;
- final String name;
- InstitutionInfo({
- required this.id,
- required this.uuid,
- required this.name,
- });
- /// 从 JSON 创建 InstitutionInfo
- factory InstitutionInfo.fromJson(Map<String, dynamic> json) =>
- _$InstitutionInfoFromJson(json);
- /// 转换为 JSON
- Map<String, dynamic> toJson() => _$InstitutionInfoToJson(this);
- }
- /// 用户信息模型
- @JsonSerializable()
- class UserInfo {
- final int id;
- final String uuid;
- @JsonKey(name: 'institution_uuid')
- final String institutionUuid;
- final String name;
- final int gender;
- final String? avatar;
- @JsonKey(name: 'base_uuid')
- final String baseUuid;
- final String username;
- final String mobile;
- UserInfo({
- required this.id,
- required this.uuid,
- required this.institutionUuid,
- required this.name,
- required this.gender,
- this.avatar,
- required this.baseUuid,
- required this.username,
- required this.mobile,
- });
- /// 从 JSON 创建 UserInfo
- factory UserInfo.fromJson(Map<String, dynamic> json) =>
- _$UserInfoFromJson(json);
- /// 转换为 JSON
- Map<String, dynamic> toJson() => _$UserInfoToJson(this);
- }
- /// 认证响应模型
- @JsonSerializable()
- class AuthModel {
- @JsonKey(name: 'access_token')
- final String accessToken;
- @JsonKey(name: 'refresh_token')
- final String? refreshToken;
- @JsonKey(name: 'institution_info')
- final List<InstitutionInfo> institutionInfo;
- @JsonKey(name: 'user_info')
- final UserInfo userInfo;
- AuthModel({
- required this.accessToken,
- this.refreshToken,
- required this.institutionInfo,
- required this.userInfo,
- });
- /// 从 JSON 创建 AuthModel
- factory AuthModel.fromJson(Map<String, dynamic> json) =>
- _$AuthModelFromJson(json);
- /// 转换为 JSON
- Map<String, dynamic> toJson() => _$AuthModelToJson(this);
- }
|