Refactor: 重构 MIoT API 模型结构并统一响应格式#63
Merged
Merged
Conversation
- **模型重构与解耦**:
- 将复杂的嵌套类(如 `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` 以匹配新的响应结构。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MiotDevices.Result.Device、MiotHomes.Result.Home)重构为独立的顶级类MiotDevice、MiotHome、MiotScene等。DeviceList、HomeList、SceneList等专门用于列表响应的数据结构。PropertyResponse、ActionResponse、PropertyResult和ActionResult。MiotResponse<T>泛型类,用于标准化处理所有包含code、message和result的 API 返回数据。MiotHomeClient、MiotUserClient、MiotDeviceClient及其 KMP 实现,以适配新的泛型响应模型。HomeService、UserService和MiotService(Retrofit/Ktorfit) 的接口定义,使用MiotResponse包装返回类型。MiotRepositoryImpl和MiotDeviceManagerImpl中的数据解析逻辑。HomeActivity、SceneFragment及相关 DataBinding 布局文件)中的类引用路径。Action.kt、DeviceAtt.kt等)。MockMiotDeviceClient以匹配新的响应结构。