代码拉取完成,页面将自动刷新
package datamanagelogic
import (
"context"
"gitee.com/i-Things/core/service/syssvr/internal/repo/cache"
"gitee.com/i-Things/core/service/syssvr/internal/repo/relationDB"
"gitee.com/i-Things/core/service/syssvr/internal/svc"
"gitee.com/i-Things/core/service/syssvr/pb/sys"
"gitee.com/i-Things/share/ctxs"
"gitee.com/i-Things/share/def"
"gitee.com/i-Things/share/errors"
"github.com/zeromicro/go-zero/core/logx"
)
type DataProjectCreateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDataProjectCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DataProjectCreateLogic {
return &DataProjectCreateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DataProjectCreateLogic) DataProjectCreate(in *sys.DataProjectSaveReq) (*sys.Empty, error) {
if in.TargetID == 0 {
return nil, errors.Parameter.AddDetail(in.TargetID).WithMsg("TargetID参数必填")
}
uc := ctxs.GetUserCtx(l.ctx)
if in.ProjectID != 0 {
uc.ProjectID = in.ProjectID
} else {
in.ProjectID = uc.ProjectID
}
project, err := relationDB.NewProjectInfoRepo(l.ctx).FindOne(l.ctx, in.ProjectID)
if err != nil {
return nil, err
}
if !(uc.IsAdmin || uc.UserID == project.AdminUserID && in.TargetType != def.TargetRole) {
return nil, errors.Permissions.WithMsg("只有管理员才有权限授权")
}
err = relationDB.NewDataProjectRepo(l.ctx).Insert(l.ctx, &relationDB.SysDataProject{
ProjectID: in.ProjectID,
TargetType: in.TargetType,
TargetID: in.TargetID,
AuthType: in.AuthType,
})
if err != nil && errors.Cmp(err, errors.Duplicate) {
return nil, err
}
if in.TargetType == def.TargetUser {
cache.ClearProjectAuth(in.TargetID)
}
return &sys.Empty{}, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。