Skip to content

Commit

Permalink
feat: 支持tdengine可选
Browse files Browse the repository at this point in the history
  • Loading branch information
godLei6 committed Jan 2, 2025
1 parent 6116799 commit 3062042
Show file tree
Hide file tree
Showing 34 changed files with 1,648 additions and 89 deletions.
2 changes: 1 addition & 1 deletion deploy/docker/conf/mysql/sql/ainitDB.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

create database if not EXISTS `iThings-ts`;
create database if not EXISTS iThings;
use iThings;

20 changes: 11 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module gitee.com/unitedrhino/things

go 1.21.4
go 1.22.0

toolchain go1.23.3

//gitee.com/unitedrhino/core => ../core
//gitee.com/unitedrhino/share => ../share

require (
gitee.com/unitedrhino/core v1.2.1
gitee.com/unitedrhino/share v1.2.1
gitee.com/unitedrhino/share v1.2.2
gitee.com/unitedrhino/squirrel v1.20.5
github.com/dgraph-io/ristretto v0.1.0
github.com/dop251/goja v0.0.0-20231024180952-594410467bc6
Expand All @@ -22,8 +24,8 @@ require (
github.com/spf13/cast v1.7.0
github.com/zeromicro/go-zero v1.7.2
go.uber.org/atomic v1.11.0
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225
golang.org/x/sync v0.9.0
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d
golang.org/x/sync v0.10.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.35.2
gorm.io/gorm v1.25.12
Expand Down Expand Up @@ -179,12 +181,12 @@ require (
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
Expand Down
39 changes: 20 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ gitee.com/unitedrhino/core v1.2.1 h1:Tu2we0stzE29lp2NwxLIlgOzdppXVDlA7r5qp1UGY+Y
gitee.com/unitedrhino/core v1.2.1/go.mod h1:D/MlLNI9gwtWB39WLVpoFfiPVg+cQQV2uhlpB1du3Xc=
gitee.com/unitedrhino/driver-go/v3 v3.30.1 h1:hVBG8jRPaPL+fS/tAvsG60Jt7QvLW50OQuD0Ms+6iao=
gitee.com/unitedrhino/driver-go/v3 v3.30.1/go.mod h1:Kdr+5rPmtqqxpliQ0NJrg24F9jCHcwywyWiDaVA5eEQ=
gitee.com/unitedrhino/share v1.2.1 h1:F5kmH/llYGXdPtvGna9ZAO+/q3dRj2TJrQuvJ2jWD7M=
gitee.com/unitedrhino/share v1.2.1/go.mod h1:WzH5clWj8kgAMTg8td8xtX1Kv7JMTPzXSG/jI88je78=
gitee.com/unitedrhino/share v1.2.2 h1:X1semTlSWMnfA/quMBHf4qFtqBw5whcLYYNQJJAyTHA=
gitee.com/unitedrhino/share v1.2.2/go.mod h1:V5RrSxLHjB9sK+Un3qL6lAzbElNUlIu0Rl/9aB/x9Sc=
gitee.com/unitedrhino/squirrel v1.20.5 h1:Mi11U2zk3VEPUMh2+TxThcjRkFA3rtBwVK6qL8dnTmU=
gitee.com/unitedrhino/squirrel v1.20.5/go.mod h1:NVTC7zI2TMArBB7L0eOp67c0TVBOJ3TKpY+Qbs8R+TU=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
Expand Down Expand Up @@ -453,8 +453,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/suifengtec/gocoord v0.0.0-20210116135606-a0cd8c71c959 h1:2wBuejoTiP4H4rdxG5MjOTrH8mp0lDXsH80kZK1ogco=
github.com/suifengtec/gocoord v0.0.0-20210116135606-a0cd8c71c959/go.mod h1:YDNVjvVwAevSbvIIoWQ6kZup578YkHhcS+NAamNzOt8=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
Expand Down Expand Up @@ -546,10 +547,10 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d h1:0olWaB5pg3+oychR51GUVCEsGkeCU/2JxjBgIo4f3M0=
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
golang.org/x/image v0.16.0 h1:9kloLAKhUufZhA12l5fwnx2NZW39/we1UhBesW433jw=
golang.org/x/image v0.16.0/go.mod h1:ugSZItdV4nOxyqp56HmXwH0Ry0nBCpjnZdpDaIHdoPs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down Expand Up @@ -577,8 +578,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -589,8 +590,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -621,17 +622,17 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand All @@ -643,8 +644,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
Expand All @@ -661,8 +662,8 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
3 changes: 3 additions & 0 deletions service/apisvr/etc/dm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ TSDB:
# DSN: root:taosdata@ws(localhost:6041)/ithings?readBufferSize=5242880
# Driver: taosSql
# DSN: root:taosdata@tcp(localhost:6030)/ithings
# DBType: mysql
# DSN: root:password@tcp(localhost:3306)/iThings-ts?charset=utf8mb4&collation=utf8mb4_bin&parseTime=true&loc=Asia%2FShanghai

AuthWhite:
Users:
- UserName: dgsvr
Expand Down
14 changes: 7 additions & 7 deletions service/dmsvr/internal/domain/deviceLog/abnormal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

type (
Abnormal struct {
ProductID string `json:"productID,omitempty"` // 产品id
DeviceName string `json:"deviceName,omitempty"` // 设备名称
Action int64 `json:"action,omitempty"` //触发1还是解除2
Type string `json:"type,omitempty"` // 异常类型
Timestamp time.Time `json:"timestamp"` // 操作时间
TraceID string `json:"traceID,omitempty"` // 服务器端事务id
Reason string `json:"reason,omitempty"` //原因
ProductID string `gorm:"column:product_id;type:varchar(100);NOT NULL" json:"productID,omitempty"` // 产品id
DeviceName string `gorm:"column:device_name;type:varchar(100);NOT NULL" json:"deviceName,omitempty"` // 设备名称
Action def.Bool `gorm:"column:user_id;type:BIGINT;default:1" json:"action,omitempty"` //触发1还是解除2
Type string `gorm:"column:type;type:varchar(100);NOT NULL" json:"type,omitempty"` // 异常类型
Timestamp time.Time `gorm:"column:ts;NOT NULL;" json:"timestamp"` // 操作时间
TraceID string `gorm:"column:trace_id;type:varchar(100);NOT NULL" json:"traceID,omitempty"` // 服务器端事务id
Reason string `gorm:"column:reason;type:varchar(100);NOT NULL" json:"reason,omitempty"` //原因
}
AbnormalFilter struct {
ProductID string // 产品id
Expand Down
20 changes: 10 additions & 10 deletions service/dmsvr/internal/domain/deviceLog/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ const (

type (
Hub struct {
ProductID string `json:"productID"` // 产品id
DeviceName string `json:"deviceName"` // 设备名称
Content string `json:"content,omitempty"` // 具体信息
Topic string `json:"topic,omitempty"` // 主题
Action ActionType `json:"action,omitempty"` // 操作类型
Timestamp time.Time `json:"timestamp,omitempty"` // 操作时间
RequestID string `json:"requestID,omitempty"` // 请求ID
TraceID string `json:"traceID,omitempty"` // 服务器端事务id
ResultCode int64 `json:"resultCode,omitempty"` // 请求结果状态,200为成功
RespPayload string `json:"respPayload,omitempty"` //返回的内容
ProductID string `gorm:"column:product_id;type:varchar(100);NOT NULL" json:"productID,omitempty"` // 产品id
DeviceName string `gorm:"column:device_name;type:varchar(100);NOT NULL" json:"deviceName,omitempty"` // 设备名称
Content string `gorm:"column:content;type:varchar(256);NOT NULL" json:"content,omitempty"` // 具体信息
Topic string `gorm:"column:topic;type:varchar(100);NOT NULL" json:"topic,omitempty"` // 主题
Action ActionType `gorm:"column:action;type:varchar(25);NOT NULL" json:"action,omitempty"` // 操作类型
Timestamp time.Time `gorm:"column:ts;NOT NULL;" json:"timestamp"` // 操作时间
RequestID string `gorm:"column:request_id;type:varchar(100);NOT NULL" json:"requestID,omitempty"` // 请求ID
TraceID string `gorm:"column:trace_id;type:varchar(100);NOT NULL" json:"traceID,omitempty"` // 服务器端事务id
ResultCode int64 `gorm:"column:result_code;type:BIGINT;default:200" json:"resultCode,omitempty"` // 请求结果状态,200为成功
RespPayload string `gorm:"column:resp_payload;type:varchar(256);NOT NULL" json:"respPayload,omitempty"` //返回的内容
}
HubFilter struct {
ProductID string // 产品id
Expand Down
10 changes: 5 additions & 5 deletions service/dmsvr/internal/domain/deviceLog/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

type (
SDK struct {
ProductID string `json:"productID"` // 产品id
DeviceName string `json:"deviceName"` // 设备名称
Content string `json:"content"` // 具体信息
Timestamp time.Time `json:"timestamp"` // 操作时间
LogLevel int64 `json:"logLevel"`
ProductID string `gorm:"column:product_id;type:varchar(100);NOT NULL" json:"productID,omitempty"` // 产品id
DeviceName string `gorm:"column:device_name;type:varchar(100);NOT NULL" json:"deviceName,omitempty"` // 设备名称
Content string `gorm:"column:content;type:varchar(256);NOT NULL" json:"content,omitempty"` // 具体信息
Timestamp time.Time `gorm:"column:ts;NOT NULL;" json:"timestamp"` // 操作时间
LogLevel int64 `gorm:"column:log_level;type:BIGINT;default:1" json:"logLevel"`
}
SDKFilter struct {
ProductID string // 产品id
Expand Down
20 changes: 10 additions & 10 deletions service/dmsvr/internal/domain/deviceLog/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import (

type (
Send struct {
UserID int64 `json:"userID"`
ProductID string `json:"productID,omitempty"` // 产品id
DeviceName string `json:"deviceName,omitempty"` // 设备名称
Action string `json:"action,omitempty"` // 操作类型 propertySend:属性控制 actionSend:操作控制 propertyGetReportSend:获取最新属性请求
DataID string `json:"dataID"`
Timestamp time.Time `json:"timestamp"` // 操作时间
TraceID string `json:"traceID,omitempty"` // 服务器端事务id
Account string `json:"account"`
Content string `json:"content"` //操作的内容
ResultCode int64 `json:"resultCode,omitempty"` // 请求结果状态,200为成功
UserID int64 `gorm:"column:user_id;type:BIGINT;NOT NULL" json:"userID"`
ProductID string `gorm:"column:product_id;type:varchar(100);NOT NULL" json:"productID,omitempty"` // 产品id
DeviceName string `gorm:"column:device_name;type:varchar(100);NOT NULL" json:"deviceName,omitempty"` // 设备名称
Action string `gorm:"column:action;type:varchar(100);NOT NULL" json:"action,omitempty"` // 操作类型 propertySend:属性控制 actionSend:操作控制 propertyGetReportSend:获取最新属性请求
DataID string `gorm:"column:data_id;type:varchar(100);NOT NULL" json:"dataID"`
Timestamp time.Time `gorm:"column:ts;NOT NULL;" json:"timestamp"` // 操作时间
TraceID string `gorm:"column:trace_id;type:varchar(100);NOT NULL" json:"traceID,omitempty"` // 服务器端事务id
Account string `gorm:"column:account;type:varchar(100);NOT NULL" json:"account"`
Content string `gorm:"column:content;type:varchar(100);NOT NULL" json:"content"` //操作的内容
ResultCode int64 `gorm:"column:result_code;type:BIGINT;default:200" json:"resultCode,omitempty"` // 请求结果状态
}
SendFilter struct {
TenantCode string
Expand Down
10 changes: 4 additions & 6 deletions service/dmsvr/internal/domain/deviceLog/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import (

type (
Status struct {
ProductID string `json:"productID"` // 产品id
DeviceName string `json:"deviceName"` // 设备名称
Status int64 `json:"status"` // 设备状态 connected:上线 disconnected:下线
Timestamp time.Time `json:"timestamp"` // 操作时间
ProductID string `gorm:"column:product_id;type:varchar(100);NOT NULL" json:"productID,omitempty"` // 产品id
DeviceName string `gorm:"column:device_name;type:varchar(100);NOT NULL" json:"deviceName,omitempty"` // 设备名称
Status def.ConnStatus `gorm:"column:status;type:BIGINT;NOT NULL" json:"status"` // 设备状态 connected:上线 disconnected:下线
Timestamp time.Time `gorm:"column:ts;NOT NULL;" json:"timestamp"` // 操作时间
}
StatusFilter struct {
TenantCode string
ProjectID int64
AreaIDs []int64
ProductID string // 产品id
DeviceName string // 设备名称
Expand Down
34 changes: 34 additions & 0 deletions service/dmsvr/internal/repo/tsDB/abnormalLogRepo/abnormalLog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package abnormalLogRepo

import (
"context"
"gitee.com/unitedrhino/share/conf"
"gitee.com/unitedrhino/share/stores"
"gitee.com/unitedrhino/things/service/dmsvr/internal/domain/deviceLog"
"gitee.com/unitedrhino/things/service/dmsvr/internal/repo/tsDB/tdengine/abnormalLogRepo"
"github.com/zeromicro/go-zero/core/logx"
)

type Abnormal struct {
*deviceLog.Abnormal
}

func (m *Abnormal) TableName() string {
return "dm_abnormal_log"
}

type AbnormalLogRepo struct {
db *stores.DB
asyncInsert *stores.AsyncInsert[Abnormal]
}

func NewAbnormalLogRepo(dataSource conf.TSDB) deviceLog.AbnormalRepo {
if dataSource.DBType == conf.Tdengine {
return abnormalLogRepo.NewAbnormalLogRepo(dataSource)
}
stores.InitTsConn(dataSource)
db := stores.GetTsConn(context.Background())
err := db.AutoMigrate(&Abnormal{})
logx.Must(err)
return &AbnormalLogRepo{db: db, asyncInsert: stores.NewAsyncInsert[Abnormal](db, "")}
}
Loading

0 comments on commit 3062042

Please sign in to comment.