37 Star 391 Fork 118

联犀/物联网iot模块

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
deviceProfileIndexLogic.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 22:13 . feat: 更新mod
package devicemanagelogic
import (
"context"
"gitee.com/unitedrhino/share/devices"
"gitee.com/unitedrhino/share/utils"
"gitee.com/unitedrhino/things/service/dmsvr/internal/repo/relationDB"
"gitee.com/unitedrhino/things/service/dmsvr/internal/svc"
"gitee.com/unitedrhino/things/service/dmsvr/pb/dm"
"github.com/zeromicro/go-zero/core/logx"
)
type DeviceProfileIndexLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDeviceProfileIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeviceProfileIndexLogic {
return &DeviceProfileIndexLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DeviceProfileIndexLogic) DeviceProfileIndex(in *dm.DeviceProfileIndexReq) (*dm.DeviceProfileIndexResp, error) {
pos, err := relationDB.NewDeviceProfileRepo(l.ctx).FindByFilter(l.ctx, relationDB.DeviceProfileFilter{
Codes: in.Codes,
Device: devices.Core{
ProductID: in.Device.ProductID,
DeviceName: in.Device.DeviceName,
},
}, nil)
if err != nil {
return nil, err
}
var rets []*dm.DeviceProfile
for _, po := range pos {
ret := utils.Copy[dm.DeviceProfile](po)
ret.Device = &dm.DeviceCore{
ProductID: po.ProductID,
DeviceName: po.DeviceName,
}
rets = append(rets, ret)
}
return &dm.DeviceProfileIndexResp{Profiles: rets}, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unitedrhino/things.git
git@gitee.com:unitedrhino/things.git
unitedrhino
things
物联网iot模块
v1.0.4

搜索帮助