更新测试案例
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
/// 全局共享实体,被 auth / chat / contact 等多个 Feature 共用。
|
||||
/// 纯 Dart 类,零 Flutter / 零网络 / 零 DB 依赖。
|
||||
///
|
||||
/// ## 数据流位置
|
||||
///
|
||||
/// ## 数据流
|
||||
/// ```
|
||||
/// 服务端 JSON
|
||||
/// → LoginData(Response DTO,data/remote/login_request.dart)
|
||||
/// → LoginData.toEntity()
|
||||
/// → ★ User ★ ← 你在这里
|
||||
/// → User.fromJson() ← 直接从网络创建
|
||||
/// → ★ User ★ ← 你在这里
|
||||
/// → userRepo.saveUser(user) ← 可选持久化
|
||||
/// → ViewModel.state
|
||||
/// → View 渲染
|
||||
/// ```
|
||||
@@ -20,16 +19,32 @@ class User {
|
||||
final String? profilePic;
|
||||
final String? profilePicGaussian;
|
||||
final String? nickname;
|
||||
final String? depositName;
|
||||
final int? hasSetDepositName;
|
||||
final String? contact;
|
||||
final String? countryCode;
|
||||
final String? username;
|
||||
final int? role;
|
||||
final int? relationship;
|
||||
final int? friendStatus;
|
||||
final String? bio;
|
||||
final String? userAlias;
|
||||
final int? requestAt;
|
||||
final int? deletedAt;
|
||||
final String? email;
|
||||
final String? recoveryEmail;
|
||||
final String? username;
|
||||
final String? bio;
|
||||
final int? relationship;
|
||||
final String? userAlias;
|
||||
final int? channelId;
|
||||
final int? channelGroupId;
|
||||
final String? remark;
|
||||
final String? source;
|
||||
final int? addIndex;
|
||||
final int? incomingSoundId;
|
||||
final int? outgoingSoundId;
|
||||
final int? notificationSoundId;
|
||||
final int? sendMessageSoundId;
|
||||
final int? groupNotificationSoundId;
|
||||
final String? groupTags;
|
||||
final String? friendTags;
|
||||
final String? publicKey;
|
||||
final int? configBits;
|
||||
final String? hint;
|
||||
|
||||
const User({
|
||||
@@ -39,19 +54,73 @@ class User {
|
||||
this.profilePic,
|
||||
this.profilePicGaussian,
|
||||
this.nickname,
|
||||
this.depositName,
|
||||
this.hasSetDepositName,
|
||||
this.contact,
|
||||
this.countryCode,
|
||||
this.username,
|
||||
this.role,
|
||||
this.relationship,
|
||||
this.friendStatus,
|
||||
this.bio,
|
||||
this.userAlias,
|
||||
this.requestAt,
|
||||
this.deletedAt,
|
||||
this.email,
|
||||
this.recoveryEmail,
|
||||
this.username,
|
||||
this.bio,
|
||||
this.relationship,
|
||||
this.userAlias,
|
||||
this.channelId,
|
||||
this.channelGroupId,
|
||||
this.remark,
|
||||
this.source,
|
||||
this.addIndex,
|
||||
this.incomingSoundId,
|
||||
this.outgoingSoundId,
|
||||
this.notificationSoundId,
|
||||
this.sendMessageSoundId,
|
||||
this.groupNotificationSoundId,
|
||||
this.groupTags,
|
||||
this.friendTags,
|
||||
this.publicKey,
|
||||
this.configBits,
|
||||
this.hint,
|
||||
});
|
||||
|
||||
/// 直接从网络 JSON 创建 Domain 实体
|
||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||
uid: json['uid'] as int,
|
||||
uuid: json['uuid'],
|
||||
lastOnline: json['last_online'],
|
||||
profilePic: json['profile_pic'],
|
||||
profilePicGaussian: json['profile_pic_gaussian'],
|
||||
nickname: json['nickname'],
|
||||
depositName: json['deposit_name'],
|
||||
hasSetDepositName: json['has_set_deposit_name'],
|
||||
contact: json['contact'],
|
||||
countryCode: json['country_code'],
|
||||
username: json['username'],
|
||||
role: json['role'],
|
||||
relationship: json['relationship'],
|
||||
friendStatus: json['friend_status'],
|
||||
bio: json['bio'],
|
||||
userAlias: json['user_alias'],
|
||||
requestAt: json['request_at'],
|
||||
deletedAt: json['deleted_at'],
|
||||
email: json['email'],
|
||||
recoveryEmail: json['recovery_email'],
|
||||
remark: json['remark'],
|
||||
source: json['source'],
|
||||
addIndex: json['__add_index'],
|
||||
incomingSoundId: json['incoming_sound_id'],
|
||||
outgoingSoundId: json['outgoing_sound_id'],
|
||||
notificationSoundId: json['notification_sound_id'],
|
||||
sendMessageSoundId: json['send_message_sound_id'],
|
||||
groupNotificationSoundId: json['group_notification_sound_id'],
|
||||
groupTags: json['group_tags'],
|
||||
friendTags: json['friend_tags'],
|
||||
publicKey: json['public_key'],
|
||||
configBits: json['config_bits'],
|
||||
hint: json['hint'],
|
||||
);
|
||||
|
||||
/// 仅更新部分字段
|
||||
User copyWith({
|
||||
int? uid,
|
||||
String? uuid,
|
||||
@@ -59,16 +128,32 @@ class User {
|
||||
String? profilePic,
|
||||
String? profilePicGaussian,
|
||||
String? nickname,
|
||||
String? depositName,
|
||||
int? hasSetDepositName,
|
||||
String? contact,
|
||||
String? countryCode,
|
||||
String? username,
|
||||
int? role,
|
||||
int? relationship,
|
||||
int? friendStatus,
|
||||
String? bio,
|
||||
String? userAlias,
|
||||
int? requestAt,
|
||||
int? deletedAt,
|
||||
String? email,
|
||||
String? recoveryEmail,
|
||||
String? username,
|
||||
String? bio,
|
||||
int? relationship,
|
||||
String? userAlias,
|
||||
int? channelId,
|
||||
int? channelGroupId,
|
||||
String? remark,
|
||||
String? source,
|
||||
int? addIndex,
|
||||
int? incomingSoundId,
|
||||
int? outgoingSoundId,
|
||||
int? notificationSoundId,
|
||||
int? sendMessageSoundId,
|
||||
int? groupNotificationSoundId,
|
||||
String? groupTags,
|
||||
String? friendTags,
|
||||
String? publicKey,
|
||||
int? configBits,
|
||||
String? hint,
|
||||
}) {
|
||||
return User(
|
||||
@@ -78,17 +163,34 @@ class User {
|
||||
profilePic: profilePic ?? this.profilePic,
|
||||
profilePicGaussian: profilePicGaussian ?? this.profilePicGaussian,
|
||||
nickname: nickname ?? this.nickname,
|
||||
depositName: depositName ?? this.depositName,
|
||||
hasSetDepositName: hasSetDepositName ?? this.hasSetDepositName,
|
||||
contact: contact ?? this.contact,
|
||||
countryCode: countryCode ?? this.countryCode,
|
||||
username: username ?? this.username,
|
||||
role: role ?? this.role,
|
||||
relationship: relationship ?? this.relationship,
|
||||
friendStatus: friendStatus ?? this.friendStatus,
|
||||
bio: bio ?? this.bio,
|
||||
userAlias: userAlias ?? this.userAlias,
|
||||
requestAt: requestAt ?? this.requestAt,
|
||||
deletedAt: deletedAt ?? this.deletedAt,
|
||||
email: email ?? this.email,
|
||||
recoveryEmail: recoveryEmail ?? this.recoveryEmail,
|
||||
username: username ?? this.username,
|
||||
bio: bio ?? this.bio,
|
||||
relationship: relationship ?? this.relationship,
|
||||
userAlias: userAlias ?? this.userAlias,
|
||||
channelId: channelId ?? this.channelId,
|
||||
channelGroupId: channelGroupId ?? this.channelGroupId,
|
||||
remark: remark ?? this.remark,
|
||||
source: source ?? this.source,
|
||||
addIndex: addIndex ?? this.addIndex,
|
||||
incomingSoundId: incomingSoundId ?? this.incomingSoundId,
|
||||
outgoingSoundId: outgoingSoundId ?? this.outgoingSoundId,
|
||||
notificationSoundId: notificationSoundId ?? this.notificationSoundId,
|
||||
sendMessageSoundId: sendMessageSoundId ?? this.sendMessageSoundId,
|
||||
groupNotificationSoundId:
|
||||
groupNotificationSoundId ?? this.groupNotificationSoundId,
|
||||
groupTags: groupTags ?? this.groupTags,
|
||||
friendTags: friendTags ?? this.friendTags,
|
||||
publicKey: publicKey ?? this.publicKey,
|
||||
configBits: configBits ?? this.configBits,
|
||||
hint: hint ?? this.hint,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user