func (ud *UserDelete) Exec(ctx context.Context) (int, error) {
	var (
		err      error
		affected int
	)
	if len(ud.hooks) == 0 {
		affected, err = ud.sqlExec(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*UserMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			ud.mutation = mutation
			affected, err = ud.sqlExec(ctx)
			mutation.done = true
			return affected, err
		})
		for i := len(ud.hooks) - 1; i >= 0; i-- {
			mut = ud.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, ud.mutation); err != nil {
			return 0, err
		}
	}
	return affected, err
}
Exec executes the deletion query and returns how many vertices were deleted.
package ent
import (
	"context"
	"fmt"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/go-kratos/beer-shop/app/user/service/internal/data/ent/predicate"
	"github.com/go-kratos/beer-shop/app/user/service/internal/data/ent/user"
)
type UserDelete struct {
	config
	hooks    []Hook
	mutation *UserMutation
}
func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
	ud.mutation.predicates = append(ud.mutation.predicates, ps...)
	return ud
}