Commit b3dcd7b1336906002cf1d96a4d5a6deb3ab573f2
1 parent
e5a74193
【功能新增】IoT: 通过 ProductKey 获得产品
Showing
1 changed file
with
15 additions
and
0 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/IotProductController.java
| ... | ... | @@ -93,6 +93,21 @@ public class IotProductController { |
| 93 | 93 | })); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | + @GetMapping("/get-by-key") | |
| 97 | + @Operation(summary = "通过 ProductKey 获得产品") | |
| 98 | + @Parameter(name = "productKey", description = "产品Key", required = true, example = "abc123") | |
| 99 | + @PreAuthorize("@ss.hasPermission('iot:product:query')") | |
| 100 | + public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) { | |
| 101 | + IotProductDO product = productService.getProductByProductKey(productKey); | |
| 102 | + // 拼接数据 | |
| 103 | + IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId()); | |
| 104 | + return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> { | |
| 105 | + if (category != null) { | |
| 106 | + bean.setCategoryName(category.getName()); | |
| 107 | + } | |
| 108 | + })); | |
| 109 | + } | |
| 110 | + | |
| 96 | 111 | @GetMapping("/page") |
| 97 | 112 | @Operation(summary = "获得产品分页") |
| 98 | 113 | @PreAuthorize("@ss.hasPermission('iot:product:query')") | ... | ... |