31 Star 294 Fork 112

联犀/things

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
propertyLatestIndexLogic.go 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 22:13 . feat: 更新mod
package msg
import (
"context"
"gitee.com/unitedrhino/share/ctxs"
"gitee.com/unitedrhino/share/errors"
"gitee.com/unitedrhino/share/utils"
"gitee.com/unitedrhino/things/service/apisvr/internal/svc"
"gitee.com/unitedrhino/things/service/apisvr/internal/types"
"gitee.com/unitedrhino/things/service/dmsvr/pb/dm"
"github.com/zeromicro/go-zero/core/logx"
)
type PropertyLatestIndexLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewPropertyLatestIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PropertyLatestIndexLogic {
return &PropertyLatestIndexLogic{
Logger: logx.WithContext(ctx),
ctx: ctxs.WithDefaultRoot(ctx),
svcCtx: svcCtx,
}
}
func (l *PropertyLatestIndexLogic) PropertyLatestIndex(req *types.DeviceMsgPropertyLogLatestIndexReq) (resp *types.DeviceMsgPropertyIndexResp, err error) {
dmResp, err := l.svcCtx.DeviceMsg.PropertyLogLatestIndex(l.ctx, &dm.PropertyLogLatestIndexReq{
DeviceName: req.DeviceName,
ProductID: req.ProductID,
DataIDs: req.DataIDs,
})
if err != nil {
er := errors.Fmt(err)
l.Errorf("%s.rpc.GetDeviceData req=%v err=%+v", utils.FuncName(), req, er)
return nil, er
}
info := make([]*types.DeviceMsgPropertyLogInfo, 0, len(dmResp.List))
for _, v := range dmResp.List {
info = append(info, &types.DeviceMsgPropertyLogInfo{
Timestamp: v.Timestamp,
DataID: v.DataID,
Value: v.Value,
})
}
return &types.DeviceMsgPropertyIndexResp{
Total: dmResp.Total,
List: info,
}, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unitedrhino/things.git
git@gitee.com:unitedrhino/things.git
unitedrhino
things
things
v1.0.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385