diff --git a/Doc/IM_App_架构设计.html b/Doc/IM_App_架构设计.html index 8cb14bf..2793eac 100644 --- a/Doc/IM_App_架构设计.html +++ b/Doc/IM_App_架构设计.html @@ -895,7 +895,7 @@ flowchart TD │ │ │ └── networks_sdk_method_channel_datasource.dart # 统一执行入口 │ │ ├── dto/ │ │ │ ├── api_requestable.dart # 请求基类 + fromJson 注册表 -│ │ │ └── api_response_wrapper.dart # { code, message/msg, data } 信封解析 +│ │ │ └── api_response_wrapper.dart # { code, message/msg, data } 响应包装解析 │ │ └── repositories/ │ │ ├── networks_sdk_repository_impl.dart │ │ └── networks_messaging_repository_impl.dart @@ -2299,8 +2299,8 @@ class LoginData { User toEntity() => User(id: userId, email: email); // DTO → Domain Entity } -// ── Request ── -// @ApiRequest 自动生成 path / method / requestType / includeToken / fromJson 注册 +// ── Request(零样板:只需 @ApiRequest,无需 @JsonSerializable / fromJson / toJson)── +// @ApiRequest 自动生成 path / method / requestType / includeToken / toJson / fromJson 注册 @ApiRequest( path: ApiPaths.authLogin, // 路径统一在 core/foundation/api_paths.dart 管理 @@ -2308,15 +2308,12 @@ class LoginData { responseType: LoginData, requestType: ApiRequestType.login, ) -@JsonSerializable() class LoginRequest extends ApiRequestable<LoginData> with _$LoginRequestApi { final String email; final String password; LoginRequest({required this.email, required this.password}); - - @override - Map<String, dynamic> toJson() => _$LoginRequestToJson(this); + // 完毕!toJson 由 mixin 从类字段自动生成,fromJson 不需要(Request 永远手动构造) } @@ -2353,17 +2350,17 @@ final user = loginData?.toEntity(); // DTO → Domain Entity 中 -@ApiRequest + @JsonSerializable -字段 + 构造函数 + @ApiRequest + @JsonSerializable -path / method / requestType / includeToken / toJson / fromJson / fromJson 注册 - +@ApiRequest(当前方案) +字段 + 构造函数 + @ApiRequest +path / method / requestType / includeToken / toJson / fromJson 注册 +极低

核心优势