// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "log" "reflect" "mingyang-admin-pay/rpc/ent/migrate" "mingyang-admin-pay/rpc/ent/app" "mingyang-admin-pay/rpc/ent/paychannel" "mingyang-admin-pay/rpc/ent/paynotifylog" "mingyang-admin-pay/rpc/ent/paynotifytask" "mingyang-admin-pay/rpc/ent/payorder" "mingyang-admin-pay/rpc/ent/payorderextension" "mingyang-admin-pay/rpc/ent/payrefund" "entgo.io/ent" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" stdsql "database/sql" ) // Client is the client that holds all ent builders. type Client struct { config // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema // App is the client for interacting with the App builders. App *AppClient // PayChannel is the client for interacting with the PayChannel builders. PayChannel *PayChannelClient // PayNotifyLog is the client for interacting with the PayNotifyLog builders. PayNotifyLog *PayNotifyLogClient // PayNotifyTask is the client for interacting with the PayNotifyTask builders. PayNotifyTask *PayNotifyTaskClient // PayOrder is the client for interacting with the PayOrder builders. PayOrder *PayOrderClient // PayOrderExtension is the client for interacting with the PayOrderExtension builders. PayOrderExtension *PayOrderExtensionClient // PayRefund is the client for interacting with the PayRefund builders. PayRefund *PayRefundClient } // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { client := &Client{config: newConfig(opts...)} client.init() return client } func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.App = NewAppClient(c.config) c.PayChannel = NewPayChannelClient(c.config) c.PayNotifyLog = NewPayNotifyLogClient(c.config) c.PayNotifyTask = NewPayNotifyTaskClient(c.config) c.PayOrder = NewPayOrderClient(c.config) c.PayOrderExtension = NewPayOrderExtensionClient(c.config) c.PayRefund = NewPayRefundClient(c.config) } type ( // config is the configuration for the client and its builder. config struct { // driver used for executing database requests. driver dialect.Driver // debug enable a debug logging. debug bool // log used for logging on debug mode. log func(...any) // hooks to execute on mutations. hooks *hooks // interceptors to execute on queries. inters *inters } // Option function to configure the client. Option func(*config) ) // newConfig creates a new config for the client. func newConfig(opts ...Option) config { cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} cfg.options(opts...) return cfg } // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { opt(c) } if c.debug { c.driver = dialect.Debug(c.driver, c.log) } } // Debug enables debug logging on the ent.Driver. func Debug() Option { return func(c *config) { c.debug = true } } // Log sets the logging function for debug mode. func Log(fn func(...any)) Option { return func(c *config) { c.log = fn } } // Driver configures the client driver. func Driver(driver dialect.Driver) Option { return func(c *config) { c.driver = driver } } // Open opens a database/sql.DB specified by the driver name and // the data source name, and returns a new client attached to it. // Optional parameters can be added for configuring the client. func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { switch driverName { case dialect.MySQL, dialect.Postgres, dialect.SQLite: drv, err := sql.Open(driverName, dataSourceName) if err != nil { return nil, err } return NewClient(append(options, Driver(drv))...), nil default: return nil, fmt.Errorf("unsupported driver: %q", driverName) } } // ErrTxStarted is returned when trying to start a new transaction from a transactional client. var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") // Tx returns a new transactional client. The provided context // is used until the transaction is committed or rolled back. func (c *Client) Tx(ctx context.Context) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { return nil, fmt.Errorf("ent: starting a transaction: %w", err) } cfg := c.config cfg.driver = tx return &Tx{ ctx: ctx, config: cfg, App: NewAppClient(cfg), PayChannel: NewPayChannelClient(cfg), PayNotifyLog: NewPayNotifyLogClient(cfg), PayNotifyTask: NewPayNotifyTaskClient(cfg), PayOrder: NewPayOrderClient(cfg), PayOrderExtension: NewPayOrderExtensionClient(cfg), PayRefund: NewPayRefundClient(cfg), }, nil } // BeginTx returns a transactional client with specified options. func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { if _, ok := c.driver.(*txDriver); ok { return nil, errors.New("ent: cannot start a transaction within a transaction") } tx, err := c.driver.(interface { BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) }).BeginTx(ctx, opts) if err != nil { return nil, fmt.Errorf("ent: starting a transaction: %w", err) } cfg := c.config cfg.driver = &txDriver{tx: tx, drv: c.driver} return &Tx{ ctx: ctx, config: cfg, App: NewAppClient(cfg), PayChannel: NewPayChannelClient(cfg), PayNotifyLog: NewPayNotifyLogClient(cfg), PayNotifyTask: NewPayNotifyTaskClient(cfg), PayOrder: NewPayOrderClient(cfg), PayOrderExtension: NewPayOrderExtensionClient(cfg), PayRefund: NewPayRefundClient(cfg), }, nil } // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). // App. // Query(). // Count(ctx) func (c *Client) Debug() *Client { if c.debug { return c } cfg := c.config cfg.driver = dialect.Debug(c.driver, c.log) client := &Client{config: cfg} client.init() return client } // Close closes the database connection and prevents new queries from starting. func (c *Client) Close() error { return c.driver.Close() } // Use adds the mutation hooks to all the entity clients. // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.App, c.PayChannel, c.PayNotifyLog, c.PayNotifyTask, c.PayOrder, c.PayOrderExtension, c.PayRefund, } { n.Use(hooks...) } } // Intercept adds the query interceptors to all the entity clients. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.App, c.PayChannel, c.PayNotifyLog, c.PayNotifyTask, c.PayOrder, c.PayOrderExtension, c.PayRefund, } { n.Intercept(interceptors...) } } // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { case *AppMutation: return c.App.mutate(ctx, m) case *PayChannelMutation: return c.PayChannel.mutate(ctx, m) case *PayNotifyLogMutation: return c.PayNotifyLog.mutate(ctx, m) case *PayNotifyTaskMutation: return c.PayNotifyTask.mutate(ctx, m) case *PayOrderMutation: return c.PayOrder.mutate(ctx, m) case *PayOrderExtensionMutation: return c.PayOrderExtension.mutate(ctx, m) case *PayRefundMutation: return c.PayRefund.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } } // AppClient is a client for the App schema. type AppClient struct { config } // NewAppClient returns a client for the App from the given config. func NewAppClient(c config) *AppClient { return &AppClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `app.Hooks(f(g(h())))`. func (c *AppClient) Use(hooks ...Hook) { c.hooks.App = append(c.hooks.App, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `app.Intercept(f(g(h())))`. func (c *AppClient) Intercept(interceptors ...Interceptor) { c.inters.App = append(c.inters.App, interceptors...) } // Create returns a builder for creating a App entity. func (c *AppClient) Create() *AppCreate { mutation := newAppMutation(c.config, OpCreate) return &AppCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of App entities. func (c *AppClient) CreateBulk(builders ...*AppCreate) *AppCreateBulk { return &AppCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *AppClient) MapCreateBulk(slice any, setFunc func(*AppCreate, int)) *AppCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &AppCreateBulk{err: fmt.Errorf("calling to AppClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*AppCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &AppCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for App. func (c *AppClient) Update() *AppUpdate { mutation := newAppMutation(c.config, OpUpdate) return &AppUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *AppClient) UpdateOne(_m *App) *AppUpdateOne { mutation := newAppMutation(c.config, OpUpdateOne, withApp(_m)) return &AppUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *AppClient) UpdateOneID(id uint64) *AppUpdateOne { mutation := newAppMutation(c.config, OpUpdateOne, withAppID(id)) return &AppUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for App. func (c *AppClient) Delete() *AppDelete { mutation := newAppMutation(c.config, OpDelete) return &AppDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *AppClient) DeleteOne(_m *App) *AppDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *AppClient) DeleteOneID(id uint64) *AppDeleteOne { builder := c.Delete().Where(app.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &AppDeleteOne{builder} } // Query returns a query builder for App. func (c *AppClient) Query() *AppQuery { return &AppQuery{ config: c.config, ctx: &QueryContext{Type: TypeApp}, inters: c.Interceptors(), } } // Get returns a App entity by its id. func (c *AppClient) Get(ctx context.Context, id uint64) (*App, error) { return c.Query().Where(app.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *AppClient) GetX(ctx context.Context, id uint64) *App { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryChannel queries the channel edge of a App. func (c *AppClient) QueryChannel(_m *App) *PayChannelQuery { query := (&PayChannelClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(app.Table, app.FieldID, id), sqlgraph.To(paychannel.Table, paychannel.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, app.ChannelTable, app.ChannelColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryNotifyTask queries the notify_task edge of a App. func (c *AppClient) QueryNotifyTask(_m *App) *PayNotifyTaskQuery { query := (&PayNotifyTaskClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(app.Table, app.FieldID, id), sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, app.NotifyTaskTable, app.NotifyTaskColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *AppClient) Hooks() []Hook { return c.hooks.App } // Interceptors returns the client interceptors. func (c *AppClient) Interceptors() []Interceptor { return c.inters.App } func (c *AppClient) mutate(ctx context.Context, m *AppMutation) (Value, error) { switch m.Op() { case OpCreate: return (&AppCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&AppUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&AppUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&AppDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown App mutation op: %q", m.Op()) } } // PayChannelClient is a client for the PayChannel schema. type PayChannelClient struct { config } // NewPayChannelClient returns a client for the PayChannel from the given config. func NewPayChannelClient(c config) *PayChannelClient { return &PayChannelClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `paychannel.Hooks(f(g(h())))`. func (c *PayChannelClient) Use(hooks ...Hook) { c.hooks.PayChannel = append(c.hooks.PayChannel, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `paychannel.Intercept(f(g(h())))`. func (c *PayChannelClient) Intercept(interceptors ...Interceptor) { c.inters.PayChannel = append(c.inters.PayChannel, interceptors...) } // Create returns a builder for creating a PayChannel entity. func (c *PayChannelClient) Create() *PayChannelCreate { mutation := newPayChannelMutation(c.config, OpCreate) return &PayChannelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PayChannel entities. func (c *PayChannelClient) CreateBulk(builders ...*PayChannelCreate) *PayChannelCreateBulk { return &PayChannelCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PayChannelClient) MapCreateBulk(slice any, setFunc func(*PayChannelCreate, int)) *PayChannelCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PayChannelCreateBulk{err: fmt.Errorf("calling to PayChannelClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PayChannelCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PayChannelCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PayChannel. func (c *PayChannelClient) Update() *PayChannelUpdate { mutation := newPayChannelMutation(c.config, OpUpdate) return &PayChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PayChannelClient) UpdateOne(_m *PayChannel) *PayChannelUpdateOne { mutation := newPayChannelMutation(c.config, OpUpdateOne, withPayChannel(_m)) return &PayChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PayChannelClient) UpdateOneID(id uint64) *PayChannelUpdateOne { mutation := newPayChannelMutation(c.config, OpUpdateOne, withPayChannelID(id)) return &PayChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PayChannel. func (c *PayChannelClient) Delete() *PayChannelDelete { mutation := newPayChannelMutation(c.config, OpDelete) return &PayChannelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PayChannelClient) DeleteOne(_m *PayChannel) *PayChannelDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PayChannelClient) DeleteOneID(id uint64) *PayChannelDeleteOne { builder := c.Delete().Where(paychannel.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PayChannelDeleteOne{builder} } // Query returns a query builder for PayChannel. func (c *PayChannelClient) Query() *PayChannelQuery { return &PayChannelQuery{ config: c.config, ctx: &QueryContext{Type: TypePayChannel}, inters: c.Interceptors(), } } // Get returns a PayChannel entity by its id. func (c *PayChannelClient) Get(ctx context.Context, id uint64) (*PayChannel, error) { return c.Query().Where(paychannel.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PayChannelClient) GetX(ctx context.Context, id uint64) *PayChannel { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryOrders queries the orders edge of a PayChannel. func (c *PayChannelClient) QueryOrders(_m *PayChannel) *PayOrderQuery { query := (&PayOrderClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paychannel.Table, paychannel.FieldID, id), sqlgraph.To(payorder.Table, payorder.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, paychannel.OrdersTable, paychannel.OrdersColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryOrdersExtension queries the orders_extension edge of a PayChannel. func (c *PayChannelClient) QueryOrdersExtension(_m *PayChannel) *PayOrderExtensionQuery { query := (&PayOrderExtensionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paychannel.Table, paychannel.FieldID, id), sqlgraph.To(payorderextension.Table, payorderextension.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, paychannel.OrdersExtensionTable, paychannel.OrdersExtensionColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRefund queries the refund edge of a PayChannel. func (c *PayChannelClient) QueryRefund(_m *PayChannel) *PayRefundQuery { query := (&PayRefundClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paychannel.Table, paychannel.FieldID, id), sqlgraph.To(payrefund.Table, payrefund.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, paychannel.RefundTable, paychannel.RefundColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryApp queries the app edge of a PayChannel. func (c *PayChannelClient) QueryApp(_m *PayChannel) *AppQuery { query := (&AppClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paychannel.Table, paychannel.FieldID, id), sqlgraph.To(app.Table, app.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, paychannel.AppTable, paychannel.AppColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PayChannelClient) Hooks() []Hook { return c.hooks.PayChannel } // Interceptors returns the client interceptors. func (c *PayChannelClient) Interceptors() []Interceptor { return c.inters.PayChannel } func (c *PayChannelClient) mutate(ctx context.Context, m *PayChannelMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PayChannelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PayChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PayChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PayChannelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PayChannel mutation op: %q", m.Op()) } } // PayNotifyLogClient is a client for the PayNotifyLog schema. type PayNotifyLogClient struct { config } // NewPayNotifyLogClient returns a client for the PayNotifyLog from the given config. func NewPayNotifyLogClient(c config) *PayNotifyLogClient { return &PayNotifyLogClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `paynotifylog.Hooks(f(g(h())))`. func (c *PayNotifyLogClient) Use(hooks ...Hook) { c.hooks.PayNotifyLog = append(c.hooks.PayNotifyLog, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `paynotifylog.Intercept(f(g(h())))`. func (c *PayNotifyLogClient) Intercept(interceptors ...Interceptor) { c.inters.PayNotifyLog = append(c.inters.PayNotifyLog, interceptors...) } // Create returns a builder for creating a PayNotifyLog entity. func (c *PayNotifyLogClient) Create() *PayNotifyLogCreate { mutation := newPayNotifyLogMutation(c.config, OpCreate) return &PayNotifyLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PayNotifyLog entities. func (c *PayNotifyLogClient) CreateBulk(builders ...*PayNotifyLogCreate) *PayNotifyLogCreateBulk { return &PayNotifyLogCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PayNotifyLogClient) MapCreateBulk(slice any, setFunc func(*PayNotifyLogCreate, int)) *PayNotifyLogCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PayNotifyLogCreateBulk{err: fmt.Errorf("calling to PayNotifyLogClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PayNotifyLogCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PayNotifyLogCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PayNotifyLog. func (c *PayNotifyLogClient) Update() *PayNotifyLogUpdate { mutation := newPayNotifyLogMutation(c.config, OpUpdate) return &PayNotifyLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PayNotifyLogClient) UpdateOne(_m *PayNotifyLog) *PayNotifyLogUpdateOne { mutation := newPayNotifyLogMutation(c.config, OpUpdateOne, withPayNotifyLog(_m)) return &PayNotifyLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PayNotifyLogClient) UpdateOneID(id uint64) *PayNotifyLogUpdateOne { mutation := newPayNotifyLogMutation(c.config, OpUpdateOne, withPayNotifyLogID(id)) return &PayNotifyLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PayNotifyLog. func (c *PayNotifyLogClient) Delete() *PayNotifyLogDelete { mutation := newPayNotifyLogMutation(c.config, OpDelete) return &PayNotifyLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PayNotifyLogClient) DeleteOne(_m *PayNotifyLog) *PayNotifyLogDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PayNotifyLogClient) DeleteOneID(id uint64) *PayNotifyLogDeleteOne { builder := c.Delete().Where(paynotifylog.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PayNotifyLogDeleteOne{builder} } // Query returns a query builder for PayNotifyLog. func (c *PayNotifyLogClient) Query() *PayNotifyLogQuery { return &PayNotifyLogQuery{ config: c.config, ctx: &QueryContext{Type: TypePayNotifyLog}, inters: c.Interceptors(), } } // Get returns a PayNotifyLog entity by its id. func (c *PayNotifyLogClient) Get(ctx context.Context, id uint64) (*PayNotifyLog, error) { return c.Query().Where(paynotifylog.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PayNotifyLogClient) GetX(ctx context.Context, id uint64) *PayNotifyLog { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryTask queries the task edge of a PayNotifyLog. func (c *PayNotifyLogClient) QueryTask(_m *PayNotifyLog) *PayNotifyTaskQuery { query := (&PayNotifyTaskClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paynotifylog.Table, paynotifylog.FieldID, id), sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, paynotifylog.TaskTable, paynotifylog.TaskColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PayNotifyLogClient) Hooks() []Hook { return c.hooks.PayNotifyLog } // Interceptors returns the client interceptors. func (c *PayNotifyLogClient) Interceptors() []Interceptor { return c.inters.PayNotifyLog } func (c *PayNotifyLogClient) mutate(ctx context.Context, m *PayNotifyLogMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PayNotifyLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PayNotifyLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PayNotifyLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PayNotifyLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PayNotifyLog mutation op: %q", m.Op()) } } // PayNotifyTaskClient is a client for the PayNotifyTask schema. type PayNotifyTaskClient struct { config } // NewPayNotifyTaskClient returns a client for the PayNotifyTask from the given config. func NewPayNotifyTaskClient(c config) *PayNotifyTaskClient { return &PayNotifyTaskClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `paynotifytask.Hooks(f(g(h())))`. func (c *PayNotifyTaskClient) Use(hooks ...Hook) { c.hooks.PayNotifyTask = append(c.hooks.PayNotifyTask, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `paynotifytask.Intercept(f(g(h())))`. func (c *PayNotifyTaskClient) Intercept(interceptors ...Interceptor) { c.inters.PayNotifyTask = append(c.inters.PayNotifyTask, interceptors...) } // Create returns a builder for creating a PayNotifyTask entity. func (c *PayNotifyTaskClient) Create() *PayNotifyTaskCreate { mutation := newPayNotifyTaskMutation(c.config, OpCreate) return &PayNotifyTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PayNotifyTask entities. func (c *PayNotifyTaskClient) CreateBulk(builders ...*PayNotifyTaskCreate) *PayNotifyTaskCreateBulk { return &PayNotifyTaskCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PayNotifyTaskClient) MapCreateBulk(slice any, setFunc func(*PayNotifyTaskCreate, int)) *PayNotifyTaskCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PayNotifyTaskCreateBulk{err: fmt.Errorf("calling to PayNotifyTaskClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PayNotifyTaskCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PayNotifyTaskCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PayNotifyTask. func (c *PayNotifyTaskClient) Update() *PayNotifyTaskUpdate { mutation := newPayNotifyTaskMutation(c.config, OpUpdate) return &PayNotifyTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PayNotifyTaskClient) UpdateOne(_m *PayNotifyTask) *PayNotifyTaskUpdateOne { mutation := newPayNotifyTaskMutation(c.config, OpUpdateOne, withPayNotifyTask(_m)) return &PayNotifyTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PayNotifyTaskClient) UpdateOneID(id uint64) *PayNotifyTaskUpdateOne { mutation := newPayNotifyTaskMutation(c.config, OpUpdateOne, withPayNotifyTaskID(id)) return &PayNotifyTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PayNotifyTask. func (c *PayNotifyTaskClient) Delete() *PayNotifyTaskDelete { mutation := newPayNotifyTaskMutation(c.config, OpDelete) return &PayNotifyTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PayNotifyTaskClient) DeleteOne(_m *PayNotifyTask) *PayNotifyTaskDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PayNotifyTaskClient) DeleteOneID(id uint64) *PayNotifyTaskDeleteOne { builder := c.Delete().Where(paynotifytask.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PayNotifyTaskDeleteOne{builder} } // Query returns a query builder for PayNotifyTask. func (c *PayNotifyTaskClient) Query() *PayNotifyTaskQuery { return &PayNotifyTaskQuery{ config: c.config, ctx: &QueryContext{Type: TypePayNotifyTask}, inters: c.Interceptors(), } } // Get returns a PayNotifyTask entity by its id. func (c *PayNotifyTaskClient) Get(ctx context.Context, id uint64) (*PayNotifyTask, error) { return c.Query().Where(paynotifytask.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PayNotifyTaskClient) GetX(ctx context.Context, id uint64) *PayNotifyTask { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryApp queries the app edge of a PayNotifyTask. func (c *PayNotifyTaskClient) QueryApp(_m *PayNotifyTask) *AppQuery { query := (&AppClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, id), sqlgraph.To(app.Table, app.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, paynotifytask.AppTable, paynotifytask.AppColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryOrder queries the order edge of a PayNotifyTask. func (c *PayNotifyTaskClient) QueryOrder(_m *PayNotifyTask) *PayOrderQuery { query := (&PayOrderClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, id), sqlgraph.To(payorder.Table, payorder.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, paynotifytask.OrderTable, paynotifytask.OrderColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryNotifyLog queries the notify_log edge of a PayNotifyTask. func (c *PayNotifyTaskClient) QueryNotifyLog(_m *PayNotifyTask) *PayNotifyLogQuery { query := (&PayNotifyLogClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, id), sqlgraph.To(paynotifylog.Table, paynotifylog.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, paynotifytask.NotifyLogTable, paynotifytask.NotifyLogColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PayNotifyTaskClient) Hooks() []Hook { return c.hooks.PayNotifyTask } // Interceptors returns the client interceptors. func (c *PayNotifyTaskClient) Interceptors() []Interceptor { return c.inters.PayNotifyTask } func (c *PayNotifyTaskClient) mutate(ctx context.Context, m *PayNotifyTaskMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PayNotifyTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PayNotifyTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PayNotifyTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PayNotifyTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PayNotifyTask mutation op: %q", m.Op()) } } // PayOrderClient is a client for the PayOrder schema. type PayOrderClient struct { config } // NewPayOrderClient returns a client for the PayOrder from the given config. func NewPayOrderClient(c config) *PayOrderClient { return &PayOrderClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `payorder.Hooks(f(g(h())))`. func (c *PayOrderClient) Use(hooks ...Hook) { c.hooks.PayOrder = append(c.hooks.PayOrder, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `payorder.Intercept(f(g(h())))`. func (c *PayOrderClient) Intercept(interceptors ...Interceptor) { c.inters.PayOrder = append(c.inters.PayOrder, interceptors...) } // Create returns a builder for creating a PayOrder entity. func (c *PayOrderClient) Create() *PayOrderCreate { mutation := newPayOrderMutation(c.config, OpCreate) return &PayOrderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PayOrder entities. func (c *PayOrderClient) CreateBulk(builders ...*PayOrderCreate) *PayOrderCreateBulk { return &PayOrderCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PayOrderClient) MapCreateBulk(slice any, setFunc func(*PayOrderCreate, int)) *PayOrderCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PayOrderCreateBulk{err: fmt.Errorf("calling to PayOrderClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PayOrderCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PayOrderCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PayOrder. func (c *PayOrderClient) Update() *PayOrderUpdate { mutation := newPayOrderMutation(c.config, OpUpdate) return &PayOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PayOrderClient) UpdateOne(_m *PayOrder) *PayOrderUpdateOne { mutation := newPayOrderMutation(c.config, OpUpdateOne, withPayOrder(_m)) return &PayOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PayOrderClient) UpdateOneID(id uint64) *PayOrderUpdateOne { mutation := newPayOrderMutation(c.config, OpUpdateOne, withPayOrderID(id)) return &PayOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PayOrder. func (c *PayOrderClient) Delete() *PayOrderDelete { mutation := newPayOrderMutation(c.config, OpDelete) return &PayOrderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PayOrderClient) DeleteOne(_m *PayOrder) *PayOrderDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PayOrderClient) DeleteOneID(id uint64) *PayOrderDeleteOne { builder := c.Delete().Where(payorder.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PayOrderDeleteOne{builder} } // Query returns a query builder for PayOrder. func (c *PayOrderClient) Query() *PayOrderQuery { return &PayOrderQuery{ config: c.config, ctx: &QueryContext{Type: TypePayOrder}, inters: c.Interceptors(), } } // Get returns a PayOrder entity by its id. func (c *PayOrderClient) Get(ctx context.Context, id uint64) (*PayOrder, error) { return c.Query().Where(payorder.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PayOrderClient) GetX(ctx context.Context, id uint64) *PayOrder { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryChannel queries the channel edge of a PayOrder. func (c *PayOrderClient) QueryChannel(_m *PayOrder) *PayChannelQuery { query := (&PayChannelClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payorder.Table, payorder.FieldID, id), sqlgraph.To(paychannel.Table, paychannel.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, payorder.ChannelTable, payorder.ChannelColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryOrdersExtension queries the orders_extension edge of a PayOrder. func (c *PayOrderClient) QueryOrdersExtension(_m *PayOrder) *PayOrderExtensionQuery { query := (&PayOrderExtensionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payorder.Table, payorder.FieldID, id), sqlgraph.To(payorderextension.Table, payorderextension.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, payorder.OrdersExtensionTable, payorder.OrdersExtensionColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryNotifyTask queries the notify_task edge of a PayOrder. func (c *PayOrderClient) QueryNotifyTask(_m *PayOrder) *PayNotifyTaskQuery { query := (&PayNotifyTaskClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payorder.Table, payorder.FieldID, id), sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, payorder.NotifyTaskTable, payorder.NotifyTaskColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRefund queries the refund edge of a PayOrder. func (c *PayOrderClient) QueryRefund(_m *PayOrder) *PayRefundQuery { query := (&PayRefundClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payorder.Table, payorder.FieldID, id), sqlgraph.To(payrefund.Table, payrefund.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, payorder.RefundTable, payorder.RefundColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PayOrderClient) Hooks() []Hook { return c.hooks.PayOrder } // Interceptors returns the client interceptors. func (c *PayOrderClient) Interceptors() []Interceptor { return c.inters.PayOrder } func (c *PayOrderClient) mutate(ctx context.Context, m *PayOrderMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PayOrderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PayOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PayOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PayOrderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PayOrder mutation op: %q", m.Op()) } } // PayOrderExtensionClient is a client for the PayOrderExtension schema. type PayOrderExtensionClient struct { config } // NewPayOrderExtensionClient returns a client for the PayOrderExtension from the given config. func NewPayOrderExtensionClient(c config) *PayOrderExtensionClient { return &PayOrderExtensionClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `payorderextension.Hooks(f(g(h())))`. func (c *PayOrderExtensionClient) Use(hooks ...Hook) { c.hooks.PayOrderExtension = append(c.hooks.PayOrderExtension, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `payorderextension.Intercept(f(g(h())))`. func (c *PayOrderExtensionClient) Intercept(interceptors ...Interceptor) { c.inters.PayOrderExtension = append(c.inters.PayOrderExtension, interceptors...) } // Create returns a builder for creating a PayOrderExtension entity. func (c *PayOrderExtensionClient) Create() *PayOrderExtensionCreate { mutation := newPayOrderExtensionMutation(c.config, OpCreate) return &PayOrderExtensionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PayOrderExtension entities. func (c *PayOrderExtensionClient) CreateBulk(builders ...*PayOrderExtensionCreate) *PayOrderExtensionCreateBulk { return &PayOrderExtensionCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PayOrderExtensionClient) MapCreateBulk(slice any, setFunc func(*PayOrderExtensionCreate, int)) *PayOrderExtensionCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PayOrderExtensionCreateBulk{err: fmt.Errorf("calling to PayOrderExtensionClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PayOrderExtensionCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PayOrderExtensionCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PayOrderExtension. func (c *PayOrderExtensionClient) Update() *PayOrderExtensionUpdate { mutation := newPayOrderExtensionMutation(c.config, OpUpdate) return &PayOrderExtensionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PayOrderExtensionClient) UpdateOne(_m *PayOrderExtension) *PayOrderExtensionUpdateOne { mutation := newPayOrderExtensionMutation(c.config, OpUpdateOne, withPayOrderExtension(_m)) return &PayOrderExtensionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PayOrderExtensionClient) UpdateOneID(id uint64) *PayOrderExtensionUpdateOne { mutation := newPayOrderExtensionMutation(c.config, OpUpdateOne, withPayOrderExtensionID(id)) return &PayOrderExtensionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PayOrderExtension. func (c *PayOrderExtensionClient) Delete() *PayOrderExtensionDelete { mutation := newPayOrderExtensionMutation(c.config, OpDelete) return &PayOrderExtensionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PayOrderExtensionClient) DeleteOne(_m *PayOrderExtension) *PayOrderExtensionDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PayOrderExtensionClient) DeleteOneID(id uint64) *PayOrderExtensionDeleteOne { builder := c.Delete().Where(payorderextension.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PayOrderExtensionDeleteOne{builder} } // Query returns a query builder for PayOrderExtension. func (c *PayOrderExtensionClient) Query() *PayOrderExtensionQuery { return &PayOrderExtensionQuery{ config: c.config, ctx: &QueryContext{Type: TypePayOrderExtension}, inters: c.Interceptors(), } } // Get returns a PayOrderExtension entity by its id. func (c *PayOrderExtensionClient) Get(ctx context.Context, id uint64) (*PayOrderExtension, error) { return c.Query().Where(payorderextension.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PayOrderExtensionClient) GetX(ctx context.Context, id uint64) *PayOrderExtension { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryChannel queries the channel edge of a PayOrderExtension. func (c *PayOrderExtensionClient) QueryChannel(_m *PayOrderExtension) *PayChannelQuery { query := (&PayChannelClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payorderextension.Table, payorderextension.FieldID, id), sqlgraph.To(paychannel.Table, paychannel.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, payorderextension.ChannelTable, payorderextension.ChannelColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryOrder queries the order edge of a PayOrderExtension. func (c *PayOrderExtensionClient) QueryOrder(_m *PayOrderExtension) *PayOrderQuery { query := (&PayOrderClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payorderextension.Table, payorderextension.FieldID, id), sqlgraph.To(payorder.Table, payorder.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, payorderextension.OrderTable, payorderextension.OrderColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PayOrderExtensionClient) Hooks() []Hook { return c.hooks.PayOrderExtension } // Interceptors returns the client interceptors. func (c *PayOrderExtensionClient) Interceptors() []Interceptor { return c.inters.PayOrderExtension } func (c *PayOrderExtensionClient) mutate(ctx context.Context, m *PayOrderExtensionMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PayOrderExtensionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PayOrderExtensionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PayOrderExtensionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PayOrderExtensionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PayOrderExtension mutation op: %q", m.Op()) } } // PayRefundClient is a client for the PayRefund schema. type PayRefundClient struct { config } // NewPayRefundClient returns a client for the PayRefund from the given config. func NewPayRefundClient(c config) *PayRefundClient { return &PayRefundClient{config: c} } // Use adds a list of mutation hooks to the hooks stack. // A call to `Use(f, g, h)` equals to `payrefund.Hooks(f(g(h())))`. func (c *PayRefundClient) Use(hooks ...Hook) { c.hooks.PayRefund = append(c.hooks.PayRefund, hooks...) } // Intercept adds a list of query interceptors to the interceptors stack. // A call to `Intercept(f, g, h)` equals to `payrefund.Intercept(f(g(h())))`. func (c *PayRefundClient) Intercept(interceptors ...Interceptor) { c.inters.PayRefund = append(c.inters.PayRefund, interceptors...) } // Create returns a builder for creating a PayRefund entity. func (c *PayRefundClient) Create() *PayRefundCreate { mutation := newPayRefundMutation(c.config, OpCreate) return &PayRefundCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // CreateBulk returns a builder for creating a bulk of PayRefund entities. func (c *PayRefundClient) CreateBulk(builders ...*PayRefundCreate) *PayRefundCreateBulk { return &PayRefundCreateBulk{config: c.config, builders: builders} } // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates // a builder and applies setFunc on it. func (c *PayRefundClient) MapCreateBulk(slice any, setFunc func(*PayRefundCreate, int)) *PayRefundCreateBulk { rv := reflect.ValueOf(slice) if rv.Kind() != reflect.Slice { return &PayRefundCreateBulk{err: fmt.Errorf("calling to PayRefundClient.MapCreateBulk with wrong type %T, need slice", slice)} } builders := make([]*PayRefundCreate, rv.Len()) for i := 0; i < rv.Len(); i++ { builders[i] = c.Create() setFunc(builders[i], i) } return &PayRefundCreateBulk{config: c.config, builders: builders} } // Update returns an update builder for PayRefund. func (c *PayRefundClient) Update() *PayRefundUpdate { mutation := newPayRefundMutation(c.config, OpUpdate) return &PayRefundUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOne returns an update builder for the given entity. func (c *PayRefundClient) UpdateOne(_m *PayRefund) *PayRefundUpdateOne { mutation := newPayRefundMutation(c.config, OpUpdateOne, withPayRefund(_m)) return &PayRefundUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // UpdateOneID returns an update builder for the given id. func (c *PayRefundClient) UpdateOneID(id uint64) *PayRefundUpdateOne { mutation := newPayRefundMutation(c.config, OpUpdateOne, withPayRefundID(id)) return &PayRefundUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } // Delete returns a delete builder for PayRefund. func (c *PayRefundClient) Delete() *PayRefundDelete { mutation := newPayRefundMutation(c.config, OpDelete) return &PayRefundDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} } // DeleteOne returns a builder for deleting the given entity. func (c *PayRefundClient) DeleteOne(_m *PayRefund) *PayRefundDeleteOne { return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. func (c *PayRefundClient) DeleteOneID(id uint64) *PayRefundDeleteOne { builder := c.Delete().Where(payrefund.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne return &PayRefundDeleteOne{builder} } // Query returns a query builder for PayRefund. func (c *PayRefundClient) Query() *PayRefundQuery { return &PayRefundQuery{ config: c.config, ctx: &QueryContext{Type: TypePayRefund}, inters: c.Interceptors(), } } // Get returns a PayRefund entity by its id. func (c *PayRefundClient) Get(ctx context.Context, id uint64) (*PayRefund, error) { return c.Query().Where(payrefund.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. func (c *PayRefundClient) GetX(ctx context.Context, id uint64) *PayRefund { obj, err := c.Get(ctx, id) if err != nil { panic(err) } return obj } // QueryOrder queries the order edge of a PayRefund. func (c *PayRefundClient) QueryOrder(_m *PayRefund) *PayOrderQuery { query := (&PayOrderClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payrefund.Table, payrefund.FieldID, id), sqlgraph.To(payorder.Table, payorder.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, payrefund.OrderTable, payrefund.OrderColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChannel queries the channel edge of a PayRefund. func (c *PayRefundClient) QueryChannel(_m *PayRefund) *PayChannelQuery { query := (&PayChannelClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(payrefund.Table, payrefund.FieldID, id), sqlgraph.To(paychannel.Table, paychannel.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, payrefund.ChannelTable, payrefund.ChannelColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // Hooks returns the client hooks. func (c *PayRefundClient) Hooks() []Hook { return c.hooks.PayRefund } // Interceptors returns the client interceptors. func (c *PayRefundClient) Interceptors() []Interceptor { return c.inters.PayRefund } func (c *PayRefundClient) mutate(ctx context.Context, m *PayRefundMutation) (Value, error) { switch m.Op() { case OpCreate: return (&PayRefundCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdate: return (&PayRefundUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpUpdateOne: return (&PayRefundUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) case OpDelete, OpDeleteOne: return (&PayRefundDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) default: return nil, fmt.Errorf("ent: unknown PayRefund mutation op: %q", m.Op()) } } // hooks and interceptors per client, for fast access. type ( hooks struct { App, PayChannel, PayNotifyLog, PayNotifyTask, PayOrder, PayOrderExtension, PayRefund []ent.Hook } inters struct { App, PayChannel, PayNotifyLog, PayNotifyTask, PayOrder, PayOrderExtension, PayRefund []ent.Interceptor } ) // ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. // See, database/sql#DB.ExecContext for more information. func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { ex, ok := c.driver.(interface { ExecContext(context.Context, string, ...any) (stdsql.Result, error) }) if !ok { return nil, fmt.Errorf("Driver.ExecContext is not supported") } return ex.ExecContext(ctx, query, args...) } // QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. // See, database/sql#DB.QueryContext for more information. func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { q, ok := c.driver.(interface { QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) }) if !ok { return nil, fmt.Errorf("Driver.QueryContext is not supported") } return q.QueryContext(ctx, query, args...) }