From f5467ac7e0170548a52058915f5b04758f9df7dd Mon Sep 17 00:00:00 2001 From: winc-link Date: Thu, 26 Oct 2023 18:03:30 +0800 Subject: [PATCH] driver add product key filed --- go.mod | 2 +- .../hummingbird/core/application/productapp/productapp.go | 6 +++--- internal/models/product.go | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index a6a8335..a35dbf4 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.617 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.617 github.com/tencentyun/cos-go-sdk-v5 v0.7.39 - github.com/winc-link/edge-driver-proto v0.0.0-20231023113502-daf15ee41883 + github.com/winc-link/edge-driver-proto v0.0.0-20231026095244-f5aaece7aee1 github.com/xuri/excelize/v2 v2.5.0 go.uber.org/atomic v1.9.0 go.uber.org/zap v1.21.0 diff --git a/internal/hummingbird/core/application/productapp/productapp.go b/internal/hummingbird/core/application/productapp/productapp.go index 22f6f81..81b590f 100644 --- a/internal/hummingbird/core/application/productapp/productapp.go +++ b/internal/hummingbird/core/application/productapp/productapp.go @@ -157,11 +157,11 @@ func (p *productApp) AddProduct(ctx context.Context, req dtos.ProductAddRequest) properties, events, actions = dtos.GetModelPropertyEventActionByThingModelTemplate(thingModelTemplateInfo.ThingModelJSON) } } - + secret := utils.GenerateDeviceSecret(15) var insertProduct models.Product insertProduct.Id = utils.RandomNum() insertProduct.Name = req.Name - insertProduct.CloudProductId = utils.GenerateDeviceSecret(15) + insertProduct.CloudProductId = secret insertProduct.Platform = constants.IotPlatform_LocalIot insertProduct.Protocol = req.Protocol insertProduct.NodeType = constants.ProductNodeType(req.NodeType) @@ -169,7 +169,7 @@ func (p *productApp) AddProduct(ctx context.Context, req dtos.ProductAddRequest) insertProduct.DataFormat = req.DataFormat insertProduct.Factory = req.Factory insertProduct.Description = req.Description - insertProduct.Key = req.Key + insertProduct.Key = secret insertProduct.Status = constants.ProductUnRelease insertProduct.Properties = properties insertProduct.Events = events diff --git a/internal/models/product.go b/internal/models/product.go index 3179244..20fdec6 100644 --- a/internal/models/product.go +++ b/internal/models/product.go @@ -59,6 +59,7 @@ func (d *Product) TransformToDriverProduct() *driverproduct.Product { driverProduct.Platform = d.Platform.TransformToDriverDevicePlatform() driverProduct.NetType = d.NetType.TransformToDriverProductNetType() driverProduct.ProtocolType = d.Protocol + driverProduct.Key = d.Key driverProduct.CreateAt = uint64(d.Created) var p []*driverproduct.Properties var e []*driverproduct.Events