37 Star 391 Fork 118

联犀/物联网iot模块

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
config.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 22:13 . feat: 更新mod
package deviceMsgEvent
import (
"context"
"gitee.com/unitedrhino/share/domain/deviceMsg"
"gitee.com/unitedrhino/share/utils"
remoteconfiglogic "gitee.com/unitedrhino/things/service/dmsvr/internal/logic/remoteconfig"
"gitee.com/unitedrhino/things/service/dmsvr/internal/svc"
"gitee.com/unitedrhino/things/service/dmsvr/pb/dm"
"github.com/zeromicro/go-zero/core/logx"
)
type ConfigLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ConfigLogic {
return &ConfigLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ConfigLogic) Handle(msg *deviceMsg.PublishMsg) (respMsg *deviceMsg.PublishMsg, err error) {
l.Infof("%s req=%+v", utils.FuncName(), msg)
//获取最新配置
resp1, err := remoteconfiglogic.NewRemoteConfigLastReadLogic(l.ctx, l.svcCtx).RemoteConfigLastRead(&dm.RemoteConfigLastReadReq{
ProductID: msg.ProductID,
})
resp := &deviceMsg.CommonMsg{
Method: deviceMsg.RemoteConfigReply,
//Timestamp: time.Now().UnixMilli(),
Data: resp1.Info.Content,
}
return &deviceMsg.PublishMsg{
Handle: msg.Handle,
Type: msg.Type,
Payload: resp.Bytes(),
ProductID: msg.ProductID,
DeviceName: msg.DeviceName,
ProtocolCode: msg.ProtocolCode,
}, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unitedrhino/things.git
git@gitee.com:unitedrhino/things.git
unitedrhino
things
物联网iot模块
v1.0.4

搜索帮助