代码拉取完成,页面将自动刷新
package datamanagelogic
import (
"context"
"gitee.com/unitedrhino/core/service/syssvr/internal/logic"
"gitee.com/unitedrhino/core/service/syssvr/internal/repo/relationDB"
"gitee.com/unitedrhino/core/service/syssvr/internal/svc"
"gitee.com/unitedrhino/core/service/syssvr/pb/sys"
"gitee.com/unitedrhino/share/ctxs"
"gitee.com/unitedrhino/share/def"
"gitee.com/unitedrhino/share/errors"
"github.com/zeromicro/go-zero/core/logx"
)
type DataProjectIndexLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
UapDB *relationDB.DataProjectRepo
}
func NewDataProjectIndexLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DataProjectIndexLogic {
return &DataProjectIndexLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
UapDB: relationDB.NewDataProjectRepo(ctx),
}
}
func (l *DataProjectIndexLogic) DataProjectIndex(in *sys.DataProjectIndexReq) (*sys.DataProjectIndexResp, error) {
var (
list []*sys.DataProject
total int64
err error
)
uc := ctxs.GetUserCtx(l.ctx)
if in.ProjectID != 0 {
uc.ProjectID = in.ProjectID
} else {
in.ProjectID = uc.ProjectID
}
if !uc.IsAdmin && in.TargetType != def.TargetUser {
return nil, errors.Permissions.AddMsg("非管理员只能获取用户类型的")
}
if uc.AllProject {
in.ProjectID = 0
}
if in.ProjectID != 0 {
if uc.IsAdmin || uc.ProjectAuth[in.ProjectID] != nil {
in.ProjectID = in.ProjectID
}
}
filter := relationDB.DataProjectFilter{
ProjectID: in.ProjectID,
AuthType: in.AuthType,
Target: &relationDB.Target{
Type: in.TargetType,
ID: in.TargetID,
},
}
if in.ProjectID != 0 && uc.IsAdmin {
filter.ProjectID = in.ProjectID
}
total, err = l.UapDB.CountByFilter(l.ctx, filter)
if err != nil {
return nil, err
}
poArr, err := l.UapDB.FindByFilter(l.ctx, filter, logic.ToPageInfo(in.Page))
if err != nil {
return nil, err
}
list = make([]*sys.DataProject, 0, len(poArr))
for _, po := range poArr {
list = append(list, transProjectPoToPb(po))
}
return &sys.DataProjectIndexResp{List: list, Total: total}, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。