Skip to content

Refactor: 重构 MIoT API 模型结构并统一响应格式#63

Merged
sky130 merged 1 commit into
masterfrom
feat-update-architecture
May 4, 2026
Merged

Refactor: 重构 MIoT API 模型结构并统一响应格式#63
sky130 merged 1 commit into
masterfrom
feat-update-architecture

Conversation

@sky130
Copy link
Copy Markdown
Owner

@sky130 sky130 commented May 4, 2026

  • 模型重构与解耦:
    • 将复杂的嵌套类(如 MiotDevices.Result.DeviceMiotHomes.Result.Home)重构为独立的顶级类 MiotDeviceMiotHomeMiotScene 等。
    • 拆分原有的大型数据模型,新增 DeviceListHomeListSceneList 等专门用于列表响应的数据结构。
    • 将属性与动作的响应模型重命名为更具描述性的 PropertyResponseActionResponsePropertyResultActionResult
  • 引入泛型响应结构:
    • 引入统一的 MiotResponse<T> 泛型类,用于标准化处理所有包含 codemessageresult 的 API 返回数据。
  • 更新 API 接口与实现:
    • 更新 MiotHomeClientMiotUserClientMiotDeviceClient 及其 KMP 实现,以适配新的泛型响应模型。
    • 调整 HomeServiceUserServiceMiotService (Retrofit/Ktorfit) 的接口定义,使用 MiotResponse 包装返回类型。
  • 客户端逻辑适配:
    • 同步更新 MiotRepositoryImplMiotDeviceManagerImpl 中的数据解析逻辑。
    • 更新 UI 层(HomeActivitySceneFragment 及相关 DataBinding 布局文件)中的类引用路径。
  • 清理与优化:
    • 移除冗余的类型别名与不再使用的旧模型文件(如原 Action.ktDeviceAtt.kt 等)。
    • 优化了 MockMiotDeviceClient 以匹配新的响应结构。

- **模型重构与解耦**:
    - 将复杂的嵌套类(如 `MiotDevices.Result.Device`、`MiotHomes.Result.Home`)重构为独立的顶级类 `MiotDevice`、`MiotHome`、`MiotScene` 等。
    - 拆分原有的大型数据模型,新增 `DeviceList`、`HomeList`、`SceneList` 等专门用于列表响应的数据结构。
    - 将属性与动作的响应模型重命名为更具描述性的 `PropertyResponse`、`ActionResponse`、`PropertyResult` 和 `ActionResult`。
- **引入泛型响应结构**:
    - 引入统一的 `MiotResponse<T>` 泛型类,用于标准化处理所有包含 `code`、`message` 和 `result` 的 API 返回数据。
- **更新 API 接口与实现**:
    - 更新 `MiotHomeClient`、`MiotUserClient`、`MiotDeviceClient` 及其 KMP 实现,以适配新的泛型响应模型。
    - 调整 `HomeService`、`UserService` 和 `MiotService` (Retrofit/Ktorfit) 的接口定义,使用 `MiotResponse` 包装返回类型。
- **客户端逻辑适配**:
    - 同步更新 `MiotRepositoryImpl` 和 `MiotDeviceManagerImpl` 中的数据解析逻辑。
    - 更新 UI 层(`HomeActivity`、`SceneFragment` 及相关 DataBinding 布局文件)中的类引用路径。
- **清理与优化**:
    - 移除冗余的类型别名与不再使用的旧模型文件(如原 `Action.kt`、`DeviceAtt.kt` 等)。
    - 优化了 `MockMiotDeviceClient` 以匹配新的响应结构。
@sky130 sky130 merged commit 45d38de into master May 4, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant