mingyang-admin-pay/rpc/ent/intercept/intercept.go

331 lines
12 KiB
Go

// Code generated by ent, DO NOT EDIT.
package intercept
import (
"context"
"fmt"
"mingyang-admin-pay/rpc/ent"
"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"
"mingyang-admin-pay/rpc/ent/predicate"
"entgo.io/ent/dialect/sql"
)
// The Query interface represents an operation that queries a graph.
// By using this interface, users can write generic code that manipulates
// query builders of different types.
type Query interface {
// Type returns the string representation of the query type.
Type() string
// Limit the number of records to be returned by this query.
Limit(int)
// Offset to start from.
Offset(int)
// Unique configures the query builder to filter duplicate records.
Unique(bool)
// Order specifies how the records should be ordered.
Order(...func(*sql.Selector))
// WhereP appends storage-level predicates to the query builder. Using this method, users
// can use type-assertion to append predicates that do not depend on any generated package.
WhereP(...func(*sql.Selector))
}
// The Func type is an adapter that allows ordinary functions to be used as interceptors.
// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the
// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc.
type Func func(context.Context, Query) error
// Intercept calls f(ctx, q) and then applied the next Querier.
func (f Func) Intercept(next ent.Querier) ent.Querier {
return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) {
query, err := NewQuery(q)
if err != nil {
return nil, err
}
if err := f(ctx, query); err != nil {
return nil, err
}
return next.Query(ctx, q)
})
}
// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser.
// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f.
type TraverseFunc func(context.Context, Query) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error {
query, err := NewQuery(q)
if err != nil {
return err
}
return f(ctx, query)
}
// The AppFunc type is an adapter to allow the use of ordinary function as a Querier.
type AppFunc func(context.Context, *ent.AppQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f AppFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.AppQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.AppQuery", q)
}
// The TraverseApp type is an adapter to allow the use of ordinary function as Traverser.
type TraverseApp func(context.Context, *ent.AppQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraverseApp) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraverseApp) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.AppQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.AppQuery", q)
}
// The PayChannelFunc type is an adapter to allow the use of ordinary function as a Querier.
type PayChannelFunc func(context.Context, *ent.PayChannelQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f PayChannelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.PayChannelQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayChannelQuery", q)
}
// The TraversePayChannel type is an adapter to allow the use of ordinary function as Traverser.
type TraversePayChannel func(context.Context, *ent.PayChannelQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePayChannel) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraversePayChannel) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.PayChannelQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.PayChannelQuery", q)
}
// The PayNotifyLogFunc type is an adapter to allow the use of ordinary function as a Querier.
type PayNotifyLogFunc func(context.Context, *ent.PayNotifyLogQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f PayNotifyLogFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.PayNotifyLogQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyLogQuery", q)
}
// The TraversePayNotifyLog type is an adapter to allow the use of ordinary function as Traverser.
type TraversePayNotifyLog func(context.Context, *ent.PayNotifyLogQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePayNotifyLog) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraversePayNotifyLog) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.PayNotifyLogQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyLogQuery", q)
}
// The PayNotifyTaskFunc type is an adapter to allow the use of ordinary function as a Querier.
type PayNotifyTaskFunc func(context.Context, *ent.PayNotifyTaskQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f PayNotifyTaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.PayNotifyTaskQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyTaskQuery", q)
}
// The TraversePayNotifyTask type is an adapter to allow the use of ordinary function as Traverser.
type TraversePayNotifyTask func(context.Context, *ent.PayNotifyTaskQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePayNotifyTask) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraversePayNotifyTask) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.PayNotifyTaskQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyTaskQuery", q)
}
// The PayOrderFunc type is an adapter to allow the use of ordinary function as a Querier.
type PayOrderFunc func(context.Context, *ent.PayOrderQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f PayOrderFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.PayOrderQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayOrderQuery", q)
}
// The TraversePayOrder type is an adapter to allow the use of ordinary function as Traverser.
type TraversePayOrder func(context.Context, *ent.PayOrderQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePayOrder) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraversePayOrder) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.PayOrderQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.PayOrderQuery", q)
}
// The PayOrderExtensionFunc type is an adapter to allow the use of ordinary function as a Querier.
type PayOrderExtensionFunc func(context.Context, *ent.PayOrderExtensionQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f PayOrderExtensionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.PayOrderExtensionQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayOrderExtensionQuery", q)
}
// The TraversePayOrderExtension type is an adapter to allow the use of ordinary function as Traverser.
type TraversePayOrderExtension func(context.Context, *ent.PayOrderExtensionQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePayOrderExtension) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraversePayOrderExtension) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.PayOrderExtensionQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.PayOrderExtensionQuery", q)
}
// The PayRefundFunc type is an adapter to allow the use of ordinary function as a Querier.
type PayRefundFunc func(context.Context, *ent.PayRefundQuery) (ent.Value, error)
// Query calls f(ctx, q).
func (f PayRefundFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
if q, ok := q.(*ent.PayRefundQuery); ok {
return f(ctx, q)
}
return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayRefundQuery", q)
}
// The TraversePayRefund type is an adapter to allow the use of ordinary function as Traverser.
type TraversePayRefund func(context.Context, *ent.PayRefundQuery) error
// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
func (f TraversePayRefund) Intercept(next ent.Querier) ent.Querier {
return next
}
// Traverse calls f(ctx, q).
func (f TraversePayRefund) Traverse(ctx context.Context, q ent.Query) error {
if q, ok := q.(*ent.PayRefundQuery); ok {
return f(ctx, q)
}
return fmt.Errorf("unexpected query type %T. expect *ent.PayRefundQuery", q)
}
// NewQuery returns the generic Query interface for the given typed query.
func NewQuery(q ent.Query) (Query, error) {
switch q := q.(type) {
case *ent.AppQuery:
return &query[*ent.AppQuery, predicate.App, app.OrderOption]{typ: ent.TypeApp, tq: q}, nil
case *ent.PayChannelQuery:
return &query[*ent.PayChannelQuery, predicate.PayChannel, paychannel.OrderOption]{typ: ent.TypePayChannel, tq: q}, nil
case *ent.PayNotifyLogQuery:
return &query[*ent.PayNotifyLogQuery, predicate.PayNotifyLog, paynotifylog.OrderOption]{typ: ent.TypePayNotifyLog, tq: q}, nil
case *ent.PayNotifyTaskQuery:
return &query[*ent.PayNotifyTaskQuery, predicate.PayNotifyTask, paynotifytask.OrderOption]{typ: ent.TypePayNotifyTask, tq: q}, nil
case *ent.PayOrderQuery:
return &query[*ent.PayOrderQuery, predicate.PayOrder, payorder.OrderOption]{typ: ent.TypePayOrder, tq: q}, nil
case *ent.PayOrderExtensionQuery:
return &query[*ent.PayOrderExtensionQuery, predicate.PayOrderExtension, payorderextension.OrderOption]{typ: ent.TypePayOrderExtension, tq: q}, nil
case *ent.PayRefundQuery:
return &query[*ent.PayRefundQuery, predicate.PayRefund, payrefund.OrderOption]{typ: ent.TypePayRefund, tq: q}, nil
default:
return nil, fmt.Errorf("unknown query type %T", q)
}
}
type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct {
typ string
tq interface {
Limit(int) T
Offset(int) T
Unique(bool) T
Order(...R) T
Where(...P) T
}
}
func (q query[T, P, R]) Type() string {
return q.typ
}
func (q query[T, P, R]) Limit(limit int) {
q.tq.Limit(limit)
}
func (q query[T, P, R]) Offset(offset int) {
q.tq.Offset(offset)
}
func (q query[T, P, R]) Unique(unique bool) {
q.tq.Unique(unique)
}
func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) {
rs := make([]R, len(orders))
for i := range orders {
rs[i] = orders[i]
}
q.tq.Order(rs...)
}
func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) {
p := make([]P, len(ps))
for i := range ps {
p[i] = ps[i]
}
q.tq.Where(p...)
}