driver add product key filed

master
winc-link 2023-10-26 18:03:30 +08:00
parent d6d281220b
commit f5467ac7e0
3 changed files with 5 additions and 4 deletions

2
go.mod
View File

@ -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

View File

@ -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

View File

@ -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