You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/oauthprovider"
"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/predicate"
)
// OauthProviderDelete is the builder for deleting a OauthProvider entity.
type OauthProviderDelete struct {
config
hooks []Hook
mutation *OauthProviderMutation
}
// Where appends a list predicates to the OauthProviderDelete builder.
func (opd *OauthProviderDelete) Where(ps ...predicate.OauthProvider) *OauthProviderDelete {
opd.mutation.Where(ps...)
return opd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (opd *OauthProviderDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, opd.sqlExec, opd.mutation, opd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (opd *OauthProviderDelete) ExecX(ctx context.Context) int {
n, err := opd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (opd *OauthProviderDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(oauthprovider.Table, sqlgraph.NewFieldSpec(oauthprovider.FieldID, field.TypeInt64))
if ps := opd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, opd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
opd.mutation.done = true
return affected, err
}
// OauthProviderDeleteOne is the builder for deleting a single OauthProvider entity.
type OauthProviderDeleteOne struct {
opd *OauthProviderDelete
}
// Where appends a list predicates to the OauthProviderDelete builder.
func (opdo *OauthProviderDeleteOne) Where(ps ...predicate.OauthProvider) *OauthProviderDeleteOne {
opdo.opd.mutation.Where(ps...)
return opdo
}
// Exec executes the deletion query.
func (opdo *OauthProviderDeleteOne) Exec(ctx context.Context) error {
n, err := opdo.opd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{oauthprovider.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (opdo *OauthProviderDeleteOne) ExecX(ctx context.Context) {
if err := opdo.Exec(ctx); err != nil {
panic(err)
}
}