feat: support bind user to tenants
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user