mirror of
https://gitee.com/winc-link/hummingbird.git
synced 2025-04-20 00:12:43 +00:00
修复device sn为空 bug
This commit is contained in:
parent
620b1b6af6
commit
01a1231a07
@ -171,6 +171,7 @@ type DeviceReportPropertiesValueSearchResponse struct {
|
|||||||
type DeviceAddRequest struct {
|
type DeviceAddRequest struct {
|
||||||
DeviceId string `json:"device_id"`
|
DeviceId string `json:"device_id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
DeviceSn string `json:"device_sn"`
|
||||||
ProductId string `json:"product_id"`
|
ProductId string `json:"product_id"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Platform constants.IotPlatform `json:"platform"`
|
Platform constants.IotPlatform `json:"platform"`
|
||||||
|
@ -152,6 +152,7 @@ func (p *deviceApp) AddDevice(ctx context.Context, req dtos.DeviceAddRequest) (s
|
|||||||
var insertDevice models.Device
|
var insertDevice models.Device
|
||||||
insertDevice.Id = deviceId
|
insertDevice.Id = deviceId
|
||||||
insertDevice.Name = req.Name
|
insertDevice.Name = req.Name
|
||||||
|
insertDevice.DeviceSn = req.DeviceSn
|
||||||
insertDevice.ProductId = req.ProductId
|
insertDevice.ProductId = req.ProductId
|
||||||
insertDevice.Platform = constants.IotPlatform_LocalIot
|
insertDevice.Platform = constants.IotPlatform_LocalIot
|
||||||
insertDevice.DriveInstanceId = req.DriverInstanceId
|
insertDevice.DriveInstanceId = req.DriverInstanceId
|
||||||
|
@ -52,7 +52,7 @@ func (s *DriverDeviceServer) GetDeviceConnectStatus(ctx context.Context, request
|
|||||||
|
|
||||||
func (s *DriverDeviceServer) QueryDeviceList(ctx context.Context, request *device.QueryDeviceListRequest) (*device.QueryDeviceListResponse, error) {
|
func (s *DriverDeviceServer) QueryDeviceList(ctx context.Context, request *device.QueryDeviceListRequest) (*device.QueryDeviceListResponse, error) {
|
||||||
deviceItf := container.DeviceItfFrom(s.dic.Get)
|
deviceItf := container.DeviceItfFrom(s.dic.Get)
|
||||||
|
|
||||||
var platform string
|
var platform string
|
||||||
if request.BaseRequest.UseCloudPlatform {
|
if request.BaseRequest.UseCloudPlatform {
|
||||||
platform = string(constants.TransformEdgePlatformToDbPlatform(request.BaseRequest.GetCloudInstanceInfo().GetIotPlatform()))
|
platform = string(constants.TransformEdgePlatformToDbPlatform(request.BaseRequest.GetCloudInstanceInfo().GetIotPlatform()))
|
||||||
@ -81,7 +81,7 @@ func (s *DriverDeviceServer) QueryDeviceList(ctx context.Context, request *devic
|
|||||||
|
|
||||||
func (s *DriverDeviceServer) QueryDeviceById(ctx context.Context, request *device.QueryDeviceByIdRequest) (*device.QueryDeviceByIdResponse, error) {
|
func (s *DriverDeviceServer) QueryDeviceById(ctx context.Context, request *device.QueryDeviceByIdRequest) (*device.QueryDeviceByIdResponse, error) {
|
||||||
deviceItf := container.DeviceItfFrom(s.dic.Get)
|
deviceItf := container.DeviceItfFrom(s.dic.Get)
|
||||||
|
|
||||||
deviceInfo, err := deviceItf.DeviceModelById(ctx, request.Id)
|
deviceInfo, err := deviceItf.DeviceModelById(ctx, request.Id)
|
||||||
response := new(device.QueryDeviceByIdResponse)
|
response := new(device.QueryDeviceByIdResponse)
|
||||||
response.BaseResponse = new(drivercommon.CommonResponse)
|
response.BaseResponse = new(drivercommon.CommonResponse)
|
||||||
@ -110,13 +110,15 @@ func (s *DriverDeviceServer) CreateDevice(ctx context.Context, request *device.C
|
|||||||
response.BaseResponse.ErrorMessage = errWrapper.Message()
|
response.BaseResponse.ErrorMessage = errWrapper.Message()
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var insertDevice dtos.DeviceAddRequest
|
var insertDevice dtos.DeviceAddRequest
|
||||||
insertDevice.ProductId = productInfo.Id
|
insertDevice.ProductId = productInfo.Id
|
||||||
insertDevice.Platform = constants.IotPlatform_LocalIot
|
insertDevice.Platform = constants.IotPlatform_LocalIot
|
||||||
insertDevice.Name = request.Device.Name
|
insertDevice.Name = request.Device.Name
|
||||||
|
insertDevice.DeviceSn = request.Device.DeviceSn
|
||||||
|
//insertDevice.d
|
||||||
insertDevice.DriverInstanceId = request.BaseRequest.GetDriverInstanceId()
|
insertDevice.DriverInstanceId = request.BaseRequest.GetDriverInstanceId()
|
||||||
|
|
||||||
deviceId, err := deviceItf.AddDevice(ctx, insertDevice)
|
deviceId, err := deviceItf.AddDevice(ctx, insertDevice)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errWrapper := errort.NewCommonEdgeXWrapper(err)
|
errWrapper := errort.NewCommonEdgeXWrapper(err)
|
||||||
|
@ -32,6 +32,7 @@ type Device struct {
|
|||||||
CloudInstanceId string `gorm:"index;type:string;size:255;comment:云实例ID"`
|
CloudInstanceId string `gorm:"index;type:string;size:255;comment:云实例ID"`
|
||||||
DriveInstanceId string `gorm:"index;type:string;size:255;comment:驱动实例ID"`
|
DriveInstanceId string `gorm:"index;type:string;size:255;comment:驱动实例ID"`
|
||||||
Name string `gorm:"type:string;size:255;comment:名字"`
|
Name string `gorm:"type:string;size:255;comment:名字"`
|
||||||
|
DeviceSn string `gorm:"type:string;size:255;comment:设备唯一编码"`
|
||||||
Status constants.DeviceStatus `gorm:"type:string;size:50;comment:设备状态"`
|
Status constants.DeviceStatus `gorm:"type:string;size:50;comment:设备状态"`
|
||||||
Description string `gorm:"type:text;comment:描述"`
|
Description string `gorm:"type:text;comment:描述"`
|
||||||
ProductId string `gorm:"type:string;size:255;comment:产品ID"`
|
ProductId string `gorm:"type:string;size:255;comment:产品ID"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user