🐛 代理设置

This commit is contained in:
sugarBecomer
2025-11-07 19:45:57 +08:00
parent 97ab3a7a1d
commit d3869f68f8
+6 -3
View File
@@ -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 {