Skip to content

Commit 7fe3f47

Browse files
committed
feat(devices): 添加产品ID绑定功能
- 在DeviceAddParams结构体中新增productId字段 - 实现模型属性中绑定productId的逻辑 - 将产品ID存储到模型属性映射中
1 parent b310684 commit 7fe3f47

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkg/rpc/devices_add.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func HandleDeviceAdd(ctx Context, params interface{}) error {
2020
// Define structure for device add parameters
2121
type DeviceAddParams struct {
2222
Plugin string `json:"plugin"`
23+
ProductId string `json:"productId"`
2324
ModelKey string `json:"modelKey"`
2425
ModelHash string `json:"modelHash"`
2526
ConnectionKey string `json:"connectionKey"`
@@ -61,6 +62,10 @@ func HandleDeviceAdd(ctx Context, params interface{}) error {
6162
return fmt.Errorf("failed to load model: %v", err)
6263
}
6364
model.Name = addParams.ModelKey + "_" + computedHash
65+
//绑定产品ID
66+
modelAttr := model.Attributes
67+
modelAttr["productId"] = addParams.ProductId
68+
model.Attributes = modelAttr
6469
err = driverbox.CoreCache().AddModel(addParams.Plugin, model)
6570
if err != nil {
6671
return err

0 commit comments

Comments
 (0)