【功能新增】IoT: 通过 ProductKey 获得产品

This commit is contained in:
puhui999 2025-03-29 11:38:13 +08:00
parent e5a74193ba
commit b3dcd7b133
1 changed files with 15 additions and 0 deletions

View File

@ -93,6 +93,21 @@ public class IotProductController {
})); }));
} }
@GetMapping("/get-by-key")
@Operation(summary = "通过 ProductKey 获得产品")
@Parameter(name = "productKey", description = "产品Key", required = true, example = "abc123")
@PreAuthorize("@ss.hasPermission('iot:product:query')")
public CommonResult<IotProductRespVO> getProductByKey(@RequestParam("productKey") String productKey) {
IotProductDO product = productService.getProductByProductKey(productKey);
// 拼接数据
IotProductCategoryDO category = categoryService.getProductCategory(product.getCategoryId());
return success(BeanUtils.toBean(product, IotProductRespVO.class, bean -> {
if (category != null) {
bean.setCategoryName(category.getName());
}
}));
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得产品分页") @Operation(summary = "获得产品分页")
@PreAuthorize("@ss.hasPermission('iot:product:query')") @PreAuthorize("@ss.hasPermission('iot:product:query')")