Merge remote-tracking branch 'origin/dev' into cody/netwrok_SDK
# Conflicts: # apps/im_app/lib/features/chat/presentation/chat_db_test_view_model.dart # apps/im_app/lib/features/login/presentation/login_view_model.dart 修复逻辑漏洞,性能优化
This commit is contained in:
@@ -28,31 +28,75 @@ part 'get_profile_request.g.dart';
|
||||
/// 用户资料响应 DTO(只需反序列化,禁止生成无用的 toJson)
|
||||
@JsonSerializable(createToJson: false)
|
||||
class ProfileData {
|
||||
@JsonKey(name: 'user_id')
|
||||
final String userId;
|
||||
final int uid;
|
||||
final String uuid;
|
||||
@JsonKey(name: 'last_online')
|
||||
final int lastOnline;
|
||||
@JsonKey(name: 'profile_pic')
|
||||
final String profilePic;
|
||||
@JsonKey(name: 'profile_pic_gaussian')
|
||||
final String profilePicGaussian;
|
||||
final String nickname;
|
||||
final String contact;
|
||||
@JsonKey(name: 'country_code')
|
||||
final String countryCode;
|
||||
final String email;
|
||||
final String? nickname;
|
||||
final String? avatar;
|
||||
@JsonKey(name: 'recovery_email')
|
||||
final String recoveryEmail;
|
||||
final String username;
|
||||
final String bio;
|
||||
final int relationship;
|
||||
@JsonKey(name: 'user_alias')
|
||||
final String? userAlias;
|
||||
@JsonKey(name: 'channel_id')
|
||||
final int channelId;
|
||||
@JsonKey(name: 'channel_group_id')
|
||||
final int channelGroupId;
|
||||
final String hint;
|
||||
|
||||
const ProfileData({
|
||||
required this.userId,
|
||||
required this.uid,
|
||||
required this.uuid,
|
||||
required this.lastOnline,
|
||||
required this.profilePic,
|
||||
required this.profilePicGaussian,
|
||||
required this.nickname,
|
||||
required this.contact,
|
||||
required this.countryCode,
|
||||
required this.email,
|
||||
this.nickname,
|
||||
this.avatar,
|
||||
required this.recoveryEmail,
|
||||
required this.username,
|
||||
required this.bio,
|
||||
required this.relationship,
|
||||
this.userAlias,
|
||||
required this.channelId,
|
||||
required this.channelGroupId,
|
||||
required this.hint,
|
||||
});
|
||||
|
||||
factory ProfileData.fromJson(Map<String, dynamic> json) =>
|
||||
_$ProfileDataFromJson(json);
|
||||
|
||||
/// DTO → Domain Entity
|
||||
User toEntity() {
|
||||
return User(
|
||||
id: userId,
|
||||
email: email,
|
||||
nickname: nickname,
|
||||
avatar: avatar,
|
||||
);
|
||||
}
|
||||
User toEntity() => User(
|
||||
uid: uid,
|
||||
uuid: uuid,
|
||||
lastOnline: lastOnline,
|
||||
profilePic: profilePic,
|
||||
profilePicGaussian: profilePicGaussian,
|
||||
nickname: nickname,
|
||||
contact: contact,
|
||||
countryCode: countryCode,
|
||||
email: email,
|
||||
recoveryEmail: recoveryEmail,
|
||||
username: username,
|
||||
bio: bio,
|
||||
relationship: relationship,
|
||||
userAlias: userAlias,
|
||||
channelId: channelId,
|
||||
channelGroupId: channelGroupId,
|
||||
hint: hint,
|
||||
);
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
@@ -61,7 +105,7 @@ class ProfileData {
|
||||
|
||||
/// 获取用户资料请求(GET,无参数)
|
||||
///
|
||||
/// GET 请求无 body,toJson() 返回空 map。
|
||||
/// GET 请求无 body,mixin 自动生成 toJson() → 空 map。
|
||||
/// 如需 query 参数(如分页),添加字段即可,
|
||||
/// toJson() 会自动将字段序列化为 URL query string。
|
||||
@ApiRequest(
|
||||
@@ -69,14 +113,7 @@ class ProfileData {
|
||||
method: HttpMethod.get,
|
||||
responseType: ProfileData,
|
||||
)
|
||||
@JsonSerializable()
|
||||
class GetProfileRequest extends ApiRequestable<ProfileData>
|
||||
with _$GetProfileRequestApi {
|
||||
GetProfileRequest();
|
||||
|
||||
factory GetProfileRequest.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetProfileRequestFromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$GetProfileRequestToJson(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user