mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
refactor: remove PaymentChannel, reuse upstream Channel with features field
- 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)
This commit is contained in:
@@ -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)
|
||||
|
||||
+4
-145
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 ---
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE channels ADD COLUMN IF NOT EXISTS features TEXT NOT NULL DEFAULT '';
|
||||
COMMENT ON COLUMN channels.features IS '渠道特性描述,JSON 数组格式,用于支付页面展示';
|
||||
Reference in New Issue
Block a user