2 Star 2 Fork 4

联犀/core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dataAreaIndexLogic.go 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
杨磊 提交于 2024-10-10 21:56 . feat: 更新mod
package datamanagelogic
import (
"context"
"gitee.com/unitedrhino/core/service/syssvr/internal/logic"
"gitee.com/unitedrhino/core/service/syssvr/internal/repo/relationDB"
"gitee.com/unitedrhino/share/ctxs"
"gitee.com/unitedrhino/core/service/syssvr/internal/svc"
"gitee.com/unitedrhino/core/service/syssvr/pb/sys"
"github.com/zeromicro/go-zero/core/logx"
)
type DataAreaIndexLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
UaaDB *relationDB.DataAreaRepo
}
func NewDataAreaIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DataAreaIndexLogic {
return &DataAreaIndexLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
UaaDB: relationDB.NewDataAreaRepo(ctx),
}
}
func (l *DataAreaIndexLogic) DataAreaIndex(in *sys.DataAreaIndexReq) (*sys.DataAreaIndexResp, error) {
var (
list []*sys.DataArea
total int64
err error
)
uc := ctxs.GetUserCtx(l.ctx)
if in.ProjectID != 0 {
uc.ProjectID = in.ProjectID
} else {
in.ProjectID = uc.ProjectID
}
filter := relationDB.DataAreaFilter{
Targets: []*relationDB.Target{{Type: in.TargetType, ID: in.TargetID}},
ProjectID: in.ProjectID,
}
total, err = l.UaaDB.CountByFilter(l.ctx, filter)
if err != nil {
return nil, err
}
poArr, err := l.UaaDB.FindByFilter(l.ctx, filter, logic.ToPageInfo(in.Page))
if err != nil {
return nil, err
}
list = make([]*sys.DataArea, 0, len(poArr))
for _, po := range poArr {
list = append(list, transAreaPoToPb(po))
}
return &sys.DataAreaIndexResp{List: list, Total: total}, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/unitedrhino/core.git
git@gitee.com:unitedrhino/core.git
unitedrhino
core
core
v1.0.1

搜索帮助