From 8cb2409ea54bf00a230e38387a2dcf2bf514eb46 Mon Sep 17 00:00:00 2001 From: erio Date: Sun, 5 Apr 2026 16:39:24 +0800 Subject: [PATCH] refactor: remove PaymentChannel, reuse upstream Channel with features field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete payment_channels table and PaymentChannel Ent schema - Add `features` column to upstream channels table (migration 095) - Add Features field to Channel struct, input types, handler request/response - Payment user/admin handlers now use ChannelService directly - Remove Channel CRUD from PaymentConfigService and admin payment routes - Remove "渠道管理" tab from admin orders page (use /admin/channels) --- backend/cmd/server/wire_gen.go | 2 +- backend/ent/client.go | 149 +-- backend/ent/ent.go | 2 - backend/ent/hook/hook.go | 12 - backend/ent/intercept/intercept.go | 29 - backend/ent/migrate/schema.go | 37 - backend/ent/mutation.go | 993 -------------- backend/ent/paymentchannel.go | 223 ---- backend/ent/paymentchannel/paymentchannel.go | 156 --- backend/ent/paymentchannel/where.go | 670 ---------- backend/ent/paymentchannel_create.go | 1166 ----------------- backend/ent/paymentchannel_delete.go | 88 -- backend/ent/paymentchannel_query.go | 564 -------- backend/ent/paymentchannel_update.go | 632 --------- backend/ent/predicate/predicate.go | 2 - backend/ent/runtime/runtime.go | 61 - backend/ent/schema/payment_channel.go | 74 -- backend/ent/tx.go | 3 - .../internal/handler/admin/channel_handler.go | 6 + .../internal/handler/admin/payment_handler.go | 65 - backend/internal/handler/payment_handler.go | 7 +- backend/internal/repository/channel_repo.go | 20 +- backend/internal/server/routes/payment.go | 8 - backend/internal/service/channel.go | 1 + backend/internal/service/channel_service.go | 6 + .../service/payment_config_service.go | 76 -- backend/migrations/092_payment_channels.sql | 16 - backend/migrations/095_channel_features.sql | 2 + 28 files changed, 35 insertions(+), 5035 deletions(-) delete mode 100644 backend/ent/paymentchannel.go delete mode 100644 backend/ent/paymentchannel/paymentchannel.go delete mode 100644 backend/ent/paymentchannel/where.go delete mode 100644 backend/ent/paymentchannel_create.go delete mode 100644 backend/ent/paymentchannel_delete.go delete mode 100644 backend/ent/paymentchannel_query.go delete mode 100644 backend/ent/paymentchannel_update.go delete mode 100644 backend/ent/schema/payment_channel.go delete mode 100644 backend/migrations/092_payment_channels.sql create mode 100644 backend/migrations/095_channel_features.sql diff --git a/backend/cmd/server/wire_gen.go b/backend/cmd/server/wire_gen.go index 5f6f19cb40..7936d181c1 100644 --- a/backend/cmd/server/wire_gen.go +++ b/backend/cmd/server/wire_gen.go @@ -234,7 +234,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { soraClientHandler := handler.NewSoraClientHandler(soraGenerationService, soraQuotaService, soraS3Storage, soraGatewayService, gatewayService, soraMediaStorage, apiKeyService) handlerSettingHandler := handler.ProvideSettingHandler(settingService, buildInfo) totpHandler := handler.NewTotpHandler(totpService) - handlerPaymentHandler := handler.NewPaymentHandler(paymentService, paymentConfigService) + handlerPaymentHandler := handler.NewPaymentHandler(paymentService, paymentConfigService, channelService) paymentWebhookHandler := handler.NewPaymentWebhookHandler(paymentService, registry) idempotencyCoordinator := service.ProvideIdempotencyCoordinator(idempotencyRepository, configConfig) idempotencyCleanupService := service.ProvideIdempotencyCleanupService(idempotencyRepository, configConfig) diff --git a/backend/ent/client.go b/backend/ent/client.go index c033d3e048..3da7acf892 100644 --- a/backend/ent/client.go +++ b/backend/ent/client.go @@ -24,7 +24,6 @@ import ( "github.com/Wei-Shaw/sub2api/ent/group" "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord" "github.com/Wei-Shaw/sub2api/ent/paymentauditlog" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" "github.com/Wei-Shaw/sub2api/ent/paymentorder" "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance" "github.com/Wei-Shaw/sub2api/ent/promocode" @@ -69,8 +68,6 @@ type Client struct { IdempotencyRecord *IdempotencyRecordClient // PaymentAuditLog is the client for interacting with the PaymentAuditLog builders. PaymentAuditLog *PaymentAuditLogClient - // PaymentChannel is the client for interacting with the PaymentChannel builders. - PaymentChannel *PaymentChannelClient // PaymentOrder is the client for interacting with the PaymentOrder builders. PaymentOrder *PaymentOrderClient // PaymentProviderInstance is the client for interacting with the PaymentProviderInstance builders. @@ -125,7 +122,6 @@ func (c *Client) init() { c.Group = NewGroupClient(c.config) c.IdempotencyRecord = NewIdempotencyRecordClient(c.config) c.PaymentAuditLog = NewPaymentAuditLogClient(c.config) - c.PaymentChannel = NewPaymentChannelClient(c.config) c.PaymentOrder = NewPaymentOrderClient(c.config) c.PaymentProviderInstance = NewPaymentProviderInstanceClient(c.config) c.PromoCode = NewPromoCodeClient(c.config) @@ -244,7 +240,6 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Group: NewGroupClient(cfg), IdempotencyRecord: NewIdempotencyRecordClient(cfg), PaymentAuditLog: NewPaymentAuditLogClient(cfg), - PaymentChannel: NewPaymentChannelClient(cfg), PaymentOrder: NewPaymentOrderClient(cfg), PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg), PromoCode: NewPromoCodeClient(cfg), @@ -290,7 +285,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Group: NewGroupClient(cfg), IdempotencyRecord: NewIdempotencyRecordClient(cfg), PaymentAuditLog: NewPaymentAuditLogClient(cfg), - PaymentChannel: NewPaymentChannelClient(cfg), PaymentOrder: NewPaymentOrderClient(cfg), PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg), PromoCode: NewPromoCodeClient(cfg), @@ -339,7 +333,7 @@ func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead, c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord, c.PaymentAuditLog, - c.PaymentChannel, c.PaymentOrder, c.PaymentProviderInstance, c.PromoCode, + c.PaymentOrder, c.PaymentProviderInstance, c.PromoCode, c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting, c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue, @@ -355,7 +349,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead, c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord, c.PaymentAuditLog, - c.PaymentChannel, c.PaymentOrder, c.PaymentProviderInstance, c.PromoCode, + c.PaymentOrder, c.PaymentProviderInstance, c.PromoCode, c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting, c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue, @@ -386,8 +380,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.IdempotencyRecord.mutate(ctx, m) case *PaymentAuditLogMutation: return c.PaymentAuditLog.mutate(ctx, m) - case *PaymentChannelMutation: - return c.PaymentChannel.mutate(ctx, m) case *PaymentOrderMutation: return c.PaymentOrder.mutate(ctx, m) case *PaymentProviderInstanceMutation: @@ -1901,139 +1893,6 @@ func (c *PaymentAuditLogClient) mutate(ctx context.Context, m *PaymentAuditLogMu } } -// PaymentChannelClient is a client for the PaymentChannel schema. -type PaymentChannelClient struct { - config -} - -// NewPaymentChannelClient returns a client for the PaymentChannel from the given config. -func NewPaymentChannelClient(c config) *PaymentChannelClient { - return &PaymentChannelClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `paymentchannel.Hooks(f(g(h())))`. -func (c *PaymentChannelClient) Use(hooks ...Hook) { - c.hooks.PaymentChannel = append(c.hooks.PaymentChannel, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `paymentchannel.Intercept(f(g(h())))`. -func (c *PaymentChannelClient) Intercept(interceptors ...Interceptor) { - c.inters.PaymentChannel = append(c.inters.PaymentChannel, interceptors...) -} - -// Create returns a builder for creating a PaymentChannel entity. -func (c *PaymentChannelClient) Create() *PaymentChannelCreate { - mutation := newPaymentChannelMutation(c.config, OpCreate) - return &PaymentChannelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of PaymentChannel entities. -func (c *PaymentChannelClient) CreateBulk(builders ...*PaymentChannelCreate) *PaymentChannelCreateBulk { - return &PaymentChannelCreateBulk{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 *PaymentChannelClient) MapCreateBulk(slice any, setFunc func(*PaymentChannelCreate, int)) *PaymentChannelCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &PaymentChannelCreateBulk{err: fmt.Errorf("calling to PaymentChannelClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*PaymentChannelCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &PaymentChannelCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for PaymentChannel. -func (c *PaymentChannelClient) Update() *PaymentChannelUpdate { - mutation := newPaymentChannelMutation(c.config, OpUpdate) - return &PaymentChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *PaymentChannelClient) UpdateOne(_m *PaymentChannel) *PaymentChannelUpdateOne { - mutation := newPaymentChannelMutation(c.config, OpUpdateOne, withPaymentChannel(_m)) - return &PaymentChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *PaymentChannelClient) UpdateOneID(id int64) *PaymentChannelUpdateOne { - mutation := newPaymentChannelMutation(c.config, OpUpdateOne, withPaymentChannelID(id)) - return &PaymentChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for PaymentChannel. -func (c *PaymentChannelClient) Delete() *PaymentChannelDelete { - mutation := newPaymentChannelMutation(c.config, OpDelete) - return &PaymentChannelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *PaymentChannelClient) DeleteOne(_m *PaymentChannel) *PaymentChannelDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *PaymentChannelClient) DeleteOneID(id int64) *PaymentChannelDeleteOne { - builder := c.Delete().Where(paymentchannel.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &PaymentChannelDeleteOne{builder} -} - -// Query returns a query builder for PaymentChannel. -func (c *PaymentChannelClient) Query() *PaymentChannelQuery { - return &PaymentChannelQuery{ - config: c.config, - ctx: &QueryContext{Type: TypePaymentChannel}, - inters: c.Interceptors(), - } -} - -// Get returns a PaymentChannel entity by its id. -func (c *PaymentChannelClient) Get(ctx context.Context, id int64) (*PaymentChannel, error) { - return c.Query().Where(paymentchannel.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *PaymentChannelClient) GetX(ctx context.Context, id int64) *PaymentChannel { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// Hooks returns the client hooks. -func (c *PaymentChannelClient) Hooks() []Hook { - return c.hooks.PaymentChannel -} - -// Interceptors returns the client interceptors. -func (c *PaymentChannelClient) Interceptors() []Interceptor { - return c.inters.PaymentChannel -} - -func (c *PaymentChannelClient) mutate(ctx context.Context, m *PaymentChannelMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&PaymentChannelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&PaymentChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&PaymentChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&PaymentChannelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown PaymentChannel mutation op: %q", m.Op()) - } -} - // PaymentOrderClient is a client for the PaymentOrder schema. type PaymentOrderClient struct { config @@ -4771,7 +4630,7 @@ type ( hooks struct { APIKey, Account, AccountGroup, Announcement, AnnouncementRead, ErrorPassthroughRule, Group, IdempotencyRecord, PaymentAuditLog, - PaymentChannel, PaymentOrder, PaymentProviderInstance, PromoCode, + PaymentOrder, PaymentProviderInstance, PromoCode, PromoCodeUsage, Proxy, RedeemCode, SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile, UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue, UserSubscription []ent.Hook @@ -4779,7 +4638,7 @@ type ( inters struct { APIKey, Account, AccountGroup, Announcement, AnnouncementRead, ErrorPassthroughRule, Group, IdempotencyRecord, PaymentAuditLog, - PaymentChannel, PaymentOrder, PaymentProviderInstance, PromoCode, + PaymentOrder, PaymentProviderInstance, PromoCode, PromoCodeUsage, Proxy, RedeemCode, SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile, UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue, UserSubscription []ent.Interceptor diff --git a/backend/ent/ent.go b/backend/ent/ent.go index cf59b09d6b..96ed5e03a9 100644 --- a/backend/ent/ent.go +++ b/backend/ent/ent.go @@ -21,7 +21,6 @@ import ( "github.com/Wei-Shaw/sub2api/ent/group" "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord" "github.com/Wei-Shaw/sub2api/ent/paymentauditlog" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" "github.com/Wei-Shaw/sub2api/ent/paymentorder" "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance" "github.com/Wei-Shaw/sub2api/ent/promocode" @@ -108,7 +107,6 @@ func checkColumn(t, c string) error { group.Table: group.ValidColumn, idempotencyrecord.Table: idempotencyrecord.ValidColumn, paymentauditlog.Table: paymentauditlog.ValidColumn, - paymentchannel.Table: paymentchannel.ValidColumn, paymentorder.Table: paymentorder.ValidColumn, paymentproviderinstance.Table: paymentproviderinstance.ValidColumn, promocode.Table: promocode.ValidColumn, diff --git a/backend/ent/hook/hook.go b/backend/ent/hook/hook.go index aa609c93cb..199dacea0e 100644 --- a/backend/ent/hook/hook.go +++ b/backend/ent/hook/hook.go @@ -117,18 +117,6 @@ func (f PaymentAuditLogFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Va return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PaymentAuditLogMutation", m) } -// The PaymentChannelFunc type is an adapter to allow the use of ordinary -// function as PaymentChannel mutator. -type PaymentChannelFunc func(context.Context, *ent.PaymentChannelMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f PaymentChannelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.PaymentChannelMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PaymentChannelMutation", m) -} - // The PaymentOrderFunc type is an adapter to allow the use of ordinary // function as PaymentOrder mutator. type PaymentOrderFunc func(context.Context, *ent.PaymentOrderMutation) (ent.Value, error) diff --git a/backend/ent/intercept/intercept.go b/backend/ent/intercept/intercept.go index ee44b3ea1d..77d3e16e06 100644 --- a/backend/ent/intercept/intercept.go +++ b/backend/ent/intercept/intercept.go @@ -17,7 +17,6 @@ import ( "github.com/Wei-Shaw/sub2api/ent/group" "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord" "github.com/Wei-Shaw/sub2api/ent/paymentauditlog" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" "github.com/Wei-Shaw/sub2api/ent/paymentorder" "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance" "github.com/Wei-Shaw/sub2api/ent/predicate" @@ -337,32 +336,6 @@ func (f TraversePaymentAuditLog) Traverse(ctx context.Context, q ent.Query) erro return fmt.Errorf("unexpected query type %T. expect *ent.PaymentAuditLogQuery", q) } -// The PaymentChannelFunc type is an adapter to allow the use of ordinary function as a Querier. -type PaymentChannelFunc func(context.Context, *ent.PaymentChannelQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f PaymentChannelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.PaymentChannelQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.PaymentChannelQuery", q) -} - -// The TraversePaymentChannel type is an adapter to allow the use of ordinary function as Traverser. -type TraversePaymentChannel func(context.Context, *ent.PaymentChannelQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraversePaymentChannel) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraversePaymentChannel) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.PaymentChannelQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.PaymentChannelQuery", q) -} // The PaymentOrderFunc type is an adapter to allow the use of ordinary function as a Querier. type PaymentOrderFunc func(context.Context, *ent.PaymentOrderQuery) (ent.Value, error) @@ -844,8 +817,6 @@ func NewQuery(q ent.Query) (Query, error) { return &query[*ent.IdempotencyRecordQuery, predicate.IdempotencyRecord, idempotencyrecord.OrderOption]{typ: ent.TypeIdempotencyRecord, tq: q}, nil case *ent.PaymentAuditLogQuery: return &query[*ent.PaymentAuditLogQuery, predicate.PaymentAuditLog, paymentauditlog.OrderOption]{typ: ent.TypePaymentAuditLog, tq: q}, nil - case *ent.PaymentChannelQuery: - return &query[*ent.PaymentChannelQuery, predicate.PaymentChannel, paymentchannel.OrderOption]{typ: ent.TypePaymentChannel, tq: q}, nil case *ent.PaymentOrderQuery: return &query[*ent.PaymentOrderQuery, predicate.PaymentOrder, paymentorder.OrderOption]{typ: ent.TypePaymentOrder, tq: q}, nil case *ent.PaymentProviderInstanceQuery: diff --git a/backend/ent/migrate/schema.go b/backend/ent/migrate/schema.go index 223266925c..e83cd2fb7b 100644 --- a/backend/ent/migrate/schema.go +++ b/backend/ent/migrate/schema.go @@ -511,39 +511,6 @@ var ( }, }, } - // PaymentChannelsColumns holds the columns for the "payment_channels" table. - PaymentChannelsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64, Increment: true}, - {Name: "group_id", Type: field.TypeInt64, Nullable: true}, - {Name: "name", Type: field.TypeString, Size: 100}, - {Name: "platform", Type: field.TypeString, Size: 50, Default: "claude"}, - {Name: "rate_multiplier", Type: field.TypeFloat64, Default: 1, SchemaType: map[string]string{"postgres": "decimal(10,4)"}}, - {Name: "description", Type: field.TypeString, Default: "", SchemaType: map[string]string{"postgres": "text"}}, - {Name: "models", Type: field.TypeString, Default: "", SchemaType: map[string]string{"postgres": "text"}}, - {Name: "features", Type: field.TypeString, Default: "", SchemaType: map[string]string{"postgres": "text"}}, - {Name: "sort_order", Type: field.TypeInt, Default: 0}, - {Name: "enabled", Type: field.TypeBool, Default: true}, - {Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}}, - {Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}}, - } - // PaymentChannelsTable holds the schema information for the "payment_channels" table. - PaymentChannelsTable = &schema.Table{ - Name: "payment_channels", - Columns: PaymentChannelsColumns, - PrimaryKey: []*schema.Column{PaymentChannelsColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "paymentchannel_group_id", - Unique: false, - Columns: []*schema.Column{PaymentChannelsColumns[1]}, - }, - { - Name: "paymentchannel_enabled", - Unique: false, - Columns: []*schema.Column{PaymentChannelsColumns[9]}, - }, - }, - } // PaymentOrdersColumns holds the columns for the "payment_orders" table. PaymentOrdersColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Increment: true}, @@ -1349,7 +1316,6 @@ var ( GroupsTable, IdempotencyRecordsTable, PaymentAuditLogsTable, - PaymentChannelsTable, PaymentOrdersTable, PaymentProviderInstancesTable, PromoCodesTable, @@ -1405,9 +1371,6 @@ func init() { PaymentAuditLogsTable.Annotation = &entsql.Annotation{ Table: "payment_audit_logs", } - PaymentChannelsTable.Annotation = &entsql.Annotation{ - Table: "payment_channels", - } PaymentOrdersTable.ForeignKeys[0].RefTable = UsersTable PaymentOrdersTable.Annotation = &entsql.Annotation{ Table: "payment_orders", diff --git a/backend/ent/mutation.go b/backend/ent/mutation.go index 88710b4a5d..a7539a584d 100644 --- a/backend/ent/mutation.go +++ b/backend/ent/mutation.go @@ -21,7 +21,6 @@ import ( "github.com/Wei-Shaw/sub2api/ent/group" "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord" "github.com/Wei-Shaw/sub2api/ent/paymentauditlog" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" "github.com/Wei-Shaw/sub2api/ent/paymentorder" "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance" "github.com/Wei-Shaw/sub2api/ent/predicate" @@ -61,7 +60,6 @@ const ( TypeGroup = "Group" TypeIdempotencyRecord = "IdempotencyRecord" TypePaymentAuditLog = "PaymentAuditLog" - TypePaymentChannel = "PaymentChannel" TypePaymentOrder = "PaymentOrder" TypePaymentProviderInstance = "PaymentProviderInstance" TypePromoCode = "PromoCode" @@ -13196,997 +13194,6 @@ func (m *PaymentAuditLogMutation) ResetEdge(name string) error { return fmt.Errorf("unknown PaymentAuditLog edge %s", name) } -// PaymentChannelMutation represents an operation that mutates the PaymentChannel nodes in the graph. -type PaymentChannelMutation struct { - config - op Op - typ string - id *int64 - group_id *int64 - addgroup_id *int64 - name *string - platform *string - rate_multiplier *float64 - addrate_multiplier *float64 - description *string - models *string - features *string - sort_order *int - addsort_order *int - enabled *bool - created_at *time.Time - updated_at *time.Time - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*PaymentChannel, error) - predicates []predicate.PaymentChannel -} - -var _ ent.Mutation = (*PaymentChannelMutation)(nil) - -// paymentchannelOption allows management of the mutation configuration using functional options. -type paymentchannelOption func(*PaymentChannelMutation) - -// newPaymentChannelMutation creates new mutation for the PaymentChannel entity. -func newPaymentChannelMutation(c config, op Op, opts ...paymentchannelOption) *PaymentChannelMutation { - m := &PaymentChannelMutation{ - config: c, - op: op, - typ: TypePaymentChannel, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withPaymentChannelID sets the ID field of the mutation. -func withPaymentChannelID(id int64) paymentchannelOption { - return func(m *PaymentChannelMutation) { - var ( - err error - once sync.Once - value *PaymentChannel - ) - m.oldValue = func(ctx context.Context) (*PaymentChannel, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().PaymentChannel.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withPaymentChannel sets the old PaymentChannel of the mutation. -func withPaymentChannel(node *PaymentChannel) paymentchannelOption { - return func(m *PaymentChannelMutation) { - m.oldValue = func(context.Context) (*PaymentChannel, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m PaymentChannelMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m PaymentChannelMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PaymentChannelMutation) ID() (id int64, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PaymentChannelMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().PaymentChannel.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetGroupID sets the "group_id" field. -func (m *PaymentChannelMutation) SetGroupID(i int64) { - m.group_id = &i - m.addgroup_id = nil -} - -// GroupID returns the value of the "group_id" field in the mutation. -func (m *PaymentChannelMutation) GroupID() (r int64, exists bool) { - v := m.group_id - if v == nil { - return - } - return *v, true -} - -// OldGroupID returns the old "group_id" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldGroupID(ctx context.Context) (v *int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGroupID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGroupID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldGroupID: %w", err) - } - return oldValue.GroupID, nil -} - -// AddGroupID adds i to the "group_id" field. -func (m *PaymentChannelMutation) AddGroupID(i int64) { - if m.addgroup_id != nil { - *m.addgroup_id += i - } else { - m.addgroup_id = &i - } -} - -// AddedGroupID returns the value that was added to the "group_id" field in this mutation. -func (m *PaymentChannelMutation) AddedGroupID() (r int64, exists bool) { - v := m.addgroup_id - if v == nil { - return - } - return *v, true -} - -// ClearGroupID clears the value of the "group_id" field. -func (m *PaymentChannelMutation) ClearGroupID() { - m.group_id = nil - m.addgroup_id = nil - m.clearedFields[paymentchannel.FieldGroupID] = struct{}{} -} - -// GroupIDCleared returns if the "group_id" field was cleared in this mutation. -func (m *PaymentChannelMutation) GroupIDCleared() bool { - _, ok := m.clearedFields[paymentchannel.FieldGroupID] - return ok -} - -// ResetGroupID resets all changes to the "group_id" field. -func (m *PaymentChannelMutation) ResetGroupID() { - m.group_id = nil - m.addgroup_id = nil - delete(m.clearedFields, paymentchannel.FieldGroupID) -} - -// SetName sets the "name" field. -func (m *PaymentChannelMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *PaymentChannelMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *PaymentChannelMutation) ResetName() { - m.name = nil -} - -// SetPlatform sets the "platform" field. -func (m *PaymentChannelMutation) SetPlatform(s string) { - m.platform = &s -} - -// Platform returns the value of the "platform" field in the mutation. -func (m *PaymentChannelMutation) Platform() (r string, exists bool) { - v := m.platform - if v == nil { - return - } - return *v, true -} - -// OldPlatform returns the old "platform" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldPlatform(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPlatform is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPlatform requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPlatform: %w", err) - } - return oldValue.Platform, nil -} - -// ResetPlatform resets all changes to the "platform" field. -func (m *PaymentChannelMutation) ResetPlatform() { - m.platform = nil -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (m *PaymentChannelMutation) SetRateMultiplier(f float64) { - m.rate_multiplier = &f - m.addrate_multiplier = nil -} - -// RateMultiplier returns the value of the "rate_multiplier" field in the mutation. -func (m *PaymentChannelMutation) RateMultiplier() (r float64, exists bool) { - v := m.rate_multiplier - if v == nil { - return - } - return *v, true -} - -// OldRateMultiplier returns the old "rate_multiplier" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRateMultiplier requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err) - } - return oldValue.RateMultiplier, nil -} - -// AddRateMultiplier adds f to the "rate_multiplier" field. -func (m *PaymentChannelMutation) AddRateMultiplier(f float64) { - if m.addrate_multiplier != nil { - *m.addrate_multiplier += f - } else { - m.addrate_multiplier = &f - } -} - -// AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation. -func (m *PaymentChannelMutation) AddedRateMultiplier() (r float64, exists bool) { - v := m.addrate_multiplier - if v == nil { - return - } - return *v, true -} - -// ResetRateMultiplier resets all changes to the "rate_multiplier" field. -func (m *PaymentChannelMutation) ResetRateMultiplier() { - m.rate_multiplier = nil - m.addrate_multiplier = nil -} - -// SetDescription sets the "description" field. -func (m *PaymentChannelMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *PaymentChannelMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *PaymentChannelMutation) ResetDescription() { - m.description = nil -} - -// SetModels sets the "models" field. -func (m *PaymentChannelMutation) SetModels(s string) { - m.models = &s -} - -// Models returns the value of the "models" field in the mutation. -func (m *PaymentChannelMutation) Models() (r string, exists bool) { - v := m.models - if v == nil { - return - } - return *v, true -} - -// OldModels returns the old "models" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldModels(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldModels is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldModels requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldModels: %w", err) - } - return oldValue.Models, nil -} - -// ResetModels resets all changes to the "models" field. -func (m *PaymentChannelMutation) ResetModels() { - m.models = nil -} - -// SetFeatures sets the "features" field. -func (m *PaymentChannelMutation) SetFeatures(s string) { - m.features = &s -} - -// Features returns the value of the "features" field in the mutation. -func (m *PaymentChannelMutation) Features() (r string, exists bool) { - v := m.features - if v == nil { - return - } - return *v, true -} - -// OldFeatures returns the old "features" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldFeatures(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldFeatures is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldFeatures requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldFeatures: %w", err) - } - return oldValue.Features, nil -} - -// ResetFeatures resets all changes to the "features" field. -func (m *PaymentChannelMutation) ResetFeatures() { - m.features = nil -} - -// SetSortOrder sets the "sort_order" field. -func (m *PaymentChannelMutation) SetSortOrder(i int) { - m.sort_order = &i - m.addsort_order = nil -} - -// SortOrder returns the value of the "sort_order" field in the mutation. -func (m *PaymentChannelMutation) SortOrder() (r int, exists bool) { - v := m.sort_order - if v == nil { - return - } - return *v, true -} - -// OldSortOrder returns the old "sort_order" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldSortOrder(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSortOrder is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSortOrder requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSortOrder: %w", err) - } - return oldValue.SortOrder, nil -} - -// AddSortOrder adds i to the "sort_order" field. -func (m *PaymentChannelMutation) AddSortOrder(i int) { - if m.addsort_order != nil { - *m.addsort_order += i - } else { - m.addsort_order = &i - } -} - -// AddedSortOrder returns the value that was added to the "sort_order" field in this mutation. -func (m *PaymentChannelMutation) AddedSortOrder() (r int, exists bool) { - v := m.addsort_order - if v == nil { - return - } - return *v, true -} - -// ResetSortOrder resets all changes to the "sort_order" field. -func (m *PaymentChannelMutation) ResetSortOrder() { - m.sort_order = nil - m.addsort_order = nil -} - -// SetEnabled sets the "enabled" field. -func (m *PaymentChannelMutation) SetEnabled(b bool) { - m.enabled = &b -} - -// Enabled returns the value of the "enabled" field in the mutation. -func (m *PaymentChannelMutation) Enabled() (r bool, exists bool) { - v := m.enabled - if v == nil { - return - } - return *v, true -} - -// OldEnabled returns the old "enabled" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldEnabled(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEnabled is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEnabled requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEnabled: %w", err) - } - return oldValue.Enabled, nil -} - -// ResetEnabled resets all changes to the "enabled" field. -func (m *PaymentChannelMutation) ResetEnabled() { - m.enabled = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *PaymentChannelMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *PaymentChannelMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *PaymentChannelMutation) ResetCreatedAt() { - m.created_at = nil -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *PaymentChannelMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *PaymentChannelMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the PaymentChannel entity. -// If the PaymentChannel object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PaymentChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *PaymentChannelMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// Where appends a list predicates to the PaymentChannelMutation builder. -func (m *PaymentChannelMutation) Where(ps ...predicate.PaymentChannel) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the PaymentChannelMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PaymentChannelMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.PaymentChannel, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *PaymentChannelMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *PaymentChannelMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (PaymentChannel). -func (m *PaymentChannelMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *PaymentChannelMutation) Fields() []string { - fields := make([]string, 0, 11) - if m.group_id != nil { - fields = append(fields, paymentchannel.FieldGroupID) - } - if m.name != nil { - fields = append(fields, paymentchannel.FieldName) - } - if m.platform != nil { - fields = append(fields, paymentchannel.FieldPlatform) - } - if m.rate_multiplier != nil { - fields = append(fields, paymentchannel.FieldRateMultiplier) - } - if m.description != nil { - fields = append(fields, paymentchannel.FieldDescription) - } - if m.models != nil { - fields = append(fields, paymentchannel.FieldModels) - } - if m.features != nil { - fields = append(fields, paymentchannel.FieldFeatures) - } - if m.sort_order != nil { - fields = append(fields, paymentchannel.FieldSortOrder) - } - if m.enabled != nil { - fields = append(fields, paymentchannel.FieldEnabled) - } - if m.created_at != nil { - fields = append(fields, paymentchannel.FieldCreatedAt) - } - if m.updated_at != nil { - fields = append(fields, paymentchannel.FieldUpdatedAt) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *PaymentChannelMutation) Field(name string) (ent.Value, bool) { - switch name { - case paymentchannel.FieldGroupID: - return m.GroupID() - case paymentchannel.FieldName: - return m.Name() - case paymentchannel.FieldPlatform: - return m.Platform() - case paymentchannel.FieldRateMultiplier: - return m.RateMultiplier() - case paymentchannel.FieldDescription: - return m.Description() - case paymentchannel.FieldModels: - return m.Models() - case paymentchannel.FieldFeatures: - return m.Features() - case paymentchannel.FieldSortOrder: - return m.SortOrder() - case paymentchannel.FieldEnabled: - return m.Enabled() - case paymentchannel.FieldCreatedAt: - return m.CreatedAt() - case paymentchannel.FieldUpdatedAt: - return m.UpdatedAt() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *PaymentChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case paymentchannel.FieldGroupID: - return m.OldGroupID(ctx) - case paymentchannel.FieldName: - return m.OldName(ctx) - case paymentchannel.FieldPlatform: - return m.OldPlatform(ctx) - case paymentchannel.FieldRateMultiplier: - return m.OldRateMultiplier(ctx) - case paymentchannel.FieldDescription: - return m.OldDescription(ctx) - case paymentchannel.FieldModels: - return m.OldModels(ctx) - case paymentchannel.FieldFeatures: - return m.OldFeatures(ctx) - case paymentchannel.FieldSortOrder: - return m.OldSortOrder(ctx) - case paymentchannel.FieldEnabled: - return m.OldEnabled(ctx) - case paymentchannel.FieldCreatedAt: - return m.OldCreatedAt(ctx) - case paymentchannel.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - } - return nil, fmt.Errorf("unknown PaymentChannel field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PaymentChannelMutation) SetField(name string, value ent.Value) error { - switch name { - case paymentchannel.FieldGroupID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetGroupID(v) - return nil - case paymentchannel.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case paymentchannel.FieldPlatform: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPlatform(v) - return nil - case paymentchannel.FieldRateMultiplier: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRateMultiplier(v) - return nil - case paymentchannel.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case paymentchannel.FieldModels: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetModels(v) - return nil - case paymentchannel.FieldFeatures: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetFeatures(v) - return nil - case paymentchannel.FieldSortOrder: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSortOrder(v) - return nil - case paymentchannel.FieldEnabled: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEnabled(v) - return nil - case paymentchannel.FieldCreatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreatedAt(v) - return nil - case paymentchannel.FieldUpdatedAt: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdatedAt(v) - return nil - } - return fmt.Errorf("unknown PaymentChannel field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PaymentChannelMutation) AddedFields() []string { - var fields []string - if m.addgroup_id != nil { - fields = append(fields, paymentchannel.FieldGroupID) - } - if m.addrate_multiplier != nil { - fields = append(fields, paymentchannel.FieldRateMultiplier) - } - if m.addsort_order != nil { - fields = append(fields, paymentchannel.FieldSortOrder) - } - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *PaymentChannelMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case paymentchannel.FieldGroupID: - return m.AddedGroupID() - case paymentchannel.FieldRateMultiplier: - return m.AddedRateMultiplier() - case paymentchannel.FieldSortOrder: - return m.AddedSortOrder() - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PaymentChannelMutation) AddField(name string, value ent.Value) error { - switch name { - case paymentchannel.FieldGroupID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddGroupID(v) - return nil - case paymentchannel.FieldRateMultiplier: - v, ok := value.(float64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddRateMultiplier(v) - return nil - case paymentchannel.FieldSortOrder: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSortOrder(v) - return nil - } - return fmt.Errorf("unknown PaymentChannel numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *PaymentChannelMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(paymentchannel.FieldGroupID) { - fields = append(fields, paymentchannel.FieldGroupID) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *PaymentChannelMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *PaymentChannelMutation) ClearField(name string) error { - switch name { - case paymentchannel.FieldGroupID: - m.ClearGroupID() - return nil - } - return fmt.Errorf("unknown PaymentChannel nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *PaymentChannelMutation) ResetField(name string) error { - switch name { - case paymentchannel.FieldGroupID: - m.ResetGroupID() - return nil - case paymentchannel.FieldName: - m.ResetName() - return nil - case paymentchannel.FieldPlatform: - m.ResetPlatform() - return nil - case paymentchannel.FieldRateMultiplier: - m.ResetRateMultiplier() - return nil - case paymentchannel.FieldDescription: - m.ResetDescription() - return nil - case paymentchannel.FieldModels: - m.ResetModels() - return nil - case paymentchannel.FieldFeatures: - m.ResetFeatures() - return nil - case paymentchannel.FieldSortOrder: - m.ResetSortOrder() - return nil - case paymentchannel.FieldEnabled: - m.ResetEnabled() - return nil - case paymentchannel.FieldCreatedAt: - m.ResetCreatedAt() - return nil - case paymentchannel.FieldUpdatedAt: - m.ResetUpdatedAt() - return nil - } - return fmt.Errorf("unknown PaymentChannel field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *PaymentChannelMutation) AddedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *PaymentChannelMutation) AddedIDs(name string) []ent.Value { - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *PaymentChannelMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *PaymentChannelMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PaymentChannelMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *PaymentChannelMutation) EdgeCleared(name string) bool { - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *PaymentChannelMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown PaymentChannel unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *PaymentChannelMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown PaymentChannel edge %s", name) -} - // PaymentOrderMutation represents an operation that mutates the PaymentOrder nodes in the graph. type PaymentOrderMutation struct { config diff --git a/backend/ent/paymentchannel.go b/backend/ent/paymentchannel.go deleted file mode 100644 index 99317e1d83..0000000000 --- a/backend/ent/paymentchannel.go +++ /dev/null @@ -1,223 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" -) - -// PaymentChannel is the model entity for the PaymentChannel schema. -type PaymentChannel struct { - config `json:"-"` - // ID of the ent. - ID int64 `json:"id,omitempty"` - // GroupID holds the value of the "group_id" field. - GroupID *int64 `json:"group_id,omitempty"` - // Name holds the value of the "name" field. - Name string `json:"name,omitempty"` - // Platform holds the value of the "platform" field. - Platform string `json:"platform,omitempty"` - // RateMultiplier holds the value of the "rate_multiplier" field. - RateMultiplier float64 `json:"rate_multiplier,omitempty"` - // Description holds the value of the "description" field. - Description string `json:"description,omitempty"` - // Models holds the value of the "models" field. - Models string `json:"models,omitempty"` - // Features holds the value of the "features" field. - Features string `json:"features,omitempty"` - // SortOrder holds the value of the "sort_order" field. - SortOrder int `json:"sort_order,omitempty"` - // Enabled holds the value of the "enabled" field. - Enabled bool `json:"enabled,omitempty"` - // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` - // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` - selectValues sql.SelectValues -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*PaymentChannel) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case paymentchannel.FieldEnabled: - values[i] = new(sql.NullBool) - case paymentchannel.FieldRateMultiplier: - values[i] = new(sql.NullFloat64) - case paymentchannel.FieldID, paymentchannel.FieldGroupID, paymentchannel.FieldSortOrder: - values[i] = new(sql.NullInt64) - case paymentchannel.FieldName, paymentchannel.FieldPlatform, paymentchannel.FieldDescription, paymentchannel.FieldModels, paymentchannel.FieldFeatures: - values[i] = new(sql.NullString) - case paymentchannel.FieldCreatedAt, paymentchannel.FieldUpdatedAt: - values[i] = new(sql.NullTime) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the PaymentChannel fields. -func (_m *PaymentChannel) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case paymentchannel.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int64(value.Int64) - case paymentchannel.FieldGroupID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field group_id", values[i]) - } else if value.Valid { - _m.GroupID = new(int64) - *_m.GroupID = value.Int64 - } - case paymentchannel.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - _m.Name = value.String - } - case paymentchannel.FieldPlatform: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field platform", values[i]) - } else if value.Valid { - _m.Platform = value.String - } - case paymentchannel.FieldRateMultiplier: - if value, ok := values[i].(*sql.NullFloat64); !ok { - return fmt.Errorf("unexpected type %T for field rate_multiplier", values[i]) - } else if value.Valid { - _m.RateMultiplier = value.Float64 - } - case paymentchannel.FieldDescription: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field description", values[i]) - } else if value.Valid { - _m.Description = value.String - } - case paymentchannel.FieldModels: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field models", values[i]) - } else if value.Valid { - _m.Models = value.String - } - case paymentchannel.FieldFeatures: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field features", values[i]) - } else if value.Valid { - _m.Features = value.String - } - case paymentchannel.FieldSortOrder: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field sort_order", values[i]) - } else if value.Valid { - _m.SortOrder = int(value.Int64) - } - case paymentchannel.FieldEnabled: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field enabled", values[i]) - } else if value.Valid { - _m.Enabled = value.Bool - } - case paymentchannel.FieldCreatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field created_at", values[i]) - } else if value.Valid { - _m.CreatedAt = value.Time - } - case paymentchannel.FieldUpdatedAt: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field updated_at", values[i]) - } else if value.Valid { - _m.UpdatedAt = value.Time - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the PaymentChannel. -// This includes values selected through modifiers, order, etc. -func (_m *PaymentChannel) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// Update returns a builder for updating this PaymentChannel. -// Note that you need to call PaymentChannel.Unwrap() before calling this method if this PaymentChannel -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *PaymentChannel) Update() *PaymentChannelUpdateOne { - return NewPaymentChannelClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the PaymentChannel entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *PaymentChannel) Unwrap() *PaymentChannel { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: PaymentChannel is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *PaymentChannel) String() string { - var builder strings.Builder - builder.WriteString("PaymentChannel(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - if v := _m.GroupID; v != nil { - builder.WriteString("group_id=") - builder.WriteString(fmt.Sprintf("%v", *v)) - } - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) - builder.WriteString(", ") - builder.WriteString("platform=") - builder.WriteString(_m.Platform) - builder.WriteString(", ") - builder.WriteString("rate_multiplier=") - builder.WriteString(fmt.Sprintf("%v", _m.RateMultiplier)) - builder.WriteString(", ") - builder.WriteString("description=") - builder.WriteString(_m.Description) - builder.WriteString(", ") - builder.WriteString("models=") - builder.WriteString(_m.Models) - builder.WriteString(", ") - builder.WriteString("features=") - builder.WriteString(_m.Features) - builder.WriteString(", ") - builder.WriteString("sort_order=") - builder.WriteString(fmt.Sprintf("%v", _m.SortOrder)) - builder.WriteString(", ") - builder.WriteString("enabled=") - builder.WriteString(fmt.Sprintf("%v", _m.Enabled)) - builder.WriteString(", ") - builder.WriteString("created_at=") - builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("updated_at=") - builder.WriteString(_m.UpdatedAt.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// PaymentChannels is a parsable slice of PaymentChannel. -type PaymentChannels []*PaymentChannel diff --git a/backend/ent/paymentchannel/paymentchannel.go b/backend/ent/paymentchannel/paymentchannel.go deleted file mode 100644 index 34d731680e..0000000000 --- a/backend/ent/paymentchannel/paymentchannel.go +++ /dev/null @@ -1,156 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package paymentchannel - -import ( - "time" - - "entgo.io/ent/dialect/sql" -) - -const ( - // Label holds the string label denoting the paymentchannel type in the database. - Label = "payment_channel" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldGroupID holds the string denoting the group_id field in the database. - FieldGroupID = "group_id" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldPlatform holds the string denoting the platform field in the database. - FieldPlatform = "platform" - // FieldRateMultiplier holds the string denoting the rate_multiplier field in the database. - FieldRateMultiplier = "rate_multiplier" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldModels holds the string denoting the models field in the database. - FieldModels = "models" - // FieldFeatures holds the string denoting the features field in the database. - FieldFeatures = "features" - // FieldSortOrder holds the string denoting the sort_order field in the database. - FieldSortOrder = "sort_order" - // FieldEnabled holds the string denoting the enabled field in the database. - FieldEnabled = "enabled" - // FieldCreatedAt holds the string denoting the created_at field in the database. - FieldCreatedAt = "created_at" - // FieldUpdatedAt holds the string denoting the updated_at field in the database. - FieldUpdatedAt = "updated_at" - // Table holds the table name of the paymentchannel in the database. - Table = "payment_channels" -) - -// Columns holds all SQL columns for paymentchannel fields. -var Columns = []string{ - FieldID, - FieldGroupID, - FieldName, - FieldPlatform, - FieldRateMultiplier, - FieldDescription, - FieldModels, - FieldFeatures, - FieldSortOrder, - FieldEnabled, - FieldCreatedAt, - FieldUpdatedAt, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DefaultPlatform holds the default value on creation for the "platform" field. - DefaultPlatform string - // PlatformValidator is a validator for the "platform" field. It is called by the builders before save. - PlatformValidator func(string) error - // DefaultRateMultiplier holds the default value on creation for the "rate_multiplier" field. - DefaultRateMultiplier float64 - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DefaultModels holds the default value on creation for the "models" field. - DefaultModels string - // DefaultFeatures holds the default value on creation for the "features" field. - DefaultFeatures string - // DefaultSortOrder holds the default value on creation for the "sort_order" field. - DefaultSortOrder int - // DefaultEnabled holds the default value on creation for the "enabled" field. - DefaultEnabled bool - // DefaultCreatedAt holds the default value on creation for the "created_at" field. - DefaultCreatedAt func() time.Time - // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. - DefaultUpdatedAt func() time.Time - // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. - UpdateDefaultUpdatedAt func() time.Time -) - -// OrderOption defines the ordering options for the PaymentChannel queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByGroupID orders the results by the group_id field. -func ByGroupID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldGroupID, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByPlatform orders the results by the platform field. -func ByPlatform(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPlatform, opts...).ToFunc() -} - -// ByRateMultiplier orders the results by the rate_multiplier field. -func ByRateMultiplier(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRateMultiplier, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByModels orders the results by the models field. -func ByModels(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldModels, opts...).ToFunc() -} - -// ByFeatures orders the results by the features field. -func ByFeatures(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldFeatures, opts...).ToFunc() -} - -// BySortOrder orders the results by the sort_order field. -func BySortOrder(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSortOrder, opts...).ToFunc() -} - -// ByEnabled orders the results by the enabled field. -func ByEnabled(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEnabled, opts...).ToFunc() -} - -// ByCreatedAt orders the results by the created_at field. -func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() -} - -// ByUpdatedAt orders the results by the updated_at field. -func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() -} diff --git a/backend/ent/paymentchannel/where.go b/backend/ent/paymentchannel/where.go deleted file mode 100644 index ab2db718ad..0000000000 --- a/backend/ent/paymentchannel/where.go +++ /dev/null @@ -1,670 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package paymentchannel - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "github.com/Wei-Shaw/sub2api/ent/predicate" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldID, id)) -} - -// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ. -func GroupID(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldGroupID, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldName, v)) -} - -// Platform applies equality check predicate on the "platform" field. It's identical to PlatformEQ. -func Platform(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldPlatform, v)) -} - -// RateMultiplier applies equality check predicate on the "rate_multiplier" field. It's identical to RateMultiplierEQ. -func RateMultiplier(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldRateMultiplier, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldDescription, v)) -} - -// Models applies equality check predicate on the "models" field. It's identical to ModelsEQ. -func Models(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldModels, v)) -} - -// Features applies equality check predicate on the "features" field. It's identical to FeaturesEQ. -func Features(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldFeatures, v)) -} - -// SortOrder applies equality check predicate on the "sort_order" field. It's identical to SortOrderEQ. -func SortOrder(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldSortOrder, v)) -} - -// Enabled applies equality check predicate on the "enabled" field. It's identical to EnabledEQ. -func Enabled(v bool) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldEnabled, v)) -} - -// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. -func CreatedAt(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldCreatedAt, v)) -} - -// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. -func UpdatedAt(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldUpdatedAt, v)) -} - -// GroupIDEQ applies the EQ predicate on the "group_id" field. -func GroupIDEQ(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldGroupID, v)) -} - -// GroupIDNEQ applies the NEQ predicate on the "group_id" field. -func GroupIDNEQ(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldGroupID, v)) -} - -// GroupIDIn applies the In predicate on the "group_id" field. -func GroupIDIn(vs ...int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldGroupID, vs...)) -} - -// GroupIDNotIn applies the NotIn predicate on the "group_id" field. -func GroupIDNotIn(vs ...int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldGroupID, vs...)) -} - -// GroupIDGT applies the GT predicate on the "group_id" field. -func GroupIDGT(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldGroupID, v)) -} - -// GroupIDGTE applies the GTE predicate on the "group_id" field. -func GroupIDGTE(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldGroupID, v)) -} - -// GroupIDLT applies the LT predicate on the "group_id" field. -func GroupIDLT(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldGroupID, v)) -} - -// GroupIDLTE applies the LTE predicate on the "group_id" field. -func GroupIDLTE(v int64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldGroupID, v)) -} - -// GroupIDIsNil applies the IsNil predicate on the "group_id" field. -func GroupIDIsNil() predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIsNull(FieldGroupID)) -} - -// GroupIDNotNil applies the NotNil predicate on the "group_id" field. -func GroupIDNotNil() predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotNull(FieldGroupID)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContainsFold(FieldName, v)) -} - -// PlatformEQ applies the EQ predicate on the "platform" field. -func PlatformEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldPlatform, v)) -} - -// PlatformNEQ applies the NEQ predicate on the "platform" field. -func PlatformNEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldPlatform, v)) -} - -// PlatformIn applies the In predicate on the "platform" field. -func PlatformIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldPlatform, vs...)) -} - -// PlatformNotIn applies the NotIn predicate on the "platform" field. -func PlatformNotIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldPlatform, vs...)) -} - -// PlatformGT applies the GT predicate on the "platform" field. -func PlatformGT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldPlatform, v)) -} - -// PlatformGTE applies the GTE predicate on the "platform" field. -func PlatformGTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldPlatform, v)) -} - -// PlatformLT applies the LT predicate on the "platform" field. -func PlatformLT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldPlatform, v)) -} - -// PlatformLTE applies the LTE predicate on the "platform" field. -func PlatformLTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldPlatform, v)) -} - -// PlatformContains applies the Contains predicate on the "platform" field. -func PlatformContains(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContains(FieldPlatform, v)) -} - -// PlatformHasPrefix applies the HasPrefix predicate on the "platform" field. -func PlatformHasPrefix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasPrefix(FieldPlatform, v)) -} - -// PlatformHasSuffix applies the HasSuffix predicate on the "platform" field. -func PlatformHasSuffix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasSuffix(FieldPlatform, v)) -} - -// PlatformEqualFold applies the EqualFold predicate on the "platform" field. -func PlatformEqualFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEqualFold(FieldPlatform, v)) -} - -// PlatformContainsFold applies the ContainsFold predicate on the "platform" field. -func PlatformContainsFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContainsFold(FieldPlatform, v)) -} - -// RateMultiplierEQ applies the EQ predicate on the "rate_multiplier" field. -func RateMultiplierEQ(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldRateMultiplier, v)) -} - -// RateMultiplierNEQ applies the NEQ predicate on the "rate_multiplier" field. -func RateMultiplierNEQ(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldRateMultiplier, v)) -} - -// RateMultiplierIn applies the In predicate on the "rate_multiplier" field. -func RateMultiplierIn(vs ...float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldRateMultiplier, vs...)) -} - -// RateMultiplierNotIn applies the NotIn predicate on the "rate_multiplier" field. -func RateMultiplierNotIn(vs ...float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldRateMultiplier, vs...)) -} - -// RateMultiplierGT applies the GT predicate on the "rate_multiplier" field. -func RateMultiplierGT(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldRateMultiplier, v)) -} - -// RateMultiplierGTE applies the GTE predicate on the "rate_multiplier" field. -func RateMultiplierGTE(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldRateMultiplier, v)) -} - -// RateMultiplierLT applies the LT predicate on the "rate_multiplier" field. -func RateMultiplierLT(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldRateMultiplier, v)) -} - -// RateMultiplierLTE applies the LTE predicate on the "rate_multiplier" field. -func RateMultiplierLTE(v float64) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldRateMultiplier, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContainsFold(FieldDescription, v)) -} - -// ModelsEQ applies the EQ predicate on the "models" field. -func ModelsEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldModels, v)) -} - -// ModelsNEQ applies the NEQ predicate on the "models" field. -func ModelsNEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldModels, v)) -} - -// ModelsIn applies the In predicate on the "models" field. -func ModelsIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldModels, vs...)) -} - -// ModelsNotIn applies the NotIn predicate on the "models" field. -func ModelsNotIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldModels, vs...)) -} - -// ModelsGT applies the GT predicate on the "models" field. -func ModelsGT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldModels, v)) -} - -// ModelsGTE applies the GTE predicate on the "models" field. -func ModelsGTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldModels, v)) -} - -// ModelsLT applies the LT predicate on the "models" field. -func ModelsLT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldModels, v)) -} - -// ModelsLTE applies the LTE predicate on the "models" field. -func ModelsLTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldModels, v)) -} - -// ModelsContains applies the Contains predicate on the "models" field. -func ModelsContains(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContains(FieldModels, v)) -} - -// ModelsHasPrefix applies the HasPrefix predicate on the "models" field. -func ModelsHasPrefix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasPrefix(FieldModels, v)) -} - -// ModelsHasSuffix applies the HasSuffix predicate on the "models" field. -func ModelsHasSuffix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasSuffix(FieldModels, v)) -} - -// ModelsEqualFold applies the EqualFold predicate on the "models" field. -func ModelsEqualFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEqualFold(FieldModels, v)) -} - -// ModelsContainsFold applies the ContainsFold predicate on the "models" field. -func ModelsContainsFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContainsFold(FieldModels, v)) -} - -// FeaturesEQ applies the EQ predicate on the "features" field. -func FeaturesEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldFeatures, v)) -} - -// FeaturesNEQ applies the NEQ predicate on the "features" field. -func FeaturesNEQ(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldFeatures, v)) -} - -// FeaturesIn applies the In predicate on the "features" field. -func FeaturesIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldFeatures, vs...)) -} - -// FeaturesNotIn applies the NotIn predicate on the "features" field. -func FeaturesNotIn(vs ...string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldFeatures, vs...)) -} - -// FeaturesGT applies the GT predicate on the "features" field. -func FeaturesGT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldFeatures, v)) -} - -// FeaturesGTE applies the GTE predicate on the "features" field. -func FeaturesGTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldFeatures, v)) -} - -// FeaturesLT applies the LT predicate on the "features" field. -func FeaturesLT(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldFeatures, v)) -} - -// FeaturesLTE applies the LTE predicate on the "features" field. -func FeaturesLTE(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldFeatures, v)) -} - -// FeaturesContains applies the Contains predicate on the "features" field. -func FeaturesContains(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContains(FieldFeatures, v)) -} - -// FeaturesHasPrefix applies the HasPrefix predicate on the "features" field. -func FeaturesHasPrefix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasPrefix(FieldFeatures, v)) -} - -// FeaturesHasSuffix applies the HasSuffix predicate on the "features" field. -func FeaturesHasSuffix(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldHasSuffix(FieldFeatures, v)) -} - -// FeaturesEqualFold applies the EqualFold predicate on the "features" field. -func FeaturesEqualFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEqualFold(FieldFeatures, v)) -} - -// FeaturesContainsFold applies the ContainsFold predicate on the "features" field. -func FeaturesContainsFold(v string) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldContainsFold(FieldFeatures, v)) -} - -// SortOrderEQ applies the EQ predicate on the "sort_order" field. -func SortOrderEQ(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldSortOrder, v)) -} - -// SortOrderNEQ applies the NEQ predicate on the "sort_order" field. -func SortOrderNEQ(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldSortOrder, v)) -} - -// SortOrderIn applies the In predicate on the "sort_order" field. -func SortOrderIn(vs ...int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldSortOrder, vs...)) -} - -// SortOrderNotIn applies the NotIn predicate on the "sort_order" field. -func SortOrderNotIn(vs ...int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldSortOrder, vs...)) -} - -// SortOrderGT applies the GT predicate on the "sort_order" field. -func SortOrderGT(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldSortOrder, v)) -} - -// SortOrderGTE applies the GTE predicate on the "sort_order" field. -func SortOrderGTE(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldSortOrder, v)) -} - -// SortOrderLT applies the LT predicate on the "sort_order" field. -func SortOrderLT(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldSortOrder, v)) -} - -// SortOrderLTE applies the LTE predicate on the "sort_order" field. -func SortOrderLTE(v int) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldSortOrder, v)) -} - -// EnabledEQ applies the EQ predicate on the "enabled" field. -func EnabledEQ(v bool) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldEnabled, v)) -} - -// EnabledNEQ applies the NEQ predicate on the "enabled" field. -func EnabledNEQ(v bool) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldEnabled, v)) -} - -// CreatedAtEQ applies the EQ predicate on the "created_at" field. -func CreatedAtEQ(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldCreatedAt, v)) -} - -// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. -func CreatedAtNEQ(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldCreatedAt, v)) -} - -// CreatedAtIn applies the In predicate on the "created_at" field. -func CreatedAtIn(vs ...time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldCreatedAt, vs...)) -} - -// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. -func CreatedAtNotIn(vs ...time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldCreatedAt, vs...)) -} - -// CreatedAtGT applies the GT predicate on the "created_at" field. -func CreatedAtGT(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldCreatedAt, v)) -} - -// CreatedAtGTE applies the GTE predicate on the "created_at" field. -func CreatedAtGTE(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldCreatedAt, v)) -} - -// CreatedAtLT applies the LT predicate on the "created_at" field. -func CreatedAtLT(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldCreatedAt, v)) -} - -// CreatedAtLTE applies the LTE predicate on the "created_at" field. -func CreatedAtLTE(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldCreatedAt, v)) -} - -// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. -func UpdatedAtEQ(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldEQ(FieldUpdatedAt, v)) -} - -// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. -func UpdatedAtNEQ(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNEQ(FieldUpdatedAt, v)) -} - -// UpdatedAtIn applies the In predicate on the "updated_at" field. -func UpdatedAtIn(vs ...time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldIn(FieldUpdatedAt, vs...)) -} - -// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. -func UpdatedAtNotIn(vs ...time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldNotIn(FieldUpdatedAt, vs...)) -} - -// UpdatedAtGT applies the GT predicate on the "updated_at" field. -func UpdatedAtGT(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGT(FieldUpdatedAt, v)) -} - -// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. -func UpdatedAtGTE(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldGTE(FieldUpdatedAt, v)) -} - -// UpdatedAtLT applies the LT predicate on the "updated_at" field. -func UpdatedAtLT(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLT(FieldUpdatedAt, v)) -} - -// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. -func UpdatedAtLTE(v time.Time) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.FieldLTE(FieldUpdatedAt, v)) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.PaymentChannel) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.PaymentChannel) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.PaymentChannel) predicate.PaymentChannel { - return predicate.PaymentChannel(sql.NotPredicates(p)) -} diff --git a/backend/ent/paymentchannel_create.go b/backend/ent/paymentchannel_create.go deleted file mode 100644 index 96edc8a892..0000000000 --- a/backend/ent/paymentchannel_create.go +++ /dev/null @@ -1,1166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" -) - -// PaymentChannelCreate is the builder for creating a PaymentChannel entity. -type PaymentChannelCreate struct { - config - mutation *PaymentChannelMutation - hooks []Hook - conflict []sql.ConflictOption -} - -// SetGroupID sets the "group_id" field. -func (_c *PaymentChannelCreate) SetGroupID(v int64) *PaymentChannelCreate { - _c.mutation.SetGroupID(v) - return _c -} - -// SetNillableGroupID sets the "group_id" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableGroupID(v *int64) *PaymentChannelCreate { - if v != nil { - _c.SetGroupID(*v) - } - return _c -} - -// SetName sets the "name" field. -func (_c *PaymentChannelCreate) SetName(v string) *PaymentChannelCreate { - _c.mutation.SetName(v) - return _c -} - -// SetPlatform sets the "platform" field. -func (_c *PaymentChannelCreate) SetPlatform(v string) *PaymentChannelCreate { - _c.mutation.SetPlatform(v) - return _c -} - -// SetNillablePlatform sets the "platform" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillablePlatform(v *string) *PaymentChannelCreate { - if v != nil { - _c.SetPlatform(*v) - } - return _c -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (_c *PaymentChannelCreate) SetRateMultiplier(v float64) *PaymentChannelCreate { - _c.mutation.SetRateMultiplier(v) - return _c -} - -// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableRateMultiplier(v *float64) *PaymentChannelCreate { - if v != nil { - _c.SetRateMultiplier(*v) - } - return _c -} - -// SetDescription sets the "description" field. -func (_c *PaymentChannelCreate) SetDescription(v string) *PaymentChannelCreate { - _c.mutation.SetDescription(v) - return _c -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableDescription(v *string) *PaymentChannelCreate { - if v != nil { - _c.SetDescription(*v) - } - return _c -} - -// SetModels sets the "models" field. -func (_c *PaymentChannelCreate) SetModels(v string) *PaymentChannelCreate { - _c.mutation.SetModels(v) - return _c -} - -// SetNillableModels sets the "models" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableModels(v *string) *PaymentChannelCreate { - if v != nil { - _c.SetModels(*v) - } - return _c -} - -// SetFeatures sets the "features" field. -func (_c *PaymentChannelCreate) SetFeatures(v string) *PaymentChannelCreate { - _c.mutation.SetFeatures(v) - return _c -} - -// SetNillableFeatures sets the "features" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableFeatures(v *string) *PaymentChannelCreate { - if v != nil { - _c.SetFeatures(*v) - } - return _c -} - -// SetSortOrder sets the "sort_order" field. -func (_c *PaymentChannelCreate) SetSortOrder(v int) *PaymentChannelCreate { - _c.mutation.SetSortOrder(v) - return _c -} - -// SetNillableSortOrder sets the "sort_order" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableSortOrder(v *int) *PaymentChannelCreate { - if v != nil { - _c.SetSortOrder(*v) - } - return _c -} - -// SetEnabled sets the "enabled" field. -func (_c *PaymentChannelCreate) SetEnabled(v bool) *PaymentChannelCreate { - _c.mutation.SetEnabled(v) - return _c -} - -// SetNillableEnabled sets the "enabled" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableEnabled(v *bool) *PaymentChannelCreate { - if v != nil { - _c.SetEnabled(*v) - } - return _c -} - -// SetCreatedAt sets the "created_at" field. -func (_c *PaymentChannelCreate) SetCreatedAt(v time.Time) *PaymentChannelCreate { - _c.mutation.SetCreatedAt(v) - return _c -} - -// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableCreatedAt(v *time.Time) *PaymentChannelCreate { - if v != nil { - _c.SetCreatedAt(*v) - } - return _c -} - -// SetUpdatedAt sets the "updated_at" field. -func (_c *PaymentChannelCreate) SetUpdatedAt(v time.Time) *PaymentChannelCreate { - _c.mutation.SetUpdatedAt(v) - return _c -} - -// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. -func (_c *PaymentChannelCreate) SetNillableUpdatedAt(v *time.Time) *PaymentChannelCreate { - if v != nil { - _c.SetUpdatedAt(*v) - } - return _c -} - -// Mutation returns the PaymentChannelMutation object of the builder. -func (_c *PaymentChannelCreate) Mutation() *PaymentChannelMutation { - return _c.mutation -} - -// Save creates the PaymentChannel in the database. -func (_c *PaymentChannelCreate) Save(ctx context.Context) (*PaymentChannel, error) { - _c.defaults() - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *PaymentChannelCreate) SaveX(ctx context.Context) *PaymentChannel { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *PaymentChannelCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *PaymentChannelCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *PaymentChannelCreate) defaults() { - if _, ok := _c.mutation.Platform(); !ok { - v := paymentchannel.DefaultPlatform - _c.mutation.SetPlatform(v) - } - if _, ok := _c.mutation.RateMultiplier(); !ok { - v := paymentchannel.DefaultRateMultiplier - _c.mutation.SetRateMultiplier(v) - } - if _, ok := _c.mutation.Description(); !ok { - v := paymentchannel.DefaultDescription - _c.mutation.SetDescription(v) - } - if _, ok := _c.mutation.Models(); !ok { - v := paymentchannel.DefaultModels - _c.mutation.SetModels(v) - } - if _, ok := _c.mutation.Features(); !ok { - v := paymentchannel.DefaultFeatures - _c.mutation.SetFeatures(v) - } - if _, ok := _c.mutation.SortOrder(); !ok { - v := paymentchannel.DefaultSortOrder - _c.mutation.SetSortOrder(v) - } - if _, ok := _c.mutation.Enabled(); !ok { - v := paymentchannel.DefaultEnabled - _c.mutation.SetEnabled(v) - } - if _, ok := _c.mutation.CreatedAt(); !ok { - v := paymentchannel.DefaultCreatedAt() - _c.mutation.SetCreatedAt(v) - } - if _, ok := _c.mutation.UpdatedAt(); !ok { - v := paymentchannel.DefaultUpdatedAt() - _c.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *PaymentChannelCreate) check() error { - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "PaymentChannel.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := paymentchannel.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "PaymentChannel.name": %w`, err)} - } - } - if _, ok := _c.mutation.Platform(); !ok { - return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "PaymentChannel.platform"`)} - } - if v, ok := _c.mutation.Platform(); ok { - if err := paymentchannel.PlatformValidator(v); err != nil { - return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "PaymentChannel.platform": %w`, err)} - } - } - if _, ok := _c.mutation.RateMultiplier(); !ok { - return &ValidationError{Name: "rate_multiplier", err: errors.New(`ent: missing required field "PaymentChannel.rate_multiplier"`)} - } - if _, ok := _c.mutation.Description(); !ok { - return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "PaymentChannel.description"`)} - } - if _, ok := _c.mutation.Models(); !ok { - return &ValidationError{Name: "models", err: errors.New(`ent: missing required field "PaymentChannel.models"`)} - } - if _, ok := _c.mutation.Features(); !ok { - return &ValidationError{Name: "features", err: errors.New(`ent: missing required field "PaymentChannel.features"`)} - } - if _, ok := _c.mutation.SortOrder(); !ok { - return &ValidationError{Name: "sort_order", err: errors.New(`ent: missing required field "PaymentChannel.sort_order"`)} - } - if _, ok := _c.mutation.Enabled(); !ok { - return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "PaymentChannel.enabled"`)} - } - if _, ok := _c.mutation.CreatedAt(); !ok { - return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PaymentChannel.created_at"`)} - } - if _, ok := _c.mutation.UpdatedAt(); !ok { - return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PaymentChannel.updated_at"`)} - } - return nil -} - -func (_c *PaymentChannelCreate) sqlSave(ctx context.Context) (*PaymentChannel, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int64(id) - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *PaymentChannelCreate) createSpec() (*PaymentChannel, *sqlgraph.CreateSpec) { - var ( - _node = &PaymentChannel{config: _c.config} - _spec = sqlgraph.NewCreateSpec(paymentchannel.Table, sqlgraph.NewFieldSpec(paymentchannel.FieldID, field.TypeInt64)) - ) - _spec.OnConflict = _c.conflict - if value, ok := _c.mutation.GroupID(); ok { - _spec.SetField(paymentchannel.FieldGroupID, field.TypeInt64, value) - _node.GroupID = &value - } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(paymentchannel.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := _c.mutation.Platform(); ok { - _spec.SetField(paymentchannel.FieldPlatform, field.TypeString, value) - _node.Platform = value - } - if value, ok := _c.mutation.RateMultiplier(); ok { - _spec.SetField(paymentchannel.FieldRateMultiplier, field.TypeFloat64, value) - _node.RateMultiplier = value - } - if value, ok := _c.mutation.Description(); ok { - _spec.SetField(paymentchannel.FieldDescription, field.TypeString, value) - _node.Description = value - } - if value, ok := _c.mutation.Models(); ok { - _spec.SetField(paymentchannel.FieldModels, field.TypeString, value) - _node.Models = value - } - if value, ok := _c.mutation.Features(); ok { - _spec.SetField(paymentchannel.FieldFeatures, field.TypeString, value) - _node.Features = value - } - if value, ok := _c.mutation.SortOrder(); ok { - _spec.SetField(paymentchannel.FieldSortOrder, field.TypeInt, value) - _node.SortOrder = value - } - if value, ok := _c.mutation.Enabled(); ok { - _spec.SetField(paymentchannel.FieldEnabled, field.TypeBool, value) - _node.Enabled = value - } - if value, ok := _c.mutation.CreatedAt(); ok { - _spec.SetField(paymentchannel.FieldCreatedAt, field.TypeTime, value) - _node.CreatedAt = value - } - if value, ok := _c.mutation.UpdatedAt(); ok { - _spec.SetField(paymentchannel.FieldUpdatedAt, field.TypeTime, value) - _node.UpdatedAt = value - } - return _node, _spec -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.PaymentChannel.Create(). -// SetGroupID(v). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.PaymentChannelUpsert) { -// SetGroupID(v+v). -// }). -// Exec(ctx) -func (_c *PaymentChannelCreate) OnConflict(opts ...sql.ConflictOption) *PaymentChannelUpsertOne { - _c.conflict = opts - return &PaymentChannelUpsertOne{ - create: _c, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.PaymentChannel.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (_c *PaymentChannelCreate) OnConflictColumns(columns ...string) *PaymentChannelUpsertOne { - _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &PaymentChannelUpsertOne{ - create: _c, - } -} - -type ( - // PaymentChannelUpsertOne is the builder for "upsert"-ing - // one PaymentChannel node. - PaymentChannelUpsertOne struct { - create *PaymentChannelCreate - } - - // PaymentChannelUpsert is the "OnConflict" setter. - PaymentChannelUpsert struct { - *sql.UpdateSet - } -) - -// SetGroupID sets the "group_id" field. -func (u *PaymentChannelUpsert) SetGroupID(v int64) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldGroupID, v) - return u -} - -// UpdateGroupID sets the "group_id" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateGroupID() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldGroupID) - return u -} - -// AddGroupID adds v to the "group_id" field. -func (u *PaymentChannelUpsert) AddGroupID(v int64) *PaymentChannelUpsert { - u.Add(paymentchannel.FieldGroupID, v) - return u -} - -// ClearGroupID clears the value of the "group_id" field. -func (u *PaymentChannelUpsert) ClearGroupID() *PaymentChannelUpsert { - u.SetNull(paymentchannel.FieldGroupID) - return u -} - -// SetName sets the "name" field. -func (u *PaymentChannelUpsert) SetName(v string) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldName, v) - return u -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateName() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldName) - return u -} - -// SetPlatform sets the "platform" field. -func (u *PaymentChannelUpsert) SetPlatform(v string) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldPlatform, v) - return u -} - -// UpdatePlatform sets the "platform" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdatePlatform() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldPlatform) - return u -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (u *PaymentChannelUpsert) SetRateMultiplier(v float64) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldRateMultiplier, v) - return u -} - -// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateRateMultiplier() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldRateMultiplier) - return u -} - -// AddRateMultiplier adds v to the "rate_multiplier" field. -func (u *PaymentChannelUpsert) AddRateMultiplier(v float64) *PaymentChannelUpsert { - u.Add(paymentchannel.FieldRateMultiplier, v) - return u -} - -// SetDescription sets the "description" field. -func (u *PaymentChannelUpsert) SetDescription(v string) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldDescription, v) - return u -} - -// UpdateDescription sets the "description" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateDescription() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldDescription) - return u -} - -// SetModels sets the "models" field. -func (u *PaymentChannelUpsert) SetModels(v string) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldModels, v) - return u -} - -// UpdateModels sets the "models" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateModels() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldModels) - return u -} - -// SetFeatures sets the "features" field. -func (u *PaymentChannelUpsert) SetFeatures(v string) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldFeatures, v) - return u -} - -// UpdateFeatures sets the "features" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateFeatures() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldFeatures) - return u -} - -// SetSortOrder sets the "sort_order" field. -func (u *PaymentChannelUpsert) SetSortOrder(v int) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldSortOrder, v) - return u -} - -// UpdateSortOrder sets the "sort_order" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateSortOrder() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldSortOrder) - return u -} - -// AddSortOrder adds v to the "sort_order" field. -func (u *PaymentChannelUpsert) AddSortOrder(v int) *PaymentChannelUpsert { - u.Add(paymentchannel.FieldSortOrder, v) - return u -} - -// SetEnabled sets the "enabled" field. -func (u *PaymentChannelUpsert) SetEnabled(v bool) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldEnabled, v) - return u -} - -// UpdateEnabled sets the "enabled" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateEnabled() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldEnabled) - return u -} - -// SetUpdatedAt sets the "updated_at" field. -func (u *PaymentChannelUpsert) SetUpdatedAt(v time.Time) *PaymentChannelUpsert { - u.Set(paymentchannel.FieldUpdatedAt, v) - return u -} - -// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. -func (u *PaymentChannelUpsert) UpdateUpdatedAt() *PaymentChannelUpsert { - u.SetExcluded(paymentchannel.FieldUpdatedAt) - return u -} - -// UpdateNewValues updates the mutable fields using the new values that were set on create. -// Using this option is equivalent to using: -// -// client.PaymentChannel.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *PaymentChannelUpsertOne) UpdateNewValues() *PaymentChannelUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - if _, exists := u.create.mutation.CreatedAt(); exists { - s.SetIgnore(paymentchannel.FieldCreatedAt) - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.PaymentChannel.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *PaymentChannelUpsertOne) Ignore() *PaymentChannelUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *PaymentChannelUpsertOne) DoNothing() *PaymentChannelUpsertOne { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the PaymentChannelCreate.OnConflict -// documentation for more info. -func (u *PaymentChannelUpsertOne) Update(set func(*PaymentChannelUpsert)) *PaymentChannelUpsertOne { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&PaymentChannelUpsert{UpdateSet: update}) - })) - return u -} - -// SetGroupID sets the "group_id" field. -func (u *PaymentChannelUpsertOne) SetGroupID(v int64) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetGroupID(v) - }) -} - -// AddGroupID adds v to the "group_id" field. -func (u *PaymentChannelUpsertOne) AddGroupID(v int64) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.AddGroupID(v) - }) -} - -// UpdateGroupID sets the "group_id" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateGroupID() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateGroupID() - }) -} - -// ClearGroupID clears the value of the "group_id" field. -func (u *PaymentChannelUpsertOne) ClearGroupID() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.ClearGroupID() - }) -} - -// SetName sets the "name" field. -func (u *PaymentChannelUpsertOne) SetName(v string) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateName() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateName() - }) -} - -// SetPlatform sets the "platform" field. -func (u *PaymentChannelUpsertOne) SetPlatform(v string) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetPlatform(v) - }) -} - -// UpdatePlatform sets the "platform" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdatePlatform() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdatePlatform() - }) -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (u *PaymentChannelUpsertOne) SetRateMultiplier(v float64) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetRateMultiplier(v) - }) -} - -// AddRateMultiplier adds v to the "rate_multiplier" field. -func (u *PaymentChannelUpsertOne) AddRateMultiplier(v float64) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.AddRateMultiplier(v) - }) -} - -// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateRateMultiplier() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateRateMultiplier() - }) -} - -// SetDescription sets the "description" field. -func (u *PaymentChannelUpsertOne) SetDescription(v string) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetDescription(v) - }) -} - -// UpdateDescription sets the "description" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateDescription() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateDescription() - }) -} - -// SetModels sets the "models" field. -func (u *PaymentChannelUpsertOne) SetModels(v string) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetModels(v) - }) -} - -// UpdateModels sets the "models" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateModels() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateModels() - }) -} - -// SetFeatures sets the "features" field. -func (u *PaymentChannelUpsertOne) SetFeatures(v string) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetFeatures(v) - }) -} - -// UpdateFeatures sets the "features" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateFeatures() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateFeatures() - }) -} - -// SetSortOrder sets the "sort_order" field. -func (u *PaymentChannelUpsertOne) SetSortOrder(v int) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetSortOrder(v) - }) -} - -// AddSortOrder adds v to the "sort_order" field. -func (u *PaymentChannelUpsertOne) AddSortOrder(v int) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.AddSortOrder(v) - }) -} - -// UpdateSortOrder sets the "sort_order" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateSortOrder() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateSortOrder() - }) -} - -// SetEnabled sets the "enabled" field. -func (u *PaymentChannelUpsertOne) SetEnabled(v bool) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetEnabled(v) - }) -} - -// UpdateEnabled sets the "enabled" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateEnabled() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateEnabled() - }) -} - -// SetUpdatedAt sets the "updated_at" field. -func (u *PaymentChannelUpsertOne) SetUpdatedAt(v time.Time) *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetUpdatedAt(v) - }) -} - -// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. -func (u *PaymentChannelUpsertOne) UpdateUpdatedAt() *PaymentChannelUpsertOne { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateUpdatedAt() - }) -} - -// Exec executes the query. -func (u *PaymentChannelUpsertOne) Exec(ctx context.Context) error { - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for PaymentChannelCreate.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *PaymentChannelUpsertOne) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} - -// Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *PaymentChannelUpsertOne) ID(ctx context.Context) (id int64, err error) { - node, err := u.create.Save(ctx) - if err != nil { - return id, err - } - return node.ID, nil -} - -// IDX is like ID, but panics if an error occurs. -func (u *PaymentChannelUpsertOne) IDX(ctx context.Context) int64 { - id, err := u.ID(ctx) - if err != nil { - panic(err) - } - return id -} - -// PaymentChannelCreateBulk is the builder for creating many PaymentChannel entities in bulk. -type PaymentChannelCreateBulk struct { - config - err error - builders []*PaymentChannelCreate - conflict []sql.ConflictOption -} - -// Save creates the PaymentChannel entities in the database. -func (_c *PaymentChannelCreateBulk) Save(ctx context.Context) ([]*PaymentChannel, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*PaymentChannel, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PaymentChannelMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - spec.OnConflict = _c.conflict - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int64(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *PaymentChannelCreateBulk) SaveX(ctx context.Context) []*PaymentChannel { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *PaymentChannelCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *PaymentChannelCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause -// of the `INSERT` statement. For example: -// -// client.PaymentChannel.CreateBulk(builders...). -// OnConflict( -// // Update the row with the new values -// // the was proposed for insertion. -// sql.ResolveWithNewValues(), -// ). -// // Override some of the fields with custom -// // update values. -// Update(func(u *ent.PaymentChannelUpsert) { -// SetGroupID(v+v). -// }). -// Exec(ctx) -func (_c *PaymentChannelCreateBulk) OnConflict(opts ...sql.ConflictOption) *PaymentChannelUpsertBulk { - _c.conflict = opts - return &PaymentChannelUpsertBulk{ - create: _c, - } -} - -// OnConflictColumns calls `OnConflict` and configures the columns -// as conflict target. Using this option is equivalent to using: -// -// client.PaymentChannel.Create(). -// OnConflict(sql.ConflictColumns(columns...)). -// Exec(ctx) -func (_c *PaymentChannelCreateBulk) OnConflictColumns(columns ...string) *PaymentChannelUpsertBulk { - _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) - return &PaymentChannelUpsertBulk{ - create: _c, - } -} - -// PaymentChannelUpsertBulk is the builder for "upsert"-ing -// a bulk of PaymentChannel nodes. -type PaymentChannelUpsertBulk struct { - create *PaymentChannelCreateBulk -} - -// UpdateNewValues updates the mutable fields using the new values that -// were set on create. Using this option is equivalent to using: -// -// client.PaymentChannel.Create(). -// OnConflict( -// sql.ResolveWithNewValues(), -// ). -// Exec(ctx) -func (u *PaymentChannelUpsertBulk) UpdateNewValues() *PaymentChannelUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { - for _, b := range u.create.builders { - if _, exists := b.mutation.CreatedAt(); exists { - s.SetIgnore(paymentchannel.FieldCreatedAt) - } - } - })) - return u -} - -// Ignore sets each column to itself in case of conflict. -// Using this option is equivalent to using: -// -// client.PaymentChannel.Create(). -// OnConflict(sql.ResolveWithIgnore()). -// Exec(ctx) -func (u *PaymentChannelUpsertBulk) Ignore() *PaymentChannelUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) - return u -} - -// DoNothing configures the conflict_action to `DO NOTHING`. -// Supported only by SQLite and PostgreSQL. -func (u *PaymentChannelUpsertBulk) DoNothing() *PaymentChannelUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.DoNothing()) - return u -} - -// Update allows overriding fields `UPDATE` values. See the PaymentChannelCreateBulk.OnConflict -// documentation for more info. -func (u *PaymentChannelUpsertBulk) Update(set func(*PaymentChannelUpsert)) *PaymentChannelUpsertBulk { - u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { - set(&PaymentChannelUpsert{UpdateSet: update}) - })) - return u -} - -// SetGroupID sets the "group_id" field. -func (u *PaymentChannelUpsertBulk) SetGroupID(v int64) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetGroupID(v) - }) -} - -// AddGroupID adds v to the "group_id" field. -func (u *PaymentChannelUpsertBulk) AddGroupID(v int64) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.AddGroupID(v) - }) -} - -// UpdateGroupID sets the "group_id" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateGroupID() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateGroupID() - }) -} - -// ClearGroupID clears the value of the "group_id" field. -func (u *PaymentChannelUpsertBulk) ClearGroupID() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.ClearGroupID() - }) -} - -// SetName sets the "name" field. -func (u *PaymentChannelUpsertBulk) SetName(v string) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetName(v) - }) -} - -// UpdateName sets the "name" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateName() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateName() - }) -} - -// SetPlatform sets the "platform" field. -func (u *PaymentChannelUpsertBulk) SetPlatform(v string) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetPlatform(v) - }) -} - -// UpdatePlatform sets the "platform" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdatePlatform() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdatePlatform() - }) -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (u *PaymentChannelUpsertBulk) SetRateMultiplier(v float64) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetRateMultiplier(v) - }) -} - -// AddRateMultiplier adds v to the "rate_multiplier" field. -func (u *PaymentChannelUpsertBulk) AddRateMultiplier(v float64) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.AddRateMultiplier(v) - }) -} - -// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateRateMultiplier() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateRateMultiplier() - }) -} - -// SetDescription sets the "description" field. -func (u *PaymentChannelUpsertBulk) SetDescription(v string) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetDescription(v) - }) -} - -// UpdateDescription sets the "description" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateDescription() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateDescription() - }) -} - -// SetModels sets the "models" field. -func (u *PaymentChannelUpsertBulk) SetModels(v string) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetModels(v) - }) -} - -// UpdateModels sets the "models" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateModels() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateModels() - }) -} - -// SetFeatures sets the "features" field. -func (u *PaymentChannelUpsertBulk) SetFeatures(v string) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetFeatures(v) - }) -} - -// UpdateFeatures sets the "features" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateFeatures() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateFeatures() - }) -} - -// SetSortOrder sets the "sort_order" field. -func (u *PaymentChannelUpsertBulk) SetSortOrder(v int) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetSortOrder(v) - }) -} - -// AddSortOrder adds v to the "sort_order" field. -func (u *PaymentChannelUpsertBulk) AddSortOrder(v int) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.AddSortOrder(v) - }) -} - -// UpdateSortOrder sets the "sort_order" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateSortOrder() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateSortOrder() - }) -} - -// SetEnabled sets the "enabled" field. -func (u *PaymentChannelUpsertBulk) SetEnabled(v bool) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetEnabled(v) - }) -} - -// UpdateEnabled sets the "enabled" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateEnabled() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateEnabled() - }) -} - -// SetUpdatedAt sets the "updated_at" field. -func (u *PaymentChannelUpsertBulk) SetUpdatedAt(v time.Time) *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.SetUpdatedAt(v) - }) -} - -// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. -func (u *PaymentChannelUpsertBulk) UpdateUpdatedAt() *PaymentChannelUpsertBulk { - return u.Update(func(s *PaymentChannelUpsert) { - s.UpdateUpdatedAt() - }) -} - -// Exec executes the query. -func (u *PaymentChannelUpsertBulk) Exec(ctx context.Context) error { - if u.create.err != nil { - return u.create.err - } - for i, b := range u.create.builders { - if len(b.conflict) != 0 { - return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the PaymentChannelCreateBulk instead", i) - } - } - if len(u.create.conflict) == 0 { - return errors.New("ent: missing options for PaymentChannelCreateBulk.OnConflict") - } - return u.create.Exec(ctx) -} - -// ExecX is like Exec, but panics if an error occurs. -func (u *PaymentChannelUpsertBulk) ExecX(ctx context.Context) { - if err := u.create.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/backend/ent/paymentchannel_delete.go b/backend/ent/paymentchannel_delete.go deleted file mode 100644 index 1255e3933a..0000000000 --- a/backend/ent/paymentchannel_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// 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" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" - "github.com/Wei-Shaw/sub2api/ent/predicate" -) - -// PaymentChannelDelete is the builder for deleting a PaymentChannel entity. -type PaymentChannelDelete struct { - config - hooks []Hook - mutation *PaymentChannelMutation -} - -// Where appends a list predicates to the PaymentChannelDelete builder. -func (_d *PaymentChannelDelete) Where(ps ...predicate.PaymentChannel) *PaymentChannelDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *PaymentChannelDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *PaymentChannelDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *PaymentChannelDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(paymentchannel.Table, sqlgraph.NewFieldSpec(paymentchannel.FieldID, field.TypeInt64)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// PaymentChannelDeleteOne is the builder for deleting a single PaymentChannel entity. -type PaymentChannelDeleteOne struct { - _d *PaymentChannelDelete -} - -// Where appends a list predicates to the PaymentChannelDelete builder. -func (_d *PaymentChannelDeleteOne) Where(ps ...predicate.PaymentChannel) *PaymentChannelDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *PaymentChannelDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{paymentchannel.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *PaymentChannelDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/backend/ent/paymentchannel_query.go b/backend/ent/paymentchannel_query.go deleted file mode 100644 index c1a8ce1fe2..0000000000 --- a/backend/ent/paymentchannel_query.go +++ /dev/null @@ -1,564 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" - "github.com/Wei-Shaw/sub2api/ent/predicate" -) - -// PaymentChannelQuery is the builder for querying PaymentChannel entities. -type PaymentChannelQuery struct { - config - ctx *QueryContext - order []paymentchannel.OrderOption - inters []Interceptor - predicates []predicate.PaymentChannel - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the PaymentChannelQuery builder. -func (_q *PaymentChannelQuery) Where(ps ...predicate.PaymentChannel) *PaymentChannelQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *PaymentChannelQuery) Limit(limit int) *PaymentChannelQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *PaymentChannelQuery) Offset(offset int) *PaymentChannelQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *PaymentChannelQuery) Unique(unique bool) *PaymentChannelQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *PaymentChannelQuery) Order(o ...paymentchannel.OrderOption) *PaymentChannelQuery { - _q.order = append(_q.order, o...) - return _q -} - -// First returns the first PaymentChannel entity from the query. -// Returns a *NotFoundError when no PaymentChannel was found. -func (_q *PaymentChannelQuery) First(ctx context.Context) (*PaymentChannel, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{paymentchannel.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *PaymentChannelQuery) FirstX(ctx context.Context) *PaymentChannel { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first PaymentChannel ID from the query. -// Returns a *NotFoundError when no PaymentChannel ID was found. -func (_q *PaymentChannelQuery) FirstID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{paymentchannel.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *PaymentChannelQuery) FirstIDX(ctx context.Context) int64 { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single PaymentChannel entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one PaymentChannel entity is found. -// Returns a *NotFoundError when no PaymentChannel entities are found. -func (_q *PaymentChannelQuery) Only(ctx context.Context) (*PaymentChannel, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{paymentchannel.Label} - default: - return nil, &NotSingularError{paymentchannel.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *PaymentChannelQuery) OnlyX(ctx context.Context) *PaymentChannel { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only PaymentChannel ID in the query. -// Returns a *NotSingularError when more than one PaymentChannel ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *PaymentChannelQuery) OnlyID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{paymentchannel.Label} - default: - err = &NotSingularError{paymentchannel.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *PaymentChannelQuery) OnlyIDX(ctx context.Context) int64 { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of PaymentChannels. -func (_q *PaymentChannelQuery) All(ctx context.Context) ([]*PaymentChannel, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*PaymentChannel, *PaymentChannelQuery]() - return withInterceptors[[]*PaymentChannel](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *PaymentChannelQuery) AllX(ctx context.Context) []*PaymentChannel { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of PaymentChannel IDs. -func (_q *PaymentChannelQuery) IDs(ctx context.Context) (ids []int64, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(paymentchannel.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *PaymentChannelQuery) IDsX(ctx context.Context) []int64 { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *PaymentChannelQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*PaymentChannelQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *PaymentChannelQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *PaymentChannelQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *PaymentChannelQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the PaymentChannelQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *PaymentChannelQuery) Clone() *PaymentChannelQuery { - if _q == nil { - return nil - } - return &PaymentChannelQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]paymentchannel.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.PaymentChannel{}, _q.predicates...), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - } -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// GroupID int64 `json:"group_id,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.PaymentChannel.Query(). -// GroupBy(paymentchannel.FieldGroupID). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *PaymentChannelQuery) GroupBy(field string, fields ...string) *PaymentChannelGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &PaymentChannelGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = paymentchannel.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// GroupID int64 `json:"group_id,omitempty"` -// } -// -// client.PaymentChannel.Query(). -// Select(paymentchannel.FieldGroupID). -// Scan(ctx, &v) -func (_q *PaymentChannelQuery) Select(fields ...string) *PaymentChannelSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &PaymentChannelSelect{PaymentChannelQuery: _q} - sbuild.label = paymentchannel.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a PaymentChannelSelect configured with the given aggregations. -func (_q *PaymentChannelQuery) Aggregate(fns ...AggregateFunc) *PaymentChannelSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *PaymentChannelQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !paymentchannel.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *PaymentChannelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PaymentChannel, error) { - var ( - nodes = []*PaymentChannel{} - _spec = _q.querySpec() - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*PaymentChannel).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &PaymentChannel{config: _q.config} - nodes = append(nodes, node) - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - return nodes, nil -} - -func (_q *PaymentChannelQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *PaymentChannelQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(paymentchannel.Table, paymentchannel.Columns, sqlgraph.NewFieldSpec(paymentchannel.FieldID, field.TypeInt64)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, paymentchannel.FieldID) - for i := range fields { - if fields[i] != paymentchannel.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *PaymentChannelQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(paymentchannel.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = paymentchannel.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *PaymentChannelQuery) ForUpdate(opts ...sql.LockOption) *PaymentChannelQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *PaymentChannelQuery) ForShare(opts ...sql.LockOption) *PaymentChannelQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// PaymentChannelGroupBy is the group-by builder for PaymentChannel entities. -type PaymentChannelGroupBy struct { - selector - build *PaymentChannelQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *PaymentChannelGroupBy) Aggregate(fns ...AggregateFunc) *PaymentChannelGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *PaymentChannelGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*PaymentChannelQuery, *PaymentChannelGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *PaymentChannelGroupBy) sqlScan(ctx context.Context, root *PaymentChannelQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// PaymentChannelSelect is the builder for selecting fields of PaymentChannel entities. -type PaymentChannelSelect struct { - *PaymentChannelQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *PaymentChannelSelect) Aggregate(fns ...AggregateFunc) *PaymentChannelSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *PaymentChannelSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*PaymentChannelQuery, *PaymentChannelSelect](ctx, _s.PaymentChannelQuery, _s, _s.inters, v) -} - -func (_s *PaymentChannelSelect) sqlScan(ctx context.Context, root *PaymentChannelQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} diff --git a/backend/ent/paymentchannel_update.go b/backend/ent/paymentchannel_update.go deleted file mode 100644 index 5b054b4c0c..0000000000 --- a/backend/ent/paymentchannel_update.go +++ /dev/null @@ -1,632 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" - "github.com/Wei-Shaw/sub2api/ent/predicate" -) - -// PaymentChannelUpdate is the builder for updating PaymentChannel entities. -type PaymentChannelUpdate struct { - config - hooks []Hook - mutation *PaymentChannelMutation -} - -// Where appends a list predicates to the PaymentChannelUpdate builder. -func (_u *PaymentChannelUpdate) Where(ps ...predicate.PaymentChannel) *PaymentChannelUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetGroupID sets the "group_id" field. -func (_u *PaymentChannelUpdate) SetGroupID(v int64) *PaymentChannelUpdate { - _u.mutation.ResetGroupID() - _u.mutation.SetGroupID(v) - return _u -} - -// SetNillableGroupID sets the "group_id" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableGroupID(v *int64) *PaymentChannelUpdate { - if v != nil { - _u.SetGroupID(*v) - } - return _u -} - -// AddGroupID adds value to the "group_id" field. -func (_u *PaymentChannelUpdate) AddGroupID(v int64) *PaymentChannelUpdate { - _u.mutation.AddGroupID(v) - return _u -} - -// ClearGroupID clears the value of the "group_id" field. -func (_u *PaymentChannelUpdate) ClearGroupID() *PaymentChannelUpdate { - _u.mutation.ClearGroupID() - return _u -} - -// SetName sets the "name" field. -func (_u *PaymentChannelUpdate) SetName(v string) *PaymentChannelUpdate { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableName(v *string) *PaymentChannelUpdate { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetPlatform sets the "platform" field. -func (_u *PaymentChannelUpdate) SetPlatform(v string) *PaymentChannelUpdate { - _u.mutation.SetPlatform(v) - return _u -} - -// SetNillablePlatform sets the "platform" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillablePlatform(v *string) *PaymentChannelUpdate { - if v != nil { - _u.SetPlatform(*v) - } - return _u -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (_u *PaymentChannelUpdate) SetRateMultiplier(v float64) *PaymentChannelUpdate { - _u.mutation.ResetRateMultiplier() - _u.mutation.SetRateMultiplier(v) - return _u -} - -// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableRateMultiplier(v *float64) *PaymentChannelUpdate { - if v != nil { - _u.SetRateMultiplier(*v) - } - return _u -} - -// AddRateMultiplier adds value to the "rate_multiplier" field. -func (_u *PaymentChannelUpdate) AddRateMultiplier(v float64) *PaymentChannelUpdate { - _u.mutation.AddRateMultiplier(v) - return _u -} - -// SetDescription sets the "description" field. -func (_u *PaymentChannelUpdate) SetDescription(v string) *PaymentChannelUpdate { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableDescription(v *string) *PaymentChannelUpdate { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetModels sets the "models" field. -func (_u *PaymentChannelUpdate) SetModels(v string) *PaymentChannelUpdate { - _u.mutation.SetModels(v) - return _u -} - -// SetNillableModels sets the "models" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableModels(v *string) *PaymentChannelUpdate { - if v != nil { - _u.SetModels(*v) - } - return _u -} - -// SetFeatures sets the "features" field. -func (_u *PaymentChannelUpdate) SetFeatures(v string) *PaymentChannelUpdate { - _u.mutation.SetFeatures(v) - return _u -} - -// SetNillableFeatures sets the "features" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableFeatures(v *string) *PaymentChannelUpdate { - if v != nil { - _u.SetFeatures(*v) - } - return _u -} - -// SetSortOrder sets the "sort_order" field. -func (_u *PaymentChannelUpdate) SetSortOrder(v int) *PaymentChannelUpdate { - _u.mutation.ResetSortOrder() - _u.mutation.SetSortOrder(v) - return _u -} - -// SetNillableSortOrder sets the "sort_order" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableSortOrder(v *int) *PaymentChannelUpdate { - if v != nil { - _u.SetSortOrder(*v) - } - return _u -} - -// AddSortOrder adds value to the "sort_order" field. -func (_u *PaymentChannelUpdate) AddSortOrder(v int) *PaymentChannelUpdate { - _u.mutation.AddSortOrder(v) - return _u -} - -// SetEnabled sets the "enabled" field. -func (_u *PaymentChannelUpdate) SetEnabled(v bool) *PaymentChannelUpdate { - _u.mutation.SetEnabled(v) - return _u -} - -// SetNillableEnabled sets the "enabled" field if the given value is not nil. -func (_u *PaymentChannelUpdate) SetNillableEnabled(v *bool) *PaymentChannelUpdate { - if v != nil { - _u.SetEnabled(*v) - } - return _u -} - -// SetUpdatedAt sets the "updated_at" field. -func (_u *PaymentChannelUpdate) SetUpdatedAt(v time.Time) *PaymentChannelUpdate { - _u.mutation.SetUpdatedAt(v) - return _u -} - -// Mutation returns the PaymentChannelMutation object of the builder. -func (_u *PaymentChannelUpdate) Mutation() *PaymentChannelMutation { - return _u.mutation -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *PaymentChannelUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *PaymentChannelUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *PaymentChannelUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *PaymentChannelUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *PaymentChannelUpdate) defaults() { - if _, ok := _u.mutation.UpdatedAt(); !ok { - v := paymentchannel.UpdateDefaultUpdatedAt() - _u.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *PaymentChannelUpdate) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := paymentchannel.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "PaymentChannel.name": %w`, err)} - } - } - if v, ok := _u.mutation.Platform(); ok { - if err := paymentchannel.PlatformValidator(v); err != nil { - return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "PaymentChannel.platform": %w`, err)} - } - } - return nil -} - -func (_u *PaymentChannelUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(paymentchannel.Table, paymentchannel.Columns, sqlgraph.NewFieldSpec(paymentchannel.FieldID, field.TypeInt64)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.GroupID(); ok { - _spec.SetField(paymentchannel.FieldGroupID, field.TypeInt64, value) - } - if value, ok := _u.mutation.AddedGroupID(); ok { - _spec.AddField(paymentchannel.FieldGroupID, field.TypeInt64, value) - } - if _u.mutation.GroupIDCleared() { - _spec.ClearField(paymentchannel.FieldGroupID, field.TypeInt64) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(paymentchannel.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Platform(); ok { - _spec.SetField(paymentchannel.FieldPlatform, field.TypeString, value) - } - if value, ok := _u.mutation.RateMultiplier(); ok { - _spec.SetField(paymentchannel.FieldRateMultiplier, field.TypeFloat64, value) - } - if value, ok := _u.mutation.AddedRateMultiplier(); ok { - _spec.AddField(paymentchannel.FieldRateMultiplier, field.TypeFloat64, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(paymentchannel.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.Models(); ok { - _spec.SetField(paymentchannel.FieldModels, field.TypeString, value) - } - if value, ok := _u.mutation.Features(); ok { - _spec.SetField(paymentchannel.FieldFeatures, field.TypeString, value) - } - if value, ok := _u.mutation.SortOrder(); ok { - _spec.SetField(paymentchannel.FieldSortOrder, field.TypeInt, value) - } - if value, ok := _u.mutation.AddedSortOrder(); ok { - _spec.AddField(paymentchannel.FieldSortOrder, field.TypeInt, value) - } - if value, ok := _u.mutation.Enabled(); ok { - _spec.SetField(paymentchannel.FieldEnabled, field.TypeBool, value) - } - if value, ok := _u.mutation.UpdatedAt(); ok { - _spec.SetField(paymentchannel.FieldUpdatedAt, field.TypeTime, value) - } - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{paymentchannel.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// PaymentChannelUpdateOne is the builder for updating a single PaymentChannel entity. -type PaymentChannelUpdateOne struct { - config - fields []string - hooks []Hook - mutation *PaymentChannelMutation -} - -// SetGroupID sets the "group_id" field. -func (_u *PaymentChannelUpdateOne) SetGroupID(v int64) *PaymentChannelUpdateOne { - _u.mutation.ResetGroupID() - _u.mutation.SetGroupID(v) - return _u -} - -// SetNillableGroupID sets the "group_id" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableGroupID(v *int64) *PaymentChannelUpdateOne { - if v != nil { - _u.SetGroupID(*v) - } - return _u -} - -// AddGroupID adds value to the "group_id" field. -func (_u *PaymentChannelUpdateOne) AddGroupID(v int64) *PaymentChannelUpdateOne { - _u.mutation.AddGroupID(v) - return _u -} - -// ClearGroupID clears the value of the "group_id" field. -func (_u *PaymentChannelUpdateOne) ClearGroupID() *PaymentChannelUpdateOne { - _u.mutation.ClearGroupID() - return _u -} - -// SetName sets the "name" field. -func (_u *PaymentChannelUpdateOne) SetName(v string) *PaymentChannelUpdateOne { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableName(v *string) *PaymentChannelUpdateOne { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetPlatform sets the "platform" field. -func (_u *PaymentChannelUpdateOne) SetPlatform(v string) *PaymentChannelUpdateOne { - _u.mutation.SetPlatform(v) - return _u -} - -// SetNillablePlatform sets the "platform" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillablePlatform(v *string) *PaymentChannelUpdateOne { - if v != nil { - _u.SetPlatform(*v) - } - return _u -} - -// SetRateMultiplier sets the "rate_multiplier" field. -func (_u *PaymentChannelUpdateOne) SetRateMultiplier(v float64) *PaymentChannelUpdateOne { - _u.mutation.ResetRateMultiplier() - _u.mutation.SetRateMultiplier(v) - return _u -} - -// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableRateMultiplier(v *float64) *PaymentChannelUpdateOne { - if v != nil { - _u.SetRateMultiplier(*v) - } - return _u -} - -// AddRateMultiplier adds value to the "rate_multiplier" field. -func (_u *PaymentChannelUpdateOne) AddRateMultiplier(v float64) *PaymentChannelUpdateOne { - _u.mutation.AddRateMultiplier(v) - return _u -} - -// SetDescription sets the "description" field. -func (_u *PaymentChannelUpdateOne) SetDescription(v string) *PaymentChannelUpdateOne { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableDescription(v *string) *PaymentChannelUpdateOne { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetModels sets the "models" field. -func (_u *PaymentChannelUpdateOne) SetModels(v string) *PaymentChannelUpdateOne { - _u.mutation.SetModels(v) - return _u -} - -// SetNillableModels sets the "models" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableModels(v *string) *PaymentChannelUpdateOne { - if v != nil { - _u.SetModels(*v) - } - return _u -} - -// SetFeatures sets the "features" field. -func (_u *PaymentChannelUpdateOne) SetFeatures(v string) *PaymentChannelUpdateOne { - _u.mutation.SetFeatures(v) - return _u -} - -// SetNillableFeatures sets the "features" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableFeatures(v *string) *PaymentChannelUpdateOne { - if v != nil { - _u.SetFeatures(*v) - } - return _u -} - -// SetSortOrder sets the "sort_order" field. -func (_u *PaymentChannelUpdateOne) SetSortOrder(v int) *PaymentChannelUpdateOne { - _u.mutation.ResetSortOrder() - _u.mutation.SetSortOrder(v) - return _u -} - -// SetNillableSortOrder sets the "sort_order" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableSortOrder(v *int) *PaymentChannelUpdateOne { - if v != nil { - _u.SetSortOrder(*v) - } - return _u -} - -// AddSortOrder adds value to the "sort_order" field. -func (_u *PaymentChannelUpdateOne) AddSortOrder(v int) *PaymentChannelUpdateOne { - _u.mutation.AddSortOrder(v) - return _u -} - -// SetEnabled sets the "enabled" field. -func (_u *PaymentChannelUpdateOne) SetEnabled(v bool) *PaymentChannelUpdateOne { - _u.mutation.SetEnabled(v) - return _u -} - -// SetNillableEnabled sets the "enabled" field if the given value is not nil. -func (_u *PaymentChannelUpdateOne) SetNillableEnabled(v *bool) *PaymentChannelUpdateOne { - if v != nil { - _u.SetEnabled(*v) - } - return _u -} - -// SetUpdatedAt sets the "updated_at" field. -func (_u *PaymentChannelUpdateOne) SetUpdatedAt(v time.Time) *PaymentChannelUpdateOne { - _u.mutation.SetUpdatedAt(v) - return _u -} - -// Mutation returns the PaymentChannelMutation object of the builder. -func (_u *PaymentChannelUpdateOne) Mutation() *PaymentChannelMutation { - return _u.mutation -} - -// Where appends a list predicates to the PaymentChannelUpdate builder. -func (_u *PaymentChannelUpdateOne) Where(ps ...predicate.PaymentChannel) *PaymentChannelUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *PaymentChannelUpdateOne) Select(field string, fields ...string) *PaymentChannelUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated PaymentChannel entity. -func (_u *PaymentChannelUpdateOne) Save(ctx context.Context) (*PaymentChannel, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *PaymentChannelUpdateOne) SaveX(ctx context.Context) *PaymentChannel { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *PaymentChannelUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *PaymentChannelUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *PaymentChannelUpdateOne) defaults() { - if _, ok := _u.mutation.UpdatedAt(); !ok { - v := paymentchannel.UpdateDefaultUpdatedAt() - _u.mutation.SetUpdatedAt(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *PaymentChannelUpdateOne) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := paymentchannel.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "PaymentChannel.name": %w`, err)} - } - } - if v, ok := _u.mutation.Platform(); ok { - if err := paymentchannel.PlatformValidator(v); err != nil { - return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "PaymentChannel.platform": %w`, err)} - } - } - return nil -} - -func (_u *PaymentChannelUpdateOne) sqlSave(ctx context.Context) (_node *PaymentChannel, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(paymentchannel.Table, paymentchannel.Columns, sqlgraph.NewFieldSpec(paymentchannel.FieldID, field.TypeInt64)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PaymentChannel.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, paymentchannel.FieldID) - for _, f := range fields { - if !paymentchannel.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != paymentchannel.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.GroupID(); ok { - _spec.SetField(paymentchannel.FieldGroupID, field.TypeInt64, value) - } - if value, ok := _u.mutation.AddedGroupID(); ok { - _spec.AddField(paymentchannel.FieldGroupID, field.TypeInt64, value) - } - if _u.mutation.GroupIDCleared() { - _spec.ClearField(paymentchannel.FieldGroupID, field.TypeInt64) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(paymentchannel.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Platform(); ok { - _spec.SetField(paymentchannel.FieldPlatform, field.TypeString, value) - } - if value, ok := _u.mutation.RateMultiplier(); ok { - _spec.SetField(paymentchannel.FieldRateMultiplier, field.TypeFloat64, value) - } - if value, ok := _u.mutation.AddedRateMultiplier(); ok { - _spec.AddField(paymentchannel.FieldRateMultiplier, field.TypeFloat64, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(paymentchannel.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.Models(); ok { - _spec.SetField(paymentchannel.FieldModels, field.TypeString, value) - } - if value, ok := _u.mutation.Features(); ok { - _spec.SetField(paymentchannel.FieldFeatures, field.TypeString, value) - } - if value, ok := _u.mutation.SortOrder(); ok { - _spec.SetField(paymentchannel.FieldSortOrder, field.TypeInt, value) - } - if value, ok := _u.mutation.AddedSortOrder(); ok { - _spec.AddField(paymentchannel.FieldSortOrder, field.TypeInt, value) - } - if value, ok := _u.mutation.Enabled(); ok { - _spec.SetField(paymentchannel.FieldEnabled, field.TypeBool, value) - } - if value, ok := _u.mutation.UpdatedAt(); ok { - _spec.SetField(paymentchannel.FieldUpdatedAt, field.TypeTime, value) - } - _node = &PaymentChannel{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{paymentchannel.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} diff --git a/backend/ent/predicate/predicate.go b/backend/ent/predicate/predicate.go index 47f49c30d8..67f37c755e 100644 --- a/backend/ent/predicate/predicate.go +++ b/backend/ent/predicate/predicate.go @@ -33,8 +33,6 @@ type IdempotencyRecord func(*sql.Selector) // PaymentAuditLog is the predicate function for paymentauditlog builders. type PaymentAuditLog func(*sql.Selector) -// PaymentChannel is the predicate function for paymentchannel builders. -type PaymentChannel func(*sql.Selector) // PaymentOrder is the predicate function for paymentorder builders. type PaymentOrder func(*sql.Selector) diff --git a/backend/ent/runtime/runtime.go b/backend/ent/runtime/runtime.go index d9b04da41d..38f80105af 100644 --- a/backend/ent/runtime/runtime.go +++ b/backend/ent/runtime/runtime.go @@ -14,7 +14,6 @@ import ( "github.com/Wei-Shaw/sub2api/ent/group" "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord" "github.com/Wei-Shaw/sub2api/ent/paymentauditlog" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" "github.com/Wei-Shaw/sub2api/ent/paymentorder" "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance" "github.com/Wei-Shaw/sub2api/ent/promocode" @@ -536,66 +535,6 @@ func init() { paymentauditlogDescCreatedAt := paymentauditlogFields[4].Descriptor() // paymentauditlog.DefaultCreatedAt holds the default value on creation for the created_at field. paymentauditlog.DefaultCreatedAt = paymentauditlogDescCreatedAt.Default.(func() time.Time) - paymentchannelFields := schema.PaymentChannel{}.Fields() - _ = paymentchannelFields - // paymentchannelDescName is the schema descriptor for name field. - paymentchannelDescName := paymentchannelFields[1].Descriptor() - // paymentchannel.NameValidator is a validator for the "name" field. It is called by the builders before save. - paymentchannel.NameValidator = func() func(string) error { - validators := paymentchannelDescName.Validators - fns := [...]func(string) error{ - validators[0].(func(string) error), - validators[1].(func(string) error), - } - return func(name string) error { - for _, fn := range fns { - if err := fn(name); err != nil { - return err - } - } - return nil - } - }() - // paymentchannelDescPlatform is the schema descriptor for platform field. - paymentchannelDescPlatform := paymentchannelFields[2].Descriptor() - // paymentchannel.DefaultPlatform holds the default value on creation for the platform field. - paymentchannel.DefaultPlatform = paymentchannelDescPlatform.Default.(string) - // paymentchannel.PlatformValidator is a validator for the "platform" field. It is called by the builders before save. - paymentchannel.PlatformValidator = paymentchannelDescPlatform.Validators[0].(func(string) error) - // paymentchannelDescRateMultiplier is the schema descriptor for rate_multiplier field. - paymentchannelDescRateMultiplier := paymentchannelFields[3].Descriptor() - // paymentchannel.DefaultRateMultiplier holds the default value on creation for the rate_multiplier field. - paymentchannel.DefaultRateMultiplier = paymentchannelDescRateMultiplier.Default.(float64) - // paymentchannelDescDescription is the schema descriptor for description field. - paymentchannelDescDescription := paymentchannelFields[4].Descriptor() - // paymentchannel.DefaultDescription holds the default value on creation for the description field. - paymentchannel.DefaultDescription = paymentchannelDescDescription.Default.(string) - // paymentchannelDescModels is the schema descriptor for models field. - paymentchannelDescModels := paymentchannelFields[5].Descriptor() - // paymentchannel.DefaultModels holds the default value on creation for the models field. - paymentchannel.DefaultModels = paymentchannelDescModels.Default.(string) - // paymentchannelDescFeatures is the schema descriptor for features field. - paymentchannelDescFeatures := paymentchannelFields[6].Descriptor() - // paymentchannel.DefaultFeatures holds the default value on creation for the features field. - paymentchannel.DefaultFeatures = paymentchannelDescFeatures.Default.(string) - // paymentchannelDescSortOrder is the schema descriptor for sort_order field. - paymentchannelDescSortOrder := paymentchannelFields[7].Descriptor() - // paymentchannel.DefaultSortOrder holds the default value on creation for the sort_order field. - paymentchannel.DefaultSortOrder = paymentchannelDescSortOrder.Default.(int) - // paymentchannelDescEnabled is the schema descriptor for enabled field. - paymentchannelDescEnabled := paymentchannelFields[8].Descriptor() - // paymentchannel.DefaultEnabled holds the default value on creation for the enabled field. - paymentchannel.DefaultEnabled = paymentchannelDescEnabled.Default.(bool) - // paymentchannelDescCreatedAt is the schema descriptor for created_at field. - paymentchannelDescCreatedAt := paymentchannelFields[9].Descriptor() - // paymentchannel.DefaultCreatedAt holds the default value on creation for the created_at field. - paymentchannel.DefaultCreatedAt = paymentchannelDescCreatedAt.Default.(func() time.Time) - // paymentchannelDescUpdatedAt is the schema descriptor for updated_at field. - paymentchannelDescUpdatedAt := paymentchannelFields[10].Descriptor() - // paymentchannel.DefaultUpdatedAt holds the default value on creation for the updated_at field. - paymentchannel.DefaultUpdatedAt = paymentchannelDescUpdatedAt.Default.(func() time.Time) - // paymentchannel.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. - paymentchannel.UpdateDefaultUpdatedAt = paymentchannelDescUpdatedAt.UpdateDefault.(func() time.Time) paymentorderFields := schema.PaymentOrder{}.Fields() _ = paymentorderFields // paymentorderDescUserEmail is the schema descriptor for user_email field. diff --git a/backend/ent/schema/payment_channel.go b/backend/ent/schema/payment_channel.go deleted file mode 100644 index c8cf0c48e7..0000000000 --- a/backend/ent/schema/payment_channel.go +++ /dev/null @@ -1,74 +0,0 @@ -package schema - -import ( - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -// PaymentChannel holds the schema definition for the PaymentChannel entity. -// -// 删除策略:硬删除 -// PaymentChannel 使用硬删除而非软删除,原因如下: -// - 渠道配置为管理员维护的元数据,删除即表示不再使用 -// - 通过 enabled 字段控制是否启用,删除仅用于彻底移除 -// - 保持查询简洁,无需额外的软删除过滤 -type PaymentChannel struct { - ent.Schema -} - -func (PaymentChannel) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Annotation{Table: "payment_channels"}, - } -} - -func (PaymentChannel) Fields() []ent.Field { - return []ent.Field{ - field.Int64("group_id"). - Optional(). - Nillable(), - field.String("name"). - MaxLen(100). - NotEmpty(), - field.String("platform"). - MaxLen(50). - Default("claude"), - field.Float("rate_multiplier"). - SchemaType(map[string]string{dialect.Postgres: "decimal(10,4)"}). - Default(1.0), - field.String("description"). - SchemaType(map[string]string{dialect.Postgres: "text"}). - Default(""), - field.String("models"). - SchemaType(map[string]string{dialect.Postgres: "text"}). - Default(""), - field.String("features"). - SchemaType(map[string]string{dialect.Postgres: "text"}). - Default(""), - field.Int("sort_order"). - Default(0), - field.Bool("enabled"). - Default(true), - field.Time("created_at"). - Immutable(). - Default(time.Now). - SchemaType(map[string]string{dialect.Postgres: "timestamptz"}), - field.Time("updated_at"). - Default(time.Now). - UpdateDefault(time.Now). - SchemaType(map[string]string{dialect.Postgres: "timestamptz"}), - } -} - -func (PaymentChannel) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("group_id"), - index.Fields("enabled"), - } -} diff --git a/backend/ent/tx.go b/backend/ent/tx.go index d329727629..bb3139d5c8 100644 --- a/backend/ent/tx.go +++ b/backend/ent/tx.go @@ -32,8 +32,6 @@ type Tx struct { IdempotencyRecord *IdempotencyRecordClient // PaymentAuditLog is the client for interacting with the PaymentAuditLog builders. PaymentAuditLog *PaymentAuditLogClient - // PaymentChannel is the client for interacting with the PaymentChannel builders. - PaymentChannel *PaymentChannelClient // PaymentOrder is the client for interacting with the PaymentOrder builders. PaymentOrder *PaymentOrderClient // PaymentProviderInstance is the client for interacting with the PaymentProviderInstance builders. @@ -208,7 +206,6 @@ func (tx *Tx) init() { tx.Group = NewGroupClient(tx.config) tx.IdempotencyRecord = NewIdempotencyRecordClient(tx.config) tx.PaymentAuditLog = NewPaymentAuditLogClient(tx.config) - tx.PaymentChannel = NewPaymentChannelClient(tx.config) tx.PaymentOrder = NewPaymentOrderClient(tx.config) tx.PaymentProviderInstance = NewPaymentProviderInstanceClient(tx.config) tx.PromoCode = NewPromoCodeClient(tx.config) diff --git a/backend/internal/handler/admin/channel_handler.go b/backend/internal/handler/admin/channel_handler.go index 563a27cea4..f908bb9103 100644 --- a/backend/internal/handler/admin/channel_handler.go +++ b/backend/internal/handler/admin/channel_handler.go @@ -35,6 +35,7 @@ type createChannelRequest struct { ModelMapping map[string]map[string]string `json:"model_mapping"` BillingModelSource string `json:"billing_model_source" binding:"omitempty,oneof=requested upstream channel_mapped"` RestrictModels bool `json:"restrict_models"` + Features string `json:"features"` } type updateChannelRequest struct { @@ -46,6 +47,7 @@ type updateChannelRequest struct { ModelMapping map[string]map[string]string `json:"model_mapping"` BillingModelSource string `json:"billing_model_source" binding:"omitempty,oneof=requested upstream channel_mapped"` RestrictModels *bool `json:"restrict_models"` + Features *string `json:"features"` } type channelModelPricingRequest struct { @@ -80,6 +82,7 @@ type channelResponse struct { Status string `json:"status"` BillingModelSource string `json:"billing_model_source"` RestrictModels bool `json:"restrict_models"` + Features string `json:"features"` GroupIDs []int64 `json:"group_ids"` ModelPricing []channelModelPricingResponse `json:"model_pricing"` ModelMapping map[string]map[string]string `json:"model_mapping"` @@ -124,6 +127,7 @@ func channelToResponse(ch *service.Channel) *channelResponse { Description: ch.Description, Status: ch.Status, RestrictModels: ch.RestrictModels, + Features: ch.Features, GroupIDs: ch.GroupIDs, ModelMapping: ch.ModelMapping, CreatedAt: ch.CreatedAt.Format("2006-01-02T15:04:05Z"), @@ -356,6 +360,7 @@ func (h *ChannelHandler) Create(c *gin.Context) { ModelMapping: req.ModelMapping, BillingModelSource: req.BillingModelSource, RestrictModels: req.RestrictModels, + Features: req.Features, }) if err != nil { response.ErrorFrom(c, err) @@ -388,6 +393,7 @@ func (h *ChannelHandler) Update(c *gin.Context) { ModelMapping: req.ModelMapping, BillingModelSource: req.BillingModelSource, RestrictModels: req.RestrictModels, + Features: req.Features, } if req.ModelPricing != nil { pricing := pricingRequestToService(*req.ModelPricing) diff --git a/backend/internal/handler/admin/payment_handler.go b/backend/internal/handler/admin/payment_handler.go index 1be1b18889..4a773e0c52 100644 --- a/backend/internal/handler/admin/payment_handler.go +++ b/backend/internal/handler/admin/payment_handler.go @@ -157,71 +157,6 @@ func (h *PaymentHandler) ProcessRefund(c *gin.Context) { response.Success(c, result) } -// --- Payment Channels --- - -// ListChannels returns all payment channels. -// GET /api/v1/admin/payment/channels -func (h *PaymentHandler) ListChannels(c *gin.Context) { - channels, err := h.configService.ListChannels(c.Request.Context()) - if err != nil { - response.ErrorFrom(c, err) - return - } - response.Success(c, channels) -} - -// CreateChannel creates a new payment channel. -// POST /api/v1/admin/payment/channels -func (h *PaymentHandler) CreateChannel(c *gin.Context) { - var req service.CreateChannelRequest - if err := c.ShouldBindJSON(&req); err != nil { - response.BadRequest(c, "Invalid request: "+err.Error()) - return - } - ch, err := h.configService.CreateChannel(c.Request.Context(), req) - if err != nil { - response.ErrorFrom(c, err) - return - } - response.Created(c, ch) -} - -// UpdateChannel updates an existing payment channel. -// PUT /api/v1/admin/payment/channels/:id -func (h *PaymentHandler) UpdateChannel(c *gin.Context) { - id, err := strconv.ParseInt(c.Param("id"), 10, 64) - if err != nil { - response.BadRequest(c, "Invalid channel ID") - return - } - var req service.UpdateChannelRequest - if err := c.ShouldBindJSON(&req); err != nil { - response.BadRequest(c, "Invalid request: "+err.Error()) - return - } - ch, err := h.configService.UpdateChannel(c.Request.Context(), id, req) - if err != nil { - response.ErrorFrom(c, err) - return - } - response.Success(c, ch) -} - -// DeleteChannel deletes a payment channel. -// DELETE /api/v1/admin/payment/channels/:id -func (h *PaymentHandler) DeleteChannel(c *gin.Context) { - id, err := strconv.ParseInt(c.Param("id"), 10, 64) - if err != nil { - response.BadRequest(c, "Invalid channel ID") - return - } - if err := h.configService.DeleteChannel(c.Request.Context(), id); err != nil { - response.ErrorFrom(c, err) - return - } - response.Success(c, gin.H{"message": "deleted"}) -} - // --- Subscription Plans --- // ListPlans returns all subscription plans. diff --git a/backend/internal/handler/payment_handler.go b/backend/internal/handler/payment_handler.go index be664ca9b5..cee80e72b8 100644 --- a/backend/internal/handler/payment_handler.go +++ b/backend/internal/handler/payment_handler.go @@ -6,6 +6,7 @@ import ( "github.com/Wei-Shaw/sub2api/internal/pkg/response" middleware2 "github.com/Wei-Shaw/sub2api/internal/server/middleware" + "github.com/Wei-Shaw/sub2api/internal/pkg/pagination" "github.com/Wei-Shaw/sub2api/internal/service" "github.com/gin-gonic/gin" @@ -13,13 +14,15 @@ import ( // PaymentHandler handles user-facing payment requests. type PaymentHandler struct { + channelService *service.ChannelService paymentService *service.PaymentService configService *service.PaymentConfigService } // NewPaymentHandler creates a new PaymentHandler. -func NewPaymentHandler(paymentService *service.PaymentService, configService *service.PaymentConfigService) *PaymentHandler { +func NewPaymentHandler(paymentService *service.PaymentService, configService *service.PaymentConfigService, channelService *service.ChannelService) *PaymentHandler { return &PaymentHandler{ + channelService: channelService, paymentService: paymentService, configService: configService, } @@ -50,7 +53,7 @@ func (h *PaymentHandler) GetPlans(c *gin.Context) { // GetChannels returns enabled payment channels. // GET /api/v1/payment/channels func (h *PaymentHandler) GetChannels(c *gin.Context) { - channels, err := h.configService.ListChannels(c.Request.Context()) + channels, _, err := h.channelService.List(c.Request.Context(), pagination.PaginationParams{Page: 1, PageSize: 1000}, "active", "") if err != nil { response.ErrorFrom(c, err) return diff --git a/backend/internal/repository/channel_repo.go b/backend/internal/repository/channel_repo.go index 1e2c2e4cf3..ab0032b46d 100644 --- a/backend/internal/repository/channel_repo.go +++ b/backend/internal/repository/channel_repo.go @@ -42,9 +42,9 @@ func (r *channelRepository) Create(ctx context.Context, channel *service.Channel return err } err = tx.QueryRowContext(ctx, - `INSERT INTO channels (name, description, status, model_mapping, billing_model_source, restrict_models) VALUES ($1, $2, $3, $4, $5, $6) + `INSERT INTO channels (name, description, status, model_mapping, billing_model_source, restrict_models, features) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id, created_at, updated_at`, - channel.Name, channel.Description, channel.Status, modelMappingJSON, channel.BillingModelSource, channel.RestrictModels, + channel.Name, channel.Description, channel.Status, modelMappingJSON, channel.BillingModelSource, channel.RestrictModels, channel.Features, ).Scan(&channel.ID, &channel.CreatedAt, &channel.UpdatedAt) if err != nil { if isUniqueViolation(err) { @@ -75,9 +75,9 @@ func (r *channelRepository) GetByID(ctx context.Context, id int64) (*service.Cha ch := &service.Channel{} var modelMappingJSON []byte err := r.db.QueryRowContext(ctx, - `SELECT id, name, description, status, model_mapping, billing_model_source, restrict_models, created_at, updated_at + `SELECT id, name, description, status, model_mapping, billing_model_source, restrict_models, features, created_at, updated_at FROM channels WHERE id = $1`, id, - ).Scan(&ch.ID, &ch.Name, &ch.Description, &ch.Status, &modelMappingJSON, &ch.BillingModelSource, &ch.RestrictModels, &ch.CreatedAt, &ch.UpdatedAt) + ).Scan(&ch.ID, &ch.Name, &ch.Description, &ch.Status, &modelMappingJSON, &ch.BillingModelSource, &ch.RestrictModels, &ch.Features, &ch.CreatedAt, &ch.UpdatedAt) if err == sql.ErrNoRows { return nil, service.ErrChannelNotFound } @@ -108,9 +108,9 @@ func (r *channelRepository) Update(ctx context.Context, channel *service.Channel return err } result, err := tx.ExecContext(ctx, - `UPDATE channels SET name = $1, description = $2, status = $3, model_mapping = $4, billing_model_source = $5, restrict_models = $6, updated_at = NOW() - WHERE id = $7`, - channel.Name, channel.Description, channel.Status, modelMappingJSON, channel.BillingModelSource, channel.RestrictModels, channel.ID, + `UPDATE channels SET name = $1, description = $2, status = $3, model_mapping = $4, billing_model_source = $5, restrict_models = $6, features = $7, updated_at = NOW() + WHERE id = $8`, + channel.Name, channel.Description, channel.Status, modelMappingJSON, channel.BillingModelSource, channel.RestrictModels, channel.Features, channel.ID, ) if err != nil { if isUniqueViolation(err) { @@ -204,7 +204,7 @@ func (r *channelRepository) List(ctx context.Context, params pagination.Paginati for rows.Next() { var ch service.Channel var modelMappingJSON []byte - if err := rows.Scan(&ch.ID, &ch.Name, &ch.Description, &ch.Status, &modelMappingJSON, &ch.BillingModelSource, &ch.RestrictModels, &ch.CreatedAt, &ch.UpdatedAt); err != nil { + if err := rows.Scan(&ch.ID, &ch.Name, &ch.Description, &ch.Status, &modelMappingJSON, &ch.BillingModelSource, &ch.RestrictModels, &ch.Features, &ch.CreatedAt, &ch.UpdatedAt); err != nil { return nil, nil, fmt.Errorf("scan channel: %w", err) } ch.ModelMapping = unmarshalModelMapping(modelMappingJSON) @@ -248,7 +248,7 @@ func (r *channelRepository) List(ctx context.Context, params pagination.Paginati func (r *channelRepository) ListAll(ctx context.Context) ([]service.Channel, error) { rows, err := r.db.QueryContext(ctx, - `SELECT id, name, description, status, model_mapping, billing_model_source, restrict_models, created_at, updated_at FROM channels ORDER BY id`, + `SELECT id, name, description, status, model_mapping, billing_model_source, restrict_models, features, created_at, updated_at FROM channels ORDER BY id`, ) if err != nil { return nil, fmt.Errorf("query all channels: %w", err) @@ -260,7 +260,7 @@ func (r *channelRepository) ListAll(ctx context.Context) ([]service.Channel, err for rows.Next() { var ch service.Channel var modelMappingJSON []byte - if err := rows.Scan(&ch.ID, &ch.Name, &ch.Description, &ch.Status, &modelMappingJSON, &ch.BillingModelSource, &ch.RestrictModels, &ch.CreatedAt, &ch.UpdatedAt); err != nil { + if err := rows.Scan(&ch.ID, &ch.Name, &ch.Description, &ch.Status, &modelMappingJSON, &ch.BillingModelSource, &ch.RestrictModels, &ch.Features, &ch.CreatedAt, &ch.UpdatedAt); err != nil { return nil, fmt.Errorf("scan channel: %w", err) } ch.ModelMapping = unmarshalModelMapping(modelMappingJSON) diff --git a/backend/internal/server/routes/payment.go b/backend/internal/server/routes/payment.go index 7fb1c02680..828b68f361 100644 --- a/backend/internal/server/routes/payment.go +++ b/backend/internal/server/routes/payment.go @@ -70,14 +70,6 @@ func RegisterPaymentRoutes( adminOrders.POST("/:id/refund", adminPaymentHandler.ProcessRefund) } - // Payment Channels - channels := adminGroup.Group("/channels") - { - channels.GET("", adminPaymentHandler.ListChannels) - channels.POST("", adminPaymentHandler.CreateChannel) - channels.PUT("/:id", adminPaymentHandler.UpdateChannel) - channels.DELETE("/:id", adminPaymentHandler.DeleteChannel) - } // Subscription Plans plans := adminGroup.Group("/plans") diff --git a/backend/internal/service/channel.go b/backend/internal/service/channel.go index 1697ed6f86..eac8144470 100644 --- a/backend/internal/service/channel.go +++ b/backend/internal/service/channel.go @@ -39,6 +39,7 @@ type Channel struct { Status string BillingModelSource string // "requested", "upstream", or "channel_mapped" RestrictModels bool // 是否限制模型(仅允许定价列表中的模型) + Features string // 渠道特性描述(JSON 数组),用于支付页面展示 CreatedAt time.Time UpdatedAt time.Time diff --git a/backend/internal/service/channel_service.go b/backend/internal/service/channel_service.go index ec8310f67c..cdf94a4c8e 100644 --- a/backend/internal/service/channel_service.go +++ b/backend/internal/service/channel_service.go @@ -584,6 +584,7 @@ func (s *ChannelService) Create(ctx context.Context, input *CreateChannelInput) GroupIDs: input.GroupIDs, ModelPricing: input.ModelPricing, ModelMapping: input.ModelMapping, + Features: input.Features, } if channel.BillingModelSource == "" { channel.BillingModelSource = BillingModelSourceChannelMapped @@ -641,6 +642,9 @@ func (s *ChannelService) Update(ctx context.Context, id int64, input *UpdateChan if input.RestrictModels != nil { channel.RestrictModels = *input.RestrictModels } + if input.Features != nil { + channel.Features = *input.Features + } // 检查分组冲突 if input.GroupIDs != nil { @@ -842,6 +846,7 @@ type CreateChannelInput struct { ModelMapping map[string]map[string]string // platform → {src→dst} BillingModelSource string RestrictModels bool + Features string } // UpdateChannelInput 更新渠道输入 @@ -854,4 +859,5 @@ type UpdateChannelInput struct { ModelMapping map[string]map[string]string // platform → {src→dst} BillingModelSource string RestrictModels *bool + Features *string } diff --git a/backend/internal/service/payment_config_service.go b/backend/internal/service/payment_config_service.go index 23694ee9e5..dafe9afd9a 100644 --- a/backend/internal/service/payment_config_service.go +++ b/backend/internal/service/payment_config_service.go @@ -8,7 +8,6 @@ import ( "strings" dbent "github.com/Wei-Shaw/sub2api/ent" - "github.com/Wei-Shaw/sub2api/ent/paymentchannel" "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance" "github.com/Wei-Shaw/sub2api/ent/subscriptionplan" "github.com/Wei-Shaw/sub2api/internal/payment" @@ -93,31 +92,6 @@ type UpdateProviderInstanceRequest struct { Limits *string `json:"limits"` RefundEnabled *bool `json:"refundEnabled"` } - -type CreateChannelRequest struct { - GroupID *int64 `json:"groupId"` - Name string `json:"name"` - Platform string `json:"platform"` - RateMultiplier float64 `json:"rateMultiplier"` - Description string `json:"description"` - Models string `json:"models"` - Features string `json:"features"` - SortOrder int `json:"sortOrder"` - Enabled bool `json:"enabled"` -} - -type UpdateChannelRequest struct { - GroupID *int64 `json:"groupId"` - Name *string `json:"name"` - Platform *string `json:"platform"` - RateMultiplier *float64 `json:"rateMultiplier"` - Description *string `json:"description"` - Models *string `json:"models"` - Features *string `json:"features"` - SortOrder *int `json:"sortOrder"` - Enabled *bool `json:"enabled"` -} - type CreatePlanRequest struct { GroupID int64 `json:"groupId"` Name string `json:"name"` @@ -318,56 +292,6 @@ func (s *PaymentConfigService) encryptConfig(cfg map[string]string) (string, err // --- Channel CRUD --- -func (s *PaymentConfigService) ListChannels(ctx context.Context) ([]*dbent.PaymentChannel, error) { - return s.entClient.PaymentChannel.Query().Order(paymentchannel.BySortOrder()).All(ctx) -} - -func (s *PaymentConfigService) CreateChannel(ctx context.Context, req CreateChannelRequest) (*dbent.PaymentChannel, error) { - b := s.entClient.PaymentChannel.Create(). - SetName(req.Name).SetPlatform(req.Platform).SetRateMultiplier(req.RateMultiplier). - SetDescription(req.Description).SetModels(req.Models).SetFeatures(req.Features). - SetSortOrder(req.SortOrder).SetEnabled(req.Enabled) - if req.GroupID != nil { - b.SetGroupID(*req.GroupID) - } - return b.Save(ctx) -} - -func (s *PaymentConfigService) UpdateChannel(ctx context.Context, id int64, req UpdateChannelRequest) (*dbent.PaymentChannel, error) { - u := s.entClient.PaymentChannel.UpdateOneID(id) - if req.GroupID != nil { - u.SetGroupID(*req.GroupID) - } - if req.Name != nil { - u.SetName(*req.Name) - } - if req.Platform != nil { - u.SetPlatform(*req.Platform) - } - if req.RateMultiplier != nil { - u.SetRateMultiplier(*req.RateMultiplier) - } - if req.Description != nil { - u.SetDescription(*req.Description) - } - if req.Models != nil { - u.SetModels(*req.Models) - } - if req.Features != nil { - u.SetFeatures(*req.Features) - } - if req.SortOrder != nil { - u.SetSortOrder(*req.SortOrder) - } - if req.Enabled != nil { - u.SetEnabled(*req.Enabled) - } - return u.Save(ctx) -} - -func (s *PaymentConfigService) DeleteChannel(ctx context.Context, id int64) error { - return s.entClient.PaymentChannel.DeleteOneID(id).Exec(ctx) -} // --- Plan CRUD --- diff --git a/backend/migrations/092_payment_channels.sql b/backend/migrations/092_payment_channels.sql deleted file mode 100644 index d21debd42d..0000000000 --- a/backend/migrations/092_payment_channels.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE IF NOT EXISTS payment_channels ( - id BIGSERIAL PRIMARY KEY, - group_id BIGINT, - name VARCHAR(100) NOT NULL, - platform VARCHAR(50) NOT NULL DEFAULT 'claude', - rate_multiplier DECIMAL(10,4) NOT NULL DEFAULT 1.0, - description TEXT NOT NULL DEFAULT '', - models TEXT NOT NULL DEFAULT '', - features TEXT NOT NULL DEFAULT '', - sort_order INT NOT NULL DEFAULT 0, - enabled BOOLEAN NOT NULL DEFAULT TRUE, - created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), - updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() -); -CREATE INDEX IF NOT EXISTS idx_payment_channels_group_id ON payment_channels(group_id); -CREATE INDEX IF NOT EXISTS idx_payment_channels_enabled ON payment_channels(enabled); diff --git a/backend/migrations/095_channel_features.sql b/backend/migrations/095_channel_features.sql new file mode 100644 index 0000000000..5f14200272 --- /dev/null +++ b/backend/migrations/095_channel_features.sql @@ -0,0 +1,2 @@ +ALTER TABLE channels ADD COLUMN IF NOT EXISTS features TEXT NOT NULL DEFAULT ''; +COMMENT ON COLUMN channels.features IS '渠道特性描述,JSON 数组格式,用于支付页面展示';