-
-
Notifications
You must be signed in to change notification settings - Fork 9k
微信小程序新增设备组相关接口 #3818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
微信小程序新增设备组相关接口 #3818
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
此 PR 为微信小程序 SDK 新增了设备组相关的 API 接口,实现了设备组的创建、查询、设备添加和删除功能。
主要变更内容:
- 新增 4 个设备组管理 API 接口(创建、查询、添加设备、删除设备)
- 添加 4 个请求/响应模型类以支持新接口
- 在 API URL 常量类中定义相关端点
- 完善测试用例以验证新增功能
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| WxMaDeviceSubscribeService.java | 定义设备组相关的 4 个接口方法签名及文档 |
| WxMaDeviceSubscribeServiceImpl.java | 实现设备组 API 的具体逻辑,包括请求发送和响应解析 |
| WxMaApiUrlConstants.java | 添加 4 个设备组相关的微信 API 端点常量 |
| WxMaCreateIotGroupIdRequest.java | 创建设备组的请求参数模型类 |
| WxMaGetIotGroupInfoRequest.java | 查询设备组信息的请求参数模型类 |
| WxMaIotGroupDeviceRequest.java | 添加/删除设备的请求参数模型类 |
| WxMaIotGroupDeviceInfoResponse.java | 设备组信息查询的响应模型类 |
| WxMaDeviceSubscribeServiceImplTest.java | 新增 4 个测试方法验证设备组 API 功能 |
...-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/device/WxMaCreateIotGroupIdRequest.java
Outdated
Show resolved
Hide resolved
...iapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImplTest.java
Outdated
Show resolved
Hide resolved
...iapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImplTest.java
Outdated
Show resolved
Hide resolved
| * 组最大设备数量 | ||
| */ | ||
| @SerializedName("max_device_count") | ||
| private String maxDeviceCount; |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WxMaIotGroupDeviceInfoResponse 类中 maxDeviceCount 字段的类型应该是 Integer 或 int,而不是 String。设备数量通常应该用数值类型表示,使用 String 类型可能导致后续的数值计算或比较操作不便。
| private String maxDeviceCount; | |
| private Integer maxDeviceCount; |
...iapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaDeviceSubscribeServiceImplTest.java
Outdated
Show resolved
Hide resolved
| request.setModelId("11111"); | ||
| request.setGroupName("测试设备组"); | ||
| String groupId = this.wxService.getDeviceSubscribeService().createIotGroupId(request); | ||
| System.out.println(groupId); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试方法使用 System.out.println 进行输出不符合测试最佳实践。应该使用断言(assertions)来验证返回结果是否符合预期,或者使用日志框架记录调试信息。
| WxMaGetIotGroupInfoRequest request = new WxMaGetIotGroupInfoRequest(); | ||
| request.setGroupId("12313123"); | ||
| WxMaIotGroupDeviceInfoResponse response = this.wxService.getDeviceSubscribeService().getIotGroupInfo(request); | ||
| System.out.println(response.toString()); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试方法使用 System.out.println 进行输出不符合测试最佳实践。应该使用断言(assertions)来验证返回结果是否符合预期,或者使用日志框架记录调试信息。
| request.setDeviceList(Collections.singletonList(deviceTicketRequest)); | ||
| request.setForceAdd(true); | ||
| List<WxMaDeviceTicketRequest> response = this.wxService.getDeviceSubscribeService().addIotGroupDevice(request); | ||
| System.out.println(response.toString()); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试方法使用 System.out.println 进行输出不符合测试最佳实践。应该使用断言(assertions)来验证返回结果是否符合预期,或者使用日志框架记录调试信息。
| /** | ||
| * <pre> | ||
| * 设备组删除设备 | ||
| * 一个设备组最多添加 50 个设备。 一个设备同一时间只能被添加到一个设备组中。 |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文档注释不准确。在 removeIotGroupDevice 方法的注释中提到"一个设备组最多添加 50 个设备",这个描述应该是针对添加设备的限制,而不是删除设备。建议修改为更适合删除操作的描述,或者删除这句话。
| * 一个设备组最多添加 50 个设备。 一个设备同一时间只能被添加到一个设备组中。 |
…n/device/WxMaCreateIotGroupIdRequest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/impl/WxMaDeviceSubscribeServiceImplTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
请楼主针对PR建议做出调整,如果不需要,请忽略即可 |
微信小程序新增设备组相关接口