37 Star 391 Fork 118

联犀/物联网iot模块

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
remoteConfigIndexLogic.go 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 22:13 . feat: 更新mod
package remoteconfiglogic
import (
"context"
"gitee.com/unitedrhino/things/service/dmsvr/internal/logic"
"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 RemoteConfigIndexLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
PrcDB *relationDB.ProductRemoteConfigRepo
}
func NewRemoteConfigIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoteConfigIndexLogic {
return &RemoteConfigIndexLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
PrcDB: relationDB.NewProductRemoteConfigRepo(ctx),
}
}
func (l *RemoteConfigIndexLogic) RemoteConfigIndex(in *dm.RemoteConfigIndexReq) (*dm.RemoteConfigIndexResp, error) {
f := relationDB.RemoteConfigFilter{ProductID: in.ProductID}
rcs, err := l.PrcDB.FindByFilter(l.ctx, f, logic.ToPageInfo(in.Page))
if err != nil {
return nil, err
}
list := make([]*dm.ProductRemoteConfig, 0, len(rcs))
for _, v := range rcs {
list = append(list, &dm.ProductRemoteConfig{
Id: v.ID,
ProductID: v.ProductID,
Content: v.Content,
CreatedTime: v.CreatedTime.Unix(),
})
}
total, err := l.PrcDB.CountByFilter(l.ctx, f)
if err != nil {
return nil, err
}
return &dm.RemoteConfigIndexResp{List: list, Total: total}, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unitedrhino/things.git
git@gitee.com:unitedrhino/things.git
unitedrhino
things
物联网iot模块
v1.0.0

搜索帮助