[fix] 设备属性读取错误

This commit is contained in:
PandaX-Go
2024-06-13 20:39:26 +08:00
parent 60f23a5920
commit b1be42a00e
2 changed files with 21 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package api
import (
"encoding/json"
"pandax/kit/biz"
"pandax/kit/model"
"pandax/kit/restfulx"
@@ -65,8 +66,9 @@ func (p *ProductTemplateApi) InsertProductTemplate(rc *restfulx.ReqCtx) {
stable := data.Pid + "_" + data.Classify
if data.Classify == entity.TELEMETRY_TSL {
if data.Type == "string" {
if maxLength, ok := data.Define["maxLength"].(float64); ok {
len = int(maxLength)
if maxLength, ok := data.Define["maxLength"].(json.Number); ok {
length, _ := maxLength.Int64()
len = int(length)
}
}
}
@@ -95,7 +97,10 @@ func (p *ProductTemplateApi) UpdateProductTemplate(rc *restfulx.ReqCtx) {
if data.Classify == entity.TELEMETRY_TSL {
stable = data.Pid + "_" + entity.TELEMETRY_TSL
if data.Type == "string" {
len = int(data.Define["length"].(int64))
if maxLength, ok := data.Define["maxLength"].(json.Number); ok {
length, _ := maxLength.Int64()
len = int(length)
}
}
global.TdDb.DelSTableField(stable, one.Key)
err := global.TdDb.AddSTableField(stable, data.Key, data.Type, len)