feat: support bind user to tenants

This commit is contained in:
Rogee
2024-12-12 19:26:48 +08:00
parent 259b334711
commit 8a1477e991
7 changed files with 113 additions and 2 deletions

View File

@@ -396,3 +396,20 @@ func (svc *Service) GetTenantUserBalance(ctx context.Context, tenantID, userID i
}
return result.Balance, nil
}
// SetTenantBindUserID
func (svc *Service) SetTenantBindUserID(ctx context.Context, tenantID, adminUserID int64) error {
log := svc.log.WithField("method", "SetTenantBindUserID")
tbl := table.Tenants
stmt := tbl.
UPDATE(tbl.BindUserID).
SET(Int64(adminUserID)).
WHERE(tbl.ID.EQ(Int64(tenantID)))
log.Debug(stmt.DebugSql())
if _, err := stmt.ExecContext(ctx, db.FromContext(ctx, svc.db)); err != nil {
return errors.Wrap(err, "failed to set tenant admin user id")
}
return nil
}