🐛 代理设置
This commit is contained in:
@@ -76,10 +76,13 @@ func (s *AgentServiceV1) Ban(ctx context.Context, req *v1.AgentBanReq) *utils.Re
|
||||
}
|
||||
|
||||
func (s *AgentServiceV1) Recharge(ctx context.Context, req *v1.AgentRechargeReq) *utils.Response[any] {
|
||||
// 参数校验
|
||||
user := db.Global.SysUser.Query().Where(sysuser.IDEQ(req.ID)).WithAgent().OnlyX(ctx)
|
||||
if !utils.IsAdminFromCtx(ctx) {
|
||||
currentUser := db.Global.SysUser.Query().Where(sysuser.ID(utils.GetUserInfoFromCtx(ctx).ID)).WithAgent().OnlyX(ctx)
|
||||
currentUser := utils.GetUserInfoFromCtx(ctx)
|
||||
// 参数校验
|
||||
user := db.Global.SysUser.Query().Where(sysuser.IDEQ(req.ID)).WithAgent().OnlyX(ctx)
|
||||
if user.Edges.Agent == nil {
|
||||
return utils.FailParam("用户不是代理")
|
||||
}
|
||||
// 判断是否是自己的下级代理
|
||||
parent := user.QueryParent().WithAgent().FirstX(ctx)
|
||||
if parent == nil || parent.ID != currentUser.ID {
|
||||
|
||||
Reference in New Issue
Block a user