Skip to content

Commit

Permalink
feat: 设备列表标签获取支持模糊查询
Browse files Browse the repository at this point in the history
  • Loading branch information
godLei6 committed Dec 18, 2024
1 parent 3a8e76e commit 693273c
Show file tree
Hide file tree
Showing 9 changed files with 1,803 additions and 1,772 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go 1.21.4

require (
gitee.com/unitedrhino/core v1.1.3
gitee.com/unitedrhino/share v1.1.9
gitee.com/unitedrhino/share v1.1.12
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 Down Expand Up @@ -130,6 +130,7 @@ require (
github.com/nats-io/nuid v1.0.1 // indirect
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.0 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/parnurzeal/gorequest v0.3.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ gitee.com/unitedrhino/core v1.1.3 h1:bW1SleP+o6H+RJw1Jm0Sru4PTwSnY4ynlr/8EDHPLHI
gitee.com/unitedrhino/core v1.1.3/go.mod h1:rsTLURVH/TDce9/XwodHv+WZl6Gk/zQooq3gdwL8Aco=
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.1.9 h1:s2IT7Acwvti54yTPZnnp0107dc7/naJXwFmR4r7/FmM=
gitee.com/unitedrhino/share v1.1.9/go.mod h1:WhkAUiCeU0mexCWyfE0yQC9H0FZyYlr5QFiit4ehMhQ=
gitee.com/unitedrhino/share v1.1.12 h1:RtLNRK9LmEqiD9KUI2zjbSwpAftWRjNi6NcWYXqbiU0=
gitee.com/unitedrhino/share v1.1.12/go.mod h1:ru75IWVu8p/1Lrcn33Ghm4f7o654H2xHhpNL9I4b9x4=
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 @@ -369,6 +369,8 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.0 h1:DL64ORGMk6AUB8q5LbRp8KRFn4oHhdrSepBmbMrtmNo=
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.9.0/go.mod h1:ln3IqPYYocZbYvl9TAOrG/cxGR9xcn4pnZRLdCTEGEU=
github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg=
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
github.com/parnurzeal/gorequest v0.3.0 h1:SoFyqCDC9COr1xuS6VA8fC8RU7XyrJZN2ona1kEX7FI=
Expand Down
4 changes: 3 additions & 1 deletion service/dmsvr/dmdirect/dmdirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"gitee.com/unitedrhino/share/utils"
"gitee.com/unitedrhino/things/service/dmsvr/internal/config"
devicegroup "gitee.com/unitedrhino/things/service/dmsvr/internal/server/devicegroup"
userdevice "gitee.com/unitedrhino/things/service/dmsvr/internal/server/userdevice"

deviceinteract "gitee.com/unitedrhino/things/service/dmsvr/internal/server/deviceinteract"
devicemanage "gitee.com/unitedrhino/things/service/dmsvr/internal/server/devicemanage"
devicemsg "gitee.com/unitedrhino/things/service/dmsvr/internal/server/devicemsg"
Expand Down Expand Up @@ -60,7 +62,7 @@ func Run(svcCtx *svc.ServiceContext) {
dm.RegisterDeviceInteractServer(grpcServer, deviceinteract.NewDeviceInteractServer(svcCtx))
dm.RegisterDeviceMsgServer(grpcServer, devicemsg.NewDeviceMsgServer(svcCtx))
dm.RegisterOtaManageServer(grpcServer, otamanage.NewOtaManageServer(svcCtx))

dm.RegisterUserDeviceServer(grpcServer, userdevice.NewUserDeviceServer(svcCtx))
//if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
//}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (l *DeviceInfoIndexLogic) DeviceInfoIndex(in *dm.DeviceInfoIndexReq) (*dm.D
Cores: cores,
Iccid: in.Iccid,
Tags: in.Tags,
TagsLike: in.TagsLike,
Range: in.Range,
Position: logic.ToStorePoint(in.Position),
DeviceAlias: in.DeviceAlias,
Expand Down
6 changes: 6 additions & 0 deletions service/dmsvr/internal/repo/relationDB/deviceInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type (
DeviceName string
DeviceNames []string
Tags map[string]string
TagsLike map[string]string
LastLoginTime *def.TimeRange
IsOnline int64
Status def.DeviceStatus
Expand Down Expand Up @@ -166,6 +167,11 @@ func (d DeviceInfoRepo) fmtFilter(ctx context.Context, f DeviceFilter) *gorm.DB
k, v)
}
}
if f.TagsLike != nil {
for k, v := range f.TagsLike {
db = db.Where(fmt.Sprintf("JSON_SEARCH(tags, 'all', '%s', NULL, '$.\"%s\"') IS NOT NULL", "%"+v+"%", k))
}
}
if f.LastLoginTime != nil {
if f.LastLoginTime.Start != 0 {
db = db.Where("last_login >= ?", utils.ToYYMMddHHSS(f.LastLoginTime.Start*1000))
Expand Down
8 changes: 4 additions & 4 deletions service/dmsvr/internal/startup/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ func InitEventBus(svcCtx *svc.ServiceContext) {
return nil
})
logx.Must(err)
err = svcCtx.FastEvent.QueueSubscribe(eventBus.SysProjectInfoDelete, func(ctx context.Context, t time.Time, body []byte) error {
err = svcCtx.FastEvent.QueueSubscribe(eventBus.CoreProjectInfoDelete, func(ctx context.Context, t time.Time, body []byte) error {
pi := cast.ToInt64(string(body))
logx.WithContext(ctx).Infof("SysProjectInfoDelete value:%v err:%v", string(body), err)
logx.WithContext(ctx).Infof("CoreProjectInfoDelete value:%v err:%v", string(body), err)
if pi == 0 {
return nil
}
Expand All @@ -340,13 +340,13 @@ func InitEventBus(svcCtx *svc.ServiceContext) {
return nil
})
logx.Must(err)
err = svcCtx.FastEvent.QueueSubscribe(eventBus.SysAreaInfoDelete, func(ctx context.Context, t time.Time, body []byte) error {
err = svcCtx.FastEvent.QueueSubscribe(eventBus.CoreAreaInfoDelete, func(ctx context.Context, t time.Time, body []byte) error {
var value application.IDs
err := json.Unmarshal(body, &value)
if err != nil {
return err
}
logx.WithContext(ctx).Infof("SysAreaInfoDelete value:%v err:%v", utils.Fmt(value), err)
logx.WithContext(ctx).Infof("CoreAreaInfoDelete value:%v err:%v", utils.Fmt(value), err)
if len(value.IDs) == 0 {
return nil
}
Expand Down
Loading

0 comments on commit 693273c

Please sign in to comment.