From f2f1bbf70169b9a9dd633d029e2c141bda51bbab Mon Sep 17 00:00:00 2001 From: winc-link Date: Sat, 9 Sep 2023 21:48:04 +0800 Subject: [PATCH] fix thing model bug --- README.md | 20 ++++++++-- go.mod | 40 +++++++++---------- internal/dtos/thinkmodelmessage.go | 2 +- .../application/deviceapp/deviceaction.go | 15 ++++++- .../application/persistence/thinkmodel.go | 11 ----- 5 files changed, 52 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index d0daee3..5f22e10 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,15 @@ # 官方文档 -官方文档地址:https://doc.hummingbird.winc-link.com/ +官方文档地址:https://doc.hummingbird.winc-link.com + +# 快速启动 + +git clone https://github.com/winc-link/hummingbird.git + +cd hummingbird/manifest/docker + +docker-compose up -d # 主要功能 @@ -72,7 +80,7 @@ 如果你在使用或者部署过程遇到任何问题,请在 QQ 群讨论或者联系作者微信。 -🌟 请记住我们不收费,代码完全开源,如果你想把蜂鸟物联网平台进行商用,请提前找作者授权!最后请点个 Start 鼓励我们吧!🌟 +如果你想把蜂鸟物联网平台进行商用,请提前找作者授权!最后请点个 Start 鼓励我们吧!🌟

@@ -88,4 +96,10 @@ # 开源协议 -`Hummingbird` 开源平台遵循 [Apache 2.0 协议](https://www.apache.org/licenses/LICENSE-2.0.html) 如果你想把蜂鸟物联网平台进行商用,请提前找作者授权! \ No newline at end of file +`Hummingbird` 开源平台遵循 [Apache 2.0 协议](https://www.apache.org/licenses/LICENSE-2.0.html) 如果你想把蜂鸟物联网平台进行商用,请提前找作者授权! + + + +## Stargazers over time + +[![Stargazers over time](https://starchart.cc/winc-link/hummingbird.svg)](https://starchart.cc/winc-link/hummingbird) diff --git a/go.mod b/go.mod index 8507510..0367805 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,7 @@ module github.com/winc-link/hummingbird go 1.18 require ( - github.com/BurntSushi/toml v1.1.0 - github.com/alexmullins/zip v0.0.0-20180717182244-4affb64b04d0 + github.com/BurntSushi/toml v1.2.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/docker/distribution v2.8.1+incompatible github.com/docker/docker v20.10.17+incompatible @@ -14,7 +13,7 @@ require ( github.com/gin-contrib/static v0.0.1 github.com/gin-gonic/gin v1.8.1 github.com/go-gormigrate/gormigrate/v2 v2.0.0 - github.com/gogf/gf/v2 v2.5.0 + github.com/gogf/gf/v2 v2.5.2 github.com/golang/mock v1.5.0 github.com/golang/protobuf v1.5.2 github.com/gomodule/redigo v1.8.9 @@ -41,7 +40,7 @@ require ( github.com/shirou/gopsutil/v3 v3.22.2 github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.2 github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a github.com/swaggo/gin-swagger v1.5.3 github.com/swaggo/swag v1.8.7 @@ -54,9 +53,9 @@ require ( github.com/xuri/excelize/v2 v2.5.0 go.uber.org/atomic v1.9.0 go.uber.org/zap v1.21.0 - golang.org/x/crypto v0.5.0 - golang.org/x/sys v0.4.0 - golang.org/x/text v0.6.0 + golang.org/x/crypto v0.11.0 + golang.org/x/sys v0.10.0 + golang.org/x/text v0.11.0 golang.org/x/time v0.0.0-20220609170525-579cf78fd858 google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c google.golang.org/grpc v1.49.0 @@ -76,13 +75,13 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/clbanning/mxj v1.8.4 // indirect - github.com/clbanning/mxj/v2 v2.5.5 // indirect + github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/go-units v0.4.0 // indirect - github.com/fatih/color v1.13.0 // indirect - github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect @@ -114,9 +113,9 @@ require ( github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-colorable v0.1.9 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect - github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mattn/go-sqlite3 v1.14.12 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/miekg/dns v1.0.14 // indirect @@ -137,6 +136,7 @@ require ( github.com/prometheus/procfs v0.8.0 // indirect github.com/richardlehane/mscfb v1.0.3 // indirect github.com/richardlehane/msoleps v1.0.1 // indirect + github.com/rivo/uniseg v0.4.4 // indirect github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/tklauser/go-sysconf v0.3.9 // indirect @@ -144,13 +144,13 @@ require ( github.com/ugorji/go/codec v1.2.7 // indirect github.com/xuri/efp v0.0.0-20210322160811-ab561f5b45e3 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - go.opentelemetry.io/otel v1.7.0 // indirect - go.opentelemetry.io/otel/sdk v1.7.0 // indirect - go.opentelemetry.io/otel/trace v1.7.0 // indirect + go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel/sdk v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/net v0.5.0 // indirect - golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect - golang.org/x/tools v0.2.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/tools v0.6.0 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gotest.tools/v3 v3.3.0 // indirect diff --git a/internal/dtos/thinkmodelmessage.go b/internal/dtos/thinkmodelmessage.go index c7bc907..e38a6e9 100644 --- a/internal/dtos/thinkmodelmessage.go +++ b/internal/dtos/thinkmodelmessage.go @@ -247,7 +247,7 @@ type ServiceExecResponse struct { MsgId string `json:"msgId"` Code string `json:"code"` Time int64 `json:"time"` - OutputParams map[string]interface{} `json:"outputParams"` + OutputParams map[string]interface{} `json:"data"` } func (r *ServiceExecResponse) Marshal() ([]byte, error) { diff --git a/internal/hummingbird/core/application/deviceapp/deviceaction.go b/internal/hummingbird/core/application/deviceapp/deviceaction.go index 7e27ae9..901722b 100644 --- a/internal/hummingbird/core/application/deviceapp/deviceaction.go +++ b/internal/hummingbird/core/application/deviceapp/deviceaction.go @@ -132,6 +132,17 @@ func (p *deviceApp) SetDeviceProperty(req dtos.OpenApiSetDeviceThingModel) error if err != nil { return nil } + + _, err = p.dbClient.ProductById(device.ProductId) + if err != nil { + return nil + } + //var findCode bool + // + //for _, property := range product.Properties { + // if property.Code + //} + deviceService, err := p.dbClient.DeviceServiceById(device.DriveInstanceId) if err != nil { return err @@ -318,7 +329,9 @@ func (p *deviceApp) DeviceInvokeThingService(invokeDeviceServiceReq dtos.InvokeD saveData.MsgId = data.MsgId saveData.Code = invokeDeviceServiceReq.Code saveData.Time = data.Time - saveData.InputParams = invokeDeviceServiceReq.Items + saveData.InputParams = make(map[string]interface{}) + saveData.InputParams["code"] = invokeDeviceServiceReq.Code + saveData.InputParams["inputParams"] = invokeDeviceServiceReq.Items //****** select { diff --git a/internal/hummingbird/core/application/persistence/thinkmodel.go b/internal/hummingbird/core/application/persistence/thinkmodel.go index 688eec1..0cd1e70 100644 --- a/internal/hummingbird/core/application/persistence/thinkmodel.go +++ b/internal/hummingbird/core/application/persistence/thinkmodel.go @@ -148,17 +148,6 @@ func (pst *persistApp) saveDeviceThingModelToLevelDB(req dtos.ThingModelMessage) if err != nil { return err } - - device, err := pst.dbClient.DeviceById(req.Cid) - if err != nil { - return err - } - - _, err = pst.dbClient.ProductById(device.ProductId) - if err != nil { - return err - } - //var find bool //var callType constants.CallType //