diff --git a/rpc/ent/app.go b/rpc/ent/app.go new file mode 100644 index 0000000..81fb30e --- /dev/null +++ b/rpc/ent/app.go @@ -0,0 +1,236 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayApp Table | 支付应用表 +type App struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // appKey 应用标识 + AppKey string `json:"app_key,omitempty"` + // 应用名称 + AppName string `json:"app_name,omitempty"` + // 支付成功回调地址 + OrderNotifyURL string `json:"order_notify_url,omitempty"` + // 退款成功回调地址 + RefundNotifyURL string `json:"refund_notify_url,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the AppQuery when eager-loading is set. + Edges AppEdges `json:"edges"` + selectValues sql.SelectValues +} + +// AppEdges holds the relations/edges for other nodes in the graph. +type AppEdges struct { + // Channel holds the value of the channel edge. + Channel []*PayChannel `json:"channel,omitempty"` + // NotifyTask holds the value of the notify_task edge. + NotifyTask []*PayNotifyTask `json:"notify_task,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ChannelOrErr returns the Channel value or an error if the edge +// was not loaded in eager-loading. +func (e AppEdges) ChannelOrErr() ([]*PayChannel, error) { + if e.loadedTypes[0] { + return e.Channel, nil + } + return nil, &NotLoadedError{edge: "channel"} +} + +// NotifyTaskOrErr returns the NotifyTask value or an error if the edge +// was not loaded in eager-loading. +func (e AppEdges) NotifyTaskOrErr() ([]*PayNotifyTask, error) { + if e.loadedTypes[1] { + return e.NotifyTask, nil + } + return nil, &NotLoadedError{edge: "notify_task"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*App) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case app.FieldID, app.FieldStatus, app.FieldTenantID: + values[i] = new(sql.NullInt64) + case app.FieldAppKey, app.FieldAppName, app.FieldOrderNotifyURL, app.FieldRefundNotifyURL: + values[i] = new(sql.NullString) + case app.FieldCreatedAt, app.FieldUpdatedAt, app.FieldDeletedAt: + 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 App fields. +func (_m *App) 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 app.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case app.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 app.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 + } + case app.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case app.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case app.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case app.FieldAppKey: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field app_key", values[i]) + } else if value.Valid { + _m.AppKey = value.String + } + case app.FieldAppName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field app_name", values[i]) + } else if value.Valid { + _m.AppName = value.String + } + case app.FieldOrderNotifyURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field order_notify_url", values[i]) + } else if value.Valid { + _m.OrderNotifyURL = value.String + } + case app.FieldRefundNotifyURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field refund_notify_url", values[i]) + } else if value.Valid { + _m.RefundNotifyURL = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the App. +// This includes values selected through modifiers, order, etc. +func (_m *App) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryChannel queries the "channel" edge of the App entity. +func (_m *App) QueryChannel() *PayChannelQuery { + return NewAppClient(_m.config).QueryChannel(_m) +} + +// QueryNotifyTask queries the "notify_task" edge of the App entity. +func (_m *App) QueryNotifyTask() *PayNotifyTaskQuery { + return NewAppClient(_m.config).QueryNotifyTask(_m) +} + +// Update returns a builder for updating this App. +// Note that you need to call App.Unwrap() before calling this method if this App +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *App) Update() *AppUpdateOne { + return NewAppClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the App 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 *App) Unwrap() *App { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: App is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *App) String() string { + var builder strings.Builder + builder.WriteString("App(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + 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.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("app_key=") + builder.WriteString(_m.AppKey) + builder.WriteString(", ") + builder.WriteString("app_name=") + builder.WriteString(_m.AppName) + builder.WriteString(", ") + builder.WriteString("order_notify_url=") + builder.WriteString(_m.OrderNotifyURL) + builder.WriteString(", ") + builder.WriteString("refund_notify_url=") + builder.WriteString(_m.RefundNotifyURL) + builder.WriteByte(')') + return builder.String() +} + +// Apps is a parsable slice of App. +type Apps []*App diff --git a/rpc/ent/app/app.go b/rpc/ent/app/app.go new file mode 100644 index 0000000..1bce7de --- /dev/null +++ b/rpc/ent/app/app.go @@ -0,0 +1,187 @@ +// Code generated by ent, DO NOT EDIT. + +package app + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the app type in the database. + Label = "app" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // 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" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldAppKey holds the string denoting the app_key field in the database. + FieldAppKey = "app_key" + // FieldAppName holds the string denoting the app_name field in the database. + FieldAppName = "app_name" + // FieldOrderNotifyURL holds the string denoting the order_notify_url field in the database. + FieldOrderNotifyURL = "order_notify_url" + // FieldRefundNotifyURL holds the string denoting the refund_notify_url field in the database. + FieldRefundNotifyURL = "refund_notify_url" + // EdgeChannel holds the string denoting the channel edge name in mutations. + EdgeChannel = "channel" + // EdgeNotifyTask holds the string denoting the notify_task edge name in mutations. + EdgeNotifyTask = "notify_task" + // Table holds the table name of the app in the database. + Table = "pay_app" + // ChannelTable is the table that holds the channel relation/edge. + ChannelTable = "pay_channel" + // ChannelInverseTable is the table name for the PayChannel entity. + // It exists in this package in order to avoid circular dependency with the "paychannel" package. + ChannelInverseTable = "pay_channel" + // ChannelColumn is the table column denoting the channel relation/edge. + ChannelColumn = "app_id" + // NotifyTaskTable is the table that holds the notify_task relation/edge. + NotifyTaskTable = "pay_notify_task" + // NotifyTaskInverseTable is the table name for the PayNotifyTask entity. + // It exists in this package in order to avoid circular dependency with the "paynotifytask" package. + NotifyTaskInverseTable = "pay_notify_task" + // NotifyTaskColumn is the table column denoting the notify_task relation/edge. + NotifyTaskColumn = "app_id" +) + +// Columns holds all SQL columns for app fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldAppKey, + FieldAppName, + FieldOrderNotifyURL, + FieldRefundNotifyURL, +} + +// 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 ( + // 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 + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 +) + +// OrderOption defines the ordering options for the App 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() +} + +// 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() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByAppKey orders the results by the app_key field. +func ByAppKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAppKey, opts...).ToFunc() +} + +// ByAppName orders the results by the app_name field. +func ByAppName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAppName, opts...).ToFunc() +} + +// ByOrderNotifyURL orders the results by the order_notify_url field. +func ByOrderNotifyURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderNotifyURL, opts...).ToFunc() +} + +// ByRefundNotifyURL orders the results by the refund_notify_url field. +func ByRefundNotifyURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundNotifyURL, opts...).ToFunc() +} + +// ByChannelCount orders the results by channel count. +func ByChannelCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChannelStep(), opts...) + } +} + +// ByChannel orders the results by channel terms. +func ByChannel(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChannelStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByNotifyTaskCount orders the results by notify_task count. +func ByNotifyTaskCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNotifyTaskStep(), opts...) + } +} + +// ByNotifyTask orders the results by notify_task terms. +func ByNotifyTask(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNotifyTaskStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newChannelStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ChannelInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ChannelTable, ChannelColumn), + ) +} +func newNotifyTaskStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NotifyTaskInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, NotifyTaskTable, NotifyTaskColumn), + ) +} diff --git a/rpc/ent/app/where.go b/rpc/ent/app/where.go new file mode 100644 index 0000000..63a1dbe --- /dev/null +++ b/rpc/ent/app/where.go @@ -0,0 +1,662 @@ +// Code generated by ent, DO NOT EDIT. + +package app + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.App { + return predicate.App(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.App { + return predicate.App(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.App { + return predicate.App(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.App { + return predicate.App(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.App { + return predicate.App(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.App { + return predicate.App(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.App { + return predicate.App(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.App { + return predicate.App(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.App { + return predicate.App(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.App { + return predicate.App(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.App { + return predicate.App(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.App { + return predicate.App(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.App { + return predicate.App(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.App { + return predicate.App(sql.FieldEQ(FieldDeletedAt, v)) +} + +// AppKey applies equality check predicate on the "app_key" field. It's identical to AppKeyEQ. +func AppKey(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldAppKey, v)) +} + +// AppName applies equality check predicate on the "app_name" field. It's identical to AppNameEQ. +func AppName(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldAppName, v)) +} + +// OrderNotifyURL applies equality check predicate on the "order_notify_url" field. It's identical to OrderNotifyURLEQ. +func OrderNotifyURL(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldOrderNotifyURL, v)) +} + +// RefundNotifyURL applies equality check predicate on the "refund_notify_url" field. It's identical to RefundNotifyURLEQ. +func RefundNotifyURL(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldRefundNotifyURL, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.App { + return predicate.App(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.App { + return predicate.App(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.App { + return predicate.App(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.App { + return predicate.App(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.App { + return predicate.App(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.App { + return predicate.App(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.App { + return predicate.App(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.App { + return predicate.App(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.App { + return predicate.App(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.App { + return predicate.App(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.App { + return predicate.App(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.App { + return predicate.App(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.App { + return predicate.App(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.App { + return predicate.App(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.App { + return predicate.App(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.App { + return predicate.App(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.App { + return predicate.App(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.App { + return predicate.App(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.App { + return predicate.App(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.App { + return predicate.App(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.App { + return predicate.App(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.App { + return predicate.App(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.App { + return predicate.App(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.App { + return predicate.App(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.App { + return predicate.App(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.App { + return predicate.App(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.App { + return predicate.App(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.App { + return predicate.App(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.App { + return predicate.App(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.App { + return predicate.App(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.App { + return predicate.App(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.App { + return predicate.App(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.App { + return predicate.App(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.App { + return predicate.App(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.App { + return predicate.App(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.App { + return predicate.App(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.App { + return predicate.App(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.App { + return predicate.App(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.App { + return predicate.App(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.App { + return predicate.App(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.App { + return predicate.App(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.App { + return predicate.App(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.App { + return predicate.App(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.App { + return predicate.App(sql.FieldNotNull(FieldDeletedAt)) +} + +// AppKeyEQ applies the EQ predicate on the "app_key" field. +func AppKeyEQ(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldAppKey, v)) +} + +// AppKeyNEQ applies the NEQ predicate on the "app_key" field. +func AppKeyNEQ(v string) predicate.App { + return predicate.App(sql.FieldNEQ(FieldAppKey, v)) +} + +// AppKeyIn applies the In predicate on the "app_key" field. +func AppKeyIn(vs ...string) predicate.App { + return predicate.App(sql.FieldIn(FieldAppKey, vs...)) +} + +// AppKeyNotIn applies the NotIn predicate on the "app_key" field. +func AppKeyNotIn(vs ...string) predicate.App { + return predicate.App(sql.FieldNotIn(FieldAppKey, vs...)) +} + +// AppKeyGT applies the GT predicate on the "app_key" field. +func AppKeyGT(v string) predicate.App { + return predicate.App(sql.FieldGT(FieldAppKey, v)) +} + +// AppKeyGTE applies the GTE predicate on the "app_key" field. +func AppKeyGTE(v string) predicate.App { + return predicate.App(sql.FieldGTE(FieldAppKey, v)) +} + +// AppKeyLT applies the LT predicate on the "app_key" field. +func AppKeyLT(v string) predicate.App { + return predicate.App(sql.FieldLT(FieldAppKey, v)) +} + +// AppKeyLTE applies the LTE predicate on the "app_key" field. +func AppKeyLTE(v string) predicate.App { + return predicate.App(sql.FieldLTE(FieldAppKey, v)) +} + +// AppKeyContains applies the Contains predicate on the "app_key" field. +func AppKeyContains(v string) predicate.App { + return predicate.App(sql.FieldContains(FieldAppKey, v)) +} + +// AppKeyHasPrefix applies the HasPrefix predicate on the "app_key" field. +func AppKeyHasPrefix(v string) predicate.App { + return predicate.App(sql.FieldHasPrefix(FieldAppKey, v)) +} + +// AppKeyHasSuffix applies the HasSuffix predicate on the "app_key" field. +func AppKeyHasSuffix(v string) predicate.App { + return predicate.App(sql.FieldHasSuffix(FieldAppKey, v)) +} + +// AppKeyEqualFold applies the EqualFold predicate on the "app_key" field. +func AppKeyEqualFold(v string) predicate.App { + return predicate.App(sql.FieldEqualFold(FieldAppKey, v)) +} + +// AppKeyContainsFold applies the ContainsFold predicate on the "app_key" field. +func AppKeyContainsFold(v string) predicate.App { + return predicate.App(sql.FieldContainsFold(FieldAppKey, v)) +} + +// AppNameEQ applies the EQ predicate on the "app_name" field. +func AppNameEQ(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldAppName, v)) +} + +// AppNameNEQ applies the NEQ predicate on the "app_name" field. +func AppNameNEQ(v string) predicate.App { + return predicate.App(sql.FieldNEQ(FieldAppName, v)) +} + +// AppNameIn applies the In predicate on the "app_name" field. +func AppNameIn(vs ...string) predicate.App { + return predicate.App(sql.FieldIn(FieldAppName, vs...)) +} + +// AppNameNotIn applies the NotIn predicate on the "app_name" field. +func AppNameNotIn(vs ...string) predicate.App { + return predicate.App(sql.FieldNotIn(FieldAppName, vs...)) +} + +// AppNameGT applies the GT predicate on the "app_name" field. +func AppNameGT(v string) predicate.App { + return predicate.App(sql.FieldGT(FieldAppName, v)) +} + +// AppNameGTE applies the GTE predicate on the "app_name" field. +func AppNameGTE(v string) predicate.App { + return predicate.App(sql.FieldGTE(FieldAppName, v)) +} + +// AppNameLT applies the LT predicate on the "app_name" field. +func AppNameLT(v string) predicate.App { + return predicate.App(sql.FieldLT(FieldAppName, v)) +} + +// AppNameLTE applies the LTE predicate on the "app_name" field. +func AppNameLTE(v string) predicate.App { + return predicate.App(sql.FieldLTE(FieldAppName, v)) +} + +// AppNameContains applies the Contains predicate on the "app_name" field. +func AppNameContains(v string) predicate.App { + return predicate.App(sql.FieldContains(FieldAppName, v)) +} + +// AppNameHasPrefix applies the HasPrefix predicate on the "app_name" field. +func AppNameHasPrefix(v string) predicate.App { + return predicate.App(sql.FieldHasPrefix(FieldAppName, v)) +} + +// AppNameHasSuffix applies the HasSuffix predicate on the "app_name" field. +func AppNameHasSuffix(v string) predicate.App { + return predicate.App(sql.FieldHasSuffix(FieldAppName, v)) +} + +// AppNameEqualFold applies the EqualFold predicate on the "app_name" field. +func AppNameEqualFold(v string) predicate.App { + return predicate.App(sql.FieldEqualFold(FieldAppName, v)) +} + +// AppNameContainsFold applies the ContainsFold predicate on the "app_name" field. +func AppNameContainsFold(v string) predicate.App { + return predicate.App(sql.FieldContainsFold(FieldAppName, v)) +} + +// OrderNotifyURLEQ applies the EQ predicate on the "order_notify_url" field. +func OrderNotifyURLEQ(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLNEQ applies the NEQ predicate on the "order_notify_url" field. +func OrderNotifyURLNEQ(v string) predicate.App { + return predicate.App(sql.FieldNEQ(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLIn applies the In predicate on the "order_notify_url" field. +func OrderNotifyURLIn(vs ...string) predicate.App { + return predicate.App(sql.FieldIn(FieldOrderNotifyURL, vs...)) +} + +// OrderNotifyURLNotIn applies the NotIn predicate on the "order_notify_url" field. +func OrderNotifyURLNotIn(vs ...string) predicate.App { + return predicate.App(sql.FieldNotIn(FieldOrderNotifyURL, vs...)) +} + +// OrderNotifyURLGT applies the GT predicate on the "order_notify_url" field. +func OrderNotifyURLGT(v string) predicate.App { + return predicate.App(sql.FieldGT(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLGTE applies the GTE predicate on the "order_notify_url" field. +func OrderNotifyURLGTE(v string) predicate.App { + return predicate.App(sql.FieldGTE(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLLT applies the LT predicate on the "order_notify_url" field. +func OrderNotifyURLLT(v string) predicate.App { + return predicate.App(sql.FieldLT(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLLTE applies the LTE predicate on the "order_notify_url" field. +func OrderNotifyURLLTE(v string) predicate.App { + return predicate.App(sql.FieldLTE(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLContains applies the Contains predicate on the "order_notify_url" field. +func OrderNotifyURLContains(v string) predicate.App { + return predicate.App(sql.FieldContains(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLHasPrefix applies the HasPrefix predicate on the "order_notify_url" field. +func OrderNotifyURLHasPrefix(v string) predicate.App { + return predicate.App(sql.FieldHasPrefix(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLHasSuffix applies the HasSuffix predicate on the "order_notify_url" field. +func OrderNotifyURLHasSuffix(v string) predicate.App { + return predicate.App(sql.FieldHasSuffix(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLIsNil applies the IsNil predicate on the "order_notify_url" field. +func OrderNotifyURLIsNil() predicate.App { + return predicate.App(sql.FieldIsNull(FieldOrderNotifyURL)) +} + +// OrderNotifyURLNotNil applies the NotNil predicate on the "order_notify_url" field. +func OrderNotifyURLNotNil() predicate.App { + return predicate.App(sql.FieldNotNull(FieldOrderNotifyURL)) +} + +// OrderNotifyURLEqualFold applies the EqualFold predicate on the "order_notify_url" field. +func OrderNotifyURLEqualFold(v string) predicate.App { + return predicate.App(sql.FieldEqualFold(FieldOrderNotifyURL, v)) +} + +// OrderNotifyURLContainsFold applies the ContainsFold predicate on the "order_notify_url" field. +func OrderNotifyURLContainsFold(v string) predicate.App { + return predicate.App(sql.FieldContainsFold(FieldOrderNotifyURL, v)) +} + +// RefundNotifyURLEQ applies the EQ predicate on the "refund_notify_url" field. +func RefundNotifyURLEQ(v string) predicate.App { + return predicate.App(sql.FieldEQ(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLNEQ applies the NEQ predicate on the "refund_notify_url" field. +func RefundNotifyURLNEQ(v string) predicate.App { + return predicate.App(sql.FieldNEQ(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLIn applies the In predicate on the "refund_notify_url" field. +func RefundNotifyURLIn(vs ...string) predicate.App { + return predicate.App(sql.FieldIn(FieldRefundNotifyURL, vs...)) +} + +// RefundNotifyURLNotIn applies the NotIn predicate on the "refund_notify_url" field. +func RefundNotifyURLNotIn(vs ...string) predicate.App { + return predicate.App(sql.FieldNotIn(FieldRefundNotifyURL, vs...)) +} + +// RefundNotifyURLGT applies the GT predicate on the "refund_notify_url" field. +func RefundNotifyURLGT(v string) predicate.App { + return predicate.App(sql.FieldGT(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLGTE applies the GTE predicate on the "refund_notify_url" field. +func RefundNotifyURLGTE(v string) predicate.App { + return predicate.App(sql.FieldGTE(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLLT applies the LT predicate on the "refund_notify_url" field. +func RefundNotifyURLLT(v string) predicate.App { + return predicate.App(sql.FieldLT(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLLTE applies the LTE predicate on the "refund_notify_url" field. +func RefundNotifyURLLTE(v string) predicate.App { + return predicate.App(sql.FieldLTE(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLContains applies the Contains predicate on the "refund_notify_url" field. +func RefundNotifyURLContains(v string) predicate.App { + return predicate.App(sql.FieldContains(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLHasPrefix applies the HasPrefix predicate on the "refund_notify_url" field. +func RefundNotifyURLHasPrefix(v string) predicate.App { + return predicate.App(sql.FieldHasPrefix(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLHasSuffix applies the HasSuffix predicate on the "refund_notify_url" field. +func RefundNotifyURLHasSuffix(v string) predicate.App { + return predicate.App(sql.FieldHasSuffix(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLIsNil applies the IsNil predicate on the "refund_notify_url" field. +func RefundNotifyURLIsNil() predicate.App { + return predicate.App(sql.FieldIsNull(FieldRefundNotifyURL)) +} + +// RefundNotifyURLNotNil applies the NotNil predicate on the "refund_notify_url" field. +func RefundNotifyURLNotNil() predicate.App { + return predicate.App(sql.FieldNotNull(FieldRefundNotifyURL)) +} + +// RefundNotifyURLEqualFold applies the EqualFold predicate on the "refund_notify_url" field. +func RefundNotifyURLEqualFold(v string) predicate.App { + return predicate.App(sql.FieldEqualFold(FieldRefundNotifyURL, v)) +} + +// RefundNotifyURLContainsFold applies the ContainsFold predicate on the "refund_notify_url" field. +func RefundNotifyURLContainsFold(v string) predicate.App { + return predicate.App(sql.FieldContainsFold(FieldRefundNotifyURL, v)) +} + +// HasChannel applies the HasEdge predicate on the "channel" edge. +func HasChannel() predicate.App { + return predicate.App(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ChannelTable, ChannelColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChannelWith applies the HasEdge predicate on the "channel" edge with a given conditions (other predicates). +func HasChannelWith(preds ...predicate.PayChannel) predicate.App { + return predicate.App(func(s *sql.Selector) { + step := newChannelStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasNotifyTask applies the HasEdge predicate on the "notify_task" edge. +func HasNotifyTask() predicate.App { + return predicate.App(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, NotifyTaskTable, NotifyTaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNotifyTaskWith applies the HasEdge predicate on the "notify_task" edge with a given conditions (other predicates). +func HasNotifyTaskWith(preds ...predicate.PayNotifyTask) predicate.App { + return predicate.App(func(s *sql.Selector) { + step := newNotifyTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.App) predicate.App { + return predicate.App(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.App) predicate.App { + return predicate.App(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.App) predicate.App { + return predicate.App(sql.NotPredicates(p)) +} diff --git a/rpc/ent/app_create.go b/rpc/ent/app_create.go new file mode 100644 index 0000000..e631580 --- /dev/null +++ b/rpc/ent/app_create.go @@ -0,0 +1,430 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// AppCreate is the builder for creating a App entity. +type AppCreate struct { + config + mutation *AppMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *AppCreate) SetCreatedAt(v time.Time) *AppCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *AppCreate) SetNillableCreatedAt(v *time.Time) *AppCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *AppCreate) SetUpdatedAt(v time.Time) *AppCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *AppCreate) SetNillableUpdatedAt(v *time.Time) *AppCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *AppCreate) SetStatus(v uint8) *AppCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *AppCreate) SetNillableStatus(v *uint8) *AppCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *AppCreate) SetTenantID(v uint64) *AppCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *AppCreate) SetNillableTenantID(v *uint64) *AppCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *AppCreate) SetDeletedAt(v time.Time) *AppCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *AppCreate) SetNillableDeletedAt(v *time.Time) *AppCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetAppKey sets the "app_key" field. +func (_c *AppCreate) SetAppKey(v string) *AppCreate { + _c.mutation.SetAppKey(v) + return _c +} + +// SetAppName sets the "app_name" field. +func (_c *AppCreate) SetAppName(v string) *AppCreate { + _c.mutation.SetAppName(v) + return _c +} + +// SetOrderNotifyURL sets the "order_notify_url" field. +func (_c *AppCreate) SetOrderNotifyURL(v string) *AppCreate { + _c.mutation.SetOrderNotifyURL(v) + return _c +} + +// SetNillableOrderNotifyURL sets the "order_notify_url" field if the given value is not nil. +func (_c *AppCreate) SetNillableOrderNotifyURL(v *string) *AppCreate { + if v != nil { + _c.SetOrderNotifyURL(*v) + } + return _c +} + +// SetRefundNotifyURL sets the "refund_notify_url" field. +func (_c *AppCreate) SetRefundNotifyURL(v string) *AppCreate { + _c.mutation.SetRefundNotifyURL(v) + return _c +} + +// SetNillableRefundNotifyURL sets the "refund_notify_url" field if the given value is not nil. +func (_c *AppCreate) SetNillableRefundNotifyURL(v *string) *AppCreate { + if v != nil { + _c.SetRefundNotifyURL(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *AppCreate) SetID(v uint64) *AppCreate { + _c.mutation.SetID(v) + return _c +} + +// AddChannelIDs adds the "channel" edge to the PayChannel entity by IDs. +func (_c *AppCreate) AddChannelIDs(ids ...uint64) *AppCreate { + _c.mutation.AddChannelIDs(ids...) + return _c +} + +// AddChannel adds the "channel" edges to the PayChannel entity. +func (_c *AppCreate) AddChannel(v ...*PayChannel) *AppCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddChannelIDs(ids...) +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by IDs. +func (_c *AppCreate) AddNotifyTaskIDs(ids ...uint64) *AppCreate { + _c.mutation.AddNotifyTaskIDs(ids...) + return _c +} + +// AddNotifyTask adds the "notify_task" edges to the PayNotifyTask entity. +func (_c *AppCreate) AddNotifyTask(v ...*PayNotifyTask) *AppCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddNotifyTaskIDs(ids...) +} + +// Mutation returns the AppMutation object of the builder. +func (_c *AppCreate) Mutation() *AppMutation { + return _c.mutation +} + +// Save creates the App in the database. +func (_c *AppCreate) Save(ctx context.Context) (*App, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *AppCreate) SaveX(ctx context.Context) *App { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AppCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AppCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *AppCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := app.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := app.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := app.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := app.DefaultTenantID + _c.mutation.SetTenantID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *AppCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "App.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "App.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "App.tenant_id"`)} + } + if _, ok := _c.mutation.AppKey(); !ok { + return &ValidationError{Name: "app_key", err: errors.New(`ent: missing required field "App.app_key"`)} + } + if _, ok := _c.mutation.AppName(); !ok { + return &ValidationError{Name: "app_name", err: errors.New(`ent: missing required field "App.app_name"`)} + } + return nil +} + +func (_c *AppCreate) sqlSave(ctx context.Context) (*App, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *AppCreate) createSpec() (*App, *sqlgraph.CreateSpec) { + var ( + _node = &App{config: _c.config} + _spec = sqlgraph.NewCreateSpec(app.Table, sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(app.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(app.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(app.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(app.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(app.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.AppKey(); ok { + _spec.SetField(app.FieldAppKey, field.TypeString, value) + _node.AppKey = value + } + if value, ok := _c.mutation.AppName(); ok { + _spec.SetField(app.FieldAppName, field.TypeString, value) + _node.AppName = value + } + if value, ok := _c.mutation.OrderNotifyURL(); ok { + _spec.SetField(app.FieldOrderNotifyURL, field.TypeString, value) + _node.OrderNotifyURL = value + } + if value, ok := _c.mutation.RefundNotifyURL(); ok { + _spec.SetField(app.FieldRefundNotifyURL, field.TypeString, value) + _node.RefundNotifyURL = value + } + if nodes := _c.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.NotifyTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// AppCreateBulk is the builder for creating many App entities in bulk. +type AppCreateBulk struct { + config + err error + builders []*AppCreate +} + +// Save creates the App entities in the database. +func (_c *AppCreateBulk) Save(ctx context.Context) ([]*App, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*App, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*AppMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *AppCreateBulk) SaveX(ctx context.Context) []*App { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *AppCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *AppCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/app_delete.go b/rpc/ent/app_delete.go new file mode 100644 index 0000000..40455d0 --- /dev/null +++ b/rpc/ent/app_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// AppDelete is the builder for deleting a App entity. +type AppDelete struct { + config + hooks []Hook + mutation *AppMutation +} + +// Where appends a list predicates to the AppDelete builder. +func (_d *AppDelete) Where(ps ...predicate.App) *AppDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *AppDelete) 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 *AppDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *AppDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(app.Table, sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64)) + 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 +} + +// AppDeleteOne is the builder for deleting a single App entity. +type AppDeleteOne struct { + _d *AppDelete +} + +// Where appends a list predicates to the AppDelete builder. +func (_d *AppDeleteOne) Where(ps ...predicate.App) *AppDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *AppDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{app.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *AppDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/app_query.go b/rpc/ent/app_query.go new file mode 100644 index 0000000..64a4f6d --- /dev/null +++ b/rpc/ent/app_query.go @@ -0,0 +1,680 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// AppQuery is the builder for querying App entities. +type AppQuery struct { + config + ctx *QueryContext + order []app.OrderOption + inters []Interceptor + predicates []predicate.App + withChannel *PayChannelQuery + withNotifyTask *PayNotifyTaskQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the AppQuery builder. +func (_q *AppQuery) Where(ps ...predicate.App) *AppQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *AppQuery) Limit(limit int) *AppQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *AppQuery) Offset(offset int) *AppQuery { + _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 *AppQuery) Unique(unique bool) *AppQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *AppQuery) Order(o ...app.OrderOption) *AppQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryChannel chains the current query on the "channel" edge. +func (_q *AppQuery) QueryChannel() *PayChannelQuery { + query := (&PayChannelClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, selector), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, app.ChannelTable, app.ChannelColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryNotifyTask chains the current query on the "notify_task" edge. +func (_q *AppQuery) QueryNotifyTask() *PayNotifyTaskQuery { + query := (&PayNotifyTaskClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, selector), + sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, app.NotifyTaskTable, app.NotifyTaskColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first App entity from the query. +// Returns a *NotFoundError when no App was found. +func (_q *AppQuery) First(ctx context.Context) (*App, 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{app.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *AppQuery) FirstX(ctx context.Context) *App { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first App ID from the query. +// Returns a *NotFoundError when no App ID was found. +func (_q *AppQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{app.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *AppQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single App entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one App entity is found. +// Returns a *NotFoundError when no App entities are found. +func (_q *AppQuery) Only(ctx context.Context) (*App, 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{app.Label} + default: + return nil, &NotSingularError{app.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *AppQuery) OnlyX(ctx context.Context) *App { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only App ID in the query. +// Returns a *NotSingularError when more than one App ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *AppQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + 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{app.Label} + default: + err = &NotSingularError{app.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *AppQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Apps. +func (_q *AppQuery) All(ctx context.Context) ([]*App, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*App, *AppQuery]() + return withInterceptors[[]*App](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *AppQuery) AllX(ctx context.Context) []*App { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of App IDs. +func (_q *AppQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(app.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *AppQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *AppQuery) 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[*AppQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *AppQuery) 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 *AppQuery) 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 *AppQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the AppQuery 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 *AppQuery) Clone() *AppQuery { + if _q == nil { + return nil + } + return &AppQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]app.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.App{}, _q.predicates...), + withChannel: _q.withChannel.Clone(), + withNotifyTask: _q.withNotifyTask.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithChannel tells the query-builder to eager-load the nodes that are connected to +// the "channel" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AppQuery) WithChannel(opts ...func(*PayChannelQuery)) *AppQuery { + query := (&PayChannelClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChannel = query + return _q +} + +// WithNotifyTask tells the query-builder to eager-load the nodes that are connected to +// the "notify_task" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *AppQuery) WithNotifyTask(opts ...func(*PayNotifyTaskQuery)) *AppQuery { + query := (&PayNotifyTaskClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withNotifyTask = query + return _q +} + +// 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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.App.Query(). +// GroupBy(app.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *AppQuery) GroupBy(field string, fields ...string) *AppGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &AppGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = app.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.App.Query(). +// Select(app.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *AppQuery) Select(fields ...string) *AppSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &AppSelect{AppQuery: _q} + sbuild.label = app.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a AppSelect configured with the given aggregations. +func (_q *AppQuery) Aggregate(fns ...AggregateFunc) *AppSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *AppQuery) 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 !app.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 *AppQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*App, error) { + var ( + nodes = []*App{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withChannel != nil, + _q.withNotifyTask != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*App).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &App{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + 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 + } + if query := _q.withChannel; query != nil { + if err := _q.loadChannel(ctx, query, nodes, + func(n *App) { n.Edges.Channel = []*PayChannel{} }, + func(n *App, e *PayChannel) { n.Edges.Channel = append(n.Edges.Channel, e) }); err != nil { + return nil, err + } + } + if query := _q.withNotifyTask; query != nil { + if err := _q.loadNotifyTask(ctx, query, nodes, + func(n *App) { n.Edges.NotifyTask = []*PayNotifyTask{} }, + func(n *App, e *PayNotifyTask) { n.Edges.NotifyTask = append(n.Edges.NotifyTask, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *AppQuery) loadChannel(ctx context.Context, query *PayChannelQuery, nodes []*App, init func(*App), assign func(*App, *PayChannel)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*App) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(paychannel.FieldAppID) + } + query.Where(predicate.PayChannel(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(app.ChannelColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.AppID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "app_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *AppQuery) loadNotifyTask(ctx context.Context, query *PayNotifyTaskQuery, nodes []*App, init func(*App), assign func(*App, *PayNotifyTask)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*App) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(paynotifytask.FieldAppID) + } + query.Where(predicate.PayNotifyTask(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(app.NotifyTaskColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.AppID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "app_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *AppQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _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 *AppQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(app.Table, app.Columns, sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64)) + _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, app.FieldID) + for i := range fields { + if fields[i] != app.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 *AppQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(app.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = app.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 _, 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 +} + +// AppGroupBy is the group-by builder for App entities. +type AppGroupBy struct { + selector + build *AppQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *AppGroupBy) Aggregate(fns ...AggregateFunc) *AppGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *AppGroupBy) 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[*AppQuery, *AppGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *AppGroupBy) sqlScan(ctx context.Context, root *AppQuery, 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) +} + +// AppSelect is the builder for selecting fields of App entities. +type AppSelect struct { + *AppQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *AppSelect) Aggregate(fns ...AggregateFunc) *AppSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *AppSelect) 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[*AppQuery, *AppSelect](ctx, _s.AppQuery, _s, _s.inters, v) +} + +func (_s *AppSelect) sqlScan(ctx context.Context, root *AppQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/app_update.go b/rpc/ent/app_update.go new file mode 100644 index 0000000..54318d3 --- /dev/null +++ b/rpc/ent/app_update.go @@ -0,0 +1,834 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// AppUpdate is the builder for updating App entities. +type AppUpdate struct { + config + hooks []Hook + mutation *AppMutation +} + +// Where appends a list predicates to the AppUpdate builder. +func (_u *AppUpdate) Where(ps ...predicate.App) *AppUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AppUpdate) SetUpdatedAt(v time.Time) *AppUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *AppUpdate) SetStatus(v uint8) *AppUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *AppUpdate) SetNillableStatus(v *uint8) *AppUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *AppUpdate) AddStatus(v int8) *AppUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *AppUpdate) ClearStatus() *AppUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *AppUpdate) SetDeletedAt(v time.Time) *AppUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *AppUpdate) SetNillableDeletedAt(v *time.Time) *AppUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *AppUpdate) ClearDeletedAt() *AppUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetAppKey sets the "app_key" field. +func (_u *AppUpdate) SetAppKey(v string) *AppUpdate { + _u.mutation.SetAppKey(v) + return _u +} + +// SetNillableAppKey sets the "app_key" field if the given value is not nil. +func (_u *AppUpdate) SetNillableAppKey(v *string) *AppUpdate { + if v != nil { + _u.SetAppKey(*v) + } + return _u +} + +// SetAppName sets the "app_name" field. +func (_u *AppUpdate) SetAppName(v string) *AppUpdate { + _u.mutation.SetAppName(v) + return _u +} + +// SetNillableAppName sets the "app_name" field if the given value is not nil. +func (_u *AppUpdate) SetNillableAppName(v *string) *AppUpdate { + if v != nil { + _u.SetAppName(*v) + } + return _u +} + +// SetOrderNotifyURL sets the "order_notify_url" field. +func (_u *AppUpdate) SetOrderNotifyURL(v string) *AppUpdate { + _u.mutation.SetOrderNotifyURL(v) + return _u +} + +// SetNillableOrderNotifyURL sets the "order_notify_url" field if the given value is not nil. +func (_u *AppUpdate) SetNillableOrderNotifyURL(v *string) *AppUpdate { + if v != nil { + _u.SetOrderNotifyURL(*v) + } + return _u +} + +// ClearOrderNotifyURL clears the value of the "order_notify_url" field. +func (_u *AppUpdate) ClearOrderNotifyURL() *AppUpdate { + _u.mutation.ClearOrderNotifyURL() + return _u +} + +// SetRefundNotifyURL sets the "refund_notify_url" field. +func (_u *AppUpdate) SetRefundNotifyURL(v string) *AppUpdate { + _u.mutation.SetRefundNotifyURL(v) + return _u +} + +// SetNillableRefundNotifyURL sets the "refund_notify_url" field if the given value is not nil. +func (_u *AppUpdate) SetNillableRefundNotifyURL(v *string) *AppUpdate { + if v != nil { + _u.SetRefundNotifyURL(*v) + } + return _u +} + +// ClearRefundNotifyURL clears the value of the "refund_notify_url" field. +func (_u *AppUpdate) ClearRefundNotifyURL() *AppUpdate { + _u.mutation.ClearRefundNotifyURL() + return _u +} + +// AddChannelIDs adds the "channel" edge to the PayChannel entity by IDs. +func (_u *AppUpdate) AddChannelIDs(ids ...uint64) *AppUpdate { + _u.mutation.AddChannelIDs(ids...) + return _u +} + +// AddChannel adds the "channel" edges to the PayChannel entity. +func (_u *AppUpdate) AddChannel(v ...*PayChannel) *AppUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChannelIDs(ids...) +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by IDs. +func (_u *AppUpdate) AddNotifyTaskIDs(ids ...uint64) *AppUpdate { + _u.mutation.AddNotifyTaskIDs(ids...) + return _u +} + +// AddNotifyTask adds the "notify_task" edges to the PayNotifyTask entity. +func (_u *AppUpdate) AddNotifyTask(v ...*PayNotifyTask) *AppUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddNotifyTaskIDs(ids...) +} + +// Mutation returns the AppMutation object of the builder. +func (_u *AppUpdate) Mutation() *AppMutation { + return _u.mutation +} + +// ClearChannel clears all "channel" edges to the PayChannel entity. +func (_u *AppUpdate) ClearChannel() *AppUpdate { + _u.mutation.ClearChannel() + return _u +} + +// RemoveChannelIDs removes the "channel" edge to PayChannel entities by IDs. +func (_u *AppUpdate) RemoveChannelIDs(ids ...uint64) *AppUpdate { + _u.mutation.RemoveChannelIDs(ids...) + return _u +} + +// RemoveChannel removes "channel" edges to PayChannel entities. +func (_u *AppUpdate) RemoveChannel(v ...*PayChannel) *AppUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChannelIDs(ids...) +} + +// ClearNotifyTask clears all "notify_task" edges to the PayNotifyTask entity. +func (_u *AppUpdate) ClearNotifyTask() *AppUpdate { + _u.mutation.ClearNotifyTask() + return _u +} + +// RemoveNotifyTaskIDs removes the "notify_task" edge to PayNotifyTask entities by IDs. +func (_u *AppUpdate) RemoveNotifyTaskIDs(ids ...uint64) *AppUpdate { + _u.mutation.RemoveNotifyTaskIDs(ids...) + return _u +} + +// RemoveNotifyTask removes "notify_task" edges to PayNotifyTask entities. +func (_u *AppUpdate) RemoveNotifyTask(v ...*PayNotifyTask) *AppUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveNotifyTaskIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *AppUpdate) 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 *AppUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *AppUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AppUpdate) 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 *AppUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := app.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +func (_u *AppUpdate) sqlSave(ctx context.Context) (_node int, err error) { + _spec := sqlgraph.NewUpdateSpec(app.Table, app.Columns, sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(app.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(app.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(app.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(app.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(app.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(app.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.AppKey(); ok { + _spec.SetField(app.FieldAppKey, field.TypeString, value) + } + if value, ok := _u.mutation.AppName(); ok { + _spec.SetField(app.FieldAppName, field.TypeString, value) + } + if value, ok := _u.mutation.OrderNotifyURL(); ok { + _spec.SetField(app.FieldOrderNotifyURL, field.TypeString, value) + } + if _u.mutation.OrderNotifyURLCleared() { + _spec.ClearField(app.FieldOrderNotifyURL, field.TypeString) + } + if value, ok := _u.mutation.RefundNotifyURL(); ok { + _spec.SetField(app.FieldRefundNotifyURL, field.TypeString, value) + } + if _u.mutation.RefundNotifyURLCleared() { + _spec.ClearField(app.FieldRefundNotifyURL, field.TypeString) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChannelIDs(); len(nodes) > 0 && !_u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedNotifyTaskIDs(); len(nodes) > 0 && !_u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.NotifyTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{app.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// AppUpdateOne is the builder for updating a single App entity. +type AppUpdateOne struct { + config + fields []string + hooks []Hook + mutation *AppMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *AppUpdateOne) SetUpdatedAt(v time.Time) *AppUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *AppUpdateOne) SetStatus(v uint8) *AppUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *AppUpdateOne) SetNillableStatus(v *uint8) *AppUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *AppUpdateOne) AddStatus(v int8) *AppUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *AppUpdateOne) ClearStatus() *AppUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *AppUpdateOne) SetDeletedAt(v time.Time) *AppUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *AppUpdateOne) SetNillableDeletedAt(v *time.Time) *AppUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *AppUpdateOne) ClearDeletedAt() *AppUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetAppKey sets the "app_key" field. +func (_u *AppUpdateOne) SetAppKey(v string) *AppUpdateOne { + _u.mutation.SetAppKey(v) + return _u +} + +// SetNillableAppKey sets the "app_key" field if the given value is not nil. +func (_u *AppUpdateOne) SetNillableAppKey(v *string) *AppUpdateOne { + if v != nil { + _u.SetAppKey(*v) + } + return _u +} + +// SetAppName sets the "app_name" field. +func (_u *AppUpdateOne) SetAppName(v string) *AppUpdateOne { + _u.mutation.SetAppName(v) + return _u +} + +// SetNillableAppName sets the "app_name" field if the given value is not nil. +func (_u *AppUpdateOne) SetNillableAppName(v *string) *AppUpdateOne { + if v != nil { + _u.SetAppName(*v) + } + return _u +} + +// SetOrderNotifyURL sets the "order_notify_url" field. +func (_u *AppUpdateOne) SetOrderNotifyURL(v string) *AppUpdateOne { + _u.mutation.SetOrderNotifyURL(v) + return _u +} + +// SetNillableOrderNotifyURL sets the "order_notify_url" field if the given value is not nil. +func (_u *AppUpdateOne) SetNillableOrderNotifyURL(v *string) *AppUpdateOne { + if v != nil { + _u.SetOrderNotifyURL(*v) + } + return _u +} + +// ClearOrderNotifyURL clears the value of the "order_notify_url" field. +func (_u *AppUpdateOne) ClearOrderNotifyURL() *AppUpdateOne { + _u.mutation.ClearOrderNotifyURL() + return _u +} + +// SetRefundNotifyURL sets the "refund_notify_url" field. +func (_u *AppUpdateOne) SetRefundNotifyURL(v string) *AppUpdateOne { + _u.mutation.SetRefundNotifyURL(v) + return _u +} + +// SetNillableRefundNotifyURL sets the "refund_notify_url" field if the given value is not nil. +func (_u *AppUpdateOne) SetNillableRefundNotifyURL(v *string) *AppUpdateOne { + if v != nil { + _u.SetRefundNotifyURL(*v) + } + return _u +} + +// ClearRefundNotifyURL clears the value of the "refund_notify_url" field. +func (_u *AppUpdateOne) ClearRefundNotifyURL() *AppUpdateOne { + _u.mutation.ClearRefundNotifyURL() + return _u +} + +// AddChannelIDs adds the "channel" edge to the PayChannel entity by IDs. +func (_u *AppUpdateOne) AddChannelIDs(ids ...uint64) *AppUpdateOne { + _u.mutation.AddChannelIDs(ids...) + return _u +} + +// AddChannel adds the "channel" edges to the PayChannel entity. +func (_u *AppUpdateOne) AddChannel(v ...*PayChannel) *AppUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChannelIDs(ids...) +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by IDs. +func (_u *AppUpdateOne) AddNotifyTaskIDs(ids ...uint64) *AppUpdateOne { + _u.mutation.AddNotifyTaskIDs(ids...) + return _u +} + +// AddNotifyTask adds the "notify_task" edges to the PayNotifyTask entity. +func (_u *AppUpdateOne) AddNotifyTask(v ...*PayNotifyTask) *AppUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddNotifyTaskIDs(ids...) +} + +// Mutation returns the AppMutation object of the builder. +func (_u *AppUpdateOne) Mutation() *AppMutation { + return _u.mutation +} + +// ClearChannel clears all "channel" edges to the PayChannel entity. +func (_u *AppUpdateOne) ClearChannel() *AppUpdateOne { + _u.mutation.ClearChannel() + return _u +} + +// RemoveChannelIDs removes the "channel" edge to PayChannel entities by IDs. +func (_u *AppUpdateOne) RemoveChannelIDs(ids ...uint64) *AppUpdateOne { + _u.mutation.RemoveChannelIDs(ids...) + return _u +} + +// RemoveChannel removes "channel" edges to PayChannel entities. +func (_u *AppUpdateOne) RemoveChannel(v ...*PayChannel) *AppUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChannelIDs(ids...) +} + +// ClearNotifyTask clears all "notify_task" edges to the PayNotifyTask entity. +func (_u *AppUpdateOne) ClearNotifyTask() *AppUpdateOne { + _u.mutation.ClearNotifyTask() + return _u +} + +// RemoveNotifyTaskIDs removes the "notify_task" edge to PayNotifyTask entities by IDs. +func (_u *AppUpdateOne) RemoveNotifyTaskIDs(ids ...uint64) *AppUpdateOne { + _u.mutation.RemoveNotifyTaskIDs(ids...) + return _u +} + +// RemoveNotifyTask removes "notify_task" edges to PayNotifyTask entities. +func (_u *AppUpdateOne) RemoveNotifyTask(v ...*PayNotifyTask) *AppUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveNotifyTaskIDs(ids...) +} + +// Where appends a list predicates to the AppUpdate builder. +func (_u *AppUpdateOne) Where(ps ...predicate.App) *AppUpdateOne { + _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 *AppUpdateOne) Select(field string, fields ...string) *AppUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated App entity. +func (_u *AppUpdateOne) Save(ctx context.Context) (*App, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *AppUpdateOne) SaveX(ctx context.Context) *App { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *AppUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *AppUpdateOne) 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 *AppUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := app.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +func (_u *AppUpdateOne) sqlSave(ctx context.Context) (_node *App, err error) { + _spec := sqlgraph.NewUpdateSpec(app.Table, app.Columns, sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "App.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, app.FieldID) + for _, f := range fields { + if !app.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != app.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.UpdatedAt(); ok { + _spec.SetField(app.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(app.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(app.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(app.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(app.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(app.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.AppKey(); ok { + _spec.SetField(app.FieldAppKey, field.TypeString, value) + } + if value, ok := _u.mutation.AppName(); ok { + _spec.SetField(app.FieldAppName, field.TypeString, value) + } + if value, ok := _u.mutation.OrderNotifyURL(); ok { + _spec.SetField(app.FieldOrderNotifyURL, field.TypeString, value) + } + if _u.mutation.OrderNotifyURLCleared() { + _spec.ClearField(app.FieldOrderNotifyURL, field.TypeString) + } + if value, ok := _u.mutation.RefundNotifyURL(); ok { + _spec.SetField(app.FieldRefundNotifyURL, field.TypeString, value) + } + if _u.mutation.RefundNotifyURLCleared() { + _spec.ClearField(app.FieldRefundNotifyURL, field.TypeString) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChannelIDs(); len(nodes) > 0 && !_u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.ChannelTable, + Columns: []string{app.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedNotifyTaskIDs(); len(nodes) > 0 && !_u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.NotifyTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: app.NotifyTaskTable, + Columns: []string{app.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &App{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{app.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/client.go b/rpc/ent/client.go new file mode 100644 index 0000000..80a3a4e --- /dev/null +++ b/rpc/ent/client.go @@ -0,0 +1,1514 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "mingyang-admin-pay/rpc/ent/migrate" + + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + + stdsql "database/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // App is the client for interacting with the App builders. + App *AppClient + // PayChannel is the client for interacting with the PayChannel builders. + PayChannel *PayChannelClient + // PayNotifyLog is the client for interacting with the PayNotifyLog builders. + PayNotifyLog *PayNotifyLogClient + // PayNotifyTask is the client for interacting with the PayNotifyTask builders. + PayNotifyTask *PayNotifyTaskClient + // PayOrder is the client for interacting with the PayOrder builders. + PayOrder *PayOrderClient + // PayOrderExtension is the client for interacting with the PayOrderExtension builders. + PayOrderExtension *PayOrderExtensionClient + // PayRefund is the client for interacting with the PayRefund builders. + PayRefund *PayRefundClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + client := &Client{config: newConfig(opts...)} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.App = NewAppClient(c.config) + c.PayChannel = NewPayChannelClient(c.config) + c.PayNotifyLog = NewPayNotifyLogClient(c.config) + c.PayNotifyTask = NewPayNotifyTaskClient(c.config) + c.PayOrder = NewPayOrderClient(c.config) + c.PayOrderExtension = NewPayOrderExtensionClient(c.config) + c.PayRefund = NewPayRefundClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + App: NewAppClient(cfg), + PayChannel: NewPayChannelClient(cfg), + PayNotifyLog: NewPayNotifyLogClient(cfg), + PayNotifyTask: NewPayNotifyTaskClient(cfg), + PayOrder: NewPayOrderClient(cfg), + PayOrderExtension: NewPayOrderExtensionClient(cfg), + PayRefund: NewPayRefundClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + App: NewAppClient(cfg), + PayChannel: NewPayChannelClient(cfg), + PayNotifyLog: NewPayNotifyLogClient(cfg), + PayNotifyTask: NewPayNotifyTaskClient(cfg), + PayOrder: NewPayOrderClient(cfg), + PayOrderExtension: NewPayOrderExtensionClient(cfg), + PayRefund: NewPayRefundClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// App. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + for _, n := range []interface{ Use(...Hook) }{ + c.App, c.PayChannel, c.PayNotifyLog, c.PayNotifyTask, c.PayOrder, + c.PayOrderExtension, c.PayRefund, + } { + n.Use(hooks...) + } +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + for _, n := range []interface{ Intercept(...Interceptor) }{ + c.App, c.PayChannel, c.PayNotifyLog, c.PayNotifyTask, c.PayOrder, + c.PayOrderExtension, c.PayRefund, + } { + n.Intercept(interceptors...) + } +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *AppMutation: + return c.App.mutate(ctx, m) + case *PayChannelMutation: + return c.PayChannel.mutate(ctx, m) + case *PayNotifyLogMutation: + return c.PayNotifyLog.mutate(ctx, m) + case *PayNotifyTaskMutation: + return c.PayNotifyTask.mutate(ctx, m) + case *PayOrderMutation: + return c.PayOrder.mutate(ctx, m) + case *PayOrderExtensionMutation: + return c.PayOrderExtension.mutate(ctx, m) + case *PayRefundMutation: + return c.PayRefund.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// AppClient is a client for the App schema. +type AppClient struct { + config +} + +// NewAppClient returns a client for the App from the given config. +func NewAppClient(c config) *AppClient { + return &AppClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `app.Hooks(f(g(h())))`. +func (c *AppClient) Use(hooks ...Hook) { + c.hooks.App = append(c.hooks.App, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `app.Intercept(f(g(h())))`. +func (c *AppClient) Intercept(interceptors ...Interceptor) { + c.inters.App = append(c.inters.App, interceptors...) +} + +// Create returns a builder for creating a App entity. +func (c *AppClient) Create() *AppCreate { + mutation := newAppMutation(c.config, OpCreate) + return &AppCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of App entities. +func (c *AppClient) CreateBulk(builders ...*AppCreate) *AppCreateBulk { + return &AppCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *AppClient) MapCreateBulk(slice any, setFunc func(*AppCreate, int)) *AppCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &AppCreateBulk{err: fmt.Errorf("calling to AppClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*AppCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &AppCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for App. +func (c *AppClient) Update() *AppUpdate { + mutation := newAppMutation(c.config, OpUpdate) + return &AppUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AppClient) UpdateOne(_m *App) *AppUpdateOne { + mutation := newAppMutation(c.config, OpUpdateOne, withApp(_m)) + return &AppUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AppClient) UpdateOneID(id uint64) *AppUpdateOne { + mutation := newAppMutation(c.config, OpUpdateOne, withAppID(id)) + return &AppUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for App. +func (c *AppClient) Delete() *AppDelete { + mutation := newAppMutation(c.config, OpDelete) + return &AppDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AppClient) DeleteOne(_m *App) *AppDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *AppClient) DeleteOneID(id uint64) *AppDeleteOne { + builder := c.Delete().Where(app.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AppDeleteOne{builder} +} + +// Query returns a query builder for App. +func (c *AppClient) Query() *AppQuery { + return &AppQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeApp}, + inters: c.Interceptors(), + } +} + +// Get returns a App entity by its id. +func (c *AppClient) Get(ctx context.Context, id uint64) (*App, error) { + return c.Query().Where(app.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AppClient) GetX(ctx context.Context, id uint64) *App { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryChannel queries the channel edge of a App. +func (c *AppClient) QueryChannel(_m *App) *PayChannelQuery { + query := (&PayChannelClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, id), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, app.ChannelTable, app.ChannelColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryNotifyTask queries the notify_task edge of a App. +func (c *AppClient) QueryNotifyTask(_m *App) *PayNotifyTaskQuery { + query := (&PayNotifyTaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(app.Table, app.FieldID, id), + sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, app.NotifyTaskTable, app.NotifyTaskColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *AppClient) Hooks() []Hook { + return c.hooks.App +} + +// Interceptors returns the client interceptors. +func (c *AppClient) Interceptors() []Interceptor { + return c.inters.App +} + +func (c *AppClient) mutate(ctx context.Context, m *AppMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&AppCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&AppUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&AppUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&AppDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown App mutation op: %q", m.Op()) + } +} + +// PayChannelClient is a client for the PayChannel schema. +type PayChannelClient struct { + config +} + +// NewPayChannelClient returns a client for the PayChannel from the given config. +func NewPayChannelClient(c config) *PayChannelClient { + return &PayChannelClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `paychannel.Hooks(f(g(h())))`. +func (c *PayChannelClient) Use(hooks ...Hook) { + c.hooks.PayChannel = append(c.hooks.PayChannel, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `paychannel.Intercept(f(g(h())))`. +func (c *PayChannelClient) Intercept(interceptors ...Interceptor) { + c.inters.PayChannel = append(c.inters.PayChannel, interceptors...) +} + +// Create returns a builder for creating a PayChannel entity. +func (c *PayChannelClient) Create() *PayChannelCreate { + mutation := newPayChannelMutation(c.config, OpCreate) + return &PayChannelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PayChannel entities. +func (c *PayChannelClient) CreateBulk(builders ...*PayChannelCreate) *PayChannelCreateBulk { + return &PayChannelCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PayChannelClient) MapCreateBulk(slice any, setFunc func(*PayChannelCreate, int)) *PayChannelCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PayChannelCreateBulk{err: fmt.Errorf("calling to PayChannelClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PayChannelCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PayChannelCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PayChannel. +func (c *PayChannelClient) Update() *PayChannelUpdate { + mutation := newPayChannelMutation(c.config, OpUpdate) + return &PayChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PayChannelClient) UpdateOne(_m *PayChannel) *PayChannelUpdateOne { + mutation := newPayChannelMutation(c.config, OpUpdateOne, withPayChannel(_m)) + return &PayChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PayChannelClient) UpdateOneID(id uint64) *PayChannelUpdateOne { + mutation := newPayChannelMutation(c.config, OpUpdateOne, withPayChannelID(id)) + return &PayChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PayChannel. +func (c *PayChannelClient) Delete() *PayChannelDelete { + mutation := newPayChannelMutation(c.config, OpDelete) + return &PayChannelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PayChannelClient) DeleteOne(_m *PayChannel) *PayChannelDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PayChannelClient) DeleteOneID(id uint64) *PayChannelDeleteOne { + builder := c.Delete().Where(paychannel.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PayChannelDeleteOne{builder} +} + +// Query returns a query builder for PayChannel. +func (c *PayChannelClient) Query() *PayChannelQuery { + return &PayChannelQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePayChannel}, + inters: c.Interceptors(), + } +} + +// Get returns a PayChannel entity by its id. +func (c *PayChannelClient) Get(ctx context.Context, id uint64) (*PayChannel, error) { + return c.Query().Where(paychannel.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PayChannelClient) GetX(ctx context.Context, id uint64) *PayChannel { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryOrders queries the orders edge of a PayChannel. +func (c *PayChannelClient) QueryOrders(_m *PayChannel) *PayOrderQuery { + query := (&PayOrderClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, id), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paychannel.OrdersTable, paychannel.OrdersColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryOrdersExtension queries the orders_extension edge of a PayChannel. +func (c *PayChannelClient) QueryOrdersExtension(_m *PayChannel) *PayOrderExtensionQuery { + query := (&PayOrderExtensionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, id), + sqlgraph.To(payorderextension.Table, payorderextension.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paychannel.OrdersExtensionTable, paychannel.OrdersExtensionColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRefund queries the refund edge of a PayChannel. +func (c *PayChannelClient) QueryRefund(_m *PayChannel) *PayRefundQuery { + query := (&PayRefundClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, id), + sqlgraph.To(payrefund.Table, payrefund.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paychannel.RefundTable, paychannel.RefundColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryApp queries the app edge of a PayChannel. +func (c *PayChannelClient) QueryApp(_m *PayChannel) *AppQuery { + query := (&AppClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, id), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paychannel.AppTable, paychannel.AppColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PayChannelClient) Hooks() []Hook { + return c.hooks.PayChannel +} + +// Interceptors returns the client interceptors. +func (c *PayChannelClient) Interceptors() []Interceptor { + return c.inters.PayChannel +} + +func (c *PayChannelClient) mutate(ctx context.Context, m *PayChannelMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PayChannelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PayChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PayChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PayChannelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PayChannel mutation op: %q", m.Op()) + } +} + +// PayNotifyLogClient is a client for the PayNotifyLog schema. +type PayNotifyLogClient struct { + config +} + +// NewPayNotifyLogClient returns a client for the PayNotifyLog from the given config. +func NewPayNotifyLogClient(c config) *PayNotifyLogClient { + return &PayNotifyLogClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `paynotifylog.Hooks(f(g(h())))`. +func (c *PayNotifyLogClient) Use(hooks ...Hook) { + c.hooks.PayNotifyLog = append(c.hooks.PayNotifyLog, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `paynotifylog.Intercept(f(g(h())))`. +func (c *PayNotifyLogClient) Intercept(interceptors ...Interceptor) { + c.inters.PayNotifyLog = append(c.inters.PayNotifyLog, interceptors...) +} + +// Create returns a builder for creating a PayNotifyLog entity. +func (c *PayNotifyLogClient) Create() *PayNotifyLogCreate { + mutation := newPayNotifyLogMutation(c.config, OpCreate) + return &PayNotifyLogCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PayNotifyLog entities. +func (c *PayNotifyLogClient) CreateBulk(builders ...*PayNotifyLogCreate) *PayNotifyLogCreateBulk { + return &PayNotifyLogCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PayNotifyLogClient) MapCreateBulk(slice any, setFunc func(*PayNotifyLogCreate, int)) *PayNotifyLogCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PayNotifyLogCreateBulk{err: fmt.Errorf("calling to PayNotifyLogClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PayNotifyLogCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PayNotifyLogCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PayNotifyLog. +func (c *PayNotifyLogClient) Update() *PayNotifyLogUpdate { + mutation := newPayNotifyLogMutation(c.config, OpUpdate) + return &PayNotifyLogUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PayNotifyLogClient) UpdateOne(_m *PayNotifyLog) *PayNotifyLogUpdateOne { + mutation := newPayNotifyLogMutation(c.config, OpUpdateOne, withPayNotifyLog(_m)) + return &PayNotifyLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PayNotifyLogClient) UpdateOneID(id uint64) *PayNotifyLogUpdateOne { + mutation := newPayNotifyLogMutation(c.config, OpUpdateOne, withPayNotifyLogID(id)) + return &PayNotifyLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PayNotifyLog. +func (c *PayNotifyLogClient) Delete() *PayNotifyLogDelete { + mutation := newPayNotifyLogMutation(c.config, OpDelete) + return &PayNotifyLogDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PayNotifyLogClient) DeleteOne(_m *PayNotifyLog) *PayNotifyLogDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PayNotifyLogClient) DeleteOneID(id uint64) *PayNotifyLogDeleteOne { + builder := c.Delete().Where(paynotifylog.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PayNotifyLogDeleteOne{builder} +} + +// Query returns a query builder for PayNotifyLog. +func (c *PayNotifyLogClient) Query() *PayNotifyLogQuery { + return &PayNotifyLogQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePayNotifyLog}, + inters: c.Interceptors(), + } +} + +// Get returns a PayNotifyLog entity by its id. +func (c *PayNotifyLogClient) Get(ctx context.Context, id uint64) (*PayNotifyLog, error) { + return c.Query().Where(paynotifylog.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PayNotifyLogClient) GetX(ctx context.Context, id uint64) *PayNotifyLog { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryTask queries the task edge of a PayNotifyLog. +func (c *PayNotifyLogClient) QueryTask(_m *PayNotifyLog) *PayNotifyTaskQuery { + query := (&PayNotifyTaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paynotifylog.Table, paynotifylog.FieldID, id), + sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paynotifylog.TaskTable, paynotifylog.TaskColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PayNotifyLogClient) Hooks() []Hook { + return c.hooks.PayNotifyLog +} + +// Interceptors returns the client interceptors. +func (c *PayNotifyLogClient) Interceptors() []Interceptor { + return c.inters.PayNotifyLog +} + +func (c *PayNotifyLogClient) mutate(ctx context.Context, m *PayNotifyLogMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PayNotifyLogCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PayNotifyLogUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PayNotifyLogUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PayNotifyLogDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PayNotifyLog mutation op: %q", m.Op()) + } +} + +// PayNotifyTaskClient is a client for the PayNotifyTask schema. +type PayNotifyTaskClient struct { + config +} + +// NewPayNotifyTaskClient returns a client for the PayNotifyTask from the given config. +func NewPayNotifyTaskClient(c config) *PayNotifyTaskClient { + return &PayNotifyTaskClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `paynotifytask.Hooks(f(g(h())))`. +func (c *PayNotifyTaskClient) Use(hooks ...Hook) { + c.hooks.PayNotifyTask = append(c.hooks.PayNotifyTask, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `paynotifytask.Intercept(f(g(h())))`. +func (c *PayNotifyTaskClient) Intercept(interceptors ...Interceptor) { + c.inters.PayNotifyTask = append(c.inters.PayNotifyTask, interceptors...) +} + +// Create returns a builder for creating a PayNotifyTask entity. +func (c *PayNotifyTaskClient) Create() *PayNotifyTaskCreate { + mutation := newPayNotifyTaskMutation(c.config, OpCreate) + return &PayNotifyTaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PayNotifyTask entities. +func (c *PayNotifyTaskClient) CreateBulk(builders ...*PayNotifyTaskCreate) *PayNotifyTaskCreateBulk { + return &PayNotifyTaskCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PayNotifyTaskClient) MapCreateBulk(slice any, setFunc func(*PayNotifyTaskCreate, int)) *PayNotifyTaskCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PayNotifyTaskCreateBulk{err: fmt.Errorf("calling to PayNotifyTaskClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PayNotifyTaskCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PayNotifyTaskCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PayNotifyTask. +func (c *PayNotifyTaskClient) Update() *PayNotifyTaskUpdate { + mutation := newPayNotifyTaskMutation(c.config, OpUpdate) + return &PayNotifyTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PayNotifyTaskClient) UpdateOne(_m *PayNotifyTask) *PayNotifyTaskUpdateOne { + mutation := newPayNotifyTaskMutation(c.config, OpUpdateOne, withPayNotifyTask(_m)) + return &PayNotifyTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PayNotifyTaskClient) UpdateOneID(id uint64) *PayNotifyTaskUpdateOne { + mutation := newPayNotifyTaskMutation(c.config, OpUpdateOne, withPayNotifyTaskID(id)) + return &PayNotifyTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PayNotifyTask. +func (c *PayNotifyTaskClient) Delete() *PayNotifyTaskDelete { + mutation := newPayNotifyTaskMutation(c.config, OpDelete) + return &PayNotifyTaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PayNotifyTaskClient) DeleteOne(_m *PayNotifyTask) *PayNotifyTaskDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PayNotifyTaskClient) DeleteOneID(id uint64) *PayNotifyTaskDeleteOne { + builder := c.Delete().Where(paynotifytask.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PayNotifyTaskDeleteOne{builder} +} + +// Query returns a query builder for PayNotifyTask. +func (c *PayNotifyTaskClient) Query() *PayNotifyTaskQuery { + return &PayNotifyTaskQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePayNotifyTask}, + inters: c.Interceptors(), + } +} + +// Get returns a PayNotifyTask entity by its id. +func (c *PayNotifyTaskClient) Get(ctx context.Context, id uint64) (*PayNotifyTask, error) { + return c.Query().Where(paynotifytask.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PayNotifyTaskClient) GetX(ctx context.Context, id uint64) *PayNotifyTask { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryApp queries the app edge of a PayNotifyTask. +func (c *PayNotifyTaskClient) QueryApp(_m *PayNotifyTask) *AppQuery { + query := (&AppClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, id), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paynotifytask.AppTable, paynotifytask.AppColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryOrder queries the order edge of a PayNotifyTask. +func (c *PayNotifyTaskClient) QueryOrder(_m *PayNotifyTask) *PayOrderQuery { + query := (&PayOrderClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, id), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paynotifytask.OrderTable, paynotifytask.OrderColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryNotifyLog queries the notify_log edge of a PayNotifyTask. +func (c *PayNotifyTaskClient) QueryNotifyLog(_m *PayNotifyTask) *PayNotifyLogQuery { + query := (&PayNotifyLogClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(paynotifytask.Table, paynotifytask.FieldID, id), + sqlgraph.To(paynotifylog.Table, paynotifylog.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paynotifytask.NotifyLogTable, paynotifytask.NotifyLogColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PayNotifyTaskClient) Hooks() []Hook { + return c.hooks.PayNotifyTask +} + +// Interceptors returns the client interceptors. +func (c *PayNotifyTaskClient) Interceptors() []Interceptor { + return c.inters.PayNotifyTask +} + +func (c *PayNotifyTaskClient) mutate(ctx context.Context, m *PayNotifyTaskMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PayNotifyTaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PayNotifyTaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PayNotifyTaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PayNotifyTaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PayNotifyTask mutation op: %q", m.Op()) + } +} + +// PayOrderClient is a client for the PayOrder schema. +type PayOrderClient struct { + config +} + +// NewPayOrderClient returns a client for the PayOrder from the given config. +func NewPayOrderClient(c config) *PayOrderClient { + return &PayOrderClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `payorder.Hooks(f(g(h())))`. +func (c *PayOrderClient) Use(hooks ...Hook) { + c.hooks.PayOrder = append(c.hooks.PayOrder, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `payorder.Intercept(f(g(h())))`. +func (c *PayOrderClient) Intercept(interceptors ...Interceptor) { + c.inters.PayOrder = append(c.inters.PayOrder, interceptors...) +} + +// Create returns a builder for creating a PayOrder entity. +func (c *PayOrderClient) Create() *PayOrderCreate { + mutation := newPayOrderMutation(c.config, OpCreate) + return &PayOrderCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PayOrder entities. +func (c *PayOrderClient) CreateBulk(builders ...*PayOrderCreate) *PayOrderCreateBulk { + return &PayOrderCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PayOrderClient) MapCreateBulk(slice any, setFunc func(*PayOrderCreate, int)) *PayOrderCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PayOrderCreateBulk{err: fmt.Errorf("calling to PayOrderClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PayOrderCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PayOrderCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PayOrder. +func (c *PayOrderClient) Update() *PayOrderUpdate { + mutation := newPayOrderMutation(c.config, OpUpdate) + return &PayOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PayOrderClient) UpdateOne(_m *PayOrder) *PayOrderUpdateOne { + mutation := newPayOrderMutation(c.config, OpUpdateOne, withPayOrder(_m)) + return &PayOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PayOrderClient) UpdateOneID(id uint64) *PayOrderUpdateOne { + mutation := newPayOrderMutation(c.config, OpUpdateOne, withPayOrderID(id)) + return &PayOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PayOrder. +func (c *PayOrderClient) Delete() *PayOrderDelete { + mutation := newPayOrderMutation(c.config, OpDelete) + return &PayOrderDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PayOrderClient) DeleteOne(_m *PayOrder) *PayOrderDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PayOrderClient) DeleteOneID(id uint64) *PayOrderDeleteOne { + builder := c.Delete().Where(payorder.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PayOrderDeleteOne{builder} +} + +// Query returns a query builder for PayOrder. +func (c *PayOrderClient) Query() *PayOrderQuery { + return &PayOrderQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePayOrder}, + inters: c.Interceptors(), + } +} + +// Get returns a PayOrder entity by its id. +func (c *PayOrderClient) Get(ctx context.Context, id uint64) (*PayOrder, error) { + return c.Query().Where(payorder.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PayOrderClient) GetX(ctx context.Context, id uint64) *PayOrder { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryChannel queries the channel edge of a PayOrder. +func (c *PayOrderClient) QueryChannel(_m *PayOrder) *PayChannelQuery { + query := (&PayChannelClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, id), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payorder.ChannelTable, payorder.ChannelColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryOrdersExtension queries the orders_extension edge of a PayOrder. +func (c *PayOrderClient) QueryOrdersExtension(_m *PayOrder) *PayOrderExtensionQuery { + query := (&PayOrderExtensionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, id), + sqlgraph.To(payorderextension.Table, payorderextension.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, payorder.OrdersExtensionTable, payorder.OrdersExtensionColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryNotifyTask queries the notify_task edge of a PayOrder. +func (c *PayOrderClient) QueryNotifyTask(_m *PayOrder) *PayNotifyTaskQuery { + query := (&PayNotifyTaskClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, id), + sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, payorder.NotifyTaskTable, payorder.NotifyTaskColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRefund queries the refund edge of a PayOrder. +func (c *PayOrderClient) QueryRefund(_m *PayOrder) *PayRefundQuery { + query := (&PayRefundClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, id), + sqlgraph.To(payrefund.Table, payrefund.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, payorder.RefundTable, payorder.RefundColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PayOrderClient) Hooks() []Hook { + return c.hooks.PayOrder +} + +// Interceptors returns the client interceptors. +func (c *PayOrderClient) Interceptors() []Interceptor { + return c.inters.PayOrder +} + +func (c *PayOrderClient) mutate(ctx context.Context, m *PayOrderMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PayOrderCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PayOrderUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PayOrderUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PayOrderDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PayOrder mutation op: %q", m.Op()) + } +} + +// PayOrderExtensionClient is a client for the PayOrderExtension schema. +type PayOrderExtensionClient struct { + config +} + +// NewPayOrderExtensionClient returns a client for the PayOrderExtension from the given config. +func NewPayOrderExtensionClient(c config) *PayOrderExtensionClient { + return &PayOrderExtensionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `payorderextension.Hooks(f(g(h())))`. +func (c *PayOrderExtensionClient) Use(hooks ...Hook) { + c.hooks.PayOrderExtension = append(c.hooks.PayOrderExtension, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `payorderextension.Intercept(f(g(h())))`. +func (c *PayOrderExtensionClient) Intercept(interceptors ...Interceptor) { + c.inters.PayOrderExtension = append(c.inters.PayOrderExtension, interceptors...) +} + +// Create returns a builder for creating a PayOrderExtension entity. +func (c *PayOrderExtensionClient) Create() *PayOrderExtensionCreate { + mutation := newPayOrderExtensionMutation(c.config, OpCreate) + return &PayOrderExtensionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PayOrderExtension entities. +func (c *PayOrderExtensionClient) CreateBulk(builders ...*PayOrderExtensionCreate) *PayOrderExtensionCreateBulk { + return &PayOrderExtensionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PayOrderExtensionClient) MapCreateBulk(slice any, setFunc func(*PayOrderExtensionCreate, int)) *PayOrderExtensionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PayOrderExtensionCreateBulk{err: fmt.Errorf("calling to PayOrderExtensionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PayOrderExtensionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PayOrderExtensionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PayOrderExtension. +func (c *PayOrderExtensionClient) Update() *PayOrderExtensionUpdate { + mutation := newPayOrderExtensionMutation(c.config, OpUpdate) + return &PayOrderExtensionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PayOrderExtensionClient) UpdateOne(_m *PayOrderExtension) *PayOrderExtensionUpdateOne { + mutation := newPayOrderExtensionMutation(c.config, OpUpdateOne, withPayOrderExtension(_m)) + return &PayOrderExtensionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PayOrderExtensionClient) UpdateOneID(id uint64) *PayOrderExtensionUpdateOne { + mutation := newPayOrderExtensionMutation(c.config, OpUpdateOne, withPayOrderExtensionID(id)) + return &PayOrderExtensionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PayOrderExtension. +func (c *PayOrderExtensionClient) Delete() *PayOrderExtensionDelete { + mutation := newPayOrderExtensionMutation(c.config, OpDelete) + return &PayOrderExtensionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PayOrderExtensionClient) DeleteOne(_m *PayOrderExtension) *PayOrderExtensionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PayOrderExtensionClient) DeleteOneID(id uint64) *PayOrderExtensionDeleteOne { + builder := c.Delete().Where(payorderextension.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PayOrderExtensionDeleteOne{builder} +} + +// Query returns a query builder for PayOrderExtension. +func (c *PayOrderExtensionClient) Query() *PayOrderExtensionQuery { + return &PayOrderExtensionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePayOrderExtension}, + inters: c.Interceptors(), + } +} + +// Get returns a PayOrderExtension entity by its id. +func (c *PayOrderExtensionClient) Get(ctx context.Context, id uint64) (*PayOrderExtension, error) { + return c.Query().Where(payorderextension.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PayOrderExtensionClient) GetX(ctx context.Context, id uint64) *PayOrderExtension { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryChannel queries the channel edge of a PayOrderExtension. +func (c *PayOrderExtensionClient) QueryChannel(_m *PayOrderExtension) *PayChannelQuery { + query := (&PayChannelClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payorderextension.Table, payorderextension.FieldID, id), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payorderextension.ChannelTable, payorderextension.ChannelColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryOrder queries the order edge of a PayOrderExtension. +func (c *PayOrderExtensionClient) QueryOrder(_m *PayOrderExtension) *PayOrderQuery { + query := (&PayOrderClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payorderextension.Table, payorderextension.FieldID, id), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payorderextension.OrderTable, payorderextension.OrderColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PayOrderExtensionClient) Hooks() []Hook { + return c.hooks.PayOrderExtension +} + +// Interceptors returns the client interceptors. +func (c *PayOrderExtensionClient) Interceptors() []Interceptor { + return c.inters.PayOrderExtension +} + +func (c *PayOrderExtensionClient) mutate(ctx context.Context, m *PayOrderExtensionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PayOrderExtensionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PayOrderExtensionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PayOrderExtensionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PayOrderExtensionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PayOrderExtension mutation op: %q", m.Op()) + } +} + +// PayRefundClient is a client for the PayRefund schema. +type PayRefundClient struct { + config +} + +// NewPayRefundClient returns a client for the PayRefund from the given config. +func NewPayRefundClient(c config) *PayRefundClient { + return &PayRefundClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `payrefund.Hooks(f(g(h())))`. +func (c *PayRefundClient) Use(hooks ...Hook) { + c.hooks.PayRefund = append(c.hooks.PayRefund, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `payrefund.Intercept(f(g(h())))`. +func (c *PayRefundClient) Intercept(interceptors ...Interceptor) { + c.inters.PayRefund = append(c.inters.PayRefund, interceptors...) +} + +// Create returns a builder for creating a PayRefund entity. +func (c *PayRefundClient) Create() *PayRefundCreate { + mutation := newPayRefundMutation(c.config, OpCreate) + return &PayRefundCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PayRefund entities. +func (c *PayRefundClient) CreateBulk(builders ...*PayRefundCreate) *PayRefundCreateBulk { + return &PayRefundCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PayRefundClient) MapCreateBulk(slice any, setFunc func(*PayRefundCreate, int)) *PayRefundCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PayRefundCreateBulk{err: fmt.Errorf("calling to PayRefundClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PayRefundCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PayRefundCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PayRefund. +func (c *PayRefundClient) Update() *PayRefundUpdate { + mutation := newPayRefundMutation(c.config, OpUpdate) + return &PayRefundUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PayRefundClient) UpdateOne(_m *PayRefund) *PayRefundUpdateOne { + mutation := newPayRefundMutation(c.config, OpUpdateOne, withPayRefund(_m)) + return &PayRefundUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PayRefundClient) UpdateOneID(id uint64) *PayRefundUpdateOne { + mutation := newPayRefundMutation(c.config, OpUpdateOne, withPayRefundID(id)) + return &PayRefundUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PayRefund. +func (c *PayRefundClient) Delete() *PayRefundDelete { + mutation := newPayRefundMutation(c.config, OpDelete) + return &PayRefundDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PayRefundClient) DeleteOne(_m *PayRefund) *PayRefundDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PayRefundClient) DeleteOneID(id uint64) *PayRefundDeleteOne { + builder := c.Delete().Where(payrefund.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PayRefundDeleteOne{builder} +} + +// Query returns a query builder for PayRefund. +func (c *PayRefundClient) Query() *PayRefundQuery { + return &PayRefundQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePayRefund}, + inters: c.Interceptors(), + } +} + +// Get returns a PayRefund entity by its id. +func (c *PayRefundClient) Get(ctx context.Context, id uint64) (*PayRefund, error) { + return c.Query().Where(payrefund.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PayRefundClient) GetX(ctx context.Context, id uint64) *PayRefund { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryOrder queries the order edge of a PayRefund. +func (c *PayRefundClient) QueryOrder(_m *PayRefund) *PayOrderQuery { + query := (&PayOrderClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payrefund.Table, payrefund.FieldID, id), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payrefund.OrderTable, payrefund.OrderColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChannel queries the channel edge of a PayRefund. +func (c *PayRefundClient) QueryChannel(_m *PayRefund) *PayChannelQuery { + query := (&PayChannelClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(payrefund.Table, payrefund.FieldID, id), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payrefund.ChannelTable, payrefund.ChannelColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PayRefundClient) Hooks() []Hook { + return c.hooks.PayRefund +} + +// Interceptors returns the client interceptors. +func (c *PayRefundClient) Interceptors() []Interceptor { + return c.inters.PayRefund +} + +func (c *PayRefundClient) mutate(ctx context.Context, m *PayRefundMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PayRefundCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PayRefundUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PayRefundUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PayRefundDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PayRefund mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + App, PayChannel, PayNotifyLog, PayNotifyTask, PayOrder, PayOrderExtension, + PayRefund []ent.Hook + } + inters struct { + App, PayChannel, PayNotifyLog, PayNotifyTask, PayOrder, PayOrderExtension, + PayRefund []ent.Interceptor + } +) + +// ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it. +// See, database/sql#DB.ExecContext for more information. +func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + ex, ok := c.driver.(interface { + ExecContext(context.Context, string, ...any) (stdsql.Result, error) + }) + if !ok { + return nil, fmt.Errorf("Driver.ExecContext is not supported") + } + return ex.ExecContext(ctx, query, args...) +} + +// QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it. +// See, database/sql#DB.QueryContext for more information. +func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { + q, ok := c.driver.(interface { + QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) + }) + if !ok { + return nil, fmt.Errorf("Driver.QueryContext is not supported") + } + return q.QueryContext(ctx, query, args...) +} diff --git a/rpc/ent/ent.go b/rpc/ent/ent.go new file mode 100644 index 0000000..329fab1 --- /dev/null +++ b/rpc/ent/ent.go @@ -0,0 +1,620 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "reflect" + "sync" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// checkColumn checks if the column exists in the given table. +func checkColumn(t, c string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + app.Table: app.ValidColumn, + paychannel.Table: paychannel.ValidColumn, + paynotifylog.Table: paynotifylog.ValidColumn, + paynotifytask.Table: paynotifytask.ValidColumn, + payorder.Table: payorder.ValidColumn, + payorderextension.Table: payorderextension.ValidColumn, + payrefund.Table: payrefund.ValidColumn, + }) + }) + return columnCheck(t, c) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/rpc/ent/enttest/enttest.go b/rpc/ent/enttest/enttest.go new file mode 100644 index 0000000..77826e2 --- /dev/null +++ b/rpc/ent/enttest/enttest.go @@ -0,0 +1,85 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "mingyang-admin-pay/rpc/ent" + // required by schema hooks. + _ "mingyang-admin-pay/rpc/ent/runtime" + + "mingyang-admin-pay/rpc/ent/migrate" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/rpc/ent/hook/hook.go b/rpc/ent/hook/hook.go new file mode 100644 index 0000000..b89d6c7 --- /dev/null +++ b/rpc/ent/hook/hook.go @@ -0,0 +1,270 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + "mingyang-admin-pay/rpc/ent" +) + +// The AppFunc type is an adapter to allow the use of ordinary +// function as App mutator. +type AppFunc func(context.Context, *ent.AppMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f AppFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.AppMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AppMutation", m) +} + +// The PayChannelFunc type is an adapter to allow the use of ordinary +// function as PayChannel mutator. +type PayChannelFunc func(context.Context, *ent.PayChannelMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PayChannelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PayChannelMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayChannelMutation", m) +} + +// The PayNotifyLogFunc type is an adapter to allow the use of ordinary +// function as PayNotifyLog mutator. +type PayNotifyLogFunc func(context.Context, *ent.PayNotifyLogMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PayNotifyLogFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PayNotifyLogMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayNotifyLogMutation", m) +} + +// The PayNotifyTaskFunc type is an adapter to allow the use of ordinary +// function as PayNotifyTask mutator. +type PayNotifyTaskFunc func(context.Context, *ent.PayNotifyTaskMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PayNotifyTaskFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PayNotifyTaskMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayNotifyTaskMutation", m) +} + +// The PayOrderFunc type is an adapter to allow the use of ordinary +// function as PayOrder mutator. +type PayOrderFunc func(context.Context, *ent.PayOrderMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PayOrderFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PayOrderMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayOrderMutation", m) +} + +// The PayOrderExtensionFunc type is an adapter to allow the use of ordinary +// function as PayOrderExtension mutator. +type PayOrderExtensionFunc func(context.Context, *ent.PayOrderExtensionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PayOrderExtensionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PayOrderExtensionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayOrderExtensionMutation", m) +} + +// The PayRefundFunc type is an adapter to allow the use of ordinary +// function as PayRefund mutator. +type PayRefundFunc func(context.Context, *ent.PayRefundMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PayRefundFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PayRefundMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PayRefundMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/rpc/ent/intercept/intercept.go b/rpc/ent/intercept/intercept.go new file mode 100644 index 0000000..e9f9b1a --- /dev/null +++ b/rpc/ent/intercept/intercept.go @@ -0,0 +1,330 @@ +// Code generated by ent, DO NOT EDIT. + +package intercept + +import ( + "context" + "fmt" + + "mingyang-admin-pay/rpc/ent" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" +) + +// The Query interface represents an operation that queries a graph. +// By using this interface, users can write generic code that manipulates +// query builders of different types. +type Query interface { + // Type returns the string representation of the query type. + Type() string + // Limit the number of records to be returned by this query. + Limit(int) + // Offset to start from. + Offset(int) + // Unique configures the query builder to filter duplicate records. + Unique(bool) + // Order specifies how the records should be ordered. + Order(...func(*sql.Selector)) + // WhereP appends storage-level predicates to the query builder. Using this method, users + // can use type-assertion to append predicates that do not depend on any generated package. + WhereP(...func(*sql.Selector)) +} + +// The Func type is an adapter that allows ordinary functions to be used as interceptors. +// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the +// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc. +type Func func(context.Context, Query) error + +// Intercept calls f(ctx, q) and then applied the next Querier. +func (f Func) Intercept(next ent.Querier) ent.Querier { + return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) { + query, err := NewQuery(q) + if err != nil { + return nil, err + } + if err := f(ctx, query); err != nil { + return nil, err + } + return next.Query(ctx, q) + }) +} + +// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser. +// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f. +type TraverseFunc func(context.Context, Query) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { + query, err := NewQuery(q) + if err != nil { + return err + } + return f(ctx, query) +} + +// The AppFunc type is an adapter to allow the use of ordinary function as a Querier. +type AppFunc func(context.Context, *ent.AppQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f AppFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.AppQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.AppQuery", q) +} + +// The TraverseApp type is an adapter to allow the use of ordinary function as Traverser. +type TraverseApp func(context.Context, *ent.AppQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseApp) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseApp) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.AppQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.AppQuery", q) +} + +// The PayChannelFunc type is an adapter to allow the use of ordinary function as a Querier. +type PayChannelFunc func(context.Context, *ent.PayChannelQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PayChannelFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PayChannelQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayChannelQuery", q) +} + +// The TraversePayChannel type is an adapter to allow the use of ordinary function as Traverser. +type TraversePayChannel func(context.Context, *ent.PayChannelQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePayChannel) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePayChannel) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PayChannelQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PayChannelQuery", q) +} + +// The PayNotifyLogFunc type is an adapter to allow the use of ordinary function as a Querier. +type PayNotifyLogFunc func(context.Context, *ent.PayNotifyLogQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PayNotifyLogFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PayNotifyLogQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyLogQuery", q) +} + +// The TraversePayNotifyLog type is an adapter to allow the use of ordinary function as Traverser. +type TraversePayNotifyLog func(context.Context, *ent.PayNotifyLogQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePayNotifyLog) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePayNotifyLog) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PayNotifyLogQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyLogQuery", q) +} + +// The PayNotifyTaskFunc type is an adapter to allow the use of ordinary function as a Querier. +type PayNotifyTaskFunc func(context.Context, *ent.PayNotifyTaskQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PayNotifyTaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PayNotifyTaskQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyTaskQuery", q) +} + +// The TraversePayNotifyTask type is an adapter to allow the use of ordinary function as Traverser. +type TraversePayNotifyTask func(context.Context, *ent.PayNotifyTaskQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePayNotifyTask) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePayNotifyTask) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PayNotifyTaskQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PayNotifyTaskQuery", q) +} + +// The PayOrderFunc type is an adapter to allow the use of ordinary function as a Querier. +type PayOrderFunc func(context.Context, *ent.PayOrderQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PayOrderFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PayOrderQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayOrderQuery", q) +} + +// The TraversePayOrder type is an adapter to allow the use of ordinary function as Traverser. +type TraversePayOrder func(context.Context, *ent.PayOrderQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePayOrder) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePayOrder) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PayOrderQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PayOrderQuery", q) +} + +// The PayOrderExtensionFunc type is an adapter to allow the use of ordinary function as a Querier. +type PayOrderExtensionFunc func(context.Context, *ent.PayOrderExtensionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PayOrderExtensionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PayOrderExtensionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayOrderExtensionQuery", q) +} + +// The TraversePayOrderExtension type is an adapter to allow the use of ordinary function as Traverser. +type TraversePayOrderExtension func(context.Context, *ent.PayOrderExtensionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePayOrderExtension) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePayOrderExtension) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PayOrderExtensionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PayOrderExtensionQuery", q) +} + +// The PayRefundFunc type is an adapter to allow the use of ordinary function as a Querier. +type PayRefundFunc func(context.Context, *ent.PayRefundQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PayRefundFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PayRefundQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PayRefundQuery", q) +} + +// The TraversePayRefund type is an adapter to allow the use of ordinary function as Traverser. +type TraversePayRefund func(context.Context, *ent.PayRefundQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePayRefund) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePayRefund) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PayRefundQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PayRefundQuery", q) +} + +// NewQuery returns the generic Query interface for the given typed query. +func NewQuery(q ent.Query) (Query, error) { + switch q := q.(type) { + case *ent.AppQuery: + return &query[*ent.AppQuery, predicate.App, app.OrderOption]{typ: ent.TypeApp, tq: q}, nil + case *ent.PayChannelQuery: + return &query[*ent.PayChannelQuery, predicate.PayChannel, paychannel.OrderOption]{typ: ent.TypePayChannel, tq: q}, nil + case *ent.PayNotifyLogQuery: + return &query[*ent.PayNotifyLogQuery, predicate.PayNotifyLog, paynotifylog.OrderOption]{typ: ent.TypePayNotifyLog, tq: q}, nil + case *ent.PayNotifyTaskQuery: + return &query[*ent.PayNotifyTaskQuery, predicate.PayNotifyTask, paynotifytask.OrderOption]{typ: ent.TypePayNotifyTask, tq: q}, nil + case *ent.PayOrderQuery: + return &query[*ent.PayOrderQuery, predicate.PayOrder, payorder.OrderOption]{typ: ent.TypePayOrder, tq: q}, nil + case *ent.PayOrderExtensionQuery: + return &query[*ent.PayOrderExtensionQuery, predicate.PayOrderExtension, payorderextension.OrderOption]{typ: ent.TypePayOrderExtension, tq: q}, nil + case *ent.PayRefundQuery: + return &query[*ent.PayRefundQuery, predicate.PayRefund, payrefund.OrderOption]{typ: ent.TypePayRefund, tq: q}, nil + default: + return nil, fmt.Errorf("unknown query type %T", q) + } +} + +type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct { + typ string + tq interface { + Limit(int) T + Offset(int) T + Unique(bool) T + Order(...R) T + Where(...P) T + } +} + +func (q query[T, P, R]) Type() string { + return q.typ +} + +func (q query[T, P, R]) Limit(limit int) { + q.tq.Limit(limit) +} + +func (q query[T, P, R]) Offset(offset int) { + q.tq.Offset(offset) +} + +func (q query[T, P, R]) Unique(unique bool) { + q.tq.Unique(unique) +} + +func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) { + rs := make([]R, len(orders)) + for i := range orders { + rs[i] = orders[i] + } + q.tq.Order(rs...) +} + +func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) { + p := make([]P, len(ps)) + for i := range ps { + p[i] = ps[i] + } + q.tq.Where(p...) +} diff --git a/rpc/ent/migrate/migrate.go b/rpc/ent/migrate/migrate.go new file mode 100644 index 0000000..1956a6b --- /dev/null +++ b/rpc/ent/migrate/migrate.go @@ -0,0 +1,64 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/rpc/ent/migrate/schema.go b/rpc/ent/migrate/schema.go new file mode 100644 index 0000000..6dd2d22 --- /dev/null +++ b/rpc/ent/migrate/schema.go @@ -0,0 +1,409 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // PayAppColumns holds the columns for the "pay_app" table. + PayAppColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "app_key", Type: field.TypeString, Comment: "appKey 应用标识"}, + {Name: "app_name", Type: field.TypeString, Comment: "应用名称"}, + {Name: "order_notify_url", Type: field.TypeString, Nullable: true, Comment: "支付成功回调地址"}, + {Name: "refund_notify_url", Type: field.TypeString, Nullable: true, Comment: "退款成功回调地址"}, + } + // PayAppTable holds the schema information for the "pay_app" table. + PayAppTable = &schema.Table{ + Name: "pay_app", + Comment: "PayApp Table | 支付应用表", + Columns: PayAppColumns, + PrimaryKey: []*schema.Column{PayAppColumns[0]}, + } + // PayChannelColumns holds the columns for the "pay_channel" table. + PayChannelColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "code", Type: field.TypeString, Comment: "Pay channel code | 支付渠道编码"}, + {Name: "name_en", Type: field.TypeString, Comment: "Pay channel name | 支付渠道英文名称"}, + {Name: "name_zh", Type: field.TypeString, Comment: "Pay channel name | 支付渠道中文名称"}, + {Name: "free_rate", Type: field.TypeString, Comment: "Free rate | 手续费比例", Default: "0"}, + {Name: "config", Type: field.TypeJSON, Comment: "Config | 配置信息"}, + {Name: "remake", Type: field.TypeString, Nullable: true, Comment: "Remark | 备注"}, + {Name: "icon", Type: field.TypeUint64, Nullable: true, Comment: "Icon | 图标"}, + {Name: "order_time_out", Type: field.TypeString, Comment: "Order time out | 订单超时时间", Default: "10m"}, + {Name: "support_currency", Type: field.TypeString, Comment: "Support currency | 支持币种", Default: "CNY,USD"}, + {Name: "app_id", Type: field.TypeUint64, Comment: "App ID | 应用ID"}, + } + // PayChannelTable holds the schema information for the "pay_channel" table. + PayChannelTable = &schema.Table{ + Name: "pay_channel", + Comment: "PayChannel Table | 支付渠道表", + Columns: PayChannelColumns, + PrimaryKey: []*schema.Column{PayChannelColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "pay_channel_pay_app_app", + Columns: []*schema.Column{PayChannelColumns[15]}, + RefColumns: []*schema.Column{PayAppColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "paychannel_app_id_code", + Unique: true, + Columns: []*schema.Column{PayChannelColumns[15], PayChannelColumns[6]}, + }, + }, + } + // PayNotifyLogColumns holds the columns for the "pay_notify_log" table. + PayNotifyLogColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "notify_count", Type: field.TypeUint32, Comment: "通知次数 | 通知次数", Default: 0}, + {Name: "response", Type: field.TypeString, Nullable: true, Comment: "响应内容 | 响应内容"}, + {Name: "notify_status", Type: field.TypeString, Nullable: true, Comment: "通知状态 | 通知状态"}, + {Name: "task_id", Type: field.TypeUint64, Comment: "任务ID | 任务ID"}, + } + // PayNotifyLogTable holds the schema information for the "pay_notify_log" table. + PayNotifyLogTable = &schema.Table{ + Name: "pay_notify_log", + Comment: "PayNotifyLog Table | 异步通知日志表", + Columns: PayNotifyLogColumns, + PrimaryKey: []*schema.Column{PayNotifyLogColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "pay_notify_log_pay_notify_task_task", + Columns: []*schema.Column{PayNotifyLogColumns[9]}, + RefColumns: []*schema.Column{PayNotifyTaskColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "paynotifylog_task_id", + Unique: false, + Columns: []*schema.Column{PayNotifyLogColumns[9]}, + }, + }, + } + // PayNotifyTaskColumns holds the columns for the "pay_notify_task" table. + PayNotifyTaskColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "type", Type: field.TypeUint8, Comment: "通知类型", Default: 1}, + {Name: "data_id", Type: field.TypeUint64, Comment: "数据 ID"}, + {Name: "notify_status", Type: field.TypeUint8, Comment: "通知状态"}, + {Name: "next_notify_time", Type: field.TypeTime, Nullable: true, Comment: "下次通知时间"}, + {Name: "last_execute_time", Type: field.TypeTime, Nullable: true, Comment: "最后一次执行时间"}, + {Name: "retry_count", Type: field.TypeUint32, Nullable: true, Comment: "重试次数"}, + {Name: "max_retry_count", Type: field.TypeUint32, Nullable: true, Comment: "最大重试次数"}, + {Name: "notify_url", Type: field.TypeString, Nullable: true, Comment: "通知地址"}, + {Name: "app_id", Type: field.TypeUint64, Comment: "应用 ID"}, + {Name: "order_id", Type: field.TypeUint64, Comment: "订单 ID"}, + } + // PayNotifyTaskTable holds the schema information for the "pay_notify_task" table. + PayNotifyTaskTable = &schema.Table{ + Name: "pay_notify_task", + Comment: "PayNotifyTask Table | 异步通知任务表", + Columns: PayNotifyTaskColumns, + PrimaryKey: []*schema.Column{PayNotifyTaskColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "pay_notify_task_pay_app_app", + Columns: []*schema.Column{PayNotifyTaskColumns[14]}, + RefColumns: []*schema.Column{PayAppColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "pay_notify_task_pay_order_order", + Columns: []*schema.Column{PayNotifyTaskColumns[15]}, + RefColumns: []*schema.Column{PayOrderColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "paynotifytask_order_id", + Unique: false, + Columns: []*schema.Column{PayNotifyTaskColumns[15]}, + }, + { + Name: "paynotifytask_data_id", + Unique: false, + Columns: []*schema.Column{PayNotifyTaskColumns[7]}, + }, + }, + } + // PayOrderColumns holds the columns for the "pay_order" table. + PayOrderColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "user_id", Type: field.TypeUint64, Comment: "用户 ID"}, + {Name: "subject", Type: field.TypeString, Comment: "商品标题"}, + {Name: "body", Type: field.TypeString, Comment: "商品描述"}, + {Name: "notify_url", Type: field.TypeString, Comment: "异步通知地址"}, + {Name: "amount", Type: field.TypeUint64, Comment: "金额,单位为分", Default: 0}, + {Name: "pay_source", Type: field.TypeString, Nullable: true, Comment: "支付来源"}, + {Name: "channel_fee_rate", Type: field.TypeString, Comment: "本次渠道费率,百分比", Default: "0.00"}, + {Name: "channel_fee", Type: field.TypeUint64, Comment: "本次渠道实际收取费y", Default: 0}, + {Name: "order_status", Type: field.TypeString, Comment: "订单状态", Default: "WAIT"}, + {Name: "user_ip", Type: field.TypeString, Nullable: true, Comment: "用户 IP"}, + {Name: "expire_time", Type: field.TypeTime, Comment: "订单过期时间"}, + {Name: "pay_no", Type: field.TypeString, Comment: "支付单号"}, + {Name: "success_time", Type: field.TypeTime, Comment: "订单支付成功时间"}, + {Name: "extension_id", Type: field.TypeUint64, Nullable: true, Comment: "支付成功的订单拓展单ID"}, + {Name: "transaction_id", Type: field.TypeString, Nullable: true, Comment: "交易流水号,有一些平台可能会有"}, + {Name: "currency", Type: field.TypeString, Comment: "货币代码", Default: "USD"}, + {Name: "refund_price", Type: field.TypeUint64, Comment: "退款金额,单位为分", Default: 0}, + {Name: "channel_order_no", Type: field.TypeString, Nullable: true, Comment: "渠道订单号"}, + {Name: "channel_user_id", Type: field.TypeString, Nullable: true, Comment: "渠道用户 ID"}, + {Name: "channel_id", Type: field.TypeUint64, Comment: "支付渠道 ID"}, + } + // PayOrderTable holds the schema information for the "pay_order" table. + PayOrderTable = &schema.Table{ + Name: "pay_order", + Comment: "PayOrder Table | 支付订单表", + Columns: PayOrderColumns, + PrimaryKey: []*schema.Column{PayOrderColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "pay_order_pay_channel_channel", + Columns: []*schema.Column{PayOrderColumns[25]}, + RefColumns: []*schema.Column{PayChannelColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "payorder_extension_id", + Unique: false, + Columns: []*schema.Column{PayOrderColumns[19]}, + }, + { + Name: "payorder_channel_order_no", + Unique: true, + Columns: []*schema.Column{PayOrderColumns[23]}, + }, + { + Name: "payorder_pay_no", + Unique: true, + Columns: []*schema.Column{PayOrderColumns[17]}, + }, + { + Name: "payorder_transaction_id", + Unique: false, + Columns: []*schema.Column{PayOrderColumns[20]}, + }, + { + Name: "payorder_user_id", + Unique: false, + Columns: []*schema.Column{PayOrderColumns[6]}, + }, + { + Name: "payorder_channel_id", + Unique: false, + Columns: []*schema.Column{PayOrderColumns[25]}, + }, + { + Name: "payorder_order_status", + Unique: false, + Columns: []*schema.Column{PayOrderColumns[14]}, + }, + }, + } + // PayOrderExtensionColumns holds the columns for the "pay_order_extension" table. + PayOrderExtensionColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "channel_extras", Type: field.TypeJSON, Nullable: true, Comment: "Channel Extras | 渠道参数"}, + {Name: "channel_error_code", Type: field.TypeString, Nullable: true, Comment: "Channel Error Code | 渠道错误码"}, + {Name: "channel_error_msg", Type: field.TypeString, Nullable: true, Comment: "Channel Error Msg | 渠道错误信息"}, + {Name: "channel_notify_data", Type: field.TypeString, Nullable: true, Comment: "Channel Notify Data | 渠道回调数据"}, + {Name: "channel_id", Type: field.TypeUint64, Comment: "Channel ID | 渠道ID"}, + {Name: "order_id", Type: field.TypeUint64, Comment: "Order ID | 订单ID"}, + } + // PayOrderExtensionTable holds the schema information for the "pay_order_extension" table. + PayOrderExtensionTable = &schema.Table{ + Name: "pay_order_extension", + Comment: "PayOrderExtension Table | 支付订单拓展表", + Columns: PayOrderExtensionColumns, + PrimaryKey: []*schema.Column{PayOrderExtensionColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "pay_order_extension_pay_channel_channel", + Columns: []*schema.Column{PayOrderExtensionColumns[10]}, + RefColumns: []*schema.Column{PayChannelColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "pay_order_extension_pay_order_order", + Columns: []*schema.Column{PayOrderExtensionColumns[11]}, + RefColumns: []*schema.Column{PayOrderColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "payorderextension_order_id", + Unique: false, + Columns: []*schema.Column{PayOrderExtensionColumns[11]}, + }, + { + Name: "payorderextension_channel_id", + Unique: false, + Columns: []*schema.Column{PayOrderExtensionColumns[10]}, + }, + }, + } + // PayRefundColumns holds the columns for the "pay_refund" table. + PayRefundColumns = []*schema.Column{ + {Name: "id", Type: field.TypeUint64, Increment: true}, + {Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"}, + {Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"}, + {Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1}, + {Name: "tenant_id", Type: field.TypeUint64, Comment: "Tenant ID | 租户 ID", Default: 1}, + {Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"}, + {Name: "user_id", Type: field.TypeUint64, Comment: "用户 ID"}, + {Name: "notify_url", Type: field.TypeString, Nullable: true, Comment: "回调地址"}, + {Name: "refund_status", Type: field.TypeUint8, Comment: "退款状态", Default: 0}, + {Name: "refund_amount", Type: field.TypeUint64, Comment: "退款金额", Default: 0}, + {Name: "pay_amount", Type: field.TypeUint64, Comment: "支付金额", Default: 0}, + {Name: "refund_no", Type: field.TypeString, Comment: "退款单号"}, + {Name: "refund_reason", Type: field.TypeString, Comment: "退款原因"}, + {Name: "user_ip", Type: field.TypeString, Nullable: true, Comment: "用户 IP"}, + {Name: "channel_refund_no", Type: field.TypeString, Comment: "渠道退款单号"}, + {Name: "refund_time", Type: field.TypeTime, Comment: "退款成功时间"}, + {Name: "channel_error_code", Type: field.TypeString, Nullable: true, Comment: "渠道错误码"}, + {Name: "channel_error_msg", Type: field.TypeString, Nullable: true, Comment: "渠道错误信息"}, + {Name: "channel_notify_data", Type: field.TypeString, Nullable: true, Comment: "渠道回调数据"}, + {Name: "order_id", Type: field.TypeUint64, Comment: "订单 ID"}, + {Name: "channel_id", Type: field.TypeUint64, Comment: "支付渠道 ID"}, + } + // PayRefundTable holds the schema information for the "pay_refund" table. + PayRefundTable = &schema.Table{ + Name: "pay_refund", + Comment: "PayRefund Table | 退款订单表", + Columns: PayRefundColumns, + PrimaryKey: []*schema.Column{PayRefundColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "pay_refund_pay_order_order", + Columns: []*schema.Column{PayRefundColumns[19]}, + RefColumns: []*schema.Column{PayOrderColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "pay_refund_pay_channel_channel", + Columns: []*schema.Column{PayRefundColumns[20]}, + RefColumns: []*schema.Column{PayChannelColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "payrefund_user_id", + Unique: false, + Columns: []*schema.Column{PayRefundColumns[6]}, + }, + { + Name: "payrefund_order_id", + Unique: false, + Columns: []*schema.Column{PayRefundColumns[19]}, + }, + { + Name: "payrefund_channel_id", + Unique: false, + Columns: []*schema.Column{PayRefundColumns[20]}, + }, + { + Name: "payrefund_refund_status", + Unique: false, + Columns: []*schema.Column{PayRefundColumns[8]}, + }, + { + Name: "payrefund_refund_no", + Unique: false, + Columns: []*schema.Column{PayRefundColumns[11]}, + }, + { + Name: "payrefund_channel_refund_no", + Unique: false, + Columns: []*schema.Column{PayRefundColumns[14]}, + }, + }, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + PayAppTable, + PayChannelTable, + PayNotifyLogTable, + PayNotifyTaskTable, + PayOrderTable, + PayOrderExtensionTable, + PayRefundTable, + } +) + +func init() { + PayAppTable.Annotation = &entsql.Annotation{ + Table: "pay_app", + } + PayChannelTable.ForeignKeys[0].RefTable = PayAppTable + PayChannelTable.Annotation = &entsql.Annotation{ + Table: "pay_channel", + } + PayNotifyLogTable.ForeignKeys[0].RefTable = PayNotifyTaskTable + PayNotifyLogTable.Annotation = &entsql.Annotation{ + Table: "pay_notify_log", + } + PayNotifyTaskTable.ForeignKeys[0].RefTable = PayAppTable + PayNotifyTaskTable.ForeignKeys[1].RefTable = PayOrderTable + PayNotifyTaskTable.Annotation = &entsql.Annotation{ + Table: "pay_notify_task", + } + PayOrderTable.ForeignKeys[0].RefTable = PayChannelTable + PayOrderTable.Annotation = &entsql.Annotation{ + Table: "pay_order", + } + PayOrderExtensionTable.ForeignKeys[0].RefTable = PayChannelTable + PayOrderExtensionTable.ForeignKeys[1].RefTable = PayOrderTable + PayOrderExtensionTable.Annotation = &entsql.Annotation{ + Table: "pay_order_extension", + } + PayRefundTable.ForeignKeys[0].RefTable = PayOrderTable + PayRefundTable.ForeignKeys[1].RefTable = PayChannelTable + PayRefundTable.Annotation = &entsql.Annotation{ + Table: "pay_refund", + } +} diff --git a/rpc/ent/mutation.go b/rpc/ent/mutation.go new file mode 100644 index 0000000..d2295ba --- /dev/null +++ b/rpc/ent/mutation.go @@ -0,0 +1,10630 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + "sync" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeApp = "App" + TypePayChannel = "PayChannel" + TypePayNotifyLog = "PayNotifyLog" + TypePayNotifyTask = "PayNotifyTask" + TypePayOrder = "PayOrder" + TypePayOrderExtension = "PayOrderExtension" + TypePayRefund = "PayRefund" +) + +// AppMutation represents an operation that mutates the App nodes in the graph. +type AppMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + app_key *string + app_name *string + order_notify_url *string + refund_notify_url *string + clearedFields map[string]struct{} + channel map[uint64]struct{} + removedchannel map[uint64]struct{} + clearedchannel bool + notify_task map[uint64]struct{} + removednotify_task map[uint64]struct{} + clearednotify_task bool + done bool + oldValue func(context.Context) (*App, error) + predicates []predicate.App +} + +var _ ent.Mutation = (*AppMutation)(nil) + +// appOption allows management of the mutation configuration using functional options. +type appOption func(*AppMutation) + +// newAppMutation creates new mutation for the App entity. +func newAppMutation(c config, op Op, opts ...appOption) *AppMutation { + m := &AppMutation{ + config: c, + op: op, + typ: TypeApp, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withAppID sets the ID field of the mutation. +func withAppID(id uint64) appOption { + return func(m *AppMutation) { + var ( + err error + once sync.Once + value *App + ) + m.oldValue = func(ctx context.Context) (*App, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().App.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withApp sets the old App of the mutation. +func withApp(node *App) appOption { + return func(m *AppMutation) { + m.oldValue = func(context.Context) (*App, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m AppMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m AppMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of App entities. +func (m *AppMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *AppMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *AppMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().App.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *AppMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *AppMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *AppMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *AppMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *AppMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *AppMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *AppMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *AppMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *AppMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *AppMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *AppMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[app.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *AppMutation) StatusCleared() bool { + _, ok := m.clearedFields[app.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *AppMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, app.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *AppMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *AppMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *AppMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *AppMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *AppMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *AppMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *AppMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *AppMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[app.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *AppMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[app.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *AppMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, app.FieldDeletedAt) +} + +// SetAppKey sets the "app_key" field. +func (m *AppMutation) SetAppKey(s string) { + m.app_key = &s +} + +// AppKey returns the value of the "app_key" field in the mutation. +func (m *AppMutation) AppKey() (r string, exists bool) { + v := m.app_key + if v == nil { + return + } + return *v, true +} + +// OldAppKey returns the old "app_key" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldAppKey(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAppKey is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAppKey requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAppKey: %w", err) + } + return oldValue.AppKey, nil +} + +// ResetAppKey resets all changes to the "app_key" field. +func (m *AppMutation) ResetAppKey() { + m.app_key = nil +} + +// SetAppName sets the "app_name" field. +func (m *AppMutation) SetAppName(s string) { + m.app_name = &s +} + +// AppName returns the value of the "app_name" field in the mutation. +func (m *AppMutation) AppName() (r string, exists bool) { + v := m.app_name + if v == nil { + return + } + return *v, true +} + +// OldAppName returns the old "app_name" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldAppName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAppName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAppName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAppName: %w", err) + } + return oldValue.AppName, nil +} + +// ResetAppName resets all changes to the "app_name" field. +func (m *AppMutation) ResetAppName() { + m.app_name = nil +} + +// SetOrderNotifyURL sets the "order_notify_url" field. +func (m *AppMutation) SetOrderNotifyURL(s string) { + m.order_notify_url = &s +} + +// OrderNotifyURL returns the value of the "order_notify_url" field in the mutation. +func (m *AppMutation) OrderNotifyURL() (r string, exists bool) { + v := m.order_notify_url + if v == nil { + return + } + return *v, true +} + +// OldOrderNotifyURL returns the old "order_notify_url" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldOrderNotifyURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderNotifyURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderNotifyURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderNotifyURL: %w", err) + } + return oldValue.OrderNotifyURL, nil +} + +// ClearOrderNotifyURL clears the value of the "order_notify_url" field. +func (m *AppMutation) ClearOrderNotifyURL() { + m.order_notify_url = nil + m.clearedFields[app.FieldOrderNotifyURL] = struct{}{} +} + +// OrderNotifyURLCleared returns if the "order_notify_url" field was cleared in this mutation. +func (m *AppMutation) OrderNotifyURLCleared() bool { + _, ok := m.clearedFields[app.FieldOrderNotifyURL] + return ok +} + +// ResetOrderNotifyURL resets all changes to the "order_notify_url" field. +func (m *AppMutation) ResetOrderNotifyURL() { + m.order_notify_url = nil + delete(m.clearedFields, app.FieldOrderNotifyURL) +} + +// SetRefundNotifyURL sets the "refund_notify_url" field. +func (m *AppMutation) SetRefundNotifyURL(s string) { + m.refund_notify_url = &s +} + +// RefundNotifyURL returns the value of the "refund_notify_url" field in the mutation. +func (m *AppMutation) RefundNotifyURL() (r string, exists bool) { + v := m.refund_notify_url + if v == nil { + return + } + return *v, true +} + +// OldRefundNotifyURL returns the old "refund_notify_url" field's value of the App entity. +// If the App object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AppMutation) OldRefundNotifyURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundNotifyURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundNotifyURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundNotifyURL: %w", err) + } + return oldValue.RefundNotifyURL, nil +} + +// ClearRefundNotifyURL clears the value of the "refund_notify_url" field. +func (m *AppMutation) ClearRefundNotifyURL() { + m.refund_notify_url = nil + m.clearedFields[app.FieldRefundNotifyURL] = struct{}{} +} + +// RefundNotifyURLCleared returns if the "refund_notify_url" field was cleared in this mutation. +func (m *AppMutation) RefundNotifyURLCleared() bool { + _, ok := m.clearedFields[app.FieldRefundNotifyURL] + return ok +} + +// ResetRefundNotifyURL resets all changes to the "refund_notify_url" field. +func (m *AppMutation) ResetRefundNotifyURL() { + m.refund_notify_url = nil + delete(m.clearedFields, app.FieldRefundNotifyURL) +} + +// AddChannelIDs adds the "channel" edge to the PayChannel entity by ids. +func (m *AppMutation) AddChannelIDs(ids ...uint64) { + if m.channel == nil { + m.channel = make(map[uint64]struct{}) + } + for i := range ids { + m.channel[ids[i]] = struct{}{} + } +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (m *AppMutation) ClearChannel() { + m.clearedchannel = true +} + +// ChannelCleared reports if the "channel" edge to the PayChannel entity was cleared. +func (m *AppMutation) ChannelCleared() bool { + return m.clearedchannel +} + +// RemoveChannelIDs removes the "channel" edge to the PayChannel entity by IDs. +func (m *AppMutation) RemoveChannelIDs(ids ...uint64) { + if m.removedchannel == nil { + m.removedchannel = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.channel, ids[i]) + m.removedchannel[ids[i]] = struct{}{} + } +} + +// RemovedChannel returns the removed IDs of the "channel" edge to the PayChannel entity. +func (m *AppMutation) RemovedChannelIDs() (ids []uint64) { + for id := range m.removedchannel { + ids = append(ids, id) + } + return +} + +// ChannelIDs returns the "channel" edge IDs in the mutation. +func (m *AppMutation) ChannelIDs() (ids []uint64) { + for id := range m.channel { + ids = append(ids, id) + } + return +} + +// ResetChannel resets all changes to the "channel" edge. +func (m *AppMutation) ResetChannel() { + m.channel = nil + m.clearedchannel = false + m.removedchannel = nil +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by ids. +func (m *AppMutation) AddNotifyTaskIDs(ids ...uint64) { + if m.notify_task == nil { + m.notify_task = make(map[uint64]struct{}) + } + for i := range ids { + m.notify_task[ids[i]] = struct{}{} + } +} + +// ClearNotifyTask clears the "notify_task" edge to the PayNotifyTask entity. +func (m *AppMutation) ClearNotifyTask() { + m.clearednotify_task = true +} + +// NotifyTaskCleared reports if the "notify_task" edge to the PayNotifyTask entity was cleared. +func (m *AppMutation) NotifyTaskCleared() bool { + return m.clearednotify_task +} + +// RemoveNotifyTaskIDs removes the "notify_task" edge to the PayNotifyTask entity by IDs. +func (m *AppMutation) RemoveNotifyTaskIDs(ids ...uint64) { + if m.removednotify_task == nil { + m.removednotify_task = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.notify_task, ids[i]) + m.removednotify_task[ids[i]] = struct{}{} + } +} + +// RemovedNotifyTask returns the removed IDs of the "notify_task" edge to the PayNotifyTask entity. +func (m *AppMutation) RemovedNotifyTaskIDs() (ids []uint64) { + for id := range m.removednotify_task { + ids = append(ids, id) + } + return +} + +// NotifyTaskIDs returns the "notify_task" edge IDs in the mutation. +func (m *AppMutation) NotifyTaskIDs() (ids []uint64) { + for id := range m.notify_task { + ids = append(ids, id) + } + return +} + +// ResetNotifyTask resets all changes to the "notify_task" edge. +func (m *AppMutation) ResetNotifyTask() { + m.notify_task = nil + m.clearednotify_task = false + m.removednotify_task = nil +} + +// Where appends a list predicates to the AppMutation builder. +func (m *AppMutation) Where(ps ...predicate.App) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the AppMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *AppMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.App, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *AppMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *AppMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (App). +func (m *AppMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AppMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.created_at != nil { + fields = append(fields, app.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, app.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, app.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, app.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, app.FieldDeletedAt) + } + if m.app_key != nil { + fields = append(fields, app.FieldAppKey) + } + if m.app_name != nil { + fields = append(fields, app.FieldAppName) + } + if m.order_notify_url != nil { + fields = append(fields, app.FieldOrderNotifyURL) + } + if m.refund_notify_url != nil { + fields = append(fields, app.FieldRefundNotifyURL) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AppMutation) Field(name string) (ent.Value, bool) { + switch name { + case app.FieldCreatedAt: + return m.CreatedAt() + case app.FieldUpdatedAt: + return m.UpdatedAt() + case app.FieldStatus: + return m.Status() + case app.FieldTenantID: + return m.TenantID() + case app.FieldDeletedAt: + return m.DeletedAt() + case app.FieldAppKey: + return m.AppKey() + case app.FieldAppName: + return m.AppName() + case app.FieldOrderNotifyURL: + return m.OrderNotifyURL() + case app.FieldRefundNotifyURL: + return m.RefundNotifyURL() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *AppMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case app.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case app.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case app.FieldStatus: + return m.OldStatus(ctx) + case app.FieldTenantID: + return m.OldTenantID(ctx) + case app.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case app.FieldAppKey: + return m.OldAppKey(ctx) + case app.FieldAppName: + return m.OldAppName(ctx) + case app.FieldOrderNotifyURL: + return m.OldOrderNotifyURL(ctx) + case app.FieldRefundNotifyURL: + return m.OldRefundNotifyURL(ctx) + } + return nil, fmt.Errorf("unknown App field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AppMutation) SetField(name string, value ent.Value) error { + switch name { + case app.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case app.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case app.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case app.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case app.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case app.FieldAppKey: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAppKey(v) + return nil + case app.FieldAppName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAppName(v) + return nil + case app.FieldOrderNotifyURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderNotifyURL(v) + return nil + case app.FieldRefundNotifyURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundNotifyURL(v) + return nil + } + return fmt.Errorf("unknown App field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AppMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, app.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, app.FieldTenantID) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *AppMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case app.FieldStatus: + return m.AddedStatus() + case app.FieldTenantID: + return m.AddedTenantID() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AppMutation) AddField(name string, value ent.Value) error { + switch name { + case app.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case app.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + } + return fmt.Errorf("unknown App numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AppMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(app.FieldStatus) { + fields = append(fields, app.FieldStatus) + } + if m.FieldCleared(app.FieldDeletedAt) { + fields = append(fields, app.FieldDeletedAt) + } + if m.FieldCleared(app.FieldOrderNotifyURL) { + fields = append(fields, app.FieldOrderNotifyURL) + } + if m.FieldCleared(app.FieldRefundNotifyURL) { + fields = append(fields, app.FieldRefundNotifyURL) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AppMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *AppMutation) ClearField(name string) error { + switch name { + case app.FieldStatus: + m.ClearStatus() + return nil + case app.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case app.FieldOrderNotifyURL: + m.ClearOrderNotifyURL() + return nil + case app.FieldRefundNotifyURL: + m.ClearRefundNotifyURL() + return nil + } + return fmt.Errorf("unknown App nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *AppMutation) ResetField(name string) error { + switch name { + case app.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case app.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case app.FieldStatus: + m.ResetStatus() + return nil + case app.FieldTenantID: + m.ResetTenantID() + return nil + case app.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case app.FieldAppKey: + m.ResetAppKey() + return nil + case app.FieldAppName: + m.ResetAppName() + return nil + case app.FieldOrderNotifyURL: + m.ResetOrderNotifyURL() + return nil + case app.FieldRefundNotifyURL: + m.ResetRefundNotifyURL() + return nil + } + return fmt.Errorf("unknown App field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AppMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.channel != nil { + edges = append(edges, app.EdgeChannel) + } + if m.notify_task != nil { + edges = append(edges, app.EdgeNotifyTask) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AppMutation) AddedIDs(name string) []ent.Value { + switch name { + case app.EdgeChannel: + ids := make([]ent.Value, 0, len(m.channel)) + for id := range m.channel { + ids = append(ids, id) + } + return ids + case app.EdgeNotifyTask: + ids := make([]ent.Value, 0, len(m.notify_task)) + for id := range m.notify_task { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AppMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedchannel != nil { + edges = append(edges, app.EdgeChannel) + } + if m.removednotify_task != nil { + edges = append(edges, app.EdgeNotifyTask) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AppMutation) RemovedIDs(name string) []ent.Value { + switch name { + case app.EdgeChannel: + ids := make([]ent.Value, 0, len(m.removedchannel)) + for id := range m.removedchannel { + ids = append(ids, id) + } + return ids + case app.EdgeNotifyTask: + ids := make([]ent.Value, 0, len(m.removednotify_task)) + for id := range m.removednotify_task { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AppMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedchannel { + edges = append(edges, app.EdgeChannel) + } + if m.clearednotify_task { + edges = append(edges, app.EdgeNotifyTask) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AppMutation) EdgeCleared(name string) bool { + switch name { + case app.EdgeChannel: + return m.clearedchannel + case app.EdgeNotifyTask: + return m.clearednotify_task + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *AppMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown App unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *AppMutation) ResetEdge(name string) error { + switch name { + case app.EdgeChannel: + m.ResetChannel() + return nil + case app.EdgeNotifyTask: + m.ResetNotifyTask() + return nil + } + return fmt.Errorf("unknown App edge %s", name) +} + +// PayChannelMutation represents an operation that mutates the PayChannel nodes in the graph. +type PayChannelMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + code *string + name_en *string + name_zh *string + free_rate *string + _config *map[string]interface{} + remake *string + icon *uint64 + addicon *int64 + order_time_out *string + support_currency *string + clearedFields map[string]struct{} + orders map[uint64]struct{} + removedorders map[uint64]struct{} + clearedorders bool + orders_extension map[uint64]struct{} + removedorders_extension map[uint64]struct{} + clearedorders_extension bool + refund map[uint64]struct{} + removedrefund map[uint64]struct{} + clearedrefund bool + app *uint64 + clearedapp bool + done bool + oldValue func(context.Context) (*PayChannel, error) + predicates []predicate.PayChannel +} + +var _ ent.Mutation = (*PayChannelMutation)(nil) + +// paychannelOption allows management of the mutation configuration using functional options. +type paychannelOption func(*PayChannelMutation) + +// newPayChannelMutation creates new mutation for the PayChannel entity. +func newPayChannelMutation(c config, op Op, opts ...paychannelOption) *PayChannelMutation { + m := &PayChannelMutation{ + config: c, + op: op, + typ: TypePayChannel, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayChannelID sets the ID field of the mutation. +func withPayChannelID(id uint64) paychannelOption { + return func(m *PayChannelMutation) { + var ( + err error + once sync.Once + value *PayChannel + ) + m.oldValue = func(ctx context.Context) (*PayChannel, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayChannel.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayChannel sets the old PayChannel of the mutation. +func withPayChannel(node *PayChannel) paychannelOption { + return func(m *PayChannelMutation) { + m.oldValue = func(context.Context) (*PayChannel, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PayChannelMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PayChannelMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayChannel entities. +func (m *PayChannelMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PayChannelMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayChannelMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayChannel.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *PayChannelMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PayChannelMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PayChannelMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PayChannelMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PayChannelMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PayChannelMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *PayChannelMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *PayChannelMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *PayChannelMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PayChannelMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *PayChannelMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[paychannel.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *PayChannelMutation) StatusCleared() bool { + _, ok := m.clearedFields[paychannel.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *PayChannelMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, paychannel.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *PayChannelMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *PayChannelMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *PayChannelMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *PayChannelMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *PayChannelMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PayChannelMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PayChannelMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PayChannelMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[paychannel.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PayChannelMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[paychannel.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PayChannelMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, paychannel.FieldDeletedAt) +} + +// SetCode sets the "code" field. +func (m *PayChannelMutation) SetCode(s string) { + m.code = &s +} + +// Code returns the value of the "code" field in the mutation. +func (m *PayChannelMutation) Code() (r string, exists bool) { + v := m.code + if v == nil { + return + } + return *v, true +} + +// OldCode returns the old "code" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCode: %w", err) + } + return oldValue.Code, nil +} + +// ResetCode resets all changes to the "code" field. +func (m *PayChannelMutation) ResetCode() { + m.code = nil +} + +// SetNameEn sets the "name_en" field. +func (m *PayChannelMutation) SetNameEn(s string) { + m.name_en = &s +} + +// NameEn returns the value of the "name_en" field in the mutation. +func (m *PayChannelMutation) NameEn() (r string, exists bool) { + v := m.name_en + if v == nil { + return + } + return *v, true +} + +// OldNameEn returns the old "name_en" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldNameEn(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNameEn is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNameEn requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNameEn: %w", err) + } + return oldValue.NameEn, nil +} + +// ResetNameEn resets all changes to the "name_en" field. +func (m *PayChannelMutation) ResetNameEn() { + m.name_en = nil +} + +// SetNameZh sets the "name_zh" field. +func (m *PayChannelMutation) SetNameZh(s string) { + m.name_zh = &s +} + +// NameZh returns the value of the "name_zh" field in the mutation. +func (m *PayChannelMutation) NameZh() (r string, exists bool) { + v := m.name_zh + if v == nil { + return + } + return *v, true +} + +// OldNameZh returns the old "name_zh" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldNameZh(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNameZh is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNameZh requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNameZh: %w", err) + } + return oldValue.NameZh, nil +} + +// ResetNameZh resets all changes to the "name_zh" field. +func (m *PayChannelMutation) ResetNameZh() { + m.name_zh = nil +} + +// SetFreeRate sets the "free_rate" field. +func (m *PayChannelMutation) SetFreeRate(s string) { + m.free_rate = &s +} + +// FreeRate returns the value of the "free_rate" field in the mutation. +func (m *PayChannelMutation) FreeRate() (r string, exists bool) { + v := m.free_rate + if v == nil { + return + } + return *v, true +} + +// OldFreeRate returns the old "free_rate" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldFreeRate(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFreeRate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFreeRate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFreeRate: %w", err) + } + return oldValue.FreeRate, nil +} + +// ResetFreeRate resets all changes to the "free_rate" field. +func (m *PayChannelMutation) ResetFreeRate() { + m.free_rate = nil +} + +// SetAppID sets the "app_id" field. +func (m *PayChannelMutation) SetAppID(u uint64) { + m.app = &u +} + +// AppID returns the value of the "app_id" field in the mutation. +func (m *PayChannelMutation) AppID() (r uint64, exists bool) { + v := m.app + if v == nil { + return + } + return *v, true +} + +// OldAppID returns the old "app_id" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldAppID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAppID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAppID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAppID: %w", err) + } + return oldValue.AppID, nil +} + +// ResetAppID resets all changes to the "app_id" field. +func (m *PayChannelMutation) ResetAppID() { + m.app = nil +} + +// SetConfig sets the "config" field. +func (m *PayChannelMutation) SetConfig(value map[string]interface{}) { + m._config = &value +} + +// Config returns the value of the "config" field in the mutation. +func (m *PayChannelMutation) Config() (r map[string]interface{}, exists bool) { + v := m._config + if v == nil { + return + } + return *v, true +} + +// OldConfig returns the old "config" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldConfig(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldConfig is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldConfig requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldConfig: %w", err) + } + return oldValue.Config, nil +} + +// ResetConfig resets all changes to the "config" field. +func (m *PayChannelMutation) ResetConfig() { + m._config = nil +} + +// SetRemake sets the "remake" field. +func (m *PayChannelMutation) SetRemake(s string) { + m.remake = &s +} + +// Remake returns the value of the "remake" field in the mutation. +func (m *PayChannelMutation) Remake() (r string, exists bool) { + v := m.remake + if v == nil { + return + } + return *v, true +} + +// OldRemake returns the old "remake" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldRemake(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemake is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemake requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemake: %w", err) + } + return oldValue.Remake, nil +} + +// ClearRemake clears the value of the "remake" field. +func (m *PayChannelMutation) ClearRemake() { + m.remake = nil + m.clearedFields[paychannel.FieldRemake] = struct{}{} +} + +// RemakeCleared returns if the "remake" field was cleared in this mutation. +func (m *PayChannelMutation) RemakeCleared() bool { + _, ok := m.clearedFields[paychannel.FieldRemake] + return ok +} + +// ResetRemake resets all changes to the "remake" field. +func (m *PayChannelMutation) ResetRemake() { + m.remake = nil + delete(m.clearedFields, paychannel.FieldRemake) +} + +// SetIcon sets the "icon" field. +func (m *PayChannelMutation) SetIcon(u uint64) { + m.icon = &u + m.addicon = nil +} + +// Icon returns the value of the "icon" field in the mutation. +func (m *PayChannelMutation) Icon() (r uint64, exists bool) { + v := m.icon + if v == nil { + return + } + return *v, true +} + +// OldIcon returns the old "icon" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldIcon(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIcon is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIcon requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIcon: %w", err) + } + return oldValue.Icon, nil +} + +// AddIcon adds u to the "icon" field. +func (m *PayChannelMutation) AddIcon(u int64) { + if m.addicon != nil { + *m.addicon += u + } else { + m.addicon = &u + } +} + +// AddedIcon returns the value that was added to the "icon" field in this mutation. +func (m *PayChannelMutation) AddedIcon() (r int64, exists bool) { + v := m.addicon + if v == nil { + return + } + return *v, true +} + +// ClearIcon clears the value of the "icon" field. +func (m *PayChannelMutation) ClearIcon() { + m.icon = nil + m.addicon = nil + m.clearedFields[paychannel.FieldIcon] = struct{}{} +} + +// IconCleared returns if the "icon" field was cleared in this mutation. +func (m *PayChannelMutation) IconCleared() bool { + _, ok := m.clearedFields[paychannel.FieldIcon] + return ok +} + +// ResetIcon resets all changes to the "icon" field. +func (m *PayChannelMutation) ResetIcon() { + m.icon = nil + m.addicon = nil + delete(m.clearedFields, paychannel.FieldIcon) +} + +// SetOrderTimeOut sets the "order_time_out" field. +func (m *PayChannelMutation) SetOrderTimeOut(s string) { + m.order_time_out = &s +} + +// OrderTimeOut returns the value of the "order_time_out" field in the mutation. +func (m *PayChannelMutation) OrderTimeOut() (r string, exists bool) { + v := m.order_time_out + if v == nil { + return + } + return *v, true +} + +// OldOrderTimeOut returns the old "order_time_out" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldOrderTimeOut(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderTimeOut is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderTimeOut requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderTimeOut: %w", err) + } + return oldValue.OrderTimeOut, nil +} + +// ResetOrderTimeOut resets all changes to the "order_time_out" field. +func (m *PayChannelMutation) ResetOrderTimeOut() { + m.order_time_out = nil +} + +// SetSupportCurrency sets the "support_currency" field. +func (m *PayChannelMutation) SetSupportCurrency(s string) { + m.support_currency = &s +} + +// SupportCurrency returns the value of the "support_currency" field in the mutation. +func (m *PayChannelMutation) SupportCurrency() (r string, exists bool) { + v := m.support_currency + if v == nil { + return + } + return *v, true +} + +// OldSupportCurrency returns the old "support_currency" field's value of the PayChannel entity. +// If the PayChannel object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayChannelMutation) OldSupportCurrency(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSupportCurrency is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSupportCurrency requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSupportCurrency: %w", err) + } + return oldValue.SupportCurrency, nil +} + +// ResetSupportCurrency resets all changes to the "support_currency" field. +func (m *PayChannelMutation) ResetSupportCurrency() { + m.support_currency = nil +} + +// AddOrderIDs adds the "orders" edge to the PayOrder entity by ids. +func (m *PayChannelMutation) AddOrderIDs(ids ...uint64) { + if m.orders == nil { + m.orders = make(map[uint64]struct{}) + } + for i := range ids { + m.orders[ids[i]] = struct{}{} + } +} + +// ClearOrders clears the "orders" edge to the PayOrder entity. +func (m *PayChannelMutation) ClearOrders() { + m.clearedorders = true +} + +// OrdersCleared reports if the "orders" edge to the PayOrder entity was cleared. +func (m *PayChannelMutation) OrdersCleared() bool { + return m.clearedorders +} + +// RemoveOrderIDs removes the "orders" edge to the PayOrder entity by IDs. +func (m *PayChannelMutation) RemoveOrderIDs(ids ...uint64) { + if m.removedorders == nil { + m.removedorders = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.orders, ids[i]) + m.removedorders[ids[i]] = struct{}{} + } +} + +// RemovedOrders returns the removed IDs of the "orders" edge to the PayOrder entity. +func (m *PayChannelMutation) RemovedOrdersIDs() (ids []uint64) { + for id := range m.removedorders { + ids = append(ids, id) + } + return +} + +// OrdersIDs returns the "orders" edge IDs in the mutation. +func (m *PayChannelMutation) OrdersIDs() (ids []uint64) { + for id := range m.orders { + ids = append(ids, id) + } + return +} + +// ResetOrders resets all changes to the "orders" edge. +func (m *PayChannelMutation) ResetOrders() { + m.orders = nil + m.clearedorders = false + m.removedorders = nil +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by ids. +func (m *PayChannelMutation) AddOrdersExtensionIDs(ids ...uint64) { + if m.orders_extension == nil { + m.orders_extension = make(map[uint64]struct{}) + } + for i := range ids { + m.orders_extension[ids[i]] = struct{}{} + } +} + +// ClearOrdersExtension clears the "orders_extension" edge to the PayOrderExtension entity. +func (m *PayChannelMutation) ClearOrdersExtension() { + m.clearedorders_extension = true +} + +// OrdersExtensionCleared reports if the "orders_extension" edge to the PayOrderExtension entity was cleared. +func (m *PayChannelMutation) OrdersExtensionCleared() bool { + return m.clearedorders_extension +} + +// RemoveOrdersExtensionIDs removes the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (m *PayChannelMutation) RemoveOrdersExtensionIDs(ids ...uint64) { + if m.removedorders_extension == nil { + m.removedorders_extension = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.orders_extension, ids[i]) + m.removedorders_extension[ids[i]] = struct{}{} + } +} + +// RemovedOrdersExtension returns the removed IDs of the "orders_extension" edge to the PayOrderExtension entity. +func (m *PayChannelMutation) RemovedOrdersExtensionIDs() (ids []uint64) { + for id := range m.removedorders_extension { + ids = append(ids, id) + } + return +} + +// OrdersExtensionIDs returns the "orders_extension" edge IDs in the mutation. +func (m *PayChannelMutation) OrdersExtensionIDs() (ids []uint64) { + for id := range m.orders_extension { + ids = append(ids, id) + } + return +} + +// ResetOrdersExtension resets all changes to the "orders_extension" edge. +func (m *PayChannelMutation) ResetOrdersExtension() { + m.orders_extension = nil + m.clearedorders_extension = false + m.removedorders_extension = nil +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by ids. +func (m *PayChannelMutation) AddRefundIDs(ids ...uint64) { + if m.refund == nil { + m.refund = make(map[uint64]struct{}) + } + for i := range ids { + m.refund[ids[i]] = struct{}{} + } +} + +// ClearRefund clears the "refund" edge to the PayRefund entity. +func (m *PayChannelMutation) ClearRefund() { + m.clearedrefund = true +} + +// RefundCleared reports if the "refund" edge to the PayRefund entity was cleared. +func (m *PayChannelMutation) RefundCleared() bool { + return m.clearedrefund +} + +// RemoveRefundIDs removes the "refund" edge to the PayRefund entity by IDs. +func (m *PayChannelMutation) RemoveRefundIDs(ids ...uint64) { + if m.removedrefund == nil { + m.removedrefund = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.refund, ids[i]) + m.removedrefund[ids[i]] = struct{}{} + } +} + +// RemovedRefund returns the removed IDs of the "refund" edge to the PayRefund entity. +func (m *PayChannelMutation) RemovedRefundIDs() (ids []uint64) { + for id := range m.removedrefund { + ids = append(ids, id) + } + return +} + +// RefundIDs returns the "refund" edge IDs in the mutation. +func (m *PayChannelMutation) RefundIDs() (ids []uint64) { + for id := range m.refund { + ids = append(ids, id) + } + return +} + +// ResetRefund resets all changes to the "refund" edge. +func (m *PayChannelMutation) ResetRefund() { + m.refund = nil + m.clearedrefund = false + m.removedrefund = nil +} + +// ClearApp clears the "app" edge to the App entity. +func (m *PayChannelMutation) ClearApp() { + m.clearedapp = true + m.clearedFields[paychannel.FieldAppID] = struct{}{} +} + +// AppCleared reports if the "app" edge to the App entity was cleared. +func (m *PayChannelMutation) AppCleared() bool { + return m.clearedapp +} + +// AppIDs returns the "app" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// AppID instead. It exists only for internal usage by the builders. +func (m *PayChannelMutation) AppIDs() (ids []uint64) { + if id := m.app; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetApp resets all changes to the "app" edge. +func (m *PayChannelMutation) ResetApp() { + m.app = nil + m.clearedapp = false +} + +// Where appends a list predicates to the PayChannelMutation builder. +func (m *PayChannelMutation) Where(ps ...predicate.PayChannel) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayChannelMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayChannelMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayChannel, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayChannelMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayChannelMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayChannel). +func (m *PayChannelMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PayChannelMutation) Fields() []string { + fields := make([]string, 0, 15) + if m.created_at != nil { + fields = append(fields, paychannel.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, paychannel.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, paychannel.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, paychannel.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, paychannel.FieldDeletedAt) + } + if m.code != nil { + fields = append(fields, paychannel.FieldCode) + } + if m.name_en != nil { + fields = append(fields, paychannel.FieldNameEn) + } + if m.name_zh != nil { + fields = append(fields, paychannel.FieldNameZh) + } + if m.free_rate != nil { + fields = append(fields, paychannel.FieldFreeRate) + } + if m.app != nil { + fields = append(fields, paychannel.FieldAppID) + } + if m._config != nil { + fields = append(fields, paychannel.FieldConfig) + } + if m.remake != nil { + fields = append(fields, paychannel.FieldRemake) + } + if m.icon != nil { + fields = append(fields, paychannel.FieldIcon) + } + if m.order_time_out != nil { + fields = append(fields, paychannel.FieldOrderTimeOut) + } + if m.support_currency != nil { + fields = append(fields, paychannel.FieldSupportCurrency) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PayChannelMutation) Field(name string) (ent.Value, bool) { + switch name { + case paychannel.FieldCreatedAt: + return m.CreatedAt() + case paychannel.FieldUpdatedAt: + return m.UpdatedAt() + case paychannel.FieldStatus: + return m.Status() + case paychannel.FieldTenantID: + return m.TenantID() + case paychannel.FieldDeletedAt: + return m.DeletedAt() + case paychannel.FieldCode: + return m.Code() + case paychannel.FieldNameEn: + return m.NameEn() + case paychannel.FieldNameZh: + return m.NameZh() + case paychannel.FieldFreeRate: + return m.FreeRate() + case paychannel.FieldAppID: + return m.AppID() + case paychannel.FieldConfig: + return m.Config() + case paychannel.FieldRemake: + return m.Remake() + case paychannel.FieldIcon: + return m.Icon() + case paychannel.FieldOrderTimeOut: + return m.OrderTimeOut() + case paychannel.FieldSupportCurrency: + return m.SupportCurrency() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PayChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case paychannel.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case paychannel.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case paychannel.FieldStatus: + return m.OldStatus(ctx) + case paychannel.FieldTenantID: + return m.OldTenantID(ctx) + case paychannel.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case paychannel.FieldCode: + return m.OldCode(ctx) + case paychannel.FieldNameEn: + return m.OldNameEn(ctx) + case paychannel.FieldNameZh: + return m.OldNameZh(ctx) + case paychannel.FieldFreeRate: + return m.OldFreeRate(ctx) + case paychannel.FieldAppID: + return m.OldAppID(ctx) + case paychannel.FieldConfig: + return m.OldConfig(ctx) + case paychannel.FieldRemake: + return m.OldRemake(ctx) + case paychannel.FieldIcon: + return m.OldIcon(ctx) + case paychannel.FieldOrderTimeOut: + return m.OldOrderTimeOut(ctx) + case paychannel.FieldSupportCurrency: + return m.OldSupportCurrency(ctx) + } + return nil, fmt.Errorf("unknown PayChannel field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayChannelMutation) SetField(name string, value ent.Value) error { + switch name { + case paychannel.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case paychannel.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case paychannel.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case paychannel.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case paychannel.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case paychannel.FieldCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCode(v) + return nil + case paychannel.FieldNameEn: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNameEn(v) + return nil + case paychannel.FieldNameZh: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNameZh(v) + return nil + case paychannel.FieldFreeRate: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFreeRate(v) + return nil + case paychannel.FieldAppID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAppID(v) + return nil + case paychannel.FieldConfig: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetConfig(v) + return nil + case paychannel.FieldRemake: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemake(v) + return nil + case paychannel.FieldIcon: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIcon(v) + return nil + case paychannel.FieldOrderTimeOut: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderTimeOut(v) + return nil + case paychannel.FieldSupportCurrency: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSupportCurrency(v) + return nil + } + return fmt.Errorf("unknown PayChannel field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayChannelMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, paychannel.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, paychannel.FieldTenantID) + } + if m.addicon != nil { + fields = append(fields, paychannel.FieldIcon) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PayChannelMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case paychannel.FieldStatus: + return m.AddedStatus() + case paychannel.FieldTenantID: + return m.AddedTenantID() + case paychannel.FieldIcon: + return m.AddedIcon() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayChannelMutation) AddField(name string, value ent.Value) error { + switch name { + case paychannel.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case paychannel.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case paychannel.FieldIcon: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddIcon(v) + return nil + } + return fmt.Errorf("unknown PayChannel numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayChannelMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(paychannel.FieldStatus) { + fields = append(fields, paychannel.FieldStatus) + } + if m.FieldCleared(paychannel.FieldDeletedAt) { + fields = append(fields, paychannel.FieldDeletedAt) + } + if m.FieldCleared(paychannel.FieldRemake) { + fields = append(fields, paychannel.FieldRemake) + } + if m.FieldCleared(paychannel.FieldIcon) { + fields = append(fields, paychannel.FieldIcon) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayChannelMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PayChannelMutation) ClearField(name string) error { + switch name { + case paychannel.FieldStatus: + m.ClearStatus() + return nil + case paychannel.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case paychannel.FieldRemake: + m.ClearRemake() + return nil + case paychannel.FieldIcon: + m.ClearIcon() + return nil + } + return fmt.Errorf("unknown PayChannel nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PayChannelMutation) ResetField(name string) error { + switch name { + case paychannel.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case paychannel.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case paychannel.FieldStatus: + m.ResetStatus() + return nil + case paychannel.FieldTenantID: + m.ResetTenantID() + return nil + case paychannel.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case paychannel.FieldCode: + m.ResetCode() + return nil + case paychannel.FieldNameEn: + m.ResetNameEn() + return nil + case paychannel.FieldNameZh: + m.ResetNameZh() + return nil + case paychannel.FieldFreeRate: + m.ResetFreeRate() + return nil + case paychannel.FieldAppID: + m.ResetAppID() + return nil + case paychannel.FieldConfig: + m.ResetConfig() + return nil + case paychannel.FieldRemake: + m.ResetRemake() + return nil + case paychannel.FieldIcon: + m.ResetIcon() + return nil + case paychannel.FieldOrderTimeOut: + m.ResetOrderTimeOut() + return nil + case paychannel.FieldSupportCurrency: + m.ResetSupportCurrency() + return nil + } + return fmt.Errorf("unknown PayChannel field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayChannelMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.orders != nil { + edges = append(edges, paychannel.EdgeOrders) + } + if m.orders_extension != nil { + edges = append(edges, paychannel.EdgeOrdersExtension) + } + if m.refund != nil { + edges = append(edges, paychannel.EdgeRefund) + } + if m.app != nil { + edges = append(edges, paychannel.EdgeApp) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayChannelMutation) AddedIDs(name string) []ent.Value { + switch name { + case paychannel.EdgeOrders: + ids := make([]ent.Value, 0, len(m.orders)) + for id := range m.orders { + ids = append(ids, id) + } + return ids + case paychannel.EdgeOrdersExtension: + ids := make([]ent.Value, 0, len(m.orders_extension)) + for id := range m.orders_extension { + ids = append(ids, id) + } + return ids + case paychannel.EdgeRefund: + ids := make([]ent.Value, 0, len(m.refund)) + for id := range m.refund { + ids = append(ids, id) + } + return ids + case paychannel.EdgeApp: + if id := m.app; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayChannelMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedorders != nil { + edges = append(edges, paychannel.EdgeOrders) + } + if m.removedorders_extension != nil { + edges = append(edges, paychannel.EdgeOrdersExtension) + } + if m.removedrefund != nil { + edges = append(edges, paychannel.EdgeRefund) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayChannelMutation) RemovedIDs(name string) []ent.Value { + switch name { + case paychannel.EdgeOrders: + ids := make([]ent.Value, 0, len(m.removedorders)) + for id := range m.removedorders { + ids = append(ids, id) + } + return ids + case paychannel.EdgeOrdersExtension: + ids := make([]ent.Value, 0, len(m.removedorders_extension)) + for id := range m.removedorders_extension { + ids = append(ids, id) + } + return ids + case paychannel.EdgeRefund: + ids := make([]ent.Value, 0, len(m.removedrefund)) + for id := range m.removedrefund { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayChannelMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedorders { + edges = append(edges, paychannel.EdgeOrders) + } + if m.clearedorders_extension { + edges = append(edges, paychannel.EdgeOrdersExtension) + } + if m.clearedrefund { + edges = append(edges, paychannel.EdgeRefund) + } + if m.clearedapp { + edges = append(edges, paychannel.EdgeApp) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayChannelMutation) EdgeCleared(name string) bool { + switch name { + case paychannel.EdgeOrders: + return m.clearedorders + case paychannel.EdgeOrdersExtension: + return m.clearedorders_extension + case paychannel.EdgeRefund: + return m.clearedrefund + case paychannel.EdgeApp: + return m.clearedapp + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PayChannelMutation) ClearEdge(name string) error { + switch name { + case paychannel.EdgeApp: + m.ClearApp() + return nil + } + return fmt.Errorf("unknown PayChannel unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PayChannelMutation) ResetEdge(name string) error { + switch name { + case paychannel.EdgeOrders: + m.ResetOrders() + return nil + case paychannel.EdgeOrdersExtension: + m.ResetOrdersExtension() + return nil + case paychannel.EdgeRefund: + m.ResetRefund() + return nil + case paychannel.EdgeApp: + m.ResetApp() + return nil + } + return fmt.Errorf("unknown PayChannel edge %s", name) +} + +// PayNotifyLogMutation represents an operation that mutates the PayNotifyLog nodes in the graph. +type PayNotifyLogMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + notify_count *uint32 + addnotify_count *int32 + response *string + notify_status *string + clearedFields map[string]struct{} + task *uint64 + clearedtask bool + done bool + oldValue func(context.Context) (*PayNotifyLog, error) + predicates []predicate.PayNotifyLog +} + +var _ ent.Mutation = (*PayNotifyLogMutation)(nil) + +// paynotifylogOption allows management of the mutation configuration using functional options. +type paynotifylogOption func(*PayNotifyLogMutation) + +// newPayNotifyLogMutation creates new mutation for the PayNotifyLog entity. +func newPayNotifyLogMutation(c config, op Op, opts ...paynotifylogOption) *PayNotifyLogMutation { + m := &PayNotifyLogMutation{ + config: c, + op: op, + typ: TypePayNotifyLog, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayNotifyLogID sets the ID field of the mutation. +func withPayNotifyLogID(id uint64) paynotifylogOption { + return func(m *PayNotifyLogMutation) { + var ( + err error + once sync.Once + value *PayNotifyLog + ) + m.oldValue = func(ctx context.Context) (*PayNotifyLog, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayNotifyLog.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayNotifyLog sets the old PayNotifyLog of the mutation. +func withPayNotifyLog(node *PayNotifyLog) paynotifylogOption { + return func(m *PayNotifyLogMutation) { + m.oldValue = func(context.Context) (*PayNotifyLog, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PayNotifyLogMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PayNotifyLogMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayNotifyLog entities. +func (m *PayNotifyLogMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PayNotifyLogMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayNotifyLogMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayNotifyLog.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *PayNotifyLogMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PayNotifyLogMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PayNotifyLogMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PayNotifyLogMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PayNotifyLogMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PayNotifyLogMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *PayNotifyLogMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *PayNotifyLogMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *PayNotifyLogMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PayNotifyLogMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *PayNotifyLogMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[paynotifylog.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *PayNotifyLogMutation) StatusCleared() bool { + _, ok := m.clearedFields[paynotifylog.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *PayNotifyLogMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, paynotifylog.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *PayNotifyLogMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *PayNotifyLogMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *PayNotifyLogMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *PayNotifyLogMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *PayNotifyLogMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PayNotifyLogMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PayNotifyLogMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PayNotifyLogMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[paynotifylog.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PayNotifyLogMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[paynotifylog.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PayNotifyLogMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, paynotifylog.FieldDeletedAt) +} + +// SetTaskID sets the "task_id" field. +func (m *PayNotifyLogMutation) SetTaskID(u uint64) { + m.task = &u +} + +// TaskID returns the value of the "task_id" field in the mutation. +func (m *PayNotifyLogMutation) TaskID() (r uint64, exists bool) { + v := m.task + if v == nil { + return + } + return *v, true +} + +// OldTaskID returns the old "task_id" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldTaskID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTaskID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTaskID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTaskID: %w", err) + } + return oldValue.TaskID, nil +} + +// ResetTaskID resets all changes to the "task_id" field. +func (m *PayNotifyLogMutation) ResetTaskID() { + m.task = nil +} + +// SetNotifyCount sets the "notify_count" field. +func (m *PayNotifyLogMutation) SetNotifyCount(u uint32) { + m.notify_count = &u + m.addnotify_count = nil +} + +// NotifyCount returns the value of the "notify_count" field in the mutation. +func (m *PayNotifyLogMutation) NotifyCount() (r uint32, exists bool) { + v := m.notify_count + if v == nil { + return + } + return *v, true +} + +// OldNotifyCount returns the old "notify_count" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldNotifyCount(ctx context.Context) (v uint32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotifyCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotifyCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotifyCount: %w", err) + } + return oldValue.NotifyCount, nil +} + +// AddNotifyCount adds u to the "notify_count" field. +func (m *PayNotifyLogMutation) AddNotifyCount(u int32) { + if m.addnotify_count != nil { + *m.addnotify_count += u + } else { + m.addnotify_count = &u + } +} + +// AddedNotifyCount returns the value that was added to the "notify_count" field in this mutation. +func (m *PayNotifyLogMutation) AddedNotifyCount() (r int32, exists bool) { + v := m.addnotify_count + if v == nil { + return + } + return *v, true +} + +// ResetNotifyCount resets all changes to the "notify_count" field. +func (m *PayNotifyLogMutation) ResetNotifyCount() { + m.notify_count = nil + m.addnotify_count = nil +} + +// SetResponse sets the "response" field. +func (m *PayNotifyLogMutation) SetResponse(s string) { + m.response = &s +} + +// Response returns the value of the "response" field in the mutation. +func (m *PayNotifyLogMutation) Response() (r string, exists bool) { + v := m.response + if v == nil { + return + } + return *v, true +} + +// OldResponse returns the old "response" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldResponse(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldResponse is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldResponse requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldResponse: %w", err) + } + return oldValue.Response, nil +} + +// ClearResponse clears the value of the "response" field. +func (m *PayNotifyLogMutation) ClearResponse() { + m.response = nil + m.clearedFields[paynotifylog.FieldResponse] = struct{}{} +} + +// ResponseCleared returns if the "response" field was cleared in this mutation. +func (m *PayNotifyLogMutation) ResponseCleared() bool { + _, ok := m.clearedFields[paynotifylog.FieldResponse] + return ok +} + +// ResetResponse resets all changes to the "response" field. +func (m *PayNotifyLogMutation) ResetResponse() { + m.response = nil + delete(m.clearedFields, paynotifylog.FieldResponse) +} + +// SetNotifyStatus sets the "notify_status" field. +func (m *PayNotifyLogMutation) SetNotifyStatus(s string) { + m.notify_status = &s +} + +// NotifyStatus returns the value of the "notify_status" field in the mutation. +func (m *PayNotifyLogMutation) NotifyStatus() (r string, exists bool) { + v := m.notify_status + if v == nil { + return + } + return *v, true +} + +// OldNotifyStatus returns the old "notify_status" field's value of the PayNotifyLog entity. +// If the PayNotifyLog object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyLogMutation) OldNotifyStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotifyStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotifyStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotifyStatus: %w", err) + } + return oldValue.NotifyStatus, nil +} + +// ClearNotifyStatus clears the value of the "notify_status" field. +func (m *PayNotifyLogMutation) ClearNotifyStatus() { + m.notify_status = nil + m.clearedFields[paynotifylog.FieldNotifyStatus] = struct{}{} +} + +// NotifyStatusCleared returns if the "notify_status" field was cleared in this mutation. +func (m *PayNotifyLogMutation) NotifyStatusCleared() bool { + _, ok := m.clearedFields[paynotifylog.FieldNotifyStatus] + return ok +} + +// ResetNotifyStatus resets all changes to the "notify_status" field. +func (m *PayNotifyLogMutation) ResetNotifyStatus() { + m.notify_status = nil + delete(m.clearedFields, paynotifylog.FieldNotifyStatus) +} + +// ClearTask clears the "task" edge to the PayNotifyTask entity. +func (m *PayNotifyLogMutation) ClearTask() { + m.clearedtask = true + m.clearedFields[paynotifylog.FieldTaskID] = struct{}{} +} + +// TaskCleared reports if the "task" edge to the PayNotifyTask entity was cleared. +func (m *PayNotifyLogMutation) TaskCleared() bool { + return m.clearedtask +} + +// TaskIDs returns the "task" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// TaskID instead. It exists only for internal usage by the builders. +func (m *PayNotifyLogMutation) TaskIDs() (ids []uint64) { + if id := m.task; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetTask resets all changes to the "task" edge. +func (m *PayNotifyLogMutation) ResetTask() { + m.task = nil + m.clearedtask = false +} + +// Where appends a list predicates to the PayNotifyLogMutation builder. +func (m *PayNotifyLogMutation) Where(ps ...predicate.PayNotifyLog) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayNotifyLogMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayNotifyLogMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayNotifyLog, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayNotifyLogMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayNotifyLogMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayNotifyLog). +func (m *PayNotifyLogMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PayNotifyLogMutation) Fields() []string { + fields := make([]string, 0, 9) + if m.created_at != nil { + fields = append(fields, paynotifylog.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, paynotifylog.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, paynotifylog.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, paynotifylog.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, paynotifylog.FieldDeletedAt) + } + if m.task != nil { + fields = append(fields, paynotifylog.FieldTaskID) + } + if m.notify_count != nil { + fields = append(fields, paynotifylog.FieldNotifyCount) + } + if m.response != nil { + fields = append(fields, paynotifylog.FieldResponse) + } + if m.notify_status != nil { + fields = append(fields, paynotifylog.FieldNotifyStatus) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PayNotifyLogMutation) Field(name string) (ent.Value, bool) { + switch name { + case paynotifylog.FieldCreatedAt: + return m.CreatedAt() + case paynotifylog.FieldUpdatedAt: + return m.UpdatedAt() + case paynotifylog.FieldStatus: + return m.Status() + case paynotifylog.FieldTenantID: + return m.TenantID() + case paynotifylog.FieldDeletedAt: + return m.DeletedAt() + case paynotifylog.FieldTaskID: + return m.TaskID() + case paynotifylog.FieldNotifyCount: + return m.NotifyCount() + case paynotifylog.FieldResponse: + return m.Response() + case paynotifylog.FieldNotifyStatus: + return m.NotifyStatus() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PayNotifyLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case paynotifylog.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case paynotifylog.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case paynotifylog.FieldStatus: + return m.OldStatus(ctx) + case paynotifylog.FieldTenantID: + return m.OldTenantID(ctx) + case paynotifylog.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case paynotifylog.FieldTaskID: + return m.OldTaskID(ctx) + case paynotifylog.FieldNotifyCount: + return m.OldNotifyCount(ctx) + case paynotifylog.FieldResponse: + return m.OldResponse(ctx) + case paynotifylog.FieldNotifyStatus: + return m.OldNotifyStatus(ctx) + } + return nil, fmt.Errorf("unknown PayNotifyLog field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayNotifyLogMutation) SetField(name string, value ent.Value) error { + switch name { + case paynotifylog.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case paynotifylog.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case paynotifylog.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case paynotifylog.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case paynotifylog.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case paynotifylog.FieldTaskID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTaskID(v) + return nil + case paynotifylog.FieldNotifyCount: + v, ok := value.(uint32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotifyCount(v) + return nil + case paynotifylog.FieldResponse: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetResponse(v) + return nil + case paynotifylog.FieldNotifyStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotifyStatus(v) + return nil + } + return fmt.Errorf("unknown PayNotifyLog field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayNotifyLogMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, paynotifylog.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, paynotifylog.FieldTenantID) + } + if m.addnotify_count != nil { + fields = append(fields, paynotifylog.FieldNotifyCount) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PayNotifyLogMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case paynotifylog.FieldStatus: + return m.AddedStatus() + case paynotifylog.FieldTenantID: + return m.AddedTenantID() + case paynotifylog.FieldNotifyCount: + return m.AddedNotifyCount() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayNotifyLogMutation) AddField(name string, value ent.Value) error { + switch name { + case paynotifylog.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case paynotifylog.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case paynotifylog.FieldNotifyCount: + v, ok := value.(int32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddNotifyCount(v) + return nil + } + return fmt.Errorf("unknown PayNotifyLog numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayNotifyLogMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(paynotifylog.FieldStatus) { + fields = append(fields, paynotifylog.FieldStatus) + } + if m.FieldCleared(paynotifylog.FieldDeletedAt) { + fields = append(fields, paynotifylog.FieldDeletedAt) + } + if m.FieldCleared(paynotifylog.FieldResponse) { + fields = append(fields, paynotifylog.FieldResponse) + } + if m.FieldCleared(paynotifylog.FieldNotifyStatus) { + fields = append(fields, paynotifylog.FieldNotifyStatus) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayNotifyLogMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PayNotifyLogMutation) ClearField(name string) error { + switch name { + case paynotifylog.FieldStatus: + m.ClearStatus() + return nil + case paynotifylog.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case paynotifylog.FieldResponse: + m.ClearResponse() + return nil + case paynotifylog.FieldNotifyStatus: + m.ClearNotifyStatus() + return nil + } + return fmt.Errorf("unknown PayNotifyLog nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PayNotifyLogMutation) ResetField(name string) error { + switch name { + case paynotifylog.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case paynotifylog.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case paynotifylog.FieldStatus: + m.ResetStatus() + return nil + case paynotifylog.FieldTenantID: + m.ResetTenantID() + return nil + case paynotifylog.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case paynotifylog.FieldTaskID: + m.ResetTaskID() + return nil + case paynotifylog.FieldNotifyCount: + m.ResetNotifyCount() + return nil + case paynotifylog.FieldResponse: + m.ResetResponse() + return nil + case paynotifylog.FieldNotifyStatus: + m.ResetNotifyStatus() + return nil + } + return fmt.Errorf("unknown PayNotifyLog field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayNotifyLogMutation) AddedEdges() []string { + edges := make([]string, 0, 1) + if m.task != nil { + edges = append(edges, paynotifylog.EdgeTask) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayNotifyLogMutation) AddedIDs(name string) []ent.Value { + switch name { + case paynotifylog.EdgeTask: + if id := m.task; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayNotifyLogMutation) RemovedEdges() []string { + edges := make([]string, 0, 1) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayNotifyLogMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayNotifyLogMutation) ClearedEdges() []string { + edges := make([]string, 0, 1) + if m.clearedtask { + edges = append(edges, paynotifylog.EdgeTask) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayNotifyLogMutation) EdgeCleared(name string) bool { + switch name { + case paynotifylog.EdgeTask: + return m.clearedtask + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PayNotifyLogMutation) ClearEdge(name string) error { + switch name { + case paynotifylog.EdgeTask: + m.ClearTask() + return nil + } + return fmt.Errorf("unknown PayNotifyLog unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PayNotifyLogMutation) ResetEdge(name string) error { + switch name { + case paynotifylog.EdgeTask: + m.ResetTask() + return nil + } + return fmt.Errorf("unknown PayNotifyLog edge %s", name) +} + +// PayNotifyTaskMutation represents an operation that mutates the PayNotifyTask nodes in the graph. +type PayNotifyTaskMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + _type *uint8 + add_type *int8 + data_id *uint64 + adddata_id *int64 + notify_status *uint8 + addnotify_status *int8 + next_notify_time *time.Time + last_execute_time *time.Time + retry_count *uint32 + addretry_count *int32 + max_retry_count *uint32 + addmax_retry_count *int32 + notify_url *string + clearedFields map[string]struct{} + app *uint64 + clearedapp bool + _order *uint64 + cleared_order bool + notify_log map[uint64]struct{} + removednotify_log map[uint64]struct{} + clearednotify_log bool + done bool + oldValue func(context.Context) (*PayNotifyTask, error) + predicates []predicate.PayNotifyTask +} + +var _ ent.Mutation = (*PayNotifyTaskMutation)(nil) + +// paynotifytaskOption allows management of the mutation configuration using functional options. +type paynotifytaskOption func(*PayNotifyTaskMutation) + +// newPayNotifyTaskMutation creates new mutation for the PayNotifyTask entity. +func newPayNotifyTaskMutation(c config, op Op, opts ...paynotifytaskOption) *PayNotifyTaskMutation { + m := &PayNotifyTaskMutation{ + config: c, + op: op, + typ: TypePayNotifyTask, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayNotifyTaskID sets the ID field of the mutation. +func withPayNotifyTaskID(id uint64) paynotifytaskOption { + return func(m *PayNotifyTaskMutation) { + var ( + err error + once sync.Once + value *PayNotifyTask + ) + m.oldValue = func(ctx context.Context) (*PayNotifyTask, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayNotifyTask.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayNotifyTask sets the old PayNotifyTask of the mutation. +func withPayNotifyTask(node *PayNotifyTask) paynotifytaskOption { + return func(m *PayNotifyTaskMutation) { + m.oldValue = func(context.Context) (*PayNotifyTask, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PayNotifyTaskMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PayNotifyTaskMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayNotifyTask entities. +func (m *PayNotifyTaskMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PayNotifyTaskMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayNotifyTaskMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayNotifyTask.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *PayNotifyTaskMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PayNotifyTaskMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PayNotifyTaskMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PayNotifyTaskMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PayNotifyTaskMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PayNotifyTaskMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *PayNotifyTaskMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *PayNotifyTaskMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *PayNotifyTaskMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PayNotifyTaskMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *PayNotifyTaskMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[paynotifytask.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) StatusCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *PayNotifyTaskMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, paynotifytask.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *PayNotifyTaskMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *PayNotifyTaskMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *PayNotifyTaskMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *PayNotifyTaskMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *PayNotifyTaskMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PayNotifyTaskMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PayNotifyTaskMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PayNotifyTaskMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[paynotifytask.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PayNotifyTaskMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, paynotifytask.FieldDeletedAt) +} + +// SetType sets the "type" field. +func (m *PayNotifyTaskMutation) SetType(u uint8) { + m._type = &u + m.add_type = nil +} + +// GetType returns the value of the "type" field in the mutation. +func (m *PayNotifyTaskMutation) GetType() (r uint8, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldType(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// AddType adds u to the "type" field. +func (m *PayNotifyTaskMutation) AddType(u int8) { + if m.add_type != nil { + *m.add_type += u + } else { + m.add_type = &u + } +} + +// AddedType returns the value that was added to the "type" field in this mutation. +func (m *PayNotifyTaskMutation) AddedType() (r int8, exists bool) { + v := m.add_type + if v == nil { + return + } + return *v, true +} + +// ResetType resets all changes to the "type" field. +func (m *PayNotifyTaskMutation) ResetType() { + m._type = nil + m.add_type = nil +} + +// SetDataID sets the "data_id" field. +func (m *PayNotifyTaskMutation) SetDataID(u uint64) { + m.data_id = &u + m.adddata_id = nil +} + +// DataID returns the value of the "data_id" field in the mutation. +func (m *PayNotifyTaskMutation) DataID() (r uint64, exists bool) { + v := m.data_id + if v == nil { + return + } + return *v, true +} + +// OldDataID returns the old "data_id" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldDataID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDataID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDataID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDataID: %w", err) + } + return oldValue.DataID, nil +} + +// AddDataID adds u to the "data_id" field. +func (m *PayNotifyTaskMutation) AddDataID(u int64) { + if m.adddata_id != nil { + *m.adddata_id += u + } else { + m.adddata_id = &u + } +} + +// AddedDataID returns the value that was added to the "data_id" field in this mutation. +func (m *PayNotifyTaskMutation) AddedDataID() (r int64, exists bool) { + v := m.adddata_id + if v == nil { + return + } + return *v, true +} + +// ResetDataID resets all changes to the "data_id" field. +func (m *PayNotifyTaskMutation) ResetDataID() { + m.data_id = nil + m.adddata_id = nil +} + +// SetOrderID sets the "order_id" field. +func (m *PayNotifyTaskMutation) SetOrderID(u uint64) { + m._order = &u +} + +// OrderID returns the value of the "order_id" field in the mutation. +func (m *PayNotifyTaskMutation) OrderID() (r uint64, exists bool) { + v := m._order + if v == nil { + return + } + return *v, true +} + +// OldOrderID returns the old "order_id" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldOrderID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderID: %w", err) + } + return oldValue.OrderID, nil +} + +// ResetOrderID resets all changes to the "order_id" field. +func (m *PayNotifyTaskMutation) ResetOrderID() { + m._order = nil +} + +// SetAppID sets the "app_id" field. +func (m *PayNotifyTaskMutation) SetAppID(u uint64) { + m.app = &u +} + +// AppID returns the value of the "app_id" field in the mutation. +func (m *PayNotifyTaskMutation) AppID() (r uint64, exists bool) { + v := m.app + if v == nil { + return + } + return *v, true +} + +// OldAppID returns the old "app_id" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldAppID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAppID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAppID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAppID: %w", err) + } + return oldValue.AppID, nil +} + +// ResetAppID resets all changes to the "app_id" field. +func (m *PayNotifyTaskMutation) ResetAppID() { + m.app = nil +} + +// SetNotifyStatus sets the "notify_status" field. +func (m *PayNotifyTaskMutation) SetNotifyStatus(u uint8) { + m.notify_status = &u + m.addnotify_status = nil +} + +// NotifyStatus returns the value of the "notify_status" field in the mutation. +func (m *PayNotifyTaskMutation) NotifyStatus() (r uint8, exists bool) { + v := m.notify_status + if v == nil { + return + } + return *v, true +} + +// OldNotifyStatus returns the old "notify_status" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldNotifyStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotifyStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotifyStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotifyStatus: %w", err) + } + return oldValue.NotifyStatus, nil +} + +// AddNotifyStatus adds u to the "notify_status" field. +func (m *PayNotifyTaskMutation) AddNotifyStatus(u int8) { + if m.addnotify_status != nil { + *m.addnotify_status += u + } else { + m.addnotify_status = &u + } +} + +// AddedNotifyStatus returns the value that was added to the "notify_status" field in this mutation. +func (m *PayNotifyTaskMutation) AddedNotifyStatus() (r int8, exists bool) { + v := m.addnotify_status + if v == nil { + return + } + return *v, true +} + +// ResetNotifyStatus resets all changes to the "notify_status" field. +func (m *PayNotifyTaskMutation) ResetNotifyStatus() { + m.notify_status = nil + m.addnotify_status = nil +} + +// SetNextNotifyTime sets the "next_notify_time" field. +func (m *PayNotifyTaskMutation) SetNextNotifyTime(t time.Time) { + m.next_notify_time = &t +} + +// NextNotifyTime returns the value of the "next_notify_time" field in the mutation. +func (m *PayNotifyTaskMutation) NextNotifyTime() (r time.Time, exists bool) { + v := m.next_notify_time + if v == nil { + return + } + return *v, true +} + +// OldNextNotifyTime returns the old "next_notify_time" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldNextNotifyTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNextNotifyTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNextNotifyTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNextNotifyTime: %w", err) + } + return oldValue.NextNotifyTime, nil +} + +// ClearNextNotifyTime clears the value of the "next_notify_time" field. +func (m *PayNotifyTaskMutation) ClearNextNotifyTime() { + m.next_notify_time = nil + m.clearedFields[paynotifytask.FieldNextNotifyTime] = struct{}{} +} + +// NextNotifyTimeCleared returns if the "next_notify_time" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) NextNotifyTimeCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldNextNotifyTime] + return ok +} + +// ResetNextNotifyTime resets all changes to the "next_notify_time" field. +func (m *PayNotifyTaskMutation) ResetNextNotifyTime() { + m.next_notify_time = nil + delete(m.clearedFields, paynotifytask.FieldNextNotifyTime) +} + +// SetLastExecuteTime sets the "last_execute_time" field. +func (m *PayNotifyTaskMutation) SetLastExecuteTime(t time.Time) { + m.last_execute_time = &t +} + +// LastExecuteTime returns the value of the "last_execute_time" field in the mutation. +func (m *PayNotifyTaskMutation) LastExecuteTime() (r time.Time, exists bool) { + v := m.last_execute_time + if v == nil { + return + } + return *v, true +} + +// OldLastExecuteTime returns the old "last_execute_time" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldLastExecuteTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastExecuteTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastExecuteTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastExecuteTime: %w", err) + } + return oldValue.LastExecuteTime, nil +} + +// ClearLastExecuteTime clears the value of the "last_execute_time" field. +func (m *PayNotifyTaskMutation) ClearLastExecuteTime() { + m.last_execute_time = nil + m.clearedFields[paynotifytask.FieldLastExecuteTime] = struct{}{} +} + +// LastExecuteTimeCleared returns if the "last_execute_time" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) LastExecuteTimeCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldLastExecuteTime] + return ok +} + +// ResetLastExecuteTime resets all changes to the "last_execute_time" field. +func (m *PayNotifyTaskMutation) ResetLastExecuteTime() { + m.last_execute_time = nil + delete(m.clearedFields, paynotifytask.FieldLastExecuteTime) +} + +// SetRetryCount sets the "retry_count" field. +func (m *PayNotifyTaskMutation) SetRetryCount(u uint32) { + m.retry_count = &u + m.addretry_count = nil +} + +// RetryCount returns the value of the "retry_count" field in the mutation. +func (m *PayNotifyTaskMutation) RetryCount() (r uint32, exists bool) { + v := m.retry_count + if v == nil { + return + } + return *v, true +} + +// OldRetryCount returns the old "retry_count" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldRetryCount(ctx context.Context) (v uint32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRetryCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRetryCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRetryCount: %w", err) + } + return oldValue.RetryCount, nil +} + +// AddRetryCount adds u to the "retry_count" field. +func (m *PayNotifyTaskMutation) AddRetryCount(u int32) { + if m.addretry_count != nil { + *m.addretry_count += u + } else { + m.addretry_count = &u + } +} + +// AddedRetryCount returns the value that was added to the "retry_count" field in this mutation. +func (m *PayNotifyTaskMutation) AddedRetryCount() (r int32, exists bool) { + v := m.addretry_count + if v == nil { + return + } + return *v, true +} + +// ClearRetryCount clears the value of the "retry_count" field. +func (m *PayNotifyTaskMutation) ClearRetryCount() { + m.retry_count = nil + m.addretry_count = nil + m.clearedFields[paynotifytask.FieldRetryCount] = struct{}{} +} + +// RetryCountCleared returns if the "retry_count" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) RetryCountCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldRetryCount] + return ok +} + +// ResetRetryCount resets all changes to the "retry_count" field. +func (m *PayNotifyTaskMutation) ResetRetryCount() { + m.retry_count = nil + m.addretry_count = nil + delete(m.clearedFields, paynotifytask.FieldRetryCount) +} + +// SetMaxRetryCount sets the "max_retry_count" field. +func (m *PayNotifyTaskMutation) SetMaxRetryCount(u uint32) { + m.max_retry_count = &u + m.addmax_retry_count = nil +} + +// MaxRetryCount returns the value of the "max_retry_count" field in the mutation. +func (m *PayNotifyTaskMutation) MaxRetryCount() (r uint32, exists bool) { + v := m.max_retry_count + if v == nil { + return + } + return *v, true +} + +// OldMaxRetryCount returns the old "max_retry_count" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldMaxRetryCount(ctx context.Context) (v uint32, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMaxRetryCount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMaxRetryCount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMaxRetryCount: %w", err) + } + return oldValue.MaxRetryCount, nil +} + +// AddMaxRetryCount adds u to the "max_retry_count" field. +func (m *PayNotifyTaskMutation) AddMaxRetryCount(u int32) { + if m.addmax_retry_count != nil { + *m.addmax_retry_count += u + } else { + m.addmax_retry_count = &u + } +} + +// AddedMaxRetryCount returns the value that was added to the "max_retry_count" field in this mutation. +func (m *PayNotifyTaskMutation) AddedMaxRetryCount() (r int32, exists bool) { + v := m.addmax_retry_count + if v == nil { + return + } + return *v, true +} + +// ClearMaxRetryCount clears the value of the "max_retry_count" field. +func (m *PayNotifyTaskMutation) ClearMaxRetryCount() { + m.max_retry_count = nil + m.addmax_retry_count = nil + m.clearedFields[paynotifytask.FieldMaxRetryCount] = struct{}{} +} + +// MaxRetryCountCleared returns if the "max_retry_count" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) MaxRetryCountCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldMaxRetryCount] + return ok +} + +// ResetMaxRetryCount resets all changes to the "max_retry_count" field. +func (m *PayNotifyTaskMutation) ResetMaxRetryCount() { + m.max_retry_count = nil + m.addmax_retry_count = nil + delete(m.clearedFields, paynotifytask.FieldMaxRetryCount) +} + +// SetNotifyURL sets the "notify_url" field. +func (m *PayNotifyTaskMutation) SetNotifyURL(s string) { + m.notify_url = &s +} + +// NotifyURL returns the value of the "notify_url" field in the mutation. +func (m *PayNotifyTaskMutation) NotifyURL() (r string, exists bool) { + v := m.notify_url + if v == nil { + return + } + return *v, true +} + +// OldNotifyURL returns the old "notify_url" field's value of the PayNotifyTask entity. +// If the PayNotifyTask object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayNotifyTaskMutation) OldNotifyURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotifyURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotifyURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotifyURL: %w", err) + } + return oldValue.NotifyURL, nil +} + +// ClearNotifyURL clears the value of the "notify_url" field. +func (m *PayNotifyTaskMutation) ClearNotifyURL() { + m.notify_url = nil + m.clearedFields[paynotifytask.FieldNotifyURL] = struct{}{} +} + +// NotifyURLCleared returns if the "notify_url" field was cleared in this mutation. +func (m *PayNotifyTaskMutation) NotifyURLCleared() bool { + _, ok := m.clearedFields[paynotifytask.FieldNotifyURL] + return ok +} + +// ResetNotifyURL resets all changes to the "notify_url" field. +func (m *PayNotifyTaskMutation) ResetNotifyURL() { + m.notify_url = nil + delete(m.clearedFields, paynotifytask.FieldNotifyURL) +} + +// ClearApp clears the "app" edge to the App entity. +func (m *PayNotifyTaskMutation) ClearApp() { + m.clearedapp = true + m.clearedFields[paynotifytask.FieldAppID] = struct{}{} +} + +// AppCleared reports if the "app" edge to the App entity was cleared. +func (m *PayNotifyTaskMutation) AppCleared() bool { + return m.clearedapp +} + +// AppIDs returns the "app" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// AppID instead. It exists only for internal usage by the builders. +func (m *PayNotifyTaskMutation) AppIDs() (ids []uint64) { + if id := m.app; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetApp resets all changes to the "app" edge. +func (m *PayNotifyTaskMutation) ResetApp() { + m.app = nil + m.clearedapp = false +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (m *PayNotifyTaskMutation) ClearOrder() { + m.cleared_order = true + m.clearedFields[paynotifytask.FieldOrderID] = struct{}{} +} + +// OrderCleared reports if the "order" edge to the PayOrder entity was cleared. +func (m *PayNotifyTaskMutation) OrderCleared() bool { + return m.cleared_order +} + +// OrderIDs returns the "order" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OrderID instead. It exists only for internal usage by the builders. +func (m *PayNotifyTaskMutation) OrderIDs() (ids []uint64) { + if id := m._order; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOrder resets all changes to the "order" edge. +func (m *PayNotifyTaskMutation) ResetOrder() { + m._order = nil + m.cleared_order = false +} + +// AddNotifyLogIDs adds the "notify_log" edge to the PayNotifyLog entity by ids. +func (m *PayNotifyTaskMutation) AddNotifyLogIDs(ids ...uint64) { + if m.notify_log == nil { + m.notify_log = make(map[uint64]struct{}) + } + for i := range ids { + m.notify_log[ids[i]] = struct{}{} + } +} + +// ClearNotifyLog clears the "notify_log" edge to the PayNotifyLog entity. +func (m *PayNotifyTaskMutation) ClearNotifyLog() { + m.clearednotify_log = true +} + +// NotifyLogCleared reports if the "notify_log" edge to the PayNotifyLog entity was cleared. +func (m *PayNotifyTaskMutation) NotifyLogCleared() bool { + return m.clearednotify_log +} + +// RemoveNotifyLogIDs removes the "notify_log" edge to the PayNotifyLog entity by IDs. +func (m *PayNotifyTaskMutation) RemoveNotifyLogIDs(ids ...uint64) { + if m.removednotify_log == nil { + m.removednotify_log = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.notify_log, ids[i]) + m.removednotify_log[ids[i]] = struct{}{} + } +} + +// RemovedNotifyLog returns the removed IDs of the "notify_log" edge to the PayNotifyLog entity. +func (m *PayNotifyTaskMutation) RemovedNotifyLogIDs() (ids []uint64) { + for id := range m.removednotify_log { + ids = append(ids, id) + } + return +} + +// NotifyLogIDs returns the "notify_log" edge IDs in the mutation. +func (m *PayNotifyTaskMutation) NotifyLogIDs() (ids []uint64) { + for id := range m.notify_log { + ids = append(ids, id) + } + return +} + +// ResetNotifyLog resets all changes to the "notify_log" edge. +func (m *PayNotifyTaskMutation) ResetNotifyLog() { + m.notify_log = nil + m.clearednotify_log = false + m.removednotify_log = nil +} + +// Where appends a list predicates to the PayNotifyTaskMutation builder. +func (m *PayNotifyTaskMutation) Where(ps ...predicate.PayNotifyTask) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayNotifyTaskMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayNotifyTaskMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayNotifyTask, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayNotifyTaskMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayNotifyTaskMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayNotifyTask). +func (m *PayNotifyTaskMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PayNotifyTaskMutation) Fields() []string { + fields := make([]string, 0, 15) + if m.created_at != nil { + fields = append(fields, paynotifytask.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, paynotifytask.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, paynotifytask.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, paynotifytask.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, paynotifytask.FieldDeletedAt) + } + if m._type != nil { + fields = append(fields, paynotifytask.FieldType) + } + if m.data_id != nil { + fields = append(fields, paynotifytask.FieldDataID) + } + if m._order != nil { + fields = append(fields, paynotifytask.FieldOrderID) + } + if m.app != nil { + fields = append(fields, paynotifytask.FieldAppID) + } + if m.notify_status != nil { + fields = append(fields, paynotifytask.FieldNotifyStatus) + } + if m.next_notify_time != nil { + fields = append(fields, paynotifytask.FieldNextNotifyTime) + } + if m.last_execute_time != nil { + fields = append(fields, paynotifytask.FieldLastExecuteTime) + } + if m.retry_count != nil { + fields = append(fields, paynotifytask.FieldRetryCount) + } + if m.max_retry_count != nil { + fields = append(fields, paynotifytask.FieldMaxRetryCount) + } + if m.notify_url != nil { + fields = append(fields, paynotifytask.FieldNotifyURL) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PayNotifyTaskMutation) Field(name string) (ent.Value, bool) { + switch name { + case paynotifytask.FieldCreatedAt: + return m.CreatedAt() + case paynotifytask.FieldUpdatedAt: + return m.UpdatedAt() + case paynotifytask.FieldStatus: + return m.Status() + case paynotifytask.FieldTenantID: + return m.TenantID() + case paynotifytask.FieldDeletedAt: + return m.DeletedAt() + case paynotifytask.FieldType: + return m.GetType() + case paynotifytask.FieldDataID: + return m.DataID() + case paynotifytask.FieldOrderID: + return m.OrderID() + case paynotifytask.FieldAppID: + return m.AppID() + case paynotifytask.FieldNotifyStatus: + return m.NotifyStatus() + case paynotifytask.FieldNextNotifyTime: + return m.NextNotifyTime() + case paynotifytask.FieldLastExecuteTime: + return m.LastExecuteTime() + case paynotifytask.FieldRetryCount: + return m.RetryCount() + case paynotifytask.FieldMaxRetryCount: + return m.MaxRetryCount() + case paynotifytask.FieldNotifyURL: + return m.NotifyURL() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PayNotifyTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case paynotifytask.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case paynotifytask.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case paynotifytask.FieldStatus: + return m.OldStatus(ctx) + case paynotifytask.FieldTenantID: + return m.OldTenantID(ctx) + case paynotifytask.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case paynotifytask.FieldType: + return m.OldType(ctx) + case paynotifytask.FieldDataID: + return m.OldDataID(ctx) + case paynotifytask.FieldOrderID: + return m.OldOrderID(ctx) + case paynotifytask.FieldAppID: + return m.OldAppID(ctx) + case paynotifytask.FieldNotifyStatus: + return m.OldNotifyStatus(ctx) + case paynotifytask.FieldNextNotifyTime: + return m.OldNextNotifyTime(ctx) + case paynotifytask.FieldLastExecuteTime: + return m.OldLastExecuteTime(ctx) + case paynotifytask.FieldRetryCount: + return m.OldRetryCount(ctx) + case paynotifytask.FieldMaxRetryCount: + return m.OldMaxRetryCount(ctx) + case paynotifytask.FieldNotifyURL: + return m.OldNotifyURL(ctx) + } + return nil, fmt.Errorf("unknown PayNotifyTask field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayNotifyTaskMutation) SetField(name string, value ent.Value) error { + switch name { + case paynotifytask.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case paynotifytask.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case paynotifytask.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case paynotifytask.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case paynotifytask.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case paynotifytask.FieldType: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case paynotifytask.FieldDataID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDataID(v) + return nil + case paynotifytask.FieldOrderID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderID(v) + return nil + case paynotifytask.FieldAppID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAppID(v) + return nil + case paynotifytask.FieldNotifyStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotifyStatus(v) + return nil + case paynotifytask.FieldNextNotifyTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNextNotifyTime(v) + return nil + case paynotifytask.FieldLastExecuteTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastExecuteTime(v) + return nil + case paynotifytask.FieldRetryCount: + v, ok := value.(uint32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRetryCount(v) + return nil + case paynotifytask.FieldMaxRetryCount: + v, ok := value.(uint32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMaxRetryCount(v) + return nil + case paynotifytask.FieldNotifyURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotifyURL(v) + return nil + } + return fmt.Errorf("unknown PayNotifyTask field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayNotifyTaskMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, paynotifytask.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, paynotifytask.FieldTenantID) + } + if m.add_type != nil { + fields = append(fields, paynotifytask.FieldType) + } + if m.adddata_id != nil { + fields = append(fields, paynotifytask.FieldDataID) + } + if m.addnotify_status != nil { + fields = append(fields, paynotifytask.FieldNotifyStatus) + } + if m.addretry_count != nil { + fields = append(fields, paynotifytask.FieldRetryCount) + } + if m.addmax_retry_count != nil { + fields = append(fields, paynotifytask.FieldMaxRetryCount) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PayNotifyTaskMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case paynotifytask.FieldStatus: + return m.AddedStatus() + case paynotifytask.FieldTenantID: + return m.AddedTenantID() + case paynotifytask.FieldType: + return m.AddedType() + case paynotifytask.FieldDataID: + return m.AddedDataID() + case paynotifytask.FieldNotifyStatus: + return m.AddedNotifyStatus() + case paynotifytask.FieldRetryCount: + return m.AddedRetryCount() + case paynotifytask.FieldMaxRetryCount: + return m.AddedMaxRetryCount() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayNotifyTaskMutation) AddField(name string, value ent.Value) error { + switch name { + case paynotifytask.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case paynotifytask.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case paynotifytask.FieldType: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddType(v) + return nil + case paynotifytask.FieldDataID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddDataID(v) + return nil + case paynotifytask.FieldNotifyStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddNotifyStatus(v) + return nil + case paynotifytask.FieldRetryCount: + v, ok := value.(int32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRetryCount(v) + return nil + case paynotifytask.FieldMaxRetryCount: + v, ok := value.(int32) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMaxRetryCount(v) + return nil + } + return fmt.Errorf("unknown PayNotifyTask numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayNotifyTaskMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(paynotifytask.FieldStatus) { + fields = append(fields, paynotifytask.FieldStatus) + } + if m.FieldCleared(paynotifytask.FieldDeletedAt) { + fields = append(fields, paynotifytask.FieldDeletedAt) + } + if m.FieldCleared(paynotifytask.FieldNextNotifyTime) { + fields = append(fields, paynotifytask.FieldNextNotifyTime) + } + if m.FieldCleared(paynotifytask.FieldLastExecuteTime) { + fields = append(fields, paynotifytask.FieldLastExecuteTime) + } + if m.FieldCleared(paynotifytask.FieldRetryCount) { + fields = append(fields, paynotifytask.FieldRetryCount) + } + if m.FieldCleared(paynotifytask.FieldMaxRetryCount) { + fields = append(fields, paynotifytask.FieldMaxRetryCount) + } + if m.FieldCleared(paynotifytask.FieldNotifyURL) { + fields = append(fields, paynotifytask.FieldNotifyURL) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayNotifyTaskMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PayNotifyTaskMutation) ClearField(name string) error { + switch name { + case paynotifytask.FieldStatus: + m.ClearStatus() + return nil + case paynotifytask.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case paynotifytask.FieldNextNotifyTime: + m.ClearNextNotifyTime() + return nil + case paynotifytask.FieldLastExecuteTime: + m.ClearLastExecuteTime() + return nil + case paynotifytask.FieldRetryCount: + m.ClearRetryCount() + return nil + case paynotifytask.FieldMaxRetryCount: + m.ClearMaxRetryCount() + return nil + case paynotifytask.FieldNotifyURL: + m.ClearNotifyURL() + return nil + } + return fmt.Errorf("unknown PayNotifyTask nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PayNotifyTaskMutation) ResetField(name string) error { + switch name { + case paynotifytask.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case paynotifytask.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case paynotifytask.FieldStatus: + m.ResetStatus() + return nil + case paynotifytask.FieldTenantID: + m.ResetTenantID() + return nil + case paynotifytask.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case paynotifytask.FieldType: + m.ResetType() + return nil + case paynotifytask.FieldDataID: + m.ResetDataID() + return nil + case paynotifytask.FieldOrderID: + m.ResetOrderID() + return nil + case paynotifytask.FieldAppID: + m.ResetAppID() + return nil + case paynotifytask.FieldNotifyStatus: + m.ResetNotifyStatus() + return nil + case paynotifytask.FieldNextNotifyTime: + m.ResetNextNotifyTime() + return nil + case paynotifytask.FieldLastExecuteTime: + m.ResetLastExecuteTime() + return nil + case paynotifytask.FieldRetryCount: + m.ResetRetryCount() + return nil + case paynotifytask.FieldMaxRetryCount: + m.ResetMaxRetryCount() + return nil + case paynotifytask.FieldNotifyURL: + m.ResetNotifyURL() + return nil + } + return fmt.Errorf("unknown PayNotifyTask field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayNotifyTaskMutation) AddedEdges() []string { + edges := make([]string, 0, 3) + if m.app != nil { + edges = append(edges, paynotifytask.EdgeApp) + } + if m._order != nil { + edges = append(edges, paynotifytask.EdgeOrder) + } + if m.notify_log != nil { + edges = append(edges, paynotifytask.EdgeNotifyLog) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayNotifyTaskMutation) AddedIDs(name string) []ent.Value { + switch name { + case paynotifytask.EdgeApp: + if id := m.app; id != nil { + return []ent.Value{*id} + } + case paynotifytask.EdgeOrder: + if id := m._order; id != nil { + return []ent.Value{*id} + } + case paynotifytask.EdgeNotifyLog: + ids := make([]ent.Value, 0, len(m.notify_log)) + for id := range m.notify_log { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayNotifyTaskMutation) RemovedEdges() []string { + edges := make([]string, 0, 3) + if m.removednotify_log != nil { + edges = append(edges, paynotifytask.EdgeNotifyLog) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayNotifyTaskMutation) RemovedIDs(name string) []ent.Value { + switch name { + case paynotifytask.EdgeNotifyLog: + ids := make([]ent.Value, 0, len(m.removednotify_log)) + for id := range m.removednotify_log { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayNotifyTaskMutation) ClearedEdges() []string { + edges := make([]string, 0, 3) + if m.clearedapp { + edges = append(edges, paynotifytask.EdgeApp) + } + if m.cleared_order { + edges = append(edges, paynotifytask.EdgeOrder) + } + if m.clearednotify_log { + edges = append(edges, paynotifytask.EdgeNotifyLog) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayNotifyTaskMutation) EdgeCleared(name string) bool { + switch name { + case paynotifytask.EdgeApp: + return m.clearedapp + case paynotifytask.EdgeOrder: + return m.cleared_order + case paynotifytask.EdgeNotifyLog: + return m.clearednotify_log + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PayNotifyTaskMutation) ClearEdge(name string) error { + switch name { + case paynotifytask.EdgeApp: + m.ClearApp() + return nil + case paynotifytask.EdgeOrder: + m.ClearOrder() + return nil + } + return fmt.Errorf("unknown PayNotifyTask unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PayNotifyTaskMutation) ResetEdge(name string) error { + switch name { + case paynotifytask.EdgeApp: + m.ResetApp() + return nil + case paynotifytask.EdgeOrder: + m.ResetOrder() + return nil + case paynotifytask.EdgeNotifyLog: + m.ResetNotifyLog() + return nil + } + return fmt.Errorf("unknown PayNotifyTask edge %s", name) +} + +// PayOrderMutation represents an operation that mutates the PayOrder nodes in the graph. +type PayOrderMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + user_id *uint64 + adduser_id *int64 + subject *string + body *string + notify_url *string + amount *uint64 + addamount *int64 + pay_source *string + channel_fee_rate *string + channel_fee *uint64 + addchannel_fee *int64 + order_status *string + user_ip *string + expire_time *time.Time + pay_no *string + success_time *time.Time + extension_id *uint64 + addextension_id *int64 + transaction_id *string + currency *string + refund_price *uint64 + addrefund_price *int64 + channel_order_no *string + channel_user_id *string + clearedFields map[string]struct{} + channel *uint64 + clearedchannel bool + orders_extension map[uint64]struct{} + removedorders_extension map[uint64]struct{} + clearedorders_extension bool + notify_task map[uint64]struct{} + removednotify_task map[uint64]struct{} + clearednotify_task bool + refund map[uint64]struct{} + removedrefund map[uint64]struct{} + clearedrefund bool + done bool + oldValue func(context.Context) (*PayOrder, error) + predicates []predicate.PayOrder +} + +var _ ent.Mutation = (*PayOrderMutation)(nil) + +// payorderOption allows management of the mutation configuration using functional options. +type payorderOption func(*PayOrderMutation) + +// newPayOrderMutation creates new mutation for the PayOrder entity. +func newPayOrderMutation(c config, op Op, opts ...payorderOption) *PayOrderMutation { + m := &PayOrderMutation{ + config: c, + op: op, + typ: TypePayOrder, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayOrderID sets the ID field of the mutation. +func withPayOrderID(id uint64) payorderOption { + return func(m *PayOrderMutation) { + var ( + err error + once sync.Once + value *PayOrder + ) + m.oldValue = func(ctx context.Context) (*PayOrder, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayOrder.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayOrder sets the old PayOrder of the mutation. +func withPayOrder(node *PayOrder) payorderOption { + return func(m *PayOrderMutation) { + m.oldValue = func(context.Context) (*PayOrder, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PayOrderMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PayOrderMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayOrder entities. +func (m *PayOrderMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PayOrderMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayOrderMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayOrder.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *PayOrderMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PayOrderMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PayOrderMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PayOrderMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PayOrderMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PayOrderMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *PayOrderMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *PayOrderMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *PayOrderMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PayOrderMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *PayOrderMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[payorder.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *PayOrderMutation) StatusCleared() bool { + _, ok := m.clearedFields[payorder.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *PayOrderMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, payorder.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *PayOrderMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *PayOrderMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *PayOrderMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *PayOrderMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *PayOrderMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PayOrderMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PayOrderMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PayOrderMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[payorder.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PayOrderMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[payorder.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PayOrderMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, payorder.FieldDeletedAt) +} + +// SetChannelID sets the "channel_id" field. +func (m *PayOrderMutation) SetChannelID(u uint64) { + m.channel = &u +} + +// ChannelID returns the value of the "channel_id" field in the mutation. +func (m *PayOrderMutation) ChannelID() (r uint64, exists bool) { + v := m.channel + if v == nil { + return + } + return *v, true +} + +// OldChannelID returns the old "channel_id" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldChannelID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelID: %w", err) + } + return oldValue.ChannelID, nil +} + +// ResetChannelID resets all changes to the "channel_id" field. +func (m *PayOrderMutation) ResetChannelID() { + m.channel = nil +} + +// SetUserID sets the "user_id" field. +func (m *PayOrderMutation) SetUserID(u uint64) { + m.user_id = &u + m.adduser_id = nil +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *PayOrderMutation) UserID() (r uint64, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldUserID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// AddUserID adds u to the "user_id" field. +func (m *PayOrderMutation) AddUserID(u int64) { + if m.adduser_id != nil { + *m.adduser_id += u + } else { + m.adduser_id = &u + } +} + +// AddedUserID returns the value that was added to the "user_id" field in this mutation. +func (m *PayOrderMutation) AddedUserID() (r int64, exists bool) { + v := m.adduser_id + if v == nil { + return + } + return *v, true +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *PayOrderMutation) ResetUserID() { + m.user_id = nil + m.adduser_id = nil +} + +// SetSubject sets the "subject" field. +func (m *PayOrderMutation) SetSubject(s string) { + m.subject = &s +} + +// Subject returns the value of the "subject" field in the mutation. +func (m *PayOrderMutation) Subject() (r string, exists bool) { + v := m.subject + if v == nil { + return + } + return *v, true +} + +// OldSubject returns the old "subject" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldSubject(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubject is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubject requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubject: %w", err) + } + return oldValue.Subject, nil +} + +// ResetSubject resets all changes to the "subject" field. +func (m *PayOrderMutation) ResetSubject() { + m.subject = nil +} + +// SetBody sets the "body" field. +func (m *PayOrderMutation) SetBody(s string) { + m.body = &s +} + +// Body returns the value of the "body" field in the mutation. +func (m *PayOrderMutation) Body() (r string, exists bool) { + v := m.body + if v == nil { + return + } + return *v, true +} + +// OldBody returns the old "body" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldBody(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBody is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBody requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBody: %w", err) + } + return oldValue.Body, nil +} + +// ResetBody resets all changes to the "body" field. +func (m *PayOrderMutation) ResetBody() { + m.body = nil +} + +// SetNotifyURL sets the "notify_url" field. +func (m *PayOrderMutation) SetNotifyURL(s string) { + m.notify_url = &s +} + +// NotifyURL returns the value of the "notify_url" field in the mutation. +func (m *PayOrderMutation) NotifyURL() (r string, exists bool) { + v := m.notify_url + if v == nil { + return + } + return *v, true +} + +// OldNotifyURL returns the old "notify_url" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldNotifyURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotifyURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotifyURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotifyURL: %w", err) + } + return oldValue.NotifyURL, nil +} + +// ResetNotifyURL resets all changes to the "notify_url" field. +func (m *PayOrderMutation) ResetNotifyURL() { + m.notify_url = nil +} + +// SetAmount sets the "amount" field. +func (m *PayOrderMutation) SetAmount(u uint64) { + m.amount = &u + m.addamount = nil +} + +// Amount returns the value of the "amount" field in the mutation. +func (m *PayOrderMutation) Amount() (r uint64, exists bool) { + v := m.amount + if v == nil { + return + } + return *v, true +} + +// OldAmount returns the old "amount" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldAmount(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAmount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAmount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAmount: %w", err) + } + return oldValue.Amount, nil +} + +// AddAmount adds u to the "amount" field. +func (m *PayOrderMutation) AddAmount(u int64) { + if m.addamount != nil { + *m.addamount += u + } else { + m.addamount = &u + } +} + +// AddedAmount returns the value that was added to the "amount" field in this mutation. +func (m *PayOrderMutation) AddedAmount() (r int64, exists bool) { + v := m.addamount + if v == nil { + return + } + return *v, true +} + +// ResetAmount resets all changes to the "amount" field. +func (m *PayOrderMutation) ResetAmount() { + m.amount = nil + m.addamount = nil +} + +// SetPaySource sets the "pay_source" field. +func (m *PayOrderMutation) SetPaySource(s string) { + m.pay_source = &s +} + +// PaySource returns the value of the "pay_source" field in the mutation. +func (m *PayOrderMutation) PaySource() (r string, exists bool) { + v := m.pay_source + if v == nil { + return + } + return *v, true +} + +// OldPaySource returns the old "pay_source" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldPaySource(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPaySource is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPaySource requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPaySource: %w", err) + } + return oldValue.PaySource, nil +} + +// ClearPaySource clears the value of the "pay_source" field. +func (m *PayOrderMutation) ClearPaySource() { + m.pay_source = nil + m.clearedFields[payorder.FieldPaySource] = struct{}{} +} + +// PaySourceCleared returns if the "pay_source" field was cleared in this mutation. +func (m *PayOrderMutation) PaySourceCleared() bool { + _, ok := m.clearedFields[payorder.FieldPaySource] + return ok +} + +// ResetPaySource resets all changes to the "pay_source" field. +func (m *PayOrderMutation) ResetPaySource() { + m.pay_source = nil + delete(m.clearedFields, payorder.FieldPaySource) +} + +// SetChannelFeeRate sets the "channel_fee_rate" field. +func (m *PayOrderMutation) SetChannelFeeRate(s string) { + m.channel_fee_rate = &s +} + +// ChannelFeeRate returns the value of the "channel_fee_rate" field in the mutation. +func (m *PayOrderMutation) ChannelFeeRate() (r string, exists bool) { + v := m.channel_fee_rate + if v == nil { + return + } + return *v, true +} + +// OldChannelFeeRate returns the old "channel_fee_rate" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldChannelFeeRate(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelFeeRate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelFeeRate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelFeeRate: %w", err) + } + return oldValue.ChannelFeeRate, nil +} + +// ResetChannelFeeRate resets all changes to the "channel_fee_rate" field. +func (m *PayOrderMutation) ResetChannelFeeRate() { + m.channel_fee_rate = nil +} + +// SetChannelFee sets the "channel_fee" field. +func (m *PayOrderMutation) SetChannelFee(u uint64) { + m.channel_fee = &u + m.addchannel_fee = nil +} + +// ChannelFee returns the value of the "channel_fee" field in the mutation. +func (m *PayOrderMutation) ChannelFee() (r uint64, exists bool) { + v := m.channel_fee + if v == nil { + return + } + return *v, true +} + +// OldChannelFee returns the old "channel_fee" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldChannelFee(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelFee is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelFee requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelFee: %w", err) + } + return oldValue.ChannelFee, nil +} + +// AddChannelFee adds u to the "channel_fee" field. +func (m *PayOrderMutation) AddChannelFee(u int64) { + if m.addchannel_fee != nil { + *m.addchannel_fee += u + } else { + m.addchannel_fee = &u + } +} + +// AddedChannelFee returns the value that was added to the "channel_fee" field in this mutation. +func (m *PayOrderMutation) AddedChannelFee() (r int64, exists bool) { + v := m.addchannel_fee + if v == nil { + return + } + return *v, true +} + +// ResetChannelFee resets all changes to the "channel_fee" field. +func (m *PayOrderMutation) ResetChannelFee() { + m.channel_fee = nil + m.addchannel_fee = nil +} + +// SetOrderStatus sets the "order_status" field. +func (m *PayOrderMutation) SetOrderStatus(s string) { + m.order_status = &s +} + +// OrderStatus returns the value of the "order_status" field in the mutation. +func (m *PayOrderMutation) OrderStatus() (r string, exists bool) { + v := m.order_status + if v == nil { + return + } + return *v, true +} + +// OldOrderStatus returns the old "order_status" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldOrderStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderStatus: %w", err) + } + return oldValue.OrderStatus, nil +} + +// ResetOrderStatus resets all changes to the "order_status" field. +func (m *PayOrderMutation) ResetOrderStatus() { + m.order_status = nil +} + +// SetUserIP sets the "user_ip" field. +func (m *PayOrderMutation) SetUserIP(s string) { + m.user_ip = &s +} + +// UserIP returns the value of the "user_ip" field in the mutation. +func (m *PayOrderMutation) UserIP() (r string, exists bool) { + v := m.user_ip + if v == nil { + return + } + return *v, true +} + +// OldUserIP returns the old "user_ip" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldUserIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserIP: %w", err) + } + return oldValue.UserIP, nil +} + +// ClearUserIP clears the value of the "user_ip" field. +func (m *PayOrderMutation) ClearUserIP() { + m.user_ip = nil + m.clearedFields[payorder.FieldUserIP] = struct{}{} +} + +// UserIPCleared returns if the "user_ip" field was cleared in this mutation. +func (m *PayOrderMutation) UserIPCleared() bool { + _, ok := m.clearedFields[payorder.FieldUserIP] + return ok +} + +// ResetUserIP resets all changes to the "user_ip" field. +func (m *PayOrderMutation) ResetUserIP() { + m.user_ip = nil + delete(m.clearedFields, payorder.FieldUserIP) +} + +// SetExpireTime sets the "expire_time" field. +func (m *PayOrderMutation) SetExpireTime(t time.Time) { + m.expire_time = &t +} + +// ExpireTime returns the value of the "expire_time" field in the mutation. +func (m *PayOrderMutation) ExpireTime() (r time.Time, exists bool) { + v := m.expire_time + if v == nil { + return + } + return *v, true +} + +// OldExpireTime returns the old "expire_time" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldExpireTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExpireTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExpireTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExpireTime: %w", err) + } + return oldValue.ExpireTime, nil +} + +// ResetExpireTime resets all changes to the "expire_time" field. +func (m *PayOrderMutation) ResetExpireTime() { + m.expire_time = nil +} + +// SetPayNo sets the "pay_no" field. +func (m *PayOrderMutation) SetPayNo(s string) { + m.pay_no = &s +} + +// PayNo returns the value of the "pay_no" field in the mutation. +func (m *PayOrderMutation) PayNo() (r string, exists bool) { + v := m.pay_no + if v == nil { + return + } + return *v, true +} + +// OldPayNo returns the old "pay_no" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldPayNo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPayNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPayNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPayNo: %w", err) + } + return oldValue.PayNo, nil +} + +// ResetPayNo resets all changes to the "pay_no" field. +func (m *PayOrderMutation) ResetPayNo() { + m.pay_no = nil +} + +// SetSuccessTime sets the "success_time" field. +func (m *PayOrderMutation) SetSuccessTime(t time.Time) { + m.success_time = &t +} + +// SuccessTime returns the value of the "success_time" field in the mutation. +func (m *PayOrderMutation) SuccessTime() (r time.Time, exists bool) { + v := m.success_time + if v == nil { + return + } + return *v, true +} + +// OldSuccessTime returns the old "success_time" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldSuccessTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSuccessTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSuccessTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSuccessTime: %w", err) + } + return oldValue.SuccessTime, nil +} + +// ResetSuccessTime resets all changes to the "success_time" field. +func (m *PayOrderMutation) ResetSuccessTime() { + m.success_time = nil +} + +// SetExtensionID sets the "extension_id" field. +func (m *PayOrderMutation) SetExtensionID(u uint64) { + m.extension_id = &u + m.addextension_id = nil +} + +// ExtensionID returns the value of the "extension_id" field in the mutation. +func (m *PayOrderMutation) ExtensionID() (r uint64, exists bool) { + v := m.extension_id + if v == nil { + return + } + return *v, true +} + +// OldExtensionID returns the old "extension_id" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldExtensionID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtensionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtensionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtensionID: %w", err) + } + return oldValue.ExtensionID, nil +} + +// AddExtensionID adds u to the "extension_id" field. +func (m *PayOrderMutation) AddExtensionID(u int64) { + if m.addextension_id != nil { + *m.addextension_id += u + } else { + m.addextension_id = &u + } +} + +// AddedExtensionID returns the value that was added to the "extension_id" field in this mutation. +func (m *PayOrderMutation) AddedExtensionID() (r int64, exists bool) { + v := m.addextension_id + if v == nil { + return + } + return *v, true +} + +// ClearExtensionID clears the value of the "extension_id" field. +func (m *PayOrderMutation) ClearExtensionID() { + m.extension_id = nil + m.addextension_id = nil + m.clearedFields[payorder.FieldExtensionID] = struct{}{} +} + +// ExtensionIDCleared returns if the "extension_id" field was cleared in this mutation. +func (m *PayOrderMutation) ExtensionIDCleared() bool { + _, ok := m.clearedFields[payorder.FieldExtensionID] + return ok +} + +// ResetExtensionID resets all changes to the "extension_id" field. +func (m *PayOrderMutation) ResetExtensionID() { + m.extension_id = nil + m.addextension_id = nil + delete(m.clearedFields, payorder.FieldExtensionID) +} + +// SetTransactionID sets the "transaction_id" field. +func (m *PayOrderMutation) SetTransactionID(s string) { + m.transaction_id = &s +} + +// TransactionID returns the value of the "transaction_id" field in the mutation. +func (m *PayOrderMutation) TransactionID() (r string, exists bool) { + v := m.transaction_id + if v == nil { + return + } + return *v, true +} + +// OldTransactionID returns the old "transaction_id" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldTransactionID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTransactionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTransactionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTransactionID: %w", err) + } + return oldValue.TransactionID, nil +} + +// ClearTransactionID clears the value of the "transaction_id" field. +func (m *PayOrderMutation) ClearTransactionID() { + m.transaction_id = nil + m.clearedFields[payorder.FieldTransactionID] = struct{}{} +} + +// TransactionIDCleared returns if the "transaction_id" field was cleared in this mutation. +func (m *PayOrderMutation) TransactionIDCleared() bool { + _, ok := m.clearedFields[payorder.FieldTransactionID] + return ok +} + +// ResetTransactionID resets all changes to the "transaction_id" field. +func (m *PayOrderMutation) ResetTransactionID() { + m.transaction_id = nil + delete(m.clearedFields, payorder.FieldTransactionID) +} + +// SetCurrency sets the "currency" field. +func (m *PayOrderMutation) SetCurrency(s string) { + m.currency = &s +} + +// Currency returns the value of the "currency" field in the mutation. +func (m *PayOrderMutation) Currency() (r string, exists bool) { + v := m.currency + if v == nil { + return + } + return *v, true +} + +// OldCurrency returns the old "currency" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldCurrency(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCurrency is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCurrency requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCurrency: %w", err) + } + return oldValue.Currency, nil +} + +// ResetCurrency resets all changes to the "currency" field. +func (m *PayOrderMutation) ResetCurrency() { + m.currency = nil +} + +// SetRefundPrice sets the "refund_price" field. +func (m *PayOrderMutation) SetRefundPrice(u uint64) { + m.refund_price = &u + m.addrefund_price = nil +} + +// RefundPrice returns the value of the "refund_price" field in the mutation. +func (m *PayOrderMutation) RefundPrice() (r uint64, exists bool) { + v := m.refund_price + if v == nil { + return + } + return *v, true +} + +// OldRefundPrice returns the old "refund_price" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldRefundPrice(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundPrice is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundPrice requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundPrice: %w", err) + } + return oldValue.RefundPrice, nil +} + +// AddRefundPrice adds u to the "refund_price" field. +func (m *PayOrderMutation) AddRefundPrice(u int64) { + if m.addrefund_price != nil { + *m.addrefund_price += u + } else { + m.addrefund_price = &u + } +} + +// AddedRefundPrice returns the value that was added to the "refund_price" field in this mutation. +func (m *PayOrderMutation) AddedRefundPrice() (r int64, exists bool) { + v := m.addrefund_price + if v == nil { + return + } + return *v, true +} + +// ResetRefundPrice resets all changes to the "refund_price" field. +func (m *PayOrderMutation) ResetRefundPrice() { + m.refund_price = nil + m.addrefund_price = nil +} + +// SetChannelOrderNo sets the "channel_order_no" field. +func (m *PayOrderMutation) SetChannelOrderNo(s string) { + m.channel_order_no = &s +} + +// ChannelOrderNo returns the value of the "channel_order_no" field in the mutation. +func (m *PayOrderMutation) ChannelOrderNo() (r string, exists bool) { + v := m.channel_order_no + if v == nil { + return + } + return *v, true +} + +// OldChannelOrderNo returns the old "channel_order_no" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldChannelOrderNo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelOrderNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelOrderNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelOrderNo: %w", err) + } + return oldValue.ChannelOrderNo, nil +} + +// ClearChannelOrderNo clears the value of the "channel_order_no" field. +func (m *PayOrderMutation) ClearChannelOrderNo() { + m.channel_order_no = nil + m.clearedFields[payorder.FieldChannelOrderNo] = struct{}{} +} + +// ChannelOrderNoCleared returns if the "channel_order_no" field was cleared in this mutation. +func (m *PayOrderMutation) ChannelOrderNoCleared() bool { + _, ok := m.clearedFields[payorder.FieldChannelOrderNo] + return ok +} + +// ResetChannelOrderNo resets all changes to the "channel_order_no" field. +func (m *PayOrderMutation) ResetChannelOrderNo() { + m.channel_order_no = nil + delete(m.clearedFields, payorder.FieldChannelOrderNo) +} + +// SetChannelUserID sets the "channel_user_id" field. +func (m *PayOrderMutation) SetChannelUserID(s string) { + m.channel_user_id = &s +} + +// ChannelUserID returns the value of the "channel_user_id" field in the mutation. +func (m *PayOrderMutation) ChannelUserID() (r string, exists bool) { + v := m.channel_user_id + if v == nil { + return + } + return *v, true +} + +// OldChannelUserID returns the old "channel_user_id" field's value of the PayOrder entity. +// If the PayOrder object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderMutation) OldChannelUserID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelUserID: %w", err) + } + return oldValue.ChannelUserID, nil +} + +// ClearChannelUserID clears the value of the "channel_user_id" field. +func (m *PayOrderMutation) ClearChannelUserID() { + m.channel_user_id = nil + m.clearedFields[payorder.FieldChannelUserID] = struct{}{} +} + +// ChannelUserIDCleared returns if the "channel_user_id" field was cleared in this mutation. +func (m *PayOrderMutation) ChannelUserIDCleared() bool { + _, ok := m.clearedFields[payorder.FieldChannelUserID] + return ok +} + +// ResetChannelUserID resets all changes to the "channel_user_id" field. +func (m *PayOrderMutation) ResetChannelUserID() { + m.channel_user_id = nil + delete(m.clearedFields, payorder.FieldChannelUserID) +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (m *PayOrderMutation) ClearChannel() { + m.clearedchannel = true + m.clearedFields[payorder.FieldChannelID] = struct{}{} +} + +// ChannelCleared reports if the "channel" edge to the PayChannel entity was cleared. +func (m *PayOrderMutation) ChannelCleared() bool { + return m.clearedchannel +} + +// ChannelIDs returns the "channel" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ChannelID instead. It exists only for internal usage by the builders. +func (m *PayOrderMutation) ChannelIDs() (ids []uint64) { + if id := m.channel; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetChannel resets all changes to the "channel" edge. +func (m *PayOrderMutation) ResetChannel() { + m.channel = nil + m.clearedchannel = false +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by ids. +func (m *PayOrderMutation) AddOrdersExtensionIDs(ids ...uint64) { + if m.orders_extension == nil { + m.orders_extension = make(map[uint64]struct{}) + } + for i := range ids { + m.orders_extension[ids[i]] = struct{}{} + } +} + +// ClearOrdersExtension clears the "orders_extension" edge to the PayOrderExtension entity. +func (m *PayOrderMutation) ClearOrdersExtension() { + m.clearedorders_extension = true +} + +// OrdersExtensionCleared reports if the "orders_extension" edge to the PayOrderExtension entity was cleared. +func (m *PayOrderMutation) OrdersExtensionCleared() bool { + return m.clearedorders_extension +} + +// RemoveOrdersExtensionIDs removes the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (m *PayOrderMutation) RemoveOrdersExtensionIDs(ids ...uint64) { + if m.removedorders_extension == nil { + m.removedorders_extension = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.orders_extension, ids[i]) + m.removedorders_extension[ids[i]] = struct{}{} + } +} + +// RemovedOrdersExtension returns the removed IDs of the "orders_extension" edge to the PayOrderExtension entity. +func (m *PayOrderMutation) RemovedOrdersExtensionIDs() (ids []uint64) { + for id := range m.removedorders_extension { + ids = append(ids, id) + } + return +} + +// OrdersExtensionIDs returns the "orders_extension" edge IDs in the mutation. +func (m *PayOrderMutation) OrdersExtensionIDs() (ids []uint64) { + for id := range m.orders_extension { + ids = append(ids, id) + } + return +} + +// ResetOrdersExtension resets all changes to the "orders_extension" edge. +func (m *PayOrderMutation) ResetOrdersExtension() { + m.orders_extension = nil + m.clearedorders_extension = false + m.removedorders_extension = nil +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by ids. +func (m *PayOrderMutation) AddNotifyTaskIDs(ids ...uint64) { + if m.notify_task == nil { + m.notify_task = make(map[uint64]struct{}) + } + for i := range ids { + m.notify_task[ids[i]] = struct{}{} + } +} + +// ClearNotifyTask clears the "notify_task" edge to the PayNotifyTask entity. +func (m *PayOrderMutation) ClearNotifyTask() { + m.clearednotify_task = true +} + +// NotifyTaskCleared reports if the "notify_task" edge to the PayNotifyTask entity was cleared. +func (m *PayOrderMutation) NotifyTaskCleared() bool { + return m.clearednotify_task +} + +// RemoveNotifyTaskIDs removes the "notify_task" edge to the PayNotifyTask entity by IDs. +func (m *PayOrderMutation) RemoveNotifyTaskIDs(ids ...uint64) { + if m.removednotify_task == nil { + m.removednotify_task = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.notify_task, ids[i]) + m.removednotify_task[ids[i]] = struct{}{} + } +} + +// RemovedNotifyTask returns the removed IDs of the "notify_task" edge to the PayNotifyTask entity. +func (m *PayOrderMutation) RemovedNotifyTaskIDs() (ids []uint64) { + for id := range m.removednotify_task { + ids = append(ids, id) + } + return +} + +// NotifyTaskIDs returns the "notify_task" edge IDs in the mutation. +func (m *PayOrderMutation) NotifyTaskIDs() (ids []uint64) { + for id := range m.notify_task { + ids = append(ids, id) + } + return +} + +// ResetNotifyTask resets all changes to the "notify_task" edge. +func (m *PayOrderMutation) ResetNotifyTask() { + m.notify_task = nil + m.clearednotify_task = false + m.removednotify_task = nil +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by ids. +func (m *PayOrderMutation) AddRefundIDs(ids ...uint64) { + if m.refund == nil { + m.refund = make(map[uint64]struct{}) + } + for i := range ids { + m.refund[ids[i]] = struct{}{} + } +} + +// ClearRefund clears the "refund" edge to the PayRefund entity. +func (m *PayOrderMutation) ClearRefund() { + m.clearedrefund = true +} + +// RefundCleared reports if the "refund" edge to the PayRefund entity was cleared. +func (m *PayOrderMutation) RefundCleared() bool { + return m.clearedrefund +} + +// RemoveRefundIDs removes the "refund" edge to the PayRefund entity by IDs. +func (m *PayOrderMutation) RemoveRefundIDs(ids ...uint64) { + if m.removedrefund == nil { + m.removedrefund = make(map[uint64]struct{}) + } + for i := range ids { + delete(m.refund, ids[i]) + m.removedrefund[ids[i]] = struct{}{} + } +} + +// RemovedRefund returns the removed IDs of the "refund" edge to the PayRefund entity. +func (m *PayOrderMutation) RemovedRefundIDs() (ids []uint64) { + for id := range m.removedrefund { + ids = append(ids, id) + } + return +} + +// RefundIDs returns the "refund" edge IDs in the mutation. +func (m *PayOrderMutation) RefundIDs() (ids []uint64) { + for id := range m.refund { + ids = append(ids, id) + } + return +} + +// ResetRefund resets all changes to the "refund" edge. +func (m *PayOrderMutation) ResetRefund() { + m.refund = nil + m.clearedrefund = false + m.removedrefund = nil +} + +// Where appends a list predicates to the PayOrderMutation builder. +func (m *PayOrderMutation) Where(ps ...predicate.PayOrder) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayOrderMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayOrderMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayOrder, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayOrderMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayOrderMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayOrder). +func (m *PayOrderMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PayOrderMutation) Fields() []string { + fields := make([]string, 0, 25) + if m.created_at != nil { + fields = append(fields, payorder.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, payorder.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, payorder.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, payorder.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, payorder.FieldDeletedAt) + } + if m.channel != nil { + fields = append(fields, payorder.FieldChannelID) + } + if m.user_id != nil { + fields = append(fields, payorder.FieldUserID) + } + if m.subject != nil { + fields = append(fields, payorder.FieldSubject) + } + if m.body != nil { + fields = append(fields, payorder.FieldBody) + } + if m.notify_url != nil { + fields = append(fields, payorder.FieldNotifyURL) + } + if m.amount != nil { + fields = append(fields, payorder.FieldAmount) + } + if m.pay_source != nil { + fields = append(fields, payorder.FieldPaySource) + } + if m.channel_fee_rate != nil { + fields = append(fields, payorder.FieldChannelFeeRate) + } + if m.channel_fee != nil { + fields = append(fields, payorder.FieldChannelFee) + } + if m.order_status != nil { + fields = append(fields, payorder.FieldOrderStatus) + } + if m.user_ip != nil { + fields = append(fields, payorder.FieldUserIP) + } + if m.expire_time != nil { + fields = append(fields, payorder.FieldExpireTime) + } + if m.pay_no != nil { + fields = append(fields, payorder.FieldPayNo) + } + if m.success_time != nil { + fields = append(fields, payorder.FieldSuccessTime) + } + if m.extension_id != nil { + fields = append(fields, payorder.FieldExtensionID) + } + if m.transaction_id != nil { + fields = append(fields, payorder.FieldTransactionID) + } + if m.currency != nil { + fields = append(fields, payorder.FieldCurrency) + } + if m.refund_price != nil { + fields = append(fields, payorder.FieldRefundPrice) + } + if m.channel_order_no != nil { + fields = append(fields, payorder.FieldChannelOrderNo) + } + if m.channel_user_id != nil { + fields = append(fields, payorder.FieldChannelUserID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PayOrderMutation) Field(name string) (ent.Value, bool) { + switch name { + case payorder.FieldCreatedAt: + return m.CreatedAt() + case payorder.FieldUpdatedAt: + return m.UpdatedAt() + case payorder.FieldStatus: + return m.Status() + case payorder.FieldTenantID: + return m.TenantID() + case payorder.FieldDeletedAt: + return m.DeletedAt() + case payorder.FieldChannelID: + return m.ChannelID() + case payorder.FieldUserID: + return m.UserID() + case payorder.FieldSubject: + return m.Subject() + case payorder.FieldBody: + return m.Body() + case payorder.FieldNotifyURL: + return m.NotifyURL() + case payorder.FieldAmount: + return m.Amount() + case payorder.FieldPaySource: + return m.PaySource() + case payorder.FieldChannelFeeRate: + return m.ChannelFeeRate() + case payorder.FieldChannelFee: + return m.ChannelFee() + case payorder.FieldOrderStatus: + return m.OrderStatus() + case payorder.FieldUserIP: + return m.UserIP() + case payorder.FieldExpireTime: + return m.ExpireTime() + case payorder.FieldPayNo: + return m.PayNo() + case payorder.FieldSuccessTime: + return m.SuccessTime() + case payorder.FieldExtensionID: + return m.ExtensionID() + case payorder.FieldTransactionID: + return m.TransactionID() + case payorder.FieldCurrency: + return m.Currency() + case payorder.FieldRefundPrice: + return m.RefundPrice() + case payorder.FieldChannelOrderNo: + return m.ChannelOrderNo() + case payorder.FieldChannelUserID: + return m.ChannelUserID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PayOrderMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case payorder.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case payorder.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case payorder.FieldStatus: + return m.OldStatus(ctx) + case payorder.FieldTenantID: + return m.OldTenantID(ctx) + case payorder.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case payorder.FieldChannelID: + return m.OldChannelID(ctx) + case payorder.FieldUserID: + return m.OldUserID(ctx) + case payorder.FieldSubject: + return m.OldSubject(ctx) + case payorder.FieldBody: + return m.OldBody(ctx) + case payorder.FieldNotifyURL: + return m.OldNotifyURL(ctx) + case payorder.FieldAmount: + return m.OldAmount(ctx) + case payorder.FieldPaySource: + return m.OldPaySource(ctx) + case payorder.FieldChannelFeeRate: + return m.OldChannelFeeRate(ctx) + case payorder.FieldChannelFee: + return m.OldChannelFee(ctx) + case payorder.FieldOrderStatus: + return m.OldOrderStatus(ctx) + case payorder.FieldUserIP: + return m.OldUserIP(ctx) + case payorder.FieldExpireTime: + return m.OldExpireTime(ctx) + case payorder.FieldPayNo: + return m.OldPayNo(ctx) + case payorder.FieldSuccessTime: + return m.OldSuccessTime(ctx) + case payorder.FieldExtensionID: + return m.OldExtensionID(ctx) + case payorder.FieldTransactionID: + return m.OldTransactionID(ctx) + case payorder.FieldCurrency: + return m.OldCurrency(ctx) + case payorder.FieldRefundPrice: + return m.OldRefundPrice(ctx) + case payorder.FieldChannelOrderNo: + return m.OldChannelOrderNo(ctx) + case payorder.FieldChannelUserID: + return m.OldChannelUserID(ctx) + } + return nil, fmt.Errorf("unknown PayOrder field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayOrderMutation) SetField(name string, value ent.Value) error { + switch name { + case payorder.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case payorder.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case payorder.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case payorder.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case payorder.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case payorder.FieldChannelID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelID(v) + return nil + case payorder.FieldUserID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case payorder.FieldSubject: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubject(v) + return nil + case payorder.FieldBody: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBody(v) + return nil + case payorder.FieldNotifyURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotifyURL(v) + return nil + case payorder.FieldAmount: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAmount(v) + return nil + case payorder.FieldPaySource: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPaySource(v) + return nil + case payorder.FieldChannelFeeRate: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelFeeRate(v) + return nil + case payorder.FieldChannelFee: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelFee(v) + return nil + case payorder.FieldOrderStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderStatus(v) + return nil + case payorder.FieldUserIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserIP(v) + return nil + case payorder.FieldExpireTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExpireTime(v) + return nil + case payorder.FieldPayNo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPayNo(v) + return nil + case payorder.FieldSuccessTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSuccessTime(v) + return nil + case payorder.FieldExtensionID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetExtensionID(v) + return nil + case payorder.FieldTransactionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTransactionID(v) + return nil + case payorder.FieldCurrency: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCurrency(v) + return nil + case payorder.FieldRefundPrice: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundPrice(v) + return nil + case payorder.FieldChannelOrderNo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelOrderNo(v) + return nil + case payorder.FieldChannelUserID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelUserID(v) + return nil + } + return fmt.Errorf("unknown PayOrder field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayOrderMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, payorder.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, payorder.FieldTenantID) + } + if m.adduser_id != nil { + fields = append(fields, payorder.FieldUserID) + } + if m.addamount != nil { + fields = append(fields, payorder.FieldAmount) + } + if m.addchannel_fee != nil { + fields = append(fields, payorder.FieldChannelFee) + } + if m.addextension_id != nil { + fields = append(fields, payorder.FieldExtensionID) + } + if m.addrefund_price != nil { + fields = append(fields, payorder.FieldRefundPrice) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PayOrderMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case payorder.FieldStatus: + return m.AddedStatus() + case payorder.FieldTenantID: + return m.AddedTenantID() + case payorder.FieldUserID: + return m.AddedUserID() + case payorder.FieldAmount: + return m.AddedAmount() + case payorder.FieldChannelFee: + return m.AddedChannelFee() + case payorder.FieldExtensionID: + return m.AddedExtensionID() + case payorder.FieldRefundPrice: + return m.AddedRefundPrice() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayOrderMutation) AddField(name string, value ent.Value) error { + switch name { + case payorder.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case payorder.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case payorder.FieldUserID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUserID(v) + return nil + case payorder.FieldAmount: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddAmount(v) + return nil + case payorder.FieldChannelFee: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddChannelFee(v) + return nil + case payorder.FieldExtensionID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddExtensionID(v) + return nil + case payorder.FieldRefundPrice: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRefundPrice(v) + return nil + } + return fmt.Errorf("unknown PayOrder numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayOrderMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(payorder.FieldStatus) { + fields = append(fields, payorder.FieldStatus) + } + if m.FieldCleared(payorder.FieldDeletedAt) { + fields = append(fields, payorder.FieldDeletedAt) + } + if m.FieldCleared(payorder.FieldPaySource) { + fields = append(fields, payorder.FieldPaySource) + } + if m.FieldCleared(payorder.FieldUserIP) { + fields = append(fields, payorder.FieldUserIP) + } + if m.FieldCleared(payorder.FieldExtensionID) { + fields = append(fields, payorder.FieldExtensionID) + } + if m.FieldCleared(payorder.FieldTransactionID) { + fields = append(fields, payorder.FieldTransactionID) + } + if m.FieldCleared(payorder.FieldChannelOrderNo) { + fields = append(fields, payorder.FieldChannelOrderNo) + } + if m.FieldCleared(payorder.FieldChannelUserID) { + fields = append(fields, payorder.FieldChannelUserID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayOrderMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PayOrderMutation) ClearField(name string) error { + switch name { + case payorder.FieldStatus: + m.ClearStatus() + return nil + case payorder.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case payorder.FieldPaySource: + m.ClearPaySource() + return nil + case payorder.FieldUserIP: + m.ClearUserIP() + return nil + case payorder.FieldExtensionID: + m.ClearExtensionID() + return nil + case payorder.FieldTransactionID: + m.ClearTransactionID() + return nil + case payorder.FieldChannelOrderNo: + m.ClearChannelOrderNo() + return nil + case payorder.FieldChannelUserID: + m.ClearChannelUserID() + return nil + } + return fmt.Errorf("unknown PayOrder nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PayOrderMutation) ResetField(name string) error { + switch name { + case payorder.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case payorder.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case payorder.FieldStatus: + m.ResetStatus() + return nil + case payorder.FieldTenantID: + m.ResetTenantID() + return nil + case payorder.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case payorder.FieldChannelID: + m.ResetChannelID() + return nil + case payorder.FieldUserID: + m.ResetUserID() + return nil + case payorder.FieldSubject: + m.ResetSubject() + return nil + case payorder.FieldBody: + m.ResetBody() + return nil + case payorder.FieldNotifyURL: + m.ResetNotifyURL() + return nil + case payorder.FieldAmount: + m.ResetAmount() + return nil + case payorder.FieldPaySource: + m.ResetPaySource() + return nil + case payorder.FieldChannelFeeRate: + m.ResetChannelFeeRate() + return nil + case payorder.FieldChannelFee: + m.ResetChannelFee() + return nil + case payorder.FieldOrderStatus: + m.ResetOrderStatus() + return nil + case payorder.FieldUserIP: + m.ResetUserIP() + return nil + case payorder.FieldExpireTime: + m.ResetExpireTime() + return nil + case payorder.FieldPayNo: + m.ResetPayNo() + return nil + case payorder.FieldSuccessTime: + m.ResetSuccessTime() + return nil + case payorder.FieldExtensionID: + m.ResetExtensionID() + return nil + case payorder.FieldTransactionID: + m.ResetTransactionID() + return nil + case payorder.FieldCurrency: + m.ResetCurrency() + return nil + case payorder.FieldRefundPrice: + m.ResetRefundPrice() + return nil + case payorder.FieldChannelOrderNo: + m.ResetChannelOrderNo() + return nil + case payorder.FieldChannelUserID: + m.ResetChannelUserID() + return nil + } + return fmt.Errorf("unknown PayOrder field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayOrderMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.channel != nil { + edges = append(edges, payorder.EdgeChannel) + } + if m.orders_extension != nil { + edges = append(edges, payorder.EdgeOrdersExtension) + } + if m.notify_task != nil { + edges = append(edges, payorder.EdgeNotifyTask) + } + if m.refund != nil { + edges = append(edges, payorder.EdgeRefund) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayOrderMutation) AddedIDs(name string) []ent.Value { + switch name { + case payorder.EdgeChannel: + if id := m.channel; id != nil { + return []ent.Value{*id} + } + case payorder.EdgeOrdersExtension: + ids := make([]ent.Value, 0, len(m.orders_extension)) + for id := range m.orders_extension { + ids = append(ids, id) + } + return ids + case payorder.EdgeNotifyTask: + ids := make([]ent.Value, 0, len(m.notify_task)) + for id := range m.notify_task { + ids = append(ids, id) + } + return ids + case payorder.EdgeRefund: + ids := make([]ent.Value, 0, len(m.refund)) + for id := range m.refund { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayOrderMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedorders_extension != nil { + edges = append(edges, payorder.EdgeOrdersExtension) + } + if m.removednotify_task != nil { + edges = append(edges, payorder.EdgeNotifyTask) + } + if m.removedrefund != nil { + edges = append(edges, payorder.EdgeRefund) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayOrderMutation) RemovedIDs(name string) []ent.Value { + switch name { + case payorder.EdgeOrdersExtension: + ids := make([]ent.Value, 0, len(m.removedorders_extension)) + for id := range m.removedorders_extension { + ids = append(ids, id) + } + return ids + case payorder.EdgeNotifyTask: + ids := make([]ent.Value, 0, len(m.removednotify_task)) + for id := range m.removednotify_task { + ids = append(ids, id) + } + return ids + case payorder.EdgeRefund: + ids := make([]ent.Value, 0, len(m.removedrefund)) + for id := range m.removedrefund { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayOrderMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedchannel { + edges = append(edges, payorder.EdgeChannel) + } + if m.clearedorders_extension { + edges = append(edges, payorder.EdgeOrdersExtension) + } + if m.clearednotify_task { + edges = append(edges, payorder.EdgeNotifyTask) + } + if m.clearedrefund { + edges = append(edges, payorder.EdgeRefund) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayOrderMutation) EdgeCleared(name string) bool { + switch name { + case payorder.EdgeChannel: + return m.clearedchannel + case payorder.EdgeOrdersExtension: + return m.clearedorders_extension + case payorder.EdgeNotifyTask: + return m.clearednotify_task + case payorder.EdgeRefund: + return m.clearedrefund + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PayOrderMutation) ClearEdge(name string) error { + switch name { + case payorder.EdgeChannel: + m.ClearChannel() + return nil + } + return fmt.Errorf("unknown PayOrder unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PayOrderMutation) ResetEdge(name string) error { + switch name { + case payorder.EdgeChannel: + m.ResetChannel() + return nil + case payorder.EdgeOrdersExtension: + m.ResetOrdersExtension() + return nil + case payorder.EdgeNotifyTask: + m.ResetNotifyTask() + return nil + case payorder.EdgeRefund: + m.ResetRefund() + return nil + } + return fmt.Errorf("unknown PayOrder edge %s", name) +} + +// PayOrderExtensionMutation represents an operation that mutates the PayOrderExtension nodes in the graph. +type PayOrderExtensionMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + channel_extras *map[string]interface{} + channel_error_code *string + channel_error_msg *string + channel_notify_data *string + clearedFields map[string]struct{} + channel *uint64 + clearedchannel bool + _order *uint64 + cleared_order bool + done bool + oldValue func(context.Context) (*PayOrderExtension, error) + predicates []predicate.PayOrderExtension +} + +var _ ent.Mutation = (*PayOrderExtensionMutation)(nil) + +// payorderextensionOption allows management of the mutation configuration using functional options. +type payorderextensionOption func(*PayOrderExtensionMutation) + +// newPayOrderExtensionMutation creates new mutation for the PayOrderExtension entity. +func newPayOrderExtensionMutation(c config, op Op, opts ...payorderextensionOption) *PayOrderExtensionMutation { + m := &PayOrderExtensionMutation{ + config: c, + op: op, + typ: TypePayOrderExtension, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayOrderExtensionID sets the ID field of the mutation. +func withPayOrderExtensionID(id uint64) payorderextensionOption { + return func(m *PayOrderExtensionMutation) { + var ( + err error + once sync.Once + value *PayOrderExtension + ) + m.oldValue = func(ctx context.Context) (*PayOrderExtension, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayOrderExtension.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayOrderExtension sets the old PayOrderExtension of the mutation. +func withPayOrderExtension(node *PayOrderExtension) payorderextensionOption { + return func(m *PayOrderExtensionMutation) { + m.oldValue = func(context.Context) (*PayOrderExtension, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PayOrderExtensionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PayOrderExtensionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayOrderExtension entities. +func (m *PayOrderExtensionMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PayOrderExtensionMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayOrderExtensionMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayOrderExtension.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *PayOrderExtensionMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PayOrderExtensionMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PayOrderExtensionMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PayOrderExtensionMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PayOrderExtensionMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PayOrderExtensionMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *PayOrderExtensionMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *PayOrderExtensionMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *PayOrderExtensionMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PayOrderExtensionMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *PayOrderExtensionMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[payorderextension.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *PayOrderExtensionMutation) StatusCleared() bool { + _, ok := m.clearedFields[payorderextension.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *PayOrderExtensionMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, payorderextension.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *PayOrderExtensionMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *PayOrderExtensionMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *PayOrderExtensionMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *PayOrderExtensionMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *PayOrderExtensionMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PayOrderExtensionMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PayOrderExtensionMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PayOrderExtensionMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[payorderextension.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PayOrderExtensionMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[payorderextension.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PayOrderExtensionMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, payorderextension.FieldDeletedAt) +} + +// SetOrderID sets the "order_id" field. +func (m *PayOrderExtensionMutation) SetOrderID(u uint64) { + m._order = &u +} + +// OrderID returns the value of the "order_id" field in the mutation. +func (m *PayOrderExtensionMutation) OrderID() (r uint64, exists bool) { + v := m._order + if v == nil { + return + } + return *v, true +} + +// OldOrderID returns the old "order_id" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldOrderID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderID: %w", err) + } + return oldValue.OrderID, nil +} + +// ResetOrderID resets all changes to the "order_id" field. +func (m *PayOrderExtensionMutation) ResetOrderID() { + m._order = nil +} + +// SetChannelID sets the "channel_id" field. +func (m *PayOrderExtensionMutation) SetChannelID(u uint64) { + m.channel = &u +} + +// ChannelID returns the value of the "channel_id" field in the mutation. +func (m *PayOrderExtensionMutation) ChannelID() (r uint64, exists bool) { + v := m.channel + if v == nil { + return + } + return *v, true +} + +// OldChannelID returns the old "channel_id" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldChannelID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelID: %w", err) + } + return oldValue.ChannelID, nil +} + +// ResetChannelID resets all changes to the "channel_id" field. +func (m *PayOrderExtensionMutation) ResetChannelID() { + m.channel = nil +} + +// SetChannelExtras sets the "channel_extras" field. +func (m *PayOrderExtensionMutation) SetChannelExtras(value map[string]interface{}) { + m.channel_extras = &value +} + +// ChannelExtras returns the value of the "channel_extras" field in the mutation. +func (m *PayOrderExtensionMutation) ChannelExtras() (r map[string]interface{}, exists bool) { + v := m.channel_extras + if v == nil { + return + } + return *v, true +} + +// OldChannelExtras returns the old "channel_extras" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldChannelExtras(ctx context.Context) (v map[string]interface{}, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelExtras is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelExtras requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelExtras: %w", err) + } + return oldValue.ChannelExtras, nil +} + +// ClearChannelExtras clears the value of the "channel_extras" field. +func (m *PayOrderExtensionMutation) ClearChannelExtras() { + m.channel_extras = nil + m.clearedFields[payorderextension.FieldChannelExtras] = struct{}{} +} + +// ChannelExtrasCleared returns if the "channel_extras" field was cleared in this mutation. +func (m *PayOrderExtensionMutation) ChannelExtrasCleared() bool { + _, ok := m.clearedFields[payorderextension.FieldChannelExtras] + return ok +} + +// ResetChannelExtras resets all changes to the "channel_extras" field. +func (m *PayOrderExtensionMutation) ResetChannelExtras() { + m.channel_extras = nil + delete(m.clearedFields, payorderextension.FieldChannelExtras) +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (m *PayOrderExtensionMutation) SetChannelErrorCode(s string) { + m.channel_error_code = &s +} + +// ChannelErrorCode returns the value of the "channel_error_code" field in the mutation. +func (m *PayOrderExtensionMutation) ChannelErrorCode() (r string, exists bool) { + v := m.channel_error_code + if v == nil { + return + } + return *v, true +} + +// OldChannelErrorCode returns the old "channel_error_code" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldChannelErrorCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelErrorCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelErrorCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelErrorCode: %w", err) + } + return oldValue.ChannelErrorCode, nil +} + +// ClearChannelErrorCode clears the value of the "channel_error_code" field. +func (m *PayOrderExtensionMutation) ClearChannelErrorCode() { + m.channel_error_code = nil + m.clearedFields[payorderextension.FieldChannelErrorCode] = struct{}{} +} + +// ChannelErrorCodeCleared returns if the "channel_error_code" field was cleared in this mutation. +func (m *PayOrderExtensionMutation) ChannelErrorCodeCleared() bool { + _, ok := m.clearedFields[payorderextension.FieldChannelErrorCode] + return ok +} + +// ResetChannelErrorCode resets all changes to the "channel_error_code" field. +func (m *PayOrderExtensionMutation) ResetChannelErrorCode() { + m.channel_error_code = nil + delete(m.clearedFields, payorderextension.FieldChannelErrorCode) +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (m *PayOrderExtensionMutation) SetChannelErrorMsg(s string) { + m.channel_error_msg = &s +} + +// ChannelErrorMsg returns the value of the "channel_error_msg" field in the mutation. +func (m *PayOrderExtensionMutation) ChannelErrorMsg() (r string, exists bool) { + v := m.channel_error_msg + if v == nil { + return + } + return *v, true +} + +// OldChannelErrorMsg returns the old "channel_error_msg" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldChannelErrorMsg(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelErrorMsg is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelErrorMsg requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelErrorMsg: %w", err) + } + return oldValue.ChannelErrorMsg, nil +} + +// ClearChannelErrorMsg clears the value of the "channel_error_msg" field. +func (m *PayOrderExtensionMutation) ClearChannelErrorMsg() { + m.channel_error_msg = nil + m.clearedFields[payorderextension.FieldChannelErrorMsg] = struct{}{} +} + +// ChannelErrorMsgCleared returns if the "channel_error_msg" field was cleared in this mutation. +func (m *PayOrderExtensionMutation) ChannelErrorMsgCleared() bool { + _, ok := m.clearedFields[payorderextension.FieldChannelErrorMsg] + return ok +} + +// ResetChannelErrorMsg resets all changes to the "channel_error_msg" field. +func (m *PayOrderExtensionMutation) ResetChannelErrorMsg() { + m.channel_error_msg = nil + delete(m.clearedFields, payorderextension.FieldChannelErrorMsg) +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (m *PayOrderExtensionMutation) SetChannelNotifyData(s string) { + m.channel_notify_data = &s +} + +// ChannelNotifyData returns the value of the "channel_notify_data" field in the mutation. +func (m *PayOrderExtensionMutation) ChannelNotifyData() (r string, exists bool) { + v := m.channel_notify_data + if v == nil { + return + } + return *v, true +} + +// OldChannelNotifyData returns the old "channel_notify_data" field's value of the PayOrderExtension entity. +// If the PayOrderExtension object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayOrderExtensionMutation) OldChannelNotifyData(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelNotifyData is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelNotifyData requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelNotifyData: %w", err) + } + return oldValue.ChannelNotifyData, nil +} + +// ClearChannelNotifyData clears the value of the "channel_notify_data" field. +func (m *PayOrderExtensionMutation) ClearChannelNotifyData() { + m.channel_notify_data = nil + m.clearedFields[payorderextension.FieldChannelNotifyData] = struct{}{} +} + +// ChannelNotifyDataCleared returns if the "channel_notify_data" field was cleared in this mutation. +func (m *PayOrderExtensionMutation) ChannelNotifyDataCleared() bool { + _, ok := m.clearedFields[payorderextension.FieldChannelNotifyData] + return ok +} + +// ResetChannelNotifyData resets all changes to the "channel_notify_data" field. +func (m *PayOrderExtensionMutation) ResetChannelNotifyData() { + m.channel_notify_data = nil + delete(m.clearedFields, payorderextension.FieldChannelNotifyData) +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (m *PayOrderExtensionMutation) ClearChannel() { + m.clearedchannel = true + m.clearedFields[payorderextension.FieldChannelID] = struct{}{} +} + +// ChannelCleared reports if the "channel" edge to the PayChannel entity was cleared. +func (m *PayOrderExtensionMutation) ChannelCleared() bool { + return m.clearedchannel +} + +// ChannelIDs returns the "channel" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ChannelID instead. It exists only for internal usage by the builders. +func (m *PayOrderExtensionMutation) ChannelIDs() (ids []uint64) { + if id := m.channel; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetChannel resets all changes to the "channel" edge. +func (m *PayOrderExtensionMutation) ResetChannel() { + m.channel = nil + m.clearedchannel = false +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (m *PayOrderExtensionMutation) ClearOrder() { + m.cleared_order = true + m.clearedFields[payorderextension.FieldOrderID] = struct{}{} +} + +// OrderCleared reports if the "order" edge to the PayOrder entity was cleared. +func (m *PayOrderExtensionMutation) OrderCleared() bool { + return m.cleared_order +} + +// OrderIDs returns the "order" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OrderID instead. It exists only for internal usage by the builders. +func (m *PayOrderExtensionMutation) OrderIDs() (ids []uint64) { + if id := m._order; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOrder resets all changes to the "order" edge. +func (m *PayOrderExtensionMutation) ResetOrder() { + m._order = nil + m.cleared_order = false +} + +// Where appends a list predicates to the PayOrderExtensionMutation builder. +func (m *PayOrderExtensionMutation) Where(ps ...predicate.PayOrderExtension) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayOrderExtensionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayOrderExtensionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayOrderExtension, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayOrderExtensionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayOrderExtensionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayOrderExtension). +func (m *PayOrderExtensionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PayOrderExtensionMutation) Fields() []string { + fields := make([]string, 0, 11) + if m.created_at != nil { + fields = append(fields, payorderextension.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, payorderextension.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, payorderextension.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, payorderextension.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, payorderextension.FieldDeletedAt) + } + if m._order != nil { + fields = append(fields, payorderextension.FieldOrderID) + } + if m.channel != nil { + fields = append(fields, payorderextension.FieldChannelID) + } + if m.channel_extras != nil { + fields = append(fields, payorderextension.FieldChannelExtras) + } + if m.channel_error_code != nil { + fields = append(fields, payorderextension.FieldChannelErrorCode) + } + if m.channel_error_msg != nil { + fields = append(fields, payorderextension.FieldChannelErrorMsg) + } + if m.channel_notify_data != nil { + fields = append(fields, payorderextension.FieldChannelNotifyData) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PayOrderExtensionMutation) Field(name string) (ent.Value, bool) { + switch name { + case payorderextension.FieldCreatedAt: + return m.CreatedAt() + case payorderextension.FieldUpdatedAt: + return m.UpdatedAt() + case payorderextension.FieldStatus: + return m.Status() + case payorderextension.FieldTenantID: + return m.TenantID() + case payorderextension.FieldDeletedAt: + return m.DeletedAt() + case payorderextension.FieldOrderID: + return m.OrderID() + case payorderextension.FieldChannelID: + return m.ChannelID() + case payorderextension.FieldChannelExtras: + return m.ChannelExtras() + case payorderextension.FieldChannelErrorCode: + return m.ChannelErrorCode() + case payorderextension.FieldChannelErrorMsg: + return m.ChannelErrorMsg() + case payorderextension.FieldChannelNotifyData: + return m.ChannelNotifyData() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PayOrderExtensionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case payorderextension.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case payorderextension.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case payorderextension.FieldStatus: + return m.OldStatus(ctx) + case payorderextension.FieldTenantID: + return m.OldTenantID(ctx) + case payorderextension.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case payorderextension.FieldOrderID: + return m.OldOrderID(ctx) + case payorderextension.FieldChannelID: + return m.OldChannelID(ctx) + case payorderextension.FieldChannelExtras: + return m.OldChannelExtras(ctx) + case payorderextension.FieldChannelErrorCode: + return m.OldChannelErrorCode(ctx) + case payorderextension.FieldChannelErrorMsg: + return m.OldChannelErrorMsg(ctx) + case payorderextension.FieldChannelNotifyData: + return m.OldChannelNotifyData(ctx) + } + return nil, fmt.Errorf("unknown PayOrderExtension field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayOrderExtensionMutation) SetField(name string, value ent.Value) error { + switch name { + case payorderextension.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case payorderextension.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case payorderextension.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case payorderextension.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case payorderextension.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case payorderextension.FieldOrderID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderID(v) + return nil + case payorderextension.FieldChannelID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelID(v) + return nil + case payorderextension.FieldChannelExtras: + v, ok := value.(map[string]interface{}) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelExtras(v) + return nil + case payorderextension.FieldChannelErrorCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelErrorCode(v) + return nil + case payorderextension.FieldChannelErrorMsg: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelErrorMsg(v) + return nil + case payorderextension.FieldChannelNotifyData: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelNotifyData(v) + return nil + } + return fmt.Errorf("unknown PayOrderExtension field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayOrderExtensionMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, payorderextension.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, payorderextension.FieldTenantID) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PayOrderExtensionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case payorderextension.FieldStatus: + return m.AddedStatus() + case payorderextension.FieldTenantID: + return m.AddedTenantID() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayOrderExtensionMutation) AddField(name string, value ent.Value) error { + switch name { + case payorderextension.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case payorderextension.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + } + return fmt.Errorf("unknown PayOrderExtension numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayOrderExtensionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(payorderextension.FieldStatus) { + fields = append(fields, payorderextension.FieldStatus) + } + if m.FieldCleared(payorderextension.FieldDeletedAt) { + fields = append(fields, payorderextension.FieldDeletedAt) + } + if m.FieldCleared(payorderextension.FieldChannelExtras) { + fields = append(fields, payorderextension.FieldChannelExtras) + } + if m.FieldCleared(payorderextension.FieldChannelErrorCode) { + fields = append(fields, payorderextension.FieldChannelErrorCode) + } + if m.FieldCleared(payorderextension.FieldChannelErrorMsg) { + fields = append(fields, payorderextension.FieldChannelErrorMsg) + } + if m.FieldCleared(payorderextension.FieldChannelNotifyData) { + fields = append(fields, payorderextension.FieldChannelNotifyData) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayOrderExtensionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PayOrderExtensionMutation) ClearField(name string) error { + switch name { + case payorderextension.FieldStatus: + m.ClearStatus() + return nil + case payorderextension.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case payorderextension.FieldChannelExtras: + m.ClearChannelExtras() + return nil + case payorderextension.FieldChannelErrorCode: + m.ClearChannelErrorCode() + return nil + case payorderextension.FieldChannelErrorMsg: + m.ClearChannelErrorMsg() + return nil + case payorderextension.FieldChannelNotifyData: + m.ClearChannelNotifyData() + return nil + } + return fmt.Errorf("unknown PayOrderExtension nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PayOrderExtensionMutation) ResetField(name string) error { + switch name { + case payorderextension.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case payorderextension.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case payorderextension.FieldStatus: + m.ResetStatus() + return nil + case payorderextension.FieldTenantID: + m.ResetTenantID() + return nil + case payorderextension.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case payorderextension.FieldOrderID: + m.ResetOrderID() + return nil + case payorderextension.FieldChannelID: + m.ResetChannelID() + return nil + case payorderextension.FieldChannelExtras: + m.ResetChannelExtras() + return nil + case payorderextension.FieldChannelErrorCode: + m.ResetChannelErrorCode() + return nil + case payorderextension.FieldChannelErrorMsg: + m.ResetChannelErrorMsg() + return nil + case payorderextension.FieldChannelNotifyData: + m.ResetChannelNotifyData() + return nil + } + return fmt.Errorf("unknown PayOrderExtension field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayOrderExtensionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.channel != nil { + edges = append(edges, payorderextension.EdgeChannel) + } + if m._order != nil { + edges = append(edges, payorderextension.EdgeOrder) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayOrderExtensionMutation) AddedIDs(name string) []ent.Value { + switch name { + case payorderextension.EdgeChannel: + if id := m.channel; id != nil { + return []ent.Value{*id} + } + case payorderextension.EdgeOrder: + if id := m._order; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayOrderExtensionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayOrderExtensionMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayOrderExtensionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedchannel { + edges = append(edges, payorderextension.EdgeChannel) + } + if m.cleared_order { + edges = append(edges, payorderextension.EdgeOrder) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayOrderExtensionMutation) EdgeCleared(name string) bool { + switch name { + case payorderextension.EdgeChannel: + return m.clearedchannel + case payorderextension.EdgeOrder: + return m.cleared_order + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PayOrderExtensionMutation) ClearEdge(name string) error { + switch name { + case payorderextension.EdgeChannel: + m.ClearChannel() + return nil + case payorderextension.EdgeOrder: + m.ClearOrder() + return nil + } + return fmt.Errorf("unknown PayOrderExtension unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PayOrderExtensionMutation) ResetEdge(name string) error { + switch name { + case payorderextension.EdgeChannel: + m.ResetChannel() + return nil + case payorderextension.EdgeOrder: + m.ResetOrder() + return nil + } + return fmt.Errorf("unknown PayOrderExtension edge %s", name) +} + +// PayRefundMutation represents an operation that mutates the PayRefund nodes in the graph. +type PayRefundMutation struct { + config + op Op + typ string + id *uint64 + created_at *time.Time + updated_at *time.Time + status *uint8 + addstatus *int8 + tenant_id *uint64 + addtenant_id *int64 + deleted_at *time.Time + user_id *uint64 + adduser_id *int64 + notify_url *string + refund_status *uint8 + addrefund_status *int8 + refund_amount *uint64 + addrefund_amount *int64 + pay_amount *uint64 + addpay_amount *int64 + refund_no *string + refund_reason *string + user_ip *string + channel_refund_no *string + refund_time *time.Time + channel_error_code *string + channel_error_msg *string + channel_notify_data *string + clearedFields map[string]struct{} + _order *uint64 + cleared_order bool + channel *uint64 + clearedchannel bool + done bool + oldValue func(context.Context) (*PayRefund, error) + predicates []predicate.PayRefund +} + +var _ ent.Mutation = (*PayRefundMutation)(nil) + +// payrefundOption allows management of the mutation configuration using functional options. +type payrefundOption func(*PayRefundMutation) + +// newPayRefundMutation creates new mutation for the PayRefund entity. +func newPayRefundMutation(c config, op Op, opts ...payrefundOption) *PayRefundMutation { + m := &PayRefundMutation{ + config: c, + op: op, + typ: TypePayRefund, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPayRefundID sets the ID field of the mutation. +func withPayRefundID(id uint64) payrefundOption { + return func(m *PayRefundMutation) { + var ( + err error + once sync.Once + value *PayRefund + ) + m.oldValue = func(ctx context.Context) (*PayRefund, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PayRefund.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPayRefund sets the old PayRefund of the mutation. +func withPayRefund(node *PayRefund) payrefundOption { + return func(m *PayRefundMutation) { + m.oldValue = func(context.Context) (*PayRefund, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PayRefundMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PayRefundMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of PayRefund entities. +func (m *PayRefundMutation) SetID(id uint64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PayRefundMutation) ID() (id uint64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PayRefundMutation) IDs(ctx context.Context) ([]uint64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uint64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PayRefund.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreatedAt sets the "created_at" field. +func (m *PayRefundMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *PayRefundMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *PayRefundMutation) ResetCreatedAt() { + m.created_at = nil +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *PayRefundMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *PayRefundMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *PayRefundMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetStatus sets the "status" field. +func (m *PayRefundMutation) SetStatus(u uint8) { + m.status = &u + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *PayRefundMutation) Status() (r uint8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds u to the "status" field. +func (m *PayRefundMutation) AddStatus(u int8) { + if m.addstatus != nil { + *m.addstatus += u + } else { + m.addstatus = &u + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PayRefundMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ClearStatus clears the value of the "status" field. +func (m *PayRefundMutation) ClearStatus() { + m.status = nil + m.addstatus = nil + m.clearedFields[payrefund.FieldStatus] = struct{}{} +} + +// StatusCleared returns if the "status" field was cleared in this mutation. +func (m *PayRefundMutation) StatusCleared() bool { + _, ok := m.clearedFields[payrefund.FieldStatus] + return ok +} + +// ResetStatus resets all changes to the "status" field. +func (m *PayRefundMutation) ResetStatus() { + m.status = nil + m.addstatus = nil + delete(m.clearedFields, payrefund.FieldStatus) +} + +// SetTenantID sets the "tenant_id" field. +func (m *PayRefundMutation) SetTenantID(u uint64) { + m.tenant_id = &u + m.addtenant_id = nil +} + +// TenantID returns the value of the "tenant_id" field in the mutation. +func (m *PayRefundMutation) TenantID() (r uint64, exists bool) { + v := m.tenant_id + if v == nil { + return + } + return *v, true +} + +// OldTenantID returns the old "tenant_id" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldTenantID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTenantID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTenantID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTenantID: %w", err) + } + return oldValue.TenantID, nil +} + +// AddTenantID adds u to the "tenant_id" field. +func (m *PayRefundMutation) AddTenantID(u int64) { + if m.addtenant_id != nil { + *m.addtenant_id += u + } else { + m.addtenant_id = &u + } +} + +// AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. +func (m *PayRefundMutation) AddedTenantID() (r int64, exists bool) { + v := m.addtenant_id + if v == nil { + return + } + return *v, true +} + +// ResetTenantID resets all changes to the "tenant_id" field. +func (m *PayRefundMutation) ResetTenantID() { + m.tenant_id = nil + m.addtenant_id = nil +} + +// SetDeletedAt sets the "deleted_at" field. +func (m *PayRefundMutation) SetDeletedAt(t time.Time) { + m.deleted_at = &t +} + +// DeletedAt returns the value of the "deleted_at" field in the mutation. +func (m *PayRefundMutation) DeletedAt() (r time.Time, exists bool) { + v := m.deleted_at + if v == nil { + return + } + return *v, true +} + +// OldDeletedAt returns the old "deleted_at" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeletedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) + } + return oldValue.DeletedAt, nil +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (m *PayRefundMutation) ClearDeletedAt() { + m.deleted_at = nil + m.clearedFields[payrefund.FieldDeletedAt] = struct{}{} +} + +// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. +func (m *PayRefundMutation) DeletedAtCleared() bool { + _, ok := m.clearedFields[payrefund.FieldDeletedAt] + return ok +} + +// ResetDeletedAt resets all changes to the "deleted_at" field. +func (m *PayRefundMutation) ResetDeletedAt() { + m.deleted_at = nil + delete(m.clearedFields, payrefund.FieldDeletedAt) +} + +// SetChannelID sets the "channel_id" field. +func (m *PayRefundMutation) SetChannelID(u uint64) { + m.channel = &u +} + +// ChannelID returns the value of the "channel_id" field in the mutation. +func (m *PayRefundMutation) ChannelID() (r uint64, exists bool) { + v := m.channel + if v == nil { + return + } + return *v, true +} + +// OldChannelID returns the old "channel_id" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldChannelID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelID: %w", err) + } + return oldValue.ChannelID, nil +} + +// ResetChannelID resets all changes to the "channel_id" field. +func (m *PayRefundMutation) ResetChannelID() { + m.channel = nil +} + +// SetUserID sets the "user_id" field. +func (m *PayRefundMutation) SetUserID(u uint64) { + m.user_id = &u + m.adduser_id = nil +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *PayRefundMutation) UserID() (r uint64, exists bool) { + v := m.user_id + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldUserID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// AddUserID adds u to the "user_id" field. +func (m *PayRefundMutation) AddUserID(u int64) { + if m.adduser_id != nil { + *m.adduser_id += u + } else { + m.adduser_id = &u + } +} + +// AddedUserID returns the value that was added to the "user_id" field in this mutation. +func (m *PayRefundMutation) AddedUserID() (r int64, exists bool) { + v := m.adduser_id + if v == nil { + return + } + return *v, true +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *PayRefundMutation) ResetUserID() { + m.user_id = nil + m.adduser_id = nil +} + +// SetOrderID sets the "order_id" field. +func (m *PayRefundMutation) SetOrderID(u uint64) { + m._order = &u +} + +// OrderID returns the value of the "order_id" field in the mutation. +func (m *PayRefundMutation) OrderID() (r uint64, exists bool) { + v := m._order + if v == nil { + return + } + return *v, true +} + +// OldOrderID returns the old "order_id" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldOrderID(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderID: %w", err) + } + return oldValue.OrderID, nil +} + +// ResetOrderID resets all changes to the "order_id" field. +func (m *PayRefundMutation) ResetOrderID() { + m._order = nil +} + +// SetNotifyURL sets the "notify_url" field. +func (m *PayRefundMutation) SetNotifyURL(s string) { + m.notify_url = &s +} + +// NotifyURL returns the value of the "notify_url" field in the mutation. +func (m *PayRefundMutation) NotifyURL() (r string, exists bool) { + v := m.notify_url + if v == nil { + return + } + return *v, true +} + +// OldNotifyURL returns the old "notify_url" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldNotifyURL(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNotifyURL is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNotifyURL requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNotifyURL: %w", err) + } + return oldValue.NotifyURL, nil +} + +// ClearNotifyURL clears the value of the "notify_url" field. +func (m *PayRefundMutation) ClearNotifyURL() { + m.notify_url = nil + m.clearedFields[payrefund.FieldNotifyURL] = struct{}{} +} + +// NotifyURLCleared returns if the "notify_url" field was cleared in this mutation. +func (m *PayRefundMutation) NotifyURLCleared() bool { + _, ok := m.clearedFields[payrefund.FieldNotifyURL] + return ok +} + +// ResetNotifyURL resets all changes to the "notify_url" field. +func (m *PayRefundMutation) ResetNotifyURL() { + m.notify_url = nil + delete(m.clearedFields, payrefund.FieldNotifyURL) +} + +// SetRefundStatus sets the "refund_status" field. +func (m *PayRefundMutation) SetRefundStatus(u uint8) { + m.refund_status = &u + m.addrefund_status = nil +} + +// RefundStatus returns the value of the "refund_status" field in the mutation. +func (m *PayRefundMutation) RefundStatus() (r uint8, exists bool) { + v := m.refund_status + if v == nil { + return + } + return *v, true +} + +// OldRefundStatus returns the old "refund_status" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldRefundStatus(ctx context.Context) (v uint8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundStatus: %w", err) + } + return oldValue.RefundStatus, nil +} + +// AddRefundStatus adds u to the "refund_status" field. +func (m *PayRefundMutation) AddRefundStatus(u int8) { + if m.addrefund_status != nil { + *m.addrefund_status += u + } else { + m.addrefund_status = &u + } +} + +// AddedRefundStatus returns the value that was added to the "refund_status" field in this mutation. +func (m *PayRefundMutation) AddedRefundStatus() (r int8, exists bool) { + v := m.addrefund_status + if v == nil { + return + } + return *v, true +} + +// ResetRefundStatus resets all changes to the "refund_status" field. +func (m *PayRefundMutation) ResetRefundStatus() { + m.refund_status = nil + m.addrefund_status = nil +} + +// SetRefundAmount sets the "refund_amount" field. +func (m *PayRefundMutation) SetRefundAmount(u uint64) { + m.refund_amount = &u + m.addrefund_amount = nil +} + +// RefundAmount returns the value of the "refund_amount" field in the mutation. +func (m *PayRefundMutation) RefundAmount() (r uint64, exists bool) { + v := m.refund_amount + if v == nil { + return + } + return *v, true +} + +// OldRefundAmount returns the old "refund_amount" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldRefundAmount(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundAmount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundAmount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundAmount: %w", err) + } + return oldValue.RefundAmount, nil +} + +// AddRefundAmount adds u to the "refund_amount" field. +func (m *PayRefundMutation) AddRefundAmount(u int64) { + if m.addrefund_amount != nil { + *m.addrefund_amount += u + } else { + m.addrefund_amount = &u + } +} + +// AddedRefundAmount returns the value that was added to the "refund_amount" field in this mutation. +func (m *PayRefundMutation) AddedRefundAmount() (r int64, exists bool) { + v := m.addrefund_amount + if v == nil { + return + } + return *v, true +} + +// ResetRefundAmount resets all changes to the "refund_amount" field. +func (m *PayRefundMutation) ResetRefundAmount() { + m.refund_amount = nil + m.addrefund_amount = nil +} + +// SetPayAmount sets the "pay_amount" field. +func (m *PayRefundMutation) SetPayAmount(u uint64) { + m.pay_amount = &u + m.addpay_amount = nil +} + +// PayAmount returns the value of the "pay_amount" field in the mutation. +func (m *PayRefundMutation) PayAmount() (r uint64, exists bool) { + v := m.pay_amount + if v == nil { + return + } + return *v, true +} + +// OldPayAmount returns the old "pay_amount" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldPayAmount(ctx context.Context) (v uint64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPayAmount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPayAmount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPayAmount: %w", err) + } + return oldValue.PayAmount, nil +} + +// AddPayAmount adds u to the "pay_amount" field. +func (m *PayRefundMutation) AddPayAmount(u int64) { + if m.addpay_amount != nil { + *m.addpay_amount += u + } else { + m.addpay_amount = &u + } +} + +// AddedPayAmount returns the value that was added to the "pay_amount" field in this mutation. +func (m *PayRefundMutation) AddedPayAmount() (r int64, exists bool) { + v := m.addpay_amount + if v == nil { + return + } + return *v, true +} + +// ResetPayAmount resets all changes to the "pay_amount" field. +func (m *PayRefundMutation) ResetPayAmount() { + m.pay_amount = nil + m.addpay_amount = nil +} + +// SetRefundNo sets the "refund_no" field. +func (m *PayRefundMutation) SetRefundNo(s string) { + m.refund_no = &s +} + +// RefundNo returns the value of the "refund_no" field in the mutation. +func (m *PayRefundMutation) RefundNo() (r string, exists bool) { + v := m.refund_no + if v == nil { + return + } + return *v, true +} + +// OldRefundNo returns the old "refund_no" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldRefundNo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundNo: %w", err) + } + return oldValue.RefundNo, nil +} + +// ResetRefundNo resets all changes to the "refund_no" field. +func (m *PayRefundMutation) ResetRefundNo() { + m.refund_no = nil +} + +// SetRefundReason sets the "refund_reason" field. +func (m *PayRefundMutation) SetRefundReason(s string) { + m.refund_reason = &s +} + +// RefundReason returns the value of the "refund_reason" field in the mutation. +func (m *PayRefundMutation) RefundReason() (r string, exists bool) { + v := m.refund_reason + if v == nil { + return + } + return *v, true +} + +// OldRefundReason returns the old "refund_reason" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldRefundReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundReason: %w", err) + } + return oldValue.RefundReason, nil +} + +// ResetRefundReason resets all changes to the "refund_reason" field. +func (m *PayRefundMutation) ResetRefundReason() { + m.refund_reason = nil +} + +// SetUserIP sets the "user_ip" field. +func (m *PayRefundMutation) SetUserIP(s string) { + m.user_ip = &s +} + +// UserIP returns the value of the "user_ip" field in the mutation. +func (m *PayRefundMutation) UserIP() (r string, exists bool) { + v := m.user_ip + if v == nil { + return + } + return *v, true +} + +// OldUserIP returns the old "user_ip" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldUserIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserIP: %w", err) + } + return oldValue.UserIP, nil +} + +// ClearUserIP clears the value of the "user_ip" field. +func (m *PayRefundMutation) ClearUserIP() { + m.user_ip = nil + m.clearedFields[payrefund.FieldUserIP] = struct{}{} +} + +// UserIPCleared returns if the "user_ip" field was cleared in this mutation. +func (m *PayRefundMutation) UserIPCleared() bool { + _, ok := m.clearedFields[payrefund.FieldUserIP] + return ok +} + +// ResetUserIP resets all changes to the "user_ip" field. +func (m *PayRefundMutation) ResetUserIP() { + m.user_ip = nil + delete(m.clearedFields, payrefund.FieldUserIP) +} + +// SetChannelRefundNo sets the "channel_refund_no" field. +func (m *PayRefundMutation) SetChannelRefundNo(s string) { + m.channel_refund_no = &s +} + +// ChannelRefundNo returns the value of the "channel_refund_no" field in the mutation. +func (m *PayRefundMutation) ChannelRefundNo() (r string, exists bool) { + v := m.channel_refund_no + if v == nil { + return + } + return *v, true +} + +// OldChannelRefundNo returns the old "channel_refund_no" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldChannelRefundNo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelRefundNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelRefundNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelRefundNo: %w", err) + } + return oldValue.ChannelRefundNo, nil +} + +// ResetChannelRefundNo resets all changes to the "channel_refund_no" field. +func (m *PayRefundMutation) ResetChannelRefundNo() { + m.channel_refund_no = nil +} + +// SetRefundTime sets the "refund_time" field. +func (m *PayRefundMutation) SetRefundTime(t time.Time) { + m.refund_time = &t +} + +// RefundTime returns the value of the "refund_time" field in the mutation. +func (m *PayRefundMutation) RefundTime() (r time.Time, exists bool) { + v := m.refund_time + if v == nil { + return + } + return *v, true +} + +// OldRefundTime returns the old "refund_time" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldRefundTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefundTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefundTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefundTime: %w", err) + } + return oldValue.RefundTime, nil +} + +// ResetRefundTime resets all changes to the "refund_time" field. +func (m *PayRefundMutation) ResetRefundTime() { + m.refund_time = nil +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (m *PayRefundMutation) SetChannelErrorCode(s string) { + m.channel_error_code = &s +} + +// ChannelErrorCode returns the value of the "channel_error_code" field in the mutation. +func (m *PayRefundMutation) ChannelErrorCode() (r string, exists bool) { + v := m.channel_error_code + if v == nil { + return + } + return *v, true +} + +// OldChannelErrorCode returns the old "channel_error_code" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldChannelErrorCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelErrorCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelErrorCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelErrorCode: %w", err) + } + return oldValue.ChannelErrorCode, nil +} + +// ClearChannelErrorCode clears the value of the "channel_error_code" field. +func (m *PayRefundMutation) ClearChannelErrorCode() { + m.channel_error_code = nil + m.clearedFields[payrefund.FieldChannelErrorCode] = struct{}{} +} + +// ChannelErrorCodeCleared returns if the "channel_error_code" field was cleared in this mutation. +func (m *PayRefundMutation) ChannelErrorCodeCleared() bool { + _, ok := m.clearedFields[payrefund.FieldChannelErrorCode] + return ok +} + +// ResetChannelErrorCode resets all changes to the "channel_error_code" field. +func (m *PayRefundMutation) ResetChannelErrorCode() { + m.channel_error_code = nil + delete(m.clearedFields, payrefund.FieldChannelErrorCode) +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (m *PayRefundMutation) SetChannelErrorMsg(s string) { + m.channel_error_msg = &s +} + +// ChannelErrorMsg returns the value of the "channel_error_msg" field in the mutation. +func (m *PayRefundMutation) ChannelErrorMsg() (r string, exists bool) { + v := m.channel_error_msg + if v == nil { + return + } + return *v, true +} + +// OldChannelErrorMsg returns the old "channel_error_msg" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldChannelErrorMsg(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelErrorMsg is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelErrorMsg requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelErrorMsg: %w", err) + } + return oldValue.ChannelErrorMsg, nil +} + +// ClearChannelErrorMsg clears the value of the "channel_error_msg" field. +func (m *PayRefundMutation) ClearChannelErrorMsg() { + m.channel_error_msg = nil + m.clearedFields[payrefund.FieldChannelErrorMsg] = struct{}{} +} + +// ChannelErrorMsgCleared returns if the "channel_error_msg" field was cleared in this mutation. +func (m *PayRefundMutation) ChannelErrorMsgCleared() bool { + _, ok := m.clearedFields[payrefund.FieldChannelErrorMsg] + return ok +} + +// ResetChannelErrorMsg resets all changes to the "channel_error_msg" field. +func (m *PayRefundMutation) ResetChannelErrorMsg() { + m.channel_error_msg = nil + delete(m.clearedFields, payrefund.FieldChannelErrorMsg) +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (m *PayRefundMutation) SetChannelNotifyData(s string) { + m.channel_notify_data = &s +} + +// ChannelNotifyData returns the value of the "channel_notify_data" field in the mutation. +func (m *PayRefundMutation) ChannelNotifyData() (r string, exists bool) { + v := m.channel_notify_data + if v == nil { + return + } + return *v, true +} + +// OldChannelNotifyData returns the old "channel_notify_data" field's value of the PayRefund entity. +// If the PayRefund object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PayRefundMutation) OldChannelNotifyData(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChannelNotifyData is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChannelNotifyData requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChannelNotifyData: %w", err) + } + return oldValue.ChannelNotifyData, nil +} + +// ClearChannelNotifyData clears the value of the "channel_notify_data" field. +func (m *PayRefundMutation) ClearChannelNotifyData() { + m.channel_notify_data = nil + m.clearedFields[payrefund.FieldChannelNotifyData] = struct{}{} +} + +// ChannelNotifyDataCleared returns if the "channel_notify_data" field was cleared in this mutation. +func (m *PayRefundMutation) ChannelNotifyDataCleared() bool { + _, ok := m.clearedFields[payrefund.FieldChannelNotifyData] + return ok +} + +// ResetChannelNotifyData resets all changes to the "channel_notify_data" field. +func (m *PayRefundMutation) ResetChannelNotifyData() { + m.channel_notify_data = nil + delete(m.clearedFields, payrefund.FieldChannelNotifyData) +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (m *PayRefundMutation) ClearOrder() { + m.cleared_order = true + m.clearedFields[payrefund.FieldOrderID] = struct{}{} +} + +// OrderCleared reports if the "order" edge to the PayOrder entity was cleared. +func (m *PayRefundMutation) OrderCleared() bool { + return m.cleared_order +} + +// OrderIDs returns the "order" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// OrderID instead. It exists only for internal usage by the builders. +func (m *PayRefundMutation) OrderIDs() (ids []uint64) { + if id := m._order; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetOrder resets all changes to the "order" edge. +func (m *PayRefundMutation) ResetOrder() { + m._order = nil + m.cleared_order = false +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (m *PayRefundMutation) ClearChannel() { + m.clearedchannel = true + m.clearedFields[payrefund.FieldChannelID] = struct{}{} +} + +// ChannelCleared reports if the "channel" edge to the PayChannel entity was cleared. +func (m *PayRefundMutation) ChannelCleared() bool { + return m.clearedchannel +} + +// ChannelIDs returns the "channel" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ChannelID instead. It exists only for internal usage by the builders. +func (m *PayRefundMutation) ChannelIDs() (ids []uint64) { + if id := m.channel; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetChannel resets all changes to the "channel" edge. +func (m *PayRefundMutation) ResetChannel() { + m.channel = nil + m.clearedchannel = false +} + +// Where appends a list predicates to the PayRefundMutation builder. +func (m *PayRefundMutation) Where(ps ...predicate.PayRefund) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PayRefundMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PayRefundMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PayRefund, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PayRefundMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PayRefundMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PayRefund). +func (m *PayRefundMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PayRefundMutation) Fields() []string { + fields := make([]string, 0, 20) + if m.created_at != nil { + fields = append(fields, payrefund.FieldCreatedAt) + } + if m.updated_at != nil { + fields = append(fields, payrefund.FieldUpdatedAt) + } + if m.status != nil { + fields = append(fields, payrefund.FieldStatus) + } + if m.tenant_id != nil { + fields = append(fields, payrefund.FieldTenantID) + } + if m.deleted_at != nil { + fields = append(fields, payrefund.FieldDeletedAt) + } + if m.channel != nil { + fields = append(fields, payrefund.FieldChannelID) + } + if m.user_id != nil { + fields = append(fields, payrefund.FieldUserID) + } + if m._order != nil { + fields = append(fields, payrefund.FieldOrderID) + } + if m.notify_url != nil { + fields = append(fields, payrefund.FieldNotifyURL) + } + if m.refund_status != nil { + fields = append(fields, payrefund.FieldRefundStatus) + } + if m.refund_amount != nil { + fields = append(fields, payrefund.FieldRefundAmount) + } + if m.pay_amount != nil { + fields = append(fields, payrefund.FieldPayAmount) + } + if m.refund_no != nil { + fields = append(fields, payrefund.FieldRefundNo) + } + if m.refund_reason != nil { + fields = append(fields, payrefund.FieldRefundReason) + } + if m.user_ip != nil { + fields = append(fields, payrefund.FieldUserIP) + } + if m.channel_refund_no != nil { + fields = append(fields, payrefund.FieldChannelRefundNo) + } + if m.refund_time != nil { + fields = append(fields, payrefund.FieldRefundTime) + } + if m.channel_error_code != nil { + fields = append(fields, payrefund.FieldChannelErrorCode) + } + if m.channel_error_msg != nil { + fields = append(fields, payrefund.FieldChannelErrorMsg) + } + if m.channel_notify_data != nil { + fields = append(fields, payrefund.FieldChannelNotifyData) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PayRefundMutation) Field(name string) (ent.Value, bool) { + switch name { + case payrefund.FieldCreatedAt: + return m.CreatedAt() + case payrefund.FieldUpdatedAt: + return m.UpdatedAt() + case payrefund.FieldStatus: + return m.Status() + case payrefund.FieldTenantID: + return m.TenantID() + case payrefund.FieldDeletedAt: + return m.DeletedAt() + case payrefund.FieldChannelID: + return m.ChannelID() + case payrefund.FieldUserID: + return m.UserID() + case payrefund.FieldOrderID: + return m.OrderID() + case payrefund.FieldNotifyURL: + return m.NotifyURL() + case payrefund.FieldRefundStatus: + return m.RefundStatus() + case payrefund.FieldRefundAmount: + return m.RefundAmount() + case payrefund.FieldPayAmount: + return m.PayAmount() + case payrefund.FieldRefundNo: + return m.RefundNo() + case payrefund.FieldRefundReason: + return m.RefundReason() + case payrefund.FieldUserIP: + return m.UserIP() + case payrefund.FieldChannelRefundNo: + return m.ChannelRefundNo() + case payrefund.FieldRefundTime: + return m.RefundTime() + case payrefund.FieldChannelErrorCode: + return m.ChannelErrorCode() + case payrefund.FieldChannelErrorMsg: + return m.ChannelErrorMsg() + case payrefund.FieldChannelNotifyData: + return m.ChannelNotifyData() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PayRefundMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case payrefund.FieldCreatedAt: + return m.OldCreatedAt(ctx) + case payrefund.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case payrefund.FieldStatus: + return m.OldStatus(ctx) + case payrefund.FieldTenantID: + return m.OldTenantID(ctx) + case payrefund.FieldDeletedAt: + return m.OldDeletedAt(ctx) + case payrefund.FieldChannelID: + return m.OldChannelID(ctx) + case payrefund.FieldUserID: + return m.OldUserID(ctx) + case payrefund.FieldOrderID: + return m.OldOrderID(ctx) + case payrefund.FieldNotifyURL: + return m.OldNotifyURL(ctx) + case payrefund.FieldRefundStatus: + return m.OldRefundStatus(ctx) + case payrefund.FieldRefundAmount: + return m.OldRefundAmount(ctx) + case payrefund.FieldPayAmount: + return m.OldPayAmount(ctx) + case payrefund.FieldRefundNo: + return m.OldRefundNo(ctx) + case payrefund.FieldRefundReason: + return m.OldRefundReason(ctx) + case payrefund.FieldUserIP: + return m.OldUserIP(ctx) + case payrefund.FieldChannelRefundNo: + return m.OldChannelRefundNo(ctx) + case payrefund.FieldRefundTime: + return m.OldRefundTime(ctx) + case payrefund.FieldChannelErrorCode: + return m.OldChannelErrorCode(ctx) + case payrefund.FieldChannelErrorMsg: + return m.OldChannelErrorMsg(ctx) + case payrefund.FieldChannelNotifyData: + return m.OldChannelNotifyData(ctx) + } + return nil, fmt.Errorf("unknown PayRefund field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayRefundMutation) SetField(name string, value ent.Value) error { + switch name { + case payrefund.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + case payrefund.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case payrefund.FieldStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case payrefund.FieldTenantID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTenantID(v) + return nil + case payrefund.FieldDeletedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDeletedAt(v) + return nil + case payrefund.FieldChannelID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelID(v) + return nil + case payrefund.FieldUserID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case payrefund.FieldOrderID: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderID(v) + return nil + case payrefund.FieldNotifyURL: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNotifyURL(v) + return nil + case payrefund.FieldRefundStatus: + v, ok := value.(uint8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundStatus(v) + return nil + case payrefund.FieldRefundAmount: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundAmount(v) + return nil + case payrefund.FieldPayAmount: + v, ok := value.(uint64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPayAmount(v) + return nil + case payrefund.FieldRefundNo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundNo(v) + return nil + case payrefund.FieldRefundReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundReason(v) + return nil + case payrefund.FieldUserIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserIP(v) + return nil + case payrefund.FieldChannelRefundNo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelRefundNo(v) + return nil + case payrefund.FieldRefundTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefundTime(v) + return nil + case payrefund.FieldChannelErrorCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelErrorCode(v) + return nil + case payrefund.FieldChannelErrorMsg: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelErrorMsg(v) + return nil + case payrefund.FieldChannelNotifyData: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetChannelNotifyData(v) + return nil + } + return fmt.Errorf("unknown PayRefund field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PayRefundMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, payrefund.FieldStatus) + } + if m.addtenant_id != nil { + fields = append(fields, payrefund.FieldTenantID) + } + if m.adduser_id != nil { + fields = append(fields, payrefund.FieldUserID) + } + if m.addrefund_status != nil { + fields = append(fields, payrefund.FieldRefundStatus) + } + if m.addrefund_amount != nil { + fields = append(fields, payrefund.FieldRefundAmount) + } + if m.addpay_amount != nil { + fields = append(fields, payrefund.FieldPayAmount) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PayRefundMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case payrefund.FieldStatus: + return m.AddedStatus() + case payrefund.FieldTenantID: + return m.AddedTenantID() + case payrefund.FieldUserID: + return m.AddedUserID() + case payrefund.FieldRefundStatus: + return m.AddedRefundStatus() + case payrefund.FieldRefundAmount: + return m.AddedRefundAmount() + case payrefund.FieldPayAmount: + return m.AddedPayAmount() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PayRefundMutation) AddField(name string, value ent.Value) error { + switch name { + case payrefund.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case payrefund.FieldTenantID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddTenantID(v) + return nil + case payrefund.FieldUserID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUserID(v) + return nil + case payrefund.FieldRefundStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRefundStatus(v) + return nil + case payrefund.FieldRefundAmount: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddRefundAmount(v) + return nil + case payrefund.FieldPayAmount: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddPayAmount(v) + return nil + } + return fmt.Errorf("unknown PayRefund numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PayRefundMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(payrefund.FieldStatus) { + fields = append(fields, payrefund.FieldStatus) + } + if m.FieldCleared(payrefund.FieldDeletedAt) { + fields = append(fields, payrefund.FieldDeletedAt) + } + if m.FieldCleared(payrefund.FieldNotifyURL) { + fields = append(fields, payrefund.FieldNotifyURL) + } + if m.FieldCleared(payrefund.FieldUserIP) { + fields = append(fields, payrefund.FieldUserIP) + } + if m.FieldCleared(payrefund.FieldChannelErrorCode) { + fields = append(fields, payrefund.FieldChannelErrorCode) + } + if m.FieldCleared(payrefund.FieldChannelErrorMsg) { + fields = append(fields, payrefund.FieldChannelErrorMsg) + } + if m.FieldCleared(payrefund.FieldChannelNotifyData) { + fields = append(fields, payrefund.FieldChannelNotifyData) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PayRefundMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PayRefundMutation) ClearField(name string) error { + switch name { + case payrefund.FieldStatus: + m.ClearStatus() + return nil + case payrefund.FieldDeletedAt: + m.ClearDeletedAt() + return nil + case payrefund.FieldNotifyURL: + m.ClearNotifyURL() + return nil + case payrefund.FieldUserIP: + m.ClearUserIP() + return nil + case payrefund.FieldChannelErrorCode: + m.ClearChannelErrorCode() + return nil + case payrefund.FieldChannelErrorMsg: + m.ClearChannelErrorMsg() + return nil + case payrefund.FieldChannelNotifyData: + m.ClearChannelNotifyData() + return nil + } + return fmt.Errorf("unknown PayRefund nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PayRefundMutation) ResetField(name string) error { + switch name { + case payrefund.FieldCreatedAt: + m.ResetCreatedAt() + return nil + case payrefund.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case payrefund.FieldStatus: + m.ResetStatus() + return nil + case payrefund.FieldTenantID: + m.ResetTenantID() + return nil + case payrefund.FieldDeletedAt: + m.ResetDeletedAt() + return nil + case payrefund.FieldChannelID: + m.ResetChannelID() + return nil + case payrefund.FieldUserID: + m.ResetUserID() + return nil + case payrefund.FieldOrderID: + m.ResetOrderID() + return nil + case payrefund.FieldNotifyURL: + m.ResetNotifyURL() + return nil + case payrefund.FieldRefundStatus: + m.ResetRefundStatus() + return nil + case payrefund.FieldRefundAmount: + m.ResetRefundAmount() + return nil + case payrefund.FieldPayAmount: + m.ResetPayAmount() + return nil + case payrefund.FieldRefundNo: + m.ResetRefundNo() + return nil + case payrefund.FieldRefundReason: + m.ResetRefundReason() + return nil + case payrefund.FieldUserIP: + m.ResetUserIP() + return nil + case payrefund.FieldChannelRefundNo: + m.ResetChannelRefundNo() + return nil + case payrefund.FieldRefundTime: + m.ResetRefundTime() + return nil + case payrefund.FieldChannelErrorCode: + m.ResetChannelErrorCode() + return nil + case payrefund.FieldChannelErrorMsg: + m.ResetChannelErrorMsg() + return nil + case payrefund.FieldChannelNotifyData: + m.ResetChannelNotifyData() + return nil + } + return fmt.Errorf("unknown PayRefund field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PayRefundMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m._order != nil { + edges = append(edges, payrefund.EdgeOrder) + } + if m.channel != nil { + edges = append(edges, payrefund.EdgeChannel) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PayRefundMutation) AddedIDs(name string) []ent.Value { + switch name { + case payrefund.EdgeOrder: + if id := m._order; id != nil { + return []ent.Value{*id} + } + case payrefund.EdgeChannel: + if id := m.channel; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PayRefundMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PayRefundMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PayRefundMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleared_order { + edges = append(edges, payrefund.EdgeOrder) + } + if m.clearedchannel { + edges = append(edges, payrefund.EdgeChannel) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PayRefundMutation) EdgeCleared(name string) bool { + switch name { + case payrefund.EdgeOrder: + return m.cleared_order + case payrefund.EdgeChannel: + return m.clearedchannel + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PayRefundMutation) ClearEdge(name string) error { + switch name { + case payrefund.EdgeOrder: + m.ClearOrder() + return nil + case payrefund.EdgeChannel: + m.ClearChannel() + return nil + } + return fmt.Errorf("unknown PayRefund unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PayRefundMutation) ResetEdge(name string) error { + switch name { + case payrefund.EdgeOrder: + m.ResetOrder() + return nil + case payrefund.EdgeChannel: + m.ResetChannel() + return nil + } + return fmt.Errorf("unknown PayRefund edge %s", name) +} diff --git a/rpc/ent/pagination.go b/rpc/ent/pagination.go new file mode 100644 index 0000000..49a18b3 --- /dev/null +++ b/rpc/ent/pagination.go @@ -0,0 +1,628 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" +) + +const errInvalidPage = "INVALID_PAGE" + +const ( + listField = "list" + pageNumField = "pageNum" + pageSizeField = "pageSize" +) + +type PageDetails struct { + Page uint64 `json:"page"` + Size uint64 `json:"size"` + Total uint64 `json:"total"` +} + +// OrderDirection defines the directions in which to order a list of items. +type OrderDirection string + +const ( + // OrderDirectionAsc specifies an ascending order. + OrderDirectionAsc OrderDirection = "ASC" + // OrderDirectionDesc specifies a descending order. + OrderDirectionDesc OrderDirection = "DESC" +) + +// Validate the order direction value. +func (o OrderDirection) Validate() error { + if o != OrderDirectionAsc && o != OrderDirectionDesc { + return fmt.Errorf("%s is not a valid OrderDirection", o) + } + return nil +} + +// String implements fmt.Stringer interface. +func (o OrderDirection) String() string { + return string(o) +} + +func (o OrderDirection) reverse() OrderDirection { + if o == OrderDirectionDesc { + return OrderDirectionAsc + } + return OrderDirectionDesc +} + +const errInvalidPagination = "INVALID_PAGINATION" + +type AppPager struct { + Order app.OrderOption + Filter func(*AppQuery) (*AppQuery, error) +} + +// AppPaginateOption enables pagination customization. +type AppPaginateOption func(*AppPager) + +// DefaultAppOrder is the default ordering of App. +var DefaultAppOrder = Desc(app.FieldID) + +func newAppPager(opts []AppPaginateOption) (*AppPager, error) { + pager := &AppPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultAppOrder + } + return pager, nil +} + +func (p *AppPager) ApplyFilter(query *AppQuery) (*AppQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// AppPageList is App PageList result. +type AppPageList struct { + List []*App `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *AppQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...AppPaginateOption, +) (*AppPageList, error) { + + pager, err := newAppPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &AppPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultAppOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type PayChannelPager struct { + Order paychannel.OrderOption + Filter func(*PayChannelQuery) (*PayChannelQuery, error) +} + +// PayChannelPaginateOption enables pagination customization. +type PayChannelPaginateOption func(*PayChannelPager) + +// DefaultPayChannelOrder is the default ordering of PayChannel. +var DefaultPayChannelOrder = Desc(paychannel.FieldID) + +func newPayChannelPager(opts []PayChannelPaginateOption) (*PayChannelPager, error) { + pager := &PayChannelPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultPayChannelOrder + } + return pager, nil +} + +func (p *PayChannelPager) ApplyFilter(query *PayChannelQuery) (*PayChannelQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// PayChannelPageList is PayChannel PageList result. +type PayChannelPageList struct { + List []*PayChannel `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *PayChannelQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...PayChannelPaginateOption, +) (*PayChannelPageList, error) { + + pager, err := newPayChannelPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &PayChannelPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultPayChannelOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type PayNotifyLogPager struct { + Order paynotifylog.OrderOption + Filter func(*PayNotifyLogQuery) (*PayNotifyLogQuery, error) +} + +// PayNotifyLogPaginateOption enables pagination customization. +type PayNotifyLogPaginateOption func(*PayNotifyLogPager) + +// DefaultPayNotifyLogOrder is the default ordering of PayNotifyLog. +var DefaultPayNotifyLogOrder = Desc(paynotifylog.FieldID) + +func newPayNotifyLogPager(opts []PayNotifyLogPaginateOption) (*PayNotifyLogPager, error) { + pager := &PayNotifyLogPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultPayNotifyLogOrder + } + return pager, nil +} + +func (p *PayNotifyLogPager) ApplyFilter(query *PayNotifyLogQuery) (*PayNotifyLogQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// PayNotifyLogPageList is PayNotifyLog PageList result. +type PayNotifyLogPageList struct { + List []*PayNotifyLog `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *PayNotifyLogQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...PayNotifyLogPaginateOption, +) (*PayNotifyLogPageList, error) { + + pager, err := newPayNotifyLogPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &PayNotifyLogPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultPayNotifyLogOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type PayNotifyTaskPager struct { + Order paynotifytask.OrderOption + Filter func(*PayNotifyTaskQuery) (*PayNotifyTaskQuery, error) +} + +// PayNotifyTaskPaginateOption enables pagination customization. +type PayNotifyTaskPaginateOption func(*PayNotifyTaskPager) + +// DefaultPayNotifyTaskOrder is the default ordering of PayNotifyTask. +var DefaultPayNotifyTaskOrder = Desc(paynotifytask.FieldID) + +func newPayNotifyTaskPager(opts []PayNotifyTaskPaginateOption) (*PayNotifyTaskPager, error) { + pager := &PayNotifyTaskPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultPayNotifyTaskOrder + } + return pager, nil +} + +func (p *PayNotifyTaskPager) ApplyFilter(query *PayNotifyTaskQuery) (*PayNotifyTaskQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// PayNotifyTaskPageList is PayNotifyTask PageList result. +type PayNotifyTaskPageList struct { + List []*PayNotifyTask `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *PayNotifyTaskQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...PayNotifyTaskPaginateOption, +) (*PayNotifyTaskPageList, error) { + + pager, err := newPayNotifyTaskPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &PayNotifyTaskPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultPayNotifyTaskOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type PayOrderPager struct { + Order payorder.OrderOption + Filter func(*PayOrderQuery) (*PayOrderQuery, error) +} + +// PayOrderPaginateOption enables pagination customization. +type PayOrderPaginateOption func(*PayOrderPager) + +// DefaultPayOrderOrder is the default ordering of PayOrder. +var DefaultPayOrderOrder = Desc(payorder.FieldID) + +func newPayOrderPager(opts []PayOrderPaginateOption) (*PayOrderPager, error) { + pager := &PayOrderPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultPayOrderOrder + } + return pager, nil +} + +func (p *PayOrderPager) ApplyFilter(query *PayOrderQuery) (*PayOrderQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// PayOrderPageList is PayOrder PageList result. +type PayOrderPageList struct { + List []*PayOrder `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *PayOrderQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...PayOrderPaginateOption, +) (*PayOrderPageList, error) { + + pager, err := newPayOrderPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &PayOrderPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultPayOrderOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type PayOrderExtensionPager struct { + Order payorderextension.OrderOption + Filter func(*PayOrderExtensionQuery) (*PayOrderExtensionQuery, error) +} + +// PayOrderExtensionPaginateOption enables pagination customization. +type PayOrderExtensionPaginateOption func(*PayOrderExtensionPager) + +// DefaultPayOrderExtensionOrder is the default ordering of PayOrderExtension. +var DefaultPayOrderExtensionOrder = Desc(payorderextension.FieldID) + +func newPayOrderExtensionPager(opts []PayOrderExtensionPaginateOption) (*PayOrderExtensionPager, error) { + pager := &PayOrderExtensionPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultPayOrderExtensionOrder + } + return pager, nil +} + +func (p *PayOrderExtensionPager) ApplyFilter(query *PayOrderExtensionQuery) (*PayOrderExtensionQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// PayOrderExtensionPageList is PayOrderExtension PageList result. +type PayOrderExtensionPageList struct { + List []*PayOrderExtension `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *PayOrderExtensionQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...PayOrderExtensionPaginateOption, +) (*PayOrderExtensionPageList, error) { + + pager, err := newPayOrderExtensionPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &PayOrderExtensionPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultPayOrderExtensionOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} + +type PayRefundPager struct { + Order payrefund.OrderOption + Filter func(*PayRefundQuery) (*PayRefundQuery, error) +} + +// PayRefundPaginateOption enables pagination customization. +type PayRefundPaginateOption func(*PayRefundPager) + +// DefaultPayRefundOrder is the default ordering of PayRefund. +var DefaultPayRefundOrder = Desc(payrefund.FieldID) + +func newPayRefundPager(opts []PayRefundPaginateOption) (*PayRefundPager, error) { + pager := &PayRefundPager{} + for _, opt := range opts { + opt(pager) + } + if pager.Order == nil { + pager.Order = DefaultPayRefundOrder + } + return pager, nil +} + +func (p *PayRefundPager) ApplyFilter(query *PayRefundQuery) (*PayRefundQuery, error) { + if p.Filter != nil { + return p.Filter(query) + } + return query, nil +} + +// PayRefundPageList is PayRefund PageList result. +type PayRefundPageList struct { + List []*PayRefund `json:"list"` + PageDetails *PageDetails `json:"pageDetails"` +} + +func (_m *PayRefundQuery) Page( + ctx context.Context, pageNum uint64, pageSize uint64, opts ...PayRefundPaginateOption, +) (*PayRefundPageList, error) { + + pager, err := newPayRefundPager(opts) + if err != nil { + return nil, err + } + + if _m, err = pager.ApplyFilter(_m); err != nil { + return nil, err + } + + ret := &PayRefundPageList{} + + ret.PageDetails = &PageDetails{ + Page: pageNum, + Size: pageSize, + } + + query := _m.Clone() + query.ctx.Fields = nil + count, err := query.Count(ctx) + + if err != nil { + return nil, err + } + + ret.PageDetails.Total = uint64(count) + + if pager.Order != nil { + _m = _m.Order(pager.Order) + } else { + _m = _m.Order(DefaultPayRefundOrder) + } + + _m = _m.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize)) + list, err := _m.All(ctx) + if err != nil { + return nil, err + } + ret.List = list + + return ret, nil +} diff --git a/rpc/ent/paychannel.go b/rpc/ent/paychannel.go new file mode 100644 index 0000000..7664948 --- /dev/null +++ b/rpc/ent/paychannel.go @@ -0,0 +1,342 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayChannel Table | 支付渠道表 +type PayChannel struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Pay channel code | 支付渠道编码 + Code string `json:"code,omitempty"` + // Pay channel name | 支付渠道英文名称 + NameEn string `json:"name_en,omitempty"` + // Pay channel name | 支付渠道中文名称 + NameZh string `json:"name_zh,omitempty"` + // Free rate | 手续费比例 + FreeRate string `json:"free_rate,omitempty"` + // App ID | 应用ID + AppID uint64 `json:"app_id,omitempty"` + // Config | 配置信息 + Config map[string]interface{} `json:"config,omitempty"` + // Remark | 备注 + Remake string `json:"remake,omitempty"` + // Icon | 图标 + Icon uint64 `json:"icon,omitempty"` + // Order time out | 订单超时时间 + OrderTimeOut string `json:"order_time_out,omitempty"` + // Support currency | 支持币种 + SupportCurrency string `json:"support_currency,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PayChannelQuery when eager-loading is set. + Edges PayChannelEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PayChannelEdges holds the relations/edges for other nodes in the graph. +type PayChannelEdges struct { + // Orders holds the value of the orders edge. + Orders []*PayOrder `json:"orders,omitempty"` + // OrdersExtension holds the value of the orders_extension edge. + OrdersExtension []*PayOrderExtension `json:"orders_extension,omitempty"` + // Refund holds the value of the refund edge. + Refund []*PayRefund `json:"refund,omitempty"` + // App holds the value of the app edge. + App *App `json:"app,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// OrdersOrErr returns the Orders value or an error if the edge +// was not loaded in eager-loading. +func (e PayChannelEdges) OrdersOrErr() ([]*PayOrder, error) { + if e.loadedTypes[0] { + return e.Orders, nil + } + return nil, &NotLoadedError{edge: "orders"} +} + +// OrdersExtensionOrErr returns the OrdersExtension value or an error if the edge +// was not loaded in eager-loading. +func (e PayChannelEdges) OrdersExtensionOrErr() ([]*PayOrderExtension, error) { + if e.loadedTypes[1] { + return e.OrdersExtension, nil + } + return nil, &NotLoadedError{edge: "orders_extension"} +} + +// RefundOrErr returns the Refund value or an error if the edge +// was not loaded in eager-loading. +func (e PayChannelEdges) RefundOrErr() ([]*PayRefund, error) { + if e.loadedTypes[2] { + return e.Refund, nil + } + return nil, &NotLoadedError{edge: "refund"} +} + +// AppOrErr returns the App value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayChannelEdges) AppOrErr() (*App, error) { + if e.App != nil { + return e.App, nil + } else if e.loadedTypes[3] { + return nil, &NotFoundError{label: app.Label} + } + return nil, &NotLoadedError{edge: "app"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PayChannel) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case paychannel.FieldConfig: + values[i] = new([]byte) + case paychannel.FieldID, paychannel.FieldStatus, paychannel.FieldTenantID, paychannel.FieldAppID, paychannel.FieldIcon: + values[i] = new(sql.NullInt64) + case paychannel.FieldCode, paychannel.FieldNameEn, paychannel.FieldNameZh, paychannel.FieldFreeRate, paychannel.FieldRemake, paychannel.FieldOrderTimeOut, paychannel.FieldSupportCurrency: + values[i] = new(sql.NullString) + case paychannel.FieldCreatedAt, paychannel.FieldUpdatedAt, paychannel.FieldDeletedAt: + 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 PayChannel fields. +func (_m *PayChannel) 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 paychannel.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case paychannel.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 paychannel.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 + } + case paychannel.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case paychannel.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case paychannel.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case paychannel.FieldCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field code", values[i]) + } else if value.Valid { + _m.Code = value.String + } + case paychannel.FieldNameEn: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name_en", values[i]) + } else if value.Valid { + _m.NameEn = value.String + } + case paychannel.FieldNameZh: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name_zh", values[i]) + } else if value.Valid { + _m.NameZh = value.String + } + case paychannel.FieldFreeRate: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field free_rate", values[i]) + } else if value.Valid { + _m.FreeRate = value.String + } + case paychannel.FieldAppID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field app_id", values[i]) + } else if value.Valid { + _m.AppID = uint64(value.Int64) + } + case paychannel.FieldConfig: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field config", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.Config); err != nil { + return fmt.Errorf("unmarshal field config: %w", err) + } + } + case paychannel.FieldRemake: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field remake", values[i]) + } else if value.Valid { + _m.Remake = value.String + } + case paychannel.FieldIcon: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field icon", values[i]) + } else if value.Valid { + _m.Icon = uint64(value.Int64) + } + case paychannel.FieldOrderTimeOut: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field order_time_out", values[i]) + } else if value.Valid { + _m.OrderTimeOut = value.String + } + case paychannel.FieldSupportCurrency: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field support_currency", values[i]) + } else if value.Valid { + _m.SupportCurrency = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PayChannel. +// This includes values selected through modifiers, order, etc. +func (_m *PayChannel) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryOrders queries the "orders" edge of the PayChannel entity. +func (_m *PayChannel) QueryOrders() *PayOrderQuery { + return NewPayChannelClient(_m.config).QueryOrders(_m) +} + +// QueryOrdersExtension queries the "orders_extension" edge of the PayChannel entity. +func (_m *PayChannel) QueryOrdersExtension() *PayOrderExtensionQuery { + return NewPayChannelClient(_m.config).QueryOrdersExtension(_m) +} + +// QueryRefund queries the "refund" edge of the PayChannel entity. +func (_m *PayChannel) QueryRefund() *PayRefundQuery { + return NewPayChannelClient(_m.config).QueryRefund(_m) +} + +// QueryApp queries the "app" edge of the PayChannel entity. +func (_m *PayChannel) QueryApp() *AppQuery { + return NewPayChannelClient(_m.config).QueryApp(_m) +} + +// Update returns a builder for updating this PayChannel. +// Note that you need to call PayChannel.Unwrap() before calling this method if this PayChannel +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PayChannel) Update() *PayChannelUpdateOne { + return NewPayChannelClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PayChannel 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 *PayChannel) Unwrap() *PayChannel { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PayChannel is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PayChannel) String() string { + var builder strings.Builder + builder.WriteString("PayChannel(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + 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.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("code=") + builder.WriteString(_m.Code) + builder.WriteString(", ") + builder.WriteString("name_en=") + builder.WriteString(_m.NameEn) + builder.WriteString(", ") + builder.WriteString("name_zh=") + builder.WriteString(_m.NameZh) + builder.WriteString(", ") + builder.WriteString("free_rate=") + builder.WriteString(_m.FreeRate) + builder.WriteString(", ") + builder.WriteString("app_id=") + builder.WriteString(fmt.Sprintf("%v", _m.AppID)) + builder.WriteString(", ") + builder.WriteString("config=") + builder.WriteString(fmt.Sprintf("%v", _m.Config)) + builder.WriteString(", ") + builder.WriteString("remake=") + builder.WriteString(_m.Remake) + builder.WriteString(", ") + builder.WriteString("icon=") + builder.WriteString(fmt.Sprintf("%v", _m.Icon)) + builder.WriteString(", ") + builder.WriteString("order_time_out=") + builder.WriteString(_m.OrderTimeOut) + builder.WriteString(", ") + builder.WriteString("support_currency=") + builder.WriteString(_m.SupportCurrency) + builder.WriteByte(')') + return builder.String() +} + +// PayChannels is a parsable slice of PayChannel. +type PayChannels []*PayChannel diff --git a/rpc/ent/paychannel/paychannel.go b/rpc/ent/paychannel/paychannel.go new file mode 100644 index 0000000..539e1c0 --- /dev/null +++ b/rpc/ent/paychannel/paychannel.go @@ -0,0 +1,289 @@ +// Code generated by ent, DO NOT EDIT. + +package paychannel + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the paychannel type in the database. + Label = "pay_channel" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // 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" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldCode holds the string denoting the code field in the database. + FieldCode = "code" + // FieldNameEn holds the string denoting the name_en field in the database. + FieldNameEn = "name_en" + // FieldNameZh holds the string denoting the name_zh field in the database. + FieldNameZh = "name_zh" + // FieldFreeRate holds the string denoting the free_rate field in the database. + FieldFreeRate = "free_rate" + // FieldAppID holds the string denoting the app_id field in the database. + FieldAppID = "app_id" + // FieldConfig holds the string denoting the config field in the database. + FieldConfig = "config" + // FieldRemake holds the string denoting the remake field in the database. + FieldRemake = "remake" + // FieldIcon holds the string denoting the icon field in the database. + FieldIcon = "icon" + // FieldOrderTimeOut holds the string denoting the order_time_out field in the database. + FieldOrderTimeOut = "order_time_out" + // FieldSupportCurrency holds the string denoting the support_currency field in the database. + FieldSupportCurrency = "support_currency" + // EdgeOrders holds the string denoting the orders edge name in mutations. + EdgeOrders = "orders" + // EdgeOrdersExtension holds the string denoting the orders_extension edge name in mutations. + EdgeOrdersExtension = "orders_extension" + // EdgeRefund holds the string denoting the refund edge name in mutations. + EdgeRefund = "refund" + // EdgeApp holds the string denoting the app edge name in mutations. + EdgeApp = "app" + // Table holds the table name of the paychannel in the database. + Table = "pay_channel" + // OrdersTable is the table that holds the orders relation/edge. + OrdersTable = "pay_order" + // OrdersInverseTable is the table name for the PayOrder entity. + // It exists in this package in order to avoid circular dependency with the "payorder" package. + OrdersInverseTable = "pay_order" + // OrdersColumn is the table column denoting the orders relation/edge. + OrdersColumn = "channel_id" + // OrdersExtensionTable is the table that holds the orders_extension relation/edge. + OrdersExtensionTable = "pay_order_extension" + // OrdersExtensionInverseTable is the table name for the PayOrderExtension entity. + // It exists in this package in order to avoid circular dependency with the "payorderextension" package. + OrdersExtensionInverseTable = "pay_order_extension" + // OrdersExtensionColumn is the table column denoting the orders_extension relation/edge. + OrdersExtensionColumn = "channel_id" + // RefundTable is the table that holds the refund relation/edge. + RefundTable = "pay_refund" + // RefundInverseTable is the table name for the PayRefund entity. + // It exists in this package in order to avoid circular dependency with the "payrefund" package. + RefundInverseTable = "pay_refund" + // RefundColumn is the table column denoting the refund relation/edge. + RefundColumn = "channel_id" + // AppTable is the table that holds the app relation/edge. + AppTable = "pay_channel" + // AppInverseTable is the table name for the App entity. + // It exists in this package in order to avoid circular dependency with the "app" package. + AppInverseTable = "pay_app" + // AppColumn is the table column denoting the app relation/edge. + AppColumn = "app_id" +) + +// Columns holds all SQL columns for paychannel fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldCode, + FieldNameEn, + FieldNameZh, + FieldFreeRate, + FieldAppID, + FieldConfig, + FieldRemake, + FieldIcon, + FieldOrderTimeOut, + FieldSupportCurrency, +} + +// 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 ( + // 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 + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // DefaultFreeRate holds the default value on creation for the "free_rate" field. + DefaultFreeRate string + // DefaultOrderTimeOut holds the default value on creation for the "order_time_out" field. + DefaultOrderTimeOut string + // DefaultSupportCurrency holds the default value on creation for the "support_currency" field. + DefaultSupportCurrency string +) + +// OrderOption defines the ordering options for the PayChannel 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() +} + +// 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() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByCode orders the results by the code field. +func ByCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCode, opts...).ToFunc() +} + +// ByNameEn orders the results by the name_en field. +func ByNameEn(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNameEn, opts...).ToFunc() +} + +// ByNameZh orders the results by the name_zh field. +func ByNameZh(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNameZh, opts...).ToFunc() +} + +// ByFreeRate orders the results by the free_rate field. +func ByFreeRate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFreeRate, opts...).ToFunc() +} + +// ByAppID orders the results by the app_id field. +func ByAppID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAppID, opts...).ToFunc() +} + +// ByRemake orders the results by the remake field. +func ByRemake(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRemake, opts...).ToFunc() +} + +// ByIcon orders the results by the icon field. +func ByIcon(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIcon, opts...).ToFunc() +} + +// ByOrderTimeOut orders the results by the order_time_out field. +func ByOrderTimeOut(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderTimeOut, opts...).ToFunc() +} + +// BySupportCurrency orders the results by the support_currency field. +func BySupportCurrency(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSupportCurrency, opts...).ToFunc() +} + +// ByOrdersCount orders the results by orders count. +func ByOrdersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newOrdersStep(), opts...) + } +} + +// ByOrders orders the results by orders terms. +func ByOrders(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOrdersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByOrdersExtensionCount orders the results by orders_extension count. +func ByOrdersExtensionCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newOrdersExtensionStep(), opts...) + } +} + +// ByOrdersExtension orders the results by orders_extension terms. +func ByOrdersExtension(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOrdersExtensionStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByRefundCount orders the results by refund count. +func ByRefundCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRefundStep(), opts...) + } +} + +// ByRefund orders the results by refund terms. +func ByRefund(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRefundStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByAppField orders the results by app field. +func ByAppField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newAppStep(), sql.OrderByField(field, opts...)) + } +} +func newOrdersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OrdersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, OrdersTable, OrdersColumn), + ) +} +func newOrdersExtensionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OrdersExtensionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, OrdersExtensionTable, OrdersExtensionColumn), + ) +} +func newRefundStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RefundInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RefundTable, RefundColumn), + ) +} +func newAppStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(AppInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, AppTable, AppColumn), + ) +} diff --git a/rpc/ent/paychannel/where.go b/rpc/ent/paychannel/where.go new file mode 100644 index 0000000..46b2b97 --- /dev/null +++ b/rpc/ent/paychannel/where.go @@ -0,0 +1,988 @@ +// Code generated by ent, DO NOT EDIT. + +package paychannel + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PayChannel { + return predicate.PayChannel(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.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldDeletedAt, v)) +} + +// Code applies equality check predicate on the "code" field. It's identical to CodeEQ. +func Code(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldCode, v)) +} + +// NameEn applies equality check predicate on the "name_en" field. It's identical to NameEnEQ. +func NameEn(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldNameEn, v)) +} + +// NameZh applies equality check predicate on the "name_zh" field. It's identical to NameZhEQ. +func NameZh(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldNameZh, v)) +} + +// FreeRate applies equality check predicate on the "free_rate" field. It's identical to FreeRateEQ. +func FreeRate(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldFreeRate, v)) +} + +// AppID applies equality check predicate on the "app_id" field. It's identical to AppIDEQ. +func AppID(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldAppID, v)) +} + +// Remake applies equality check predicate on the "remake" field. It's identical to RemakeEQ. +func Remake(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldRemake, v)) +} + +// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. +func Icon(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldIcon, v)) +} + +// OrderTimeOut applies equality check predicate on the "order_time_out" field. It's identical to OrderTimeOutEQ. +func OrderTimeOut(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldOrderTimeOut, v)) +} + +// SupportCurrency applies equality check predicate on the "support_currency" field. It's identical to SupportCurrencyEQ. +func SupportCurrency(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldSupportCurrency, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotNull(FieldDeletedAt)) +} + +// CodeEQ applies the EQ predicate on the "code" field. +func CodeEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldCode, v)) +} + +// CodeNEQ applies the NEQ predicate on the "code" field. +func CodeNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldCode, v)) +} + +// CodeIn applies the In predicate on the "code" field. +func CodeIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldCode, vs...)) +} + +// CodeNotIn applies the NotIn predicate on the "code" field. +func CodeNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldCode, vs...)) +} + +// CodeGT applies the GT predicate on the "code" field. +func CodeGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldCode, v)) +} + +// CodeGTE applies the GTE predicate on the "code" field. +func CodeGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldCode, v)) +} + +// CodeLT applies the LT predicate on the "code" field. +func CodeLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldCode, v)) +} + +// CodeLTE applies the LTE predicate on the "code" field. +func CodeLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldCode, v)) +} + +// CodeContains applies the Contains predicate on the "code" field. +func CodeContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldCode, v)) +} + +// CodeHasPrefix applies the HasPrefix predicate on the "code" field. +func CodeHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldCode, v)) +} + +// CodeHasSuffix applies the HasSuffix predicate on the "code" field. +func CodeHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldCode, v)) +} + +// CodeEqualFold applies the EqualFold predicate on the "code" field. +func CodeEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldCode, v)) +} + +// CodeContainsFold applies the ContainsFold predicate on the "code" field. +func CodeContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldCode, v)) +} + +// NameEnEQ applies the EQ predicate on the "name_en" field. +func NameEnEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldNameEn, v)) +} + +// NameEnNEQ applies the NEQ predicate on the "name_en" field. +func NameEnNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldNameEn, v)) +} + +// NameEnIn applies the In predicate on the "name_en" field. +func NameEnIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldNameEn, vs...)) +} + +// NameEnNotIn applies the NotIn predicate on the "name_en" field. +func NameEnNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldNameEn, vs...)) +} + +// NameEnGT applies the GT predicate on the "name_en" field. +func NameEnGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldNameEn, v)) +} + +// NameEnGTE applies the GTE predicate on the "name_en" field. +func NameEnGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldNameEn, v)) +} + +// NameEnLT applies the LT predicate on the "name_en" field. +func NameEnLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldNameEn, v)) +} + +// NameEnLTE applies the LTE predicate on the "name_en" field. +func NameEnLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldNameEn, v)) +} + +// NameEnContains applies the Contains predicate on the "name_en" field. +func NameEnContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldNameEn, v)) +} + +// NameEnHasPrefix applies the HasPrefix predicate on the "name_en" field. +func NameEnHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldNameEn, v)) +} + +// NameEnHasSuffix applies the HasSuffix predicate on the "name_en" field. +func NameEnHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldNameEn, v)) +} + +// NameEnEqualFold applies the EqualFold predicate on the "name_en" field. +func NameEnEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldNameEn, v)) +} + +// NameEnContainsFold applies the ContainsFold predicate on the "name_en" field. +func NameEnContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldNameEn, v)) +} + +// NameZhEQ applies the EQ predicate on the "name_zh" field. +func NameZhEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldNameZh, v)) +} + +// NameZhNEQ applies the NEQ predicate on the "name_zh" field. +func NameZhNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldNameZh, v)) +} + +// NameZhIn applies the In predicate on the "name_zh" field. +func NameZhIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldNameZh, vs...)) +} + +// NameZhNotIn applies the NotIn predicate on the "name_zh" field. +func NameZhNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldNameZh, vs...)) +} + +// NameZhGT applies the GT predicate on the "name_zh" field. +func NameZhGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldNameZh, v)) +} + +// NameZhGTE applies the GTE predicate on the "name_zh" field. +func NameZhGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldNameZh, v)) +} + +// NameZhLT applies the LT predicate on the "name_zh" field. +func NameZhLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldNameZh, v)) +} + +// NameZhLTE applies the LTE predicate on the "name_zh" field. +func NameZhLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldNameZh, v)) +} + +// NameZhContains applies the Contains predicate on the "name_zh" field. +func NameZhContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldNameZh, v)) +} + +// NameZhHasPrefix applies the HasPrefix predicate on the "name_zh" field. +func NameZhHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldNameZh, v)) +} + +// NameZhHasSuffix applies the HasSuffix predicate on the "name_zh" field. +func NameZhHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldNameZh, v)) +} + +// NameZhEqualFold applies the EqualFold predicate on the "name_zh" field. +func NameZhEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldNameZh, v)) +} + +// NameZhContainsFold applies the ContainsFold predicate on the "name_zh" field. +func NameZhContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldNameZh, v)) +} + +// FreeRateEQ applies the EQ predicate on the "free_rate" field. +func FreeRateEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldFreeRate, v)) +} + +// FreeRateNEQ applies the NEQ predicate on the "free_rate" field. +func FreeRateNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldFreeRate, v)) +} + +// FreeRateIn applies the In predicate on the "free_rate" field. +func FreeRateIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldFreeRate, vs...)) +} + +// FreeRateNotIn applies the NotIn predicate on the "free_rate" field. +func FreeRateNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldFreeRate, vs...)) +} + +// FreeRateGT applies the GT predicate on the "free_rate" field. +func FreeRateGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldFreeRate, v)) +} + +// FreeRateGTE applies the GTE predicate on the "free_rate" field. +func FreeRateGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldFreeRate, v)) +} + +// FreeRateLT applies the LT predicate on the "free_rate" field. +func FreeRateLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldFreeRate, v)) +} + +// FreeRateLTE applies the LTE predicate on the "free_rate" field. +func FreeRateLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldFreeRate, v)) +} + +// FreeRateContains applies the Contains predicate on the "free_rate" field. +func FreeRateContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldFreeRate, v)) +} + +// FreeRateHasPrefix applies the HasPrefix predicate on the "free_rate" field. +func FreeRateHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldFreeRate, v)) +} + +// FreeRateHasSuffix applies the HasSuffix predicate on the "free_rate" field. +func FreeRateHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldFreeRate, v)) +} + +// FreeRateEqualFold applies the EqualFold predicate on the "free_rate" field. +func FreeRateEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldFreeRate, v)) +} + +// FreeRateContainsFold applies the ContainsFold predicate on the "free_rate" field. +func FreeRateContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldFreeRate, v)) +} + +// AppIDEQ applies the EQ predicate on the "app_id" field. +func AppIDEQ(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldAppID, v)) +} + +// AppIDNEQ applies the NEQ predicate on the "app_id" field. +func AppIDNEQ(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldAppID, v)) +} + +// AppIDIn applies the In predicate on the "app_id" field. +func AppIDIn(vs ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldAppID, vs...)) +} + +// AppIDNotIn applies the NotIn predicate on the "app_id" field. +func AppIDNotIn(vs ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldAppID, vs...)) +} + +// RemakeEQ applies the EQ predicate on the "remake" field. +func RemakeEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldRemake, v)) +} + +// RemakeNEQ applies the NEQ predicate on the "remake" field. +func RemakeNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldRemake, v)) +} + +// RemakeIn applies the In predicate on the "remake" field. +func RemakeIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldRemake, vs...)) +} + +// RemakeNotIn applies the NotIn predicate on the "remake" field. +func RemakeNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldRemake, vs...)) +} + +// RemakeGT applies the GT predicate on the "remake" field. +func RemakeGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldRemake, v)) +} + +// RemakeGTE applies the GTE predicate on the "remake" field. +func RemakeGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldRemake, v)) +} + +// RemakeLT applies the LT predicate on the "remake" field. +func RemakeLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldRemake, v)) +} + +// RemakeLTE applies the LTE predicate on the "remake" field. +func RemakeLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldRemake, v)) +} + +// RemakeContains applies the Contains predicate on the "remake" field. +func RemakeContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldRemake, v)) +} + +// RemakeHasPrefix applies the HasPrefix predicate on the "remake" field. +func RemakeHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldRemake, v)) +} + +// RemakeHasSuffix applies the HasSuffix predicate on the "remake" field. +func RemakeHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldRemake, v)) +} + +// RemakeIsNil applies the IsNil predicate on the "remake" field. +func RemakeIsNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldIsNull(FieldRemake)) +} + +// RemakeNotNil applies the NotNil predicate on the "remake" field. +func RemakeNotNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotNull(FieldRemake)) +} + +// RemakeEqualFold applies the EqualFold predicate on the "remake" field. +func RemakeEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldRemake, v)) +} + +// RemakeContainsFold applies the ContainsFold predicate on the "remake" field. +func RemakeContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldRemake, v)) +} + +// IconEQ applies the EQ predicate on the "icon" field. +func IconEQ(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldIcon, v)) +} + +// IconNEQ applies the NEQ predicate on the "icon" field. +func IconNEQ(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldIcon, v)) +} + +// IconIn applies the In predicate on the "icon" field. +func IconIn(vs ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldIcon, vs...)) +} + +// IconNotIn applies the NotIn predicate on the "icon" field. +func IconNotIn(vs ...uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldIcon, vs...)) +} + +// IconGT applies the GT predicate on the "icon" field. +func IconGT(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldIcon, v)) +} + +// IconGTE applies the GTE predicate on the "icon" field. +func IconGTE(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldIcon, v)) +} + +// IconLT applies the LT predicate on the "icon" field. +func IconLT(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldIcon, v)) +} + +// IconLTE applies the LTE predicate on the "icon" field. +func IconLTE(v uint64) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldIcon, v)) +} + +// IconIsNil applies the IsNil predicate on the "icon" field. +func IconIsNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldIsNull(FieldIcon)) +} + +// IconNotNil applies the NotNil predicate on the "icon" field. +func IconNotNil() predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotNull(FieldIcon)) +} + +// OrderTimeOutEQ applies the EQ predicate on the "order_time_out" field. +func OrderTimeOutEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldOrderTimeOut, v)) +} + +// OrderTimeOutNEQ applies the NEQ predicate on the "order_time_out" field. +func OrderTimeOutNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldOrderTimeOut, v)) +} + +// OrderTimeOutIn applies the In predicate on the "order_time_out" field. +func OrderTimeOutIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldOrderTimeOut, vs...)) +} + +// OrderTimeOutNotIn applies the NotIn predicate on the "order_time_out" field. +func OrderTimeOutNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldOrderTimeOut, vs...)) +} + +// OrderTimeOutGT applies the GT predicate on the "order_time_out" field. +func OrderTimeOutGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldOrderTimeOut, v)) +} + +// OrderTimeOutGTE applies the GTE predicate on the "order_time_out" field. +func OrderTimeOutGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldOrderTimeOut, v)) +} + +// OrderTimeOutLT applies the LT predicate on the "order_time_out" field. +func OrderTimeOutLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldOrderTimeOut, v)) +} + +// OrderTimeOutLTE applies the LTE predicate on the "order_time_out" field. +func OrderTimeOutLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldOrderTimeOut, v)) +} + +// OrderTimeOutContains applies the Contains predicate on the "order_time_out" field. +func OrderTimeOutContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldOrderTimeOut, v)) +} + +// OrderTimeOutHasPrefix applies the HasPrefix predicate on the "order_time_out" field. +func OrderTimeOutHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldOrderTimeOut, v)) +} + +// OrderTimeOutHasSuffix applies the HasSuffix predicate on the "order_time_out" field. +func OrderTimeOutHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldOrderTimeOut, v)) +} + +// OrderTimeOutEqualFold applies the EqualFold predicate on the "order_time_out" field. +func OrderTimeOutEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldOrderTimeOut, v)) +} + +// OrderTimeOutContainsFold applies the ContainsFold predicate on the "order_time_out" field. +func OrderTimeOutContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldOrderTimeOut, v)) +} + +// SupportCurrencyEQ applies the EQ predicate on the "support_currency" field. +func SupportCurrencyEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEQ(FieldSupportCurrency, v)) +} + +// SupportCurrencyNEQ applies the NEQ predicate on the "support_currency" field. +func SupportCurrencyNEQ(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNEQ(FieldSupportCurrency, v)) +} + +// SupportCurrencyIn applies the In predicate on the "support_currency" field. +func SupportCurrencyIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldIn(FieldSupportCurrency, vs...)) +} + +// SupportCurrencyNotIn applies the NotIn predicate on the "support_currency" field. +func SupportCurrencyNotIn(vs ...string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldNotIn(FieldSupportCurrency, vs...)) +} + +// SupportCurrencyGT applies the GT predicate on the "support_currency" field. +func SupportCurrencyGT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGT(FieldSupportCurrency, v)) +} + +// SupportCurrencyGTE applies the GTE predicate on the "support_currency" field. +func SupportCurrencyGTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldGTE(FieldSupportCurrency, v)) +} + +// SupportCurrencyLT applies the LT predicate on the "support_currency" field. +func SupportCurrencyLT(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLT(FieldSupportCurrency, v)) +} + +// SupportCurrencyLTE applies the LTE predicate on the "support_currency" field. +func SupportCurrencyLTE(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldLTE(FieldSupportCurrency, v)) +} + +// SupportCurrencyContains applies the Contains predicate on the "support_currency" field. +func SupportCurrencyContains(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContains(FieldSupportCurrency, v)) +} + +// SupportCurrencyHasPrefix applies the HasPrefix predicate on the "support_currency" field. +func SupportCurrencyHasPrefix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasPrefix(FieldSupportCurrency, v)) +} + +// SupportCurrencyHasSuffix applies the HasSuffix predicate on the "support_currency" field. +func SupportCurrencyHasSuffix(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldHasSuffix(FieldSupportCurrency, v)) +} + +// SupportCurrencyEqualFold applies the EqualFold predicate on the "support_currency" field. +func SupportCurrencyEqualFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldEqualFold(FieldSupportCurrency, v)) +} + +// SupportCurrencyContainsFold applies the ContainsFold predicate on the "support_currency" field. +func SupportCurrencyContainsFold(v string) predicate.PayChannel { + return predicate.PayChannel(sql.FieldContainsFold(FieldSupportCurrency, v)) +} + +// HasOrders applies the HasEdge predicate on the "orders" edge. +func HasOrders() predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, OrdersTable, OrdersColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOrdersWith applies the HasEdge predicate on the "orders" edge with a given conditions (other predicates). +func HasOrdersWith(preds ...predicate.PayOrder) predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := newOrdersStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasOrdersExtension applies the HasEdge predicate on the "orders_extension" edge. +func HasOrdersExtension() predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, OrdersExtensionTable, OrdersExtensionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOrdersExtensionWith applies the HasEdge predicate on the "orders_extension" edge with a given conditions (other predicates). +func HasOrdersExtensionWith(preds ...predicate.PayOrderExtension) predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := newOrdersExtensionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRefund applies the HasEdge predicate on the "refund" edge. +func HasRefund() predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RefundTable, RefundColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRefundWith applies the HasEdge predicate on the "refund" edge with a given conditions (other predicates). +func HasRefundWith(preds ...predicate.PayRefund) predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := newRefundStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasApp applies the HasEdge predicate on the "app" edge. +func HasApp() predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, AppTable, AppColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasAppWith applies the HasEdge predicate on the "app" edge with a given conditions (other predicates). +func HasAppWith(preds ...predicate.App) predicate.PayChannel { + return predicate.PayChannel(func(s *sql.Selector) { + step := newAppStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PayChannel) predicate.PayChannel { + return predicate.PayChannel(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PayChannel) predicate.PayChannel { + return predicate.PayChannel(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PayChannel) predicate.PayChannel { + return predicate.PayChannel(sql.NotPredicates(p)) +} diff --git a/rpc/ent/paychannel_create.go b/rpc/ent/paychannel_create.go new file mode 100644 index 0000000..c18bb78 --- /dev/null +++ b/rpc/ent/paychannel_create.go @@ -0,0 +1,598 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayChannelCreate is the builder for creating a PayChannel entity. +type PayChannelCreate struct { + config + mutation *PayChannelMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *PayChannelCreate) SetCreatedAt(v time.Time) *PayChannelCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableCreatedAt(v *time.Time) *PayChannelCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *PayChannelCreate) SetUpdatedAt(v time.Time) *PayChannelCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableUpdatedAt(v *time.Time) *PayChannelCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *PayChannelCreate) SetStatus(v uint8) *PayChannelCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableStatus(v *uint8) *PayChannelCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *PayChannelCreate) SetTenantID(v uint64) *PayChannelCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableTenantID(v *uint64) *PayChannelCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *PayChannelCreate) SetDeletedAt(v time.Time) *PayChannelCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableDeletedAt(v *time.Time) *PayChannelCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetCode sets the "code" field. +func (_c *PayChannelCreate) SetCode(v string) *PayChannelCreate { + _c.mutation.SetCode(v) + return _c +} + +// SetNameEn sets the "name_en" field. +func (_c *PayChannelCreate) SetNameEn(v string) *PayChannelCreate { + _c.mutation.SetNameEn(v) + return _c +} + +// SetNameZh sets the "name_zh" field. +func (_c *PayChannelCreate) SetNameZh(v string) *PayChannelCreate { + _c.mutation.SetNameZh(v) + return _c +} + +// SetFreeRate sets the "free_rate" field. +func (_c *PayChannelCreate) SetFreeRate(v string) *PayChannelCreate { + _c.mutation.SetFreeRate(v) + return _c +} + +// SetNillableFreeRate sets the "free_rate" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableFreeRate(v *string) *PayChannelCreate { + if v != nil { + _c.SetFreeRate(*v) + } + return _c +} + +// SetAppID sets the "app_id" field. +func (_c *PayChannelCreate) SetAppID(v uint64) *PayChannelCreate { + _c.mutation.SetAppID(v) + return _c +} + +// SetConfig sets the "config" field. +func (_c *PayChannelCreate) SetConfig(v map[string]interface{}) *PayChannelCreate { + _c.mutation.SetConfig(v) + return _c +} + +// SetRemake sets the "remake" field. +func (_c *PayChannelCreate) SetRemake(v string) *PayChannelCreate { + _c.mutation.SetRemake(v) + return _c +} + +// SetNillableRemake sets the "remake" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableRemake(v *string) *PayChannelCreate { + if v != nil { + _c.SetRemake(*v) + } + return _c +} + +// SetIcon sets the "icon" field. +func (_c *PayChannelCreate) SetIcon(v uint64) *PayChannelCreate { + _c.mutation.SetIcon(v) + return _c +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableIcon(v *uint64) *PayChannelCreate { + if v != nil { + _c.SetIcon(*v) + } + return _c +} + +// SetOrderTimeOut sets the "order_time_out" field. +func (_c *PayChannelCreate) SetOrderTimeOut(v string) *PayChannelCreate { + _c.mutation.SetOrderTimeOut(v) + return _c +} + +// SetNillableOrderTimeOut sets the "order_time_out" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableOrderTimeOut(v *string) *PayChannelCreate { + if v != nil { + _c.SetOrderTimeOut(*v) + } + return _c +} + +// SetSupportCurrency sets the "support_currency" field. +func (_c *PayChannelCreate) SetSupportCurrency(v string) *PayChannelCreate { + _c.mutation.SetSupportCurrency(v) + return _c +} + +// SetNillableSupportCurrency sets the "support_currency" field if the given value is not nil. +func (_c *PayChannelCreate) SetNillableSupportCurrency(v *string) *PayChannelCreate { + if v != nil { + _c.SetSupportCurrency(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PayChannelCreate) SetID(v uint64) *PayChannelCreate { + _c.mutation.SetID(v) + return _c +} + +// AddOrderIDs adds the "orders" edge to the PayOrder entity by IDs. +func (_c *PayChannelCreate) AddOrderIDs(ids ...uint64) *PayChannelCreate { + _c.mutation.AddOrderIDs(ids...) + return _c +} + +// AddOrders adds the "orders" edges to the PayOrder entity. +func (_c *PayChannelCreate) AddOrders(v ...*PayOrder) *PayChannelCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddOrderIDs(ids...) +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (_c *PayChannelCreate) AddOrdersExtensionIDs(ids ...uint64) *PayChannelCreate { + _c.mutation.AddOrdersExtensionIDs(ids...) + return _c +} + +// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity. +func (_c *PayChannelCreate) AddOrdersExtension(v ...*PayOrderExtension) *PayChannelCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddOrdersExtensionIDs(ids...) +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs. +func (_c *PayChannelCreate) AddRefundIDs(ids ...uint64) *PayChannelCreate { + _c.mutation.AddRefundIDs(ids...) + return _c +} + +// AddRefund adds the "refund" edges to the PayRefund entity. +func (_c *PayChannelCreate) AddRefund(v ...*PayRefund) *PayChannelCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddRefundIDs(ids...) +} + +// SetApp sets the "app" edge to the App entity. +func (_c *PayChannelCreate) SetApp(v *App) *PayChannelCreate { + return _c.SetAppID(v.ID) +} + +// Mutation returns the PayChannelMutation object of the builder. +func (_c *PayChannelCreate) Mutation() *PayChannelMutation { + return _c.mutation +} + +// Save creates the PayChannel in the database. +func (_c *PayChannelCreate) Save(ctx context.Context) (*PayChannel, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PayChannelCreate) SaveX(ctx context.Context) *PayChannel { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayChannelCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayChannelCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PayChannelCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := paychannel.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := paychannel.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := paychannel.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := paychannel.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.FreeRate(); !ok { + v := paychannel.DefaultFreeRate + _c.mutation.SetFreeRate(v) + } + if _, ok := _c.mutation.OrderTimeOut(); !ok { + v := paychannel.DefaultOrderTimeOut + _c.mutation.SetOrderTimeOut(v) + } + if _, ok := _c.mutation.SupportCurrency(); !ok { + v := paychannel.DefaultSupportCurrency + _c.mutation.SetSupportCurrency(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PayChannelCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayChannel.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayChannel.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayChannel.tenant_id"`)} + } + if _, ok := _c.mutation.Code(); !ok { + return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "PayChannel.code"`)} + } + if _, ok := _c.mutation.NameEn(); !ok { + return &ValidationError{Name: "name_en", err: errors.New(`ent: missing required field "PayChannel.name_en"`)} + } + if _, ok := _c.mutation.NameZh(); !ok { + return &ValidationError{Name: "name_zh", err: errors.New(`ent: missing required field "PayChannel.name_zh"`)} + } + if _, ok := _c.mutation.FreeRate(); !ok { + return &ValidationError{Name: "free_rate", err: errors.New(`ent: missing required field "PayChannel.free_rate"`)} + } + if _, ok := _c.mutation.AppID(); !ok { + return &ValidationError{Name: "app_id", err: errors.New(`ent: missing required field "PayChannel.app_id"`)} + } + if _, ok := _c.mutation.Config(); !ok { + return &ValidationError{Name: "config", err: errors.New(`ent: missing required field "PayChannel.config"`)} + } + if _, ok := _c.mutation.OrderTimeOut(); !ok { + return &ValidationError{Name: "order_time_out", err: errors.New(`ent: missing required field "PayChannel.order_time_out"`)} + } + if _, ok := _c.mutation.SupportCurrency(); !ok { + return &ValidationError{Name: "support_currency", err: errors.New(`ent: missing required field "PayChannel.support_currency"`)} + } + if len(_c.mutation.AppIDs()) == 0 { + return &ValidationError{Name: "app", err: errors.New(`ent: missing required edge "PayChannel.app"`)} + } + return nil +} + +func (_c *PayChannelCreate) sqlSave(ctx context.Context) (*PayChannel, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PayChannelCreate) createSpec() (*PayChannel, *sqlgraph.CreateSpec) { + var ( + _node = &PayChannel{config: _c.config} + _spec = sqlgraph.NewCreateSpec(paychannel.Table, sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(paychannel.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(paychannel.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(paychannel.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(paychannel.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(paychannel.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.Code(); ok { + _spec.SetField(paychannel.FieldCode, field.TypeString, value) + _node.Code = value + } + if value, ok := _c.mutation.NameEn(); ok { + _spec.SetField(paychannel.FieldNameEn, field.TypeString, value) + _node.NameEn = value + } + if value, ok := _c.mutation.NameZh(); ok { + _spec.SetField(paychannel.FieldNameZh, field.TypeString, value) + _node.NameZh = value + } + if value, ok := _c.mutation.FreeRate(); ok { + _spec.SetField(paychannel.FieldFreeRate, field.TypeString, value) + _node.FreeRate = value + } + if value, ok := _c.mutation.Config(); ok { + _spec.SetField(paychannel.FieldConfig, field.TypeJSON, value) + _node.Config = value + } + if value, ok := _c.mutation.Remake(); ok { + _spec.SetField(paychannel.FieldRemake, field.TypeString, value) + _node.Remake = value + } + if value, ok := _c.mutation.Icon(); ok { + _spec.SetField(paychannel.FieldIcon, field.TypeUint64, value) + _node.Icon = value + } + if value, ok := _c.mutation.OrderTimeOut(); ok { + _spec.SetField(paychannel.FieldOrderTimeOut, field.TypeString, value) + _node.OrderTimeOut = value + } + if value, ok := _c.mutation.SupportCurrency(); ok { + _spec.SetField(paychannel.FieldSupportCurrency, field.TypeString, value) + _node.SupportCurrency = value + } + if nodes := _c.mutation.OrdersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.OrdersExtensionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.RefundIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.AppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paychannel.AppTable, + Columns: []string{paychannel.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.AppID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PayChannelCreateBulk is the builder for creating many PayChannel entities in bulk. +type PayChannelCreateBulk struct { + config + err error + builders []*PayChannelCreate +} + +// Save creates the PayChannel entities in the database. +func (_c *PayChannelCreateBulk) Save(ctx context.Context) ([]*PayChannel, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PayChannel, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PayChannelMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PayChannelCreateBulk) SaveX(ctx context.Context) []*PayChannel { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayChannelCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayChannelCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/paychannel_delete.go b/rpc/ent/paychannel_delete.go new file mode 100644 index 0000000..44d6d5a --- /dev/null +++ b/rpc/ent/paychannel_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayChannelDelete is the builder for deleting a PayChannel entity. +type PayChannelDelete struct { + config + hooks []Hook + mutation *PayChannelMutation +} + +// Where appends a list predicates to the PayChannelDelete builder. +func (_d *PayChannelDelete) Where(ps ...predicate.PayChannel) *PayChannelDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PayChannelDelete) 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 *PayChannelDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PayChannelDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(paychannel.Table, sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64)) + 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 +} + +// PayChannelDeleteOne is the builder for deleting a single PayChannel entity. +type PayChannelDeleteOne struct { + _d *PayChannelDelete +} + +// Where appends a list predicates to the PayChannelDelete builder. +func (_d *PayChannelDeleteOne) Where(ps ...predicate.PayChannel) *PayChannelDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PayChannelDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{paychannel.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayChannelDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/paychannel_query.go b/rpc/ent/paychannel_query.go new file mode 100644 index 0000000..0048476 --- /dev/null +++ b/rpc/ent/paychannel_query.go @@ -0,0 +1,831 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayChannelQuery is the builder for querying PayChannel entities. +type PayChannelQuery struct { + config + ctx *QueryContext + order []paychannel.OrderOption + inters []Interceptor + predicates []predicate.PayChannel + withOrders *PayOrderQuery + withOrdersExtension *PayOrderExtensionQuery + withRefund *PayRefundQuery + withApp *AppQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PayChannelQuery builder. +func (_q *PayChannelQuery) Where(ps ...predicate.PayChannel) *PayChannelQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PayChannelQuery) Limit(limit int) *PayChannelQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PayChannelQuery) Offset(offset int) *PayChannelQuery { + _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 *PayChannelQuery) Unique(unique bool) *PayChannelQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PayChannelQuery) Order(o ...paychannel.OrderOption) *PayChannelQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryOrders chains the current query on the "orders" edge. +func (_q *PayChannelQuery) QueryOrders() *PayOrderQuery { + query := (&PayOrderClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, selector), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paychannel.OrdersTable, paychannel.OrdersColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryOrdersExtension chains the current query on the "orders_extension" edge. +func (_q *PayChannelQuery) QueryOrdersExtension() *PayOrderExtensionQuery { + query := (&PayOrderExtensionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, selector), + sqlgraph.To(payorderextension.Table, payorderextension.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paychannel.OrdersExtensionTable, paychannel.OrdersExtensionColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRefund chains the current query on the "refund" edge. +func (_q *PayChannelQuery) QueryRefund() *PayRefundQuery { + query := (&PayRefundClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, selector), + sqlgraph.To(payrefund.Table, payrefund.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, paychannel.RefundTable, paychannel.RefundColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryApp chains the current query on the "app" edge. +func (_q *PayChannelQuery) QueryApp() *AppQuery { + query := (&AppClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(paychannel.Table, paychannel.FieldID, selector), + sqlgraph.To(app.Table, app.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, paychannel.AppTable, paychannel.AppColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PayChannel entity from the query. +// Returns a *NotFoundError when no PayChannel was found. +func (_q *PayChannelQuery) First(ctx context.Context) (*PayChannel, 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{paychannel.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PayChannelQuery) FirstX(ctx context.Context) *PayChannel { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PayChannel ID from the query. +// Returns a *NotFoundError when no PayChannel ID was found. +func (_q *PayChannelQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{paychannel.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PayChannelQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PayChannel entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PayChannel entity is found. +// Returns a *NotFoundError when no PayChannel entities are found. +func (_q *PayChannelQuery) Only(ctx context.Context) (*PayChannel, 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{paychannel.Label} + default: + return nil, &NotSingularError{paychannel.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PayChannelQuery) OnlyX(ctx context.Context) *PayChannel { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PayChannel ID in the query. +// Returns a *NotSingularError when more than one PayChannel ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PayChannelQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + 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{paychannel.Label} + default: + err = &NotSingularError{paychannel.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PayChannelQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PayChannels. +func (_q *PayChannelQuery) All(ctx context.Context) ([]*PayChannel, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PayChannel, *PayChannelQuery]() + return withInterceptors[[]*PayChannel](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PayChannelQuery) AllX(ctx context.Context) []*PayChannel { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PayChannel IDs. +func (_q *PayChannelQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(paychannel.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PayChannelQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PayChannelQuery) 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[*PayChannelQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PayChannelQuery) 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 *PayChannelQuery) 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 *PayChannelQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PayChannelQuery 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 *PayChannelQuery) Clone() *PayChannelQuery { + if _q == nil { + return nil + } + return &PayChannelQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]paychannel.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PayChannel{}, _q.predicates...), + withOrders: _q.withOrders.Clone(), + withOrdersExtension: _q.withOrdersExtension.Clone(), + withRefund: _q.withRefund.Clone(), + withApp: _q.withApp.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithOrders tells the query-builder to eager-load the nodes that are connected to +// the "orders" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayChannelQuery) WithOrders(opts ...func(*PayOrderQuery)) *PayChannelQuery { + query := (&PayOrderClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withOrders = query + return _q +} + +// WithOrdersExtension tells the query-builder to eager-load the nodes that are connected to +// the "orders_extension" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayChannelQuery) WithOrdersExtension(opts ...func(*PayOrderExtensionQuery)) *PayChannelQuery { + query := (&PayOrderExtensionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withOrdersExtension = query + return _q +} + +// WithRefund tells the query-builder to eager-load the nodes that are connected to +// the "refund" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayChannelQuery) WithRefund(opts ...func(*PayRefundQuery)) *PayChannelQuery { + query := (&PayRefundClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRefund = query + return _q +} + +// WithApp tells the query-builder to eager-load the nodes that are connected to +// the "app" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayChannelQuery) WithApp(opts ...func(*AppQuery)) *PayChannelQuery { + query := (&AppClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withApp = query + return _q +} + +// 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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PayChannel.Query(). +// GroupBy(paychannel.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PayChannelQuery) GroupBy(field string, fields ...string) *PayChannelGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PayChannelGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = paychannel.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.PayChannel.Query(). +// Select(paychannel.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *PayChannelQuery) Select(fields ...string) *PayChannelSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PayChannelSelect{PayChannelQuery: _q} + sbuild.label = paychannel.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PayChannelSelect configured with the given aggregations. +func (_q *PayChannelQuery) Aggregate(fns ...AggregateFunc) *PayChannelSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PayChannelQuery) 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 !paychannel.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 *PayChannelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PayChannel, error) { + var ( + nodes = []*PayChannel{} + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withOrders != nil, + _q.withOrdersExtension != nil, + _q.withRefund != nil, + _q.withApp != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PayChannel).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PayChannel{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + 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 + } + if query := _q.withOrders; query != nil { + if err := _q.loadOrders(ctx, query, nodes, + func(n *PayChannel) { n.Edges.Orders = []*PayOrder{} }, + func(n *PayChannel, e *PayOrder) { n.Edges.Orders = append(n.Edges.Orders, e) }); err != nil { + return nil, err + } + } + if query := _q.withOrdersExtension; query != nil { + if err := _q.loadOrdersExtension(ctx, query, nodes, + func(n *PayChannel) { n.Edges.OrdersExtension = []*PayOrderExtension{} }, + func(n *PayChannel, e *PayOrderExtension) { + n.Edges.OrdersExtension = append(n.Edges.OrdersExtension, e) + }); err != nil { + return nil, err + } + } + if query := _q.withRefund; query != nil { + if err := _q.loadRefund(ctx, query, nodes, + func(n *PayChannel) { n.Edges.Refund = []*PayRefund{} }, + func(n *PayChannel, e *PayRefund) { n.Edges.Refund = append(n.Edges.Refund, e) }); err != nil { + return nil, err + } + } + if query := _q.withApp; query != nil { + if err := _q.loadApp(ctx, query, nodes, nil, + func(n *PayChannel, e *App) { n.Edges.App = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PayChannelQuery) loadOrders(ctx context.Context, query *PayOrderQuery, nodes []*PayChannel, init func(*PayChannel), assign func(*PayChannel, *PayOrder)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayChannel) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(payorder.FieldChannelID) + } + query.Where(predicate.PayOrder(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(paychannel.OrdersColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ChannelID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "channel_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *PayChannelQuery) loadOrdersExtension(ctx context.Context, query *PayOrderExtensionQuery, nodes []*PayChannel, init func(*PayChannel), assign func(*PayChannel, *PayOrderExtension)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayChannel) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(payorderextension.FieldChannelID) + } + query.Where(predicate.PayOrderExtension(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(paychannel.OrdersExtensionColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ChannelID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "channel_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *PayChannelQuery) loadRefund(ctx context.Context, query *PayRefundQuery, nodes []*PayChannel, init func(*PayChannel), assign func(*PayChannel, *PayRefund)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayChannel) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(payrefund.FieldChannelID) + } + query.Where(predicate.PayRefund(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(paychannel.RefundColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ChannelID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "channel_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *PayChannelQuery) loadApp(ctx context.Context, query *AppQuery, nodes []*PayChannel, init func(*PayChannel), assign func(*PayChannel, *App)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayChannel) + for i := range nodes { + fk := nodes[i].AppID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(app.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "app_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *PayChannelQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _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 *PayChannelQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(paychannel.Table, paychannel.Columns, sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64)) + _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, paychannel.FieldID) + for i := range fields { + if fields[i] != paychannel.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withApp != nil { + _spec.Node.AddColumnOnce(paychannel.FieldAppID) + } + } + 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 *PayChannelQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(paychannel.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = paychannel.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 _, 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 +} + +// PayChannelGroupBy is the group-by builder for PayChannel entities. +type PayChannelGroupBy struct { + selector + build *PayChannelQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PayChannelGroupBy) Aggregate(fns ...AggregateFunc) *PayChannelGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PayChannelGroupBy) 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[*PayChannelQuery, *PayChannelGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PayChannelGroupBy) sqlScan(ctx context.Context, root *PayChannelQuery, 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) +} + +// PayChannelSelect is the builder for selecting fields of PayChannel entities. +type PayChannelSelect struct { + *PayChannelQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PayChannelSelect) Aggregate(fns ...AggregateFunc) *PayChannelSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PayChannelSelect) 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[*PayChannelQuery, *PayChannelSelect](ctx, _s.PayChannelQuery, _s, _s.inters, v) +} + +func (_s *PayChannelSelect) sqlScan(ctx context.Context, root *PayChannelQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/paychannel_update.go b/rpc/ent/paychannel_update.go new file mode 100644 index 0000000..d051624 --- /dev/null +++ b/rpc/ent/paychannel_update.go @@ -0,0 +1,1302 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayChannelUpdate is the builder for updating PayChannel entities. +type PayChannelUpdate struct { + config + hooks []Hook + mutation *PayChannelMutation +} + +// Where appends a list predicates to the PayChannelUpdate builder. +func (_u *PayChannelUpdate) Where(ps ...predicate.PayChannel) *PayChannelUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayChannelUpdate) SetUpdatedAt(v time.Time) *PayChannelUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayChannelUpdate) SetStatus(v uint8) *PayChannelUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableStatus(v *uint8) *PayChannelUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayChannelUpdate) AddStatus(v int8) *PayChannelUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayChannelUpdate) ClearStatus() *PayChannelUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayChannelUpdate) SetDeletedAt(v time.Time) *PayChannelUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableDeletedAt(v *time.Time) *PayChannelUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayChannelUpdate) ClearDeletedAt() *PayChannelUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetCode sets the "code" field. +func (_u *PayChannelUpdate) SetCode(v string) *PayChannelUpdate { + _u.mutation.SetCode(v) + return _u +} + +// SetNillableCode sets the "code" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableCode(v *string) *PayChannelUpdate { + if v != nil { + _u.SetCode(*v) + } + return _u +} + +// SetNameEn sets the "name_en" field. +func (_u *PayChannelUpdate) SetNameEn(v string) *PayChannelUpdate { + _u.mutation.SetNameEn(v) + return _u +} + +// SetNillableNameEn sets the "name_en" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableNameEn(v *string) *PayChannelUpdate { + if v != nil { + _u.SetNameEn(*v) + } + return _u +} + +// SetNameZh sets the "name_zh" field. +func (_u *PayChannelUpdate) SetNameZh(v string) *PayChannelUpdate { + _u.mutation.SetNameZh(v) + return _u +} + +// SetNillableNameZh sets the "name_zh" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableNameZh(v *string) *PayChannelUpdate { + if v != nil { + _u.SetNameZh(*v) + } + return _u +} + +// SetFreeRate sets the "free_rate" field. +func (_u *PayChannelUpdate) SetFreeRate(v string) *PayChannelUpdate { + _u.mutation.SetFreeRate(v) + return _u +} + +// SetNillableFreeRate sets the "free_rate" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableFreeRate(v *string) *PayChannelUpdate { + if v != nil { + _u.SetFreeRate(*v) + } + return _u +} + +// SetAppID sets the "app_id" field. +func (_u *PayChannelUpdate) SetAppID(v uint64) *PayChannelUpdate { + _u.mutation.SetAppID(v) + return _u +} + +// SetNillableAppID sets the "app_id" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableAppID(v *uint64) *PayChannelUpdate { + if v != nil { + _u.SetAppID(*v) + } + return _u +} + +// SetConfig sets the "config" field. +func (_u *PayChannelUpdate) SetConfig(v map[string]interface{}) *PayChannelUpdate { + _u.mutation.SetConfig(v) + return _u +} + +// SetRemake sets the "remake" field. +func (_u *PayChannelUpdate) SetRemake(v string) *PayChannelUpdate { + _u.mutation.SetRemake(v) + return _u +} + +// SetNillableRemake sets the "remake" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableRemake(v *string) *PayChannelUpdate { + if v != nil { + _u.SetRemake(*v) + } + return _u +} + +// ClearRemake clears the value of the "remake" field. +func (_u *PayChannelUpdate) ClearRemake() *PayChannelUpdate { + _u.mutation.ClearRemake() + return _u +} + +// SetIcon sets the "icon" field. +func (_u *PayChannelUpdate) SetIcon(v uint64) *PayChannelUpdate { + _u.mutation.ResetIcon() + _u.mutation.SetIcon(v) + return _u +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableIcon(v *uint64) *PayChannelUpdate { + if v != nil { + _u.SetIcon(*v) + } + return _u +} + +// AddIcon adds value to the "icon" field. +func (_u *PayChannelUpdate) AddIcon(v int64) *PayChannelUpdate { + _u.mutation.AddIcon(v) + return _u +} + +// ClearIcon clears the value of the "icon" field. +func (_u *PayChannelUpdate) ClearIcon() *PayChannelUpdate { + _u.mutation.ClearIcon() + return _u +} + +// SetOrderTimeOut sets the "order_time_out" field. +func (_u *PayChannelUpdate) SetOrderTimeOut(v string) *PayChannelUpdate { + _u.mutation.SetOrderTimeOut(v) + return _u +} + +// SetNillableOrderTimeOut sets the "order_time_out" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableOrderTimeOut(v *string) *PayChannelUpdate { + if v != nil { + _u.SetOrderTimeOut(*v) + } + return _u +} + +// SetSupportCurrency sets the "support_currency" field. +func (_u *PayChannelUpdate) SetSupportCurrency(v string) *PayChannelUpdate { + _u.mutation.SetSupportCurrency(v) + return _u +} + +// SetNillableSupportCurrency sets the "support_currency" field if the given value is not nil. +func (_u *PayChannelUpdate) SetNillableSupportCurrency(v *string) *PayChannelUpdate { + if v != nil { + _u.SetSupportCurrency(*v) + } + return _u +} + +// AddOrderIDs adds the "orders" edge to the PayOrder entity by IDs. +func (_u *PayChannelUpdate) AddOrderIDs(ids ...uint64) *PayChannelUpdate { + _u.mutation.AddOrderIDs(ids...) + return _u +} + +// AddOrders adds the "orders" edges to the PayOrder entity. +func (_u *PayChannelUpdate) AddOrders(v ...*PayOrder) *PayChannelUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddOrderIDs(ids...) +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (_u *PayChannelUpdate) AddOrdersExtensionIDs(ids ...uint64) *PayChannelUpdate { + _u.mutation.AddOrdersExtensionIDs(ids...) + return _u +} + +// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayChannelUpdate) AddOrdersExtension(v ...*PayOrderExtension) *PayChannelUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddOrdersExtensionIDs(ids...) +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs. +func (_u *PayChannelUpdate) AddRefundIDs(ids ...uint64) *PayChannelUpdate { + _u.mutation.AddRefundIDs(ids...) + return _u +} + +// AddRefund adds the "refund" edges to the PayRefund entity. +func (_u *PayChannelUpdate) AddRefund(v ...*PayRefund) *PayChannelUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRefundIDs(ids...) +} + +// SetApp sets the "app" edge to the App entity. +func (_u *PayChannelUpdate) SetApp(v *App) *PayChannelUpdate { + return _u.SetAppID(v.ID) +} + +// Mutation returns the PayChannelMutation object of the builder. +func (_u *PayChannelUpdate) Mutation() *PayChannelMutation { + return _u.mutation +} + +// ClearOrders clears all "orders" edges to the PayOrder entity. +func (_u *PayChannelUpdate) ClearOrders() *PayChannelUpdate { + _u.mutation.ClearOrders() + return _u +} + +// RemoveOrderIDs removes the "orders" edge to PayOrder entities by IDs. +func (_u *PayChannelUpdate) RemoveOrderIDs(ids ...uint64) *PayChannelUpdate { + _u.mutation.RemoveOrderIDs(ids...) + return _u +} + +// RemoveOrders removes "orders" edges to PayOrder entities. +func (_u *PayChannelUpdate) RemoveOrders(v ...*PayOrder) *PayChannelUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveOrderIDs(ids...) +} + +// ClearOrdersExtension clears all "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayChannelUpdate) ClearOrdersExtension() *PayChannelUpdate { + _u.mutation.ClearOrdersExtension() + return _u +} + +// RemoveOrdersExtensionIDs removes the "orders_extension" edge to PayOrderExtension entities by IDs. +func (_u *PayChannelUpdate) RemoveOrdersExtensionIDs(ids ...uint64) *PayChannelUpdate { + _u.mutation.RemoveOrdersExtensionIDs(ids...) + return _u +} + +// RemoveOrdersExtension removes "orders_extension" edges to PayOrderExtension entities. +func (_u *PayChannelUpdate) RemoveOrdersExtension(v ...*PayOrderExtension) *PayChannelUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveOrdersExtensionIDs(ids...) +} + +// ClearRefund clears all "refund" edges to the PayRefund entity. +func (_u *PayChannelUpdate) ClearRefund() *PayChannelUpdate { + _u.mutation.ClearRefund() + return _u +} + +// RemoveRefundIDs removes the "refund" edge to PayRefund entities by IDs. +func (_u *PayChannelUpdate) RemoveRefundIDs(ids ...uint64) *PayChannelUpdate { + _u.mutation.RemoveRefundIDs(ids...) + return _u +} + +// RemoveRefund removes "refund" edges to PayRefund entities. +func (_u *PayChannelUpdate) RemoveRefund(v ...*PayRefund) *PayChannelUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRefundIDs(ids...) +} + +// ClearApp clears the "app" edge to the App entity. +func (_u *PayChannelUpdate) ClearApp() *PayChannelUpdate { + _u.mutation.ClearApp() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PayChannelUpdate) 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 *PayChannelUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PayChannelUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayChannelUpdate) 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 *PayChannelUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := paychannel.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayChannelUpdate) check() error { + if _u.mutation.AppCleared() && len(_u.mutation.AppIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayChannel.app"`) + } + return nil +} + +func (_u *PayChannelUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(paychannel.Table, paychannel.Columns, sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(paychannel.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(paychannel.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(paychannel.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(paychannel.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(paychannel.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(paychannel.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.Code(); ok { + _spec.SetField(paychannel.FieldCode, field.TypeString, value) + } + if value, ok := _u.mutation.NameEn(); ok { + _spec.SetField(paychannel.FieldNameEn, field.TypeString, value) + } + if value, ok := _u.mutation.NameZh(); ok { + _spec.SetField(paychannel.FieldNameZh, field.TypeString, value) + } + if value, ok := _u.mutation.FreeRate(); ok { + _spec.SetField(paychannel.FieldFreeRate, field.TypeString, value) + } + if value, ok := _u.mutation.Config(); ok { + _spec.SetField(paychannel.FieldConfig, field.TypeJSON, value) + } + if value, ok := _u.mutation.Remake(); ok { + _spec.SetField(paychannel.FieldRemake, field.TypeString, value) + } + if _u.mutation.RemakeCleared() { + _spec.ClearField(paychannel.FieldRemake, field.TypeString) + } + if value, ok := _u.mutation.Icon(); ok { + _spec.SetField(paychannel.FieldIcon, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedIcon(); ok { + _spec.AddField(paychannel.FieldIcon, field.TypeUint64, value) + } + if _u.mutation.IconCleared() { + _spec.ClearField(paychannel.FieldIcon, field.TypeUint64) + } + if value, ok := _u.mutation.OrderTimeOut(); ok { + _spec.SetField(paychannel.FieldOrderTimeOut, field.TypeString, value) + } + if value, ok := _u.mutation.SupportCurrency(); ok { + _spec.SetField(paychannel.FieldSupportCurrency, field.TypeString, value) + } + if _u.mutation.OrdersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedOrdersIDs(); len(nodes) > 0 && !_u.mutation.OrdersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrdersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedOrdersExtensionIDs(); len(nodes) > 0 && !_u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrdersExtensionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRefundIDs(); len(nodes) > 0 && !_u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RefundIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.AppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paychannel.AppTable, + Columns: []string{paychannel.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paychannel.AppTable, + Columns: []string{paychannel.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{paychannel.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PayChannelUpdateOne is the builder for updating a single PayChannel entity. +type PayChannelUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PayChannelMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayChannelUpdateOne) SetUpdatedAt(v time.Time) *PayChannelUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayChannelUpdateOne) SetStatus(v uint8) *PayChannelUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableStatus(v *uint8) *PayChannelUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayChannelUpdateOne) AddStatus(v int8) *PayChannelUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayChannelUpdateOne) ClearStatus() *PayChannelUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayChannelUpdateOne) SetDeletedAt(v time.Time) *PayChannelUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableDeletedAt(v *time.Time) *PayChannelUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayChannelUpdateOne) ClearDeletedAt() *PayChannelUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetCode sets the "code" field. +func (_u *PayChannelUpdateOne) SetCode(v string) *PayChannelUpdateOne { + _u.mutation.SetCode(v) + return _u +} + +// SetNillableCode sets the "code" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableCode(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetCode(*v) + } + return _u +} + +// SetNameEn sets the "name_en" field. +func (_u *PayChannelUpdateOne) SetNameEn(v string) *PayChannelUpdateOne { + _u.mutation.SetNameEn(v) + return _u +} + +// SetNillableNameEn sets the "name_en" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableNameEn(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetNameEn(*v) + } + return _u +} + +// SetNameZh sets the "name_zh" field. +func (_u *PayChannelUpdateOne) SetNameZh(v string) *PayChannelUpdateOne { + _u.mutation.SetNameZh(v) + return _u +} + +// SetNillableNameZh sets the "name_zh" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableNameZh(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetNameZh(*v) + } + return _u +} + +// SetFreeRate sets the "free_rate" field. +func (_u *PayChannelUpdateOne) SetFreeRate(v string) *PayChannelUpdateOne { + _u.mutation.SetFreeRate(v) + return _u +} + +// SetNillableFreeRate sets the "free_rate" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableFreeRate(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetFreeRate(*v) + } + return _u +} + +// SetAppID sets the "app_id" field. +func (_u *PayChannelUpdateOne) SetAppID(v uint64) *PayChannelUpdateOne { + _u.mutation.SetAppID(v) + return _u +} + +// SetNillableAppID sets the "app_id" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableAppID(v *uint64) *PayChannelUpdateOne { + if v != nil { + _u.SetAppID(*v) + } + return _u +} + +// SetConfig sets the "config" field. +func (_u *PayChannelUpdateOne) SetConfig(v map[string]interface{}) *PayChannelUpdateOne { + _u.mutation.SetConfig(v) + return _u +} + +// SetRemake sets the "remake" field. +func (_u *PayChannelUpdateOne) SetRemake(v string) *PayChannelUpdateOne { + _u.mutation.SetRemake(v) + return _u +} + +// SetNillableRemake sets the "remake" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableRemake(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetRemake(*v) + } + return _u +} + +// ClearRemake clears the value of the "remake" field. +func (_u *PayChannelUpdateOne) ClearRemake() *PayChannelUpdateOne { + _u.mutation.ClearRemake() + return _u +} + +// SetIcon sets the "icon" field. +func (_u *PayChannelUpdateOne) SetIcon(v uint64) *PayChannelUpdateOne { + _u.mutation.ResetIcon() + _u.mutation.SetIcon(v) + return _u +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableIcon(v *uint64) *PayChannelUpdateOne { + if v != nil { + _u.SetIcon(*v) + } + return _u +} + +// AddIcon adds value to the "icon" field. +func (_u *PayChannelUpdateOne) AddIcon(v int64) *PayChannelUpdateOne { + _u.mutation.AddIcon(v) + return _u +} + +// ClearIcon clears the value of the "icon" field. +func (_u *PayChannelUpdateOne) ClearIcon() *PayChannelUpdateOne { + _u.mutation.ClearIcon() + return _u +} + +// SetOrderTimeOut sets the "order_time_out" field. +func (_u *PayChannelUpdateOne) SetOrderTimeOut(v string) *PayChannelUpdateOne { + _u.mutation.SetOrderTimeOut(v) + return _u +} + +// SetNillableOrderTimeOut sets the "order_time_out" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableOrderTimeOut(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetOrderTimeOut(*v) + } + return _u +} + +// SetSupportCurrency sets the "support_currency" field. +func (_u *PayChannelUpdateOne) SetSupportCurrency(v string) *PayChannelUpdateOne { + _u.mutation.SetSupportCurrency(v) + return _u +} + +// SetNillableSupportCurrency sets the "support_currency" field if the given value is not nil. +func (_u *PayChannelUpdateOne) SetNillableSupportCurrency(v *string) *PayChannelUpdateOne { + if v != nil { + _u.SetSupportCurrency(*v) + } + return _u +} + +// AddOrderIDs adds the "orders" edge to the PayOrder entity by IDs. +func (_u *PayChannelUpdateOne) AddOrderIDs(ids ...uint64) *PayChannelUpdateOne { + _u.mutation.AddOrderIDs(ids...) + return _u +} + +// AddOrders adds the "orders" edges to the PayOrder entity. +func (_u *PayChannelUpdateOne) AddOrders(v ...*PayOrder) *PayChannelUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddOrderIDs(ids...) +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (_u *PayChannelUpdateOne) AddOrdersExtensionIDs(ids ...uint64) *PayChannelUpdateOne { + _u.mutation.AddOrdersExtensionIDs(ids...) + return _u +} + +// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayChannelUpdateOne) AddOrdersExtension(v ...*PayOrderExtension) *PayChannelUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddOrdersExtensionIDs(ids...) +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs. +func (_u *PayChannelUpdateOne) AddRefundIDs(ids ...uint64) *PayChannelUpdateOne { + _u.mutation.AddRefundIDs(ids...) + return _u +} + +// AddRefund adds the "refund" edges to the PayRefund entity. +func (_u *PayChannelUpdateOne) AddRefund(v ...*PayRefund) *PayChannelUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRefundIDs(ids...) +} + +// SetApp sets the "app" edge to the App entity. +func (_u *PayChannelUpdateOne) SetApp(v *App) *PayChannelUpdateOne { + return _u.SetAppID(v.ID) +} + +// Mutation returns the PayChannelMutation object of the builder. +func (_u *PayChannelUpdateOne) Mutation() *PayChannelMutation { + return _u.mutation +} + +// ClearOrders clears all "orders" edges to the PayOrder entity. +func (_u *PayChannelUpdateOne) ClearOrders() *PayChannelUpdateOne { + _u.mutation.ClearOrders() + return _u +} + +// RemoveOrderIDs removes the "orders" edge to PayOrder entities by IDs. +func (_u *PayChannelUpdateOne) RemoveOrderIDs(ids ...uint64) *PayChannelUpdateOne { + _u.mutation.RemoveOrderIDs(ids...) + return _u +} + +// RemoveOrders removes "orders" edges to PayOrder entities. +func (_u *PayChannelUpdateOne) RemoveOrders(v ...*PayOrder) *PayChannelUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveOrderIDs(ids...) +} + +// ClearOrdersExtension clears all "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayChannelUpdateOne) ClearOrdersExtension() *PayChannelUpdateOne { + _u.mutation.ClearOrdersExtension() + return _u +} + +// RemoveOrdersExtensionIDs removes the "orders_extension" edge to PayOrderExtension entities by IDs. +func (_u *PayChannelUpdateOne) RemoveOrdersExtensionIDs(ids ...uint64) *PayChannelUpdateOne { + _u.mutation.RemoveOrdersExtensionIDs(ids...) + return _u +} + +// RemoveOrdersExtension removes "orders_extension" edges to PayOrderExtension entities. +func (_u *PayChannelUpdateOne) RemoveOrdersExtension(v ...*PayOrderExtension) *PayChannelUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveOrdersExtensionIDs(ids...) +} + +// ClearRefund clears all "refund" edges to the PayRefund entity. +func (_u *PayChannelUpdateOne) ClearRefund() *PayChannelUpdateOne { + _u.mutation.ClearRefund() + return _u +} + +// RemoveRefundIDs removes the "refund" edge to PayRefund entities by IDs. +func (_u *PayChannelUpdateOne) RemoveRefundIDs(ids ...uint64) *PayChannelUpdateOne { + _u.mutation.RemoveRefundIDs(ids...) + return _u +} + +// RemoveRefund removes "refund" edges to PayRefund entities. +func (_u *PayChannelUpdateOne) RemoveRefund(v ...*PayRefund) *PayChannelUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRefundIDs(ids...) +} + +// ClearApp clears the "app" edge to the App entity. +func (_u *PayChannelUpdateOne) ClearApp() *PayChannelUpdateOne { + _u.mutation.ClearApp() + return _u +} + +// Where appends a list predicates to the PayChannelUpdate builder. +func (_u *PayChannelUpdateOne) Where(ps ...predicate.PayChannel) *PayChannelUpdateOne { + _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 *PayChannelUpdateOne) Select(field string, fields ...string) *PayChannelUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PayChannel entity. +func (_u *PayChannelUpdateOne) Save(ctx context.Context) (*PayChannel, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PayChannelUpdateOne) SaveX(ctx context.Context) *PayChannel { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PayChannelUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayChannelUpdateOne) 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 *PayChannelUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := paychannel.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayChannelUpdateOne) check() error { + if _u.mutation.AppCleared() && len(_u.mutation.AppIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayChannel.app"`) + } + return nil +} + +func (_u *PayChannelUpdateOne) sqlSave(ctx context.Context) (_node *PayChannel, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(paychannel.Table, paychannel.Columns, sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayChannel.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, paychannel.FieldID) + for _, f := range fields { + if !paychannel.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != paychannel.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.UpdatedAt(); ok { + _spec.SetField(paychannel.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(paychannel.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(paychannel.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(paychannel.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(paychannel.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(paychannel.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.Code(); ok { + _spec.SetField(paychannel.FieldCode, field.TypeString, value) + } + if value, ok := _u.mutation.NameEn(); ok { + _spec.SetField(paychannel.FieldNameEn, field.TypeString, value) + } + if value, ok := _u.mutation.NameZh(); ok { + _spec.SetField(paychannel.FieldNameZh, field.TypeString, value) + } + if value, ok := _u.mutation.FreeRate(); ok { + _spec.SetField(paychannel.FieldFreeRate, field.TypeString, value) + } + if value, ok := _u.mutation.Config(); ok { + _spec.SetField(paychannel.FieldConfig, field.TypeJSON, value) + } + if value, ok := _u.mutation.Remake(); ok { + _spec.SetField(paychannel.FieldRemake, field.TypeString, value) + } + if _u.mutation.RemakeCleared() { + _spec.ClearField(paychannel.FieldRemake, field.TypeString) + } + if value, ok := _u.mutation.Icon(); ok { + _spec.SetField(paychannel.FieldIcon, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedIcon(); ok { + _spec.AddField(paychannel.FieldIcon, field.TypeUint64, value) + } + if _u.mutation.IconCleared() { + _spec.ClearField(paychannel.FieldIcon, field.TypeUint64) + } + if value, ok := _u.mutation.OrderTimeOut(); ok { + _spec.SetField(paychannel.FieldOrderTimeOut, field.TypeString, value) + } + if value, ok := _u.mutation.SupportCurrency(); ok { + _spec.SetField(paychannel.FieldSupportCurrency, field.TypeString, value) + } + if _u.mutation.OrdersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedOrdersIDs(); len(nodes) > 0 && !_u.mutation.OrdersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrdersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersTable, + Columns: []string{paychannel.OrdersColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedOrdersExtensionIDs(); len(nodes) > 0 && !_u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrdersExtensionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.OrdersExtensionTable, + Columns: []string{paychannel.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRefundIDs(); len(nodes) > 0 && !_u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RefundIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: paychannel.RefundTable, + Columns: []string{paychannel.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.AppCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paychannel.AppTable, + Columns: []string{paychannel.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.AppIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: paychannel.AppTable, + Columns: []string{paychannel.AppColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PayChannel{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{paychannel.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/payorder.go b/rpc/ent/payorder.go new file mode 100644 index 0000000..0c034e0 --- /dev/null +++ b/rpc/ent/payorder.go @@ -0,0 +1,447 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayOrder Table | 支付订单表 +type PayOrder struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // 支付渠道 ID + ChannelID uint64 `json:"channel_id,omitempty"` + // 用户 ID + UserID uint64 `json:"user_id,omitempty"` + // 商品标题 + Subject string `json:"subject,omitempty"` + // 商品描述 + Body string `json:"body,omitempty"` + // 异步通知地址 + NotifyURL string `json:"notify_url,omitempty"` + // 金额,单位为分 + Amount uint64 `json:"amount,omitempty"` + // 支付来源 + PaySource string `json:"pay_source,omitempty"` + // 本次渠道费率,百分比 + ChannelFeeRate string `json:"channel_fee_rate,omitempty"` + // 本次渠道实际收取费y + ChannelFee uint64 `json:"channel_fee,omitempty"` + // 订单状态 + OrderStatus string `json:"order_status,omitempty"` + // 用户 IP + UserIP string `json:"user_ip,omitempty"` + // 订单过期时间 + ExpireTime time.Time `json:"expire_time,omitempty"` + // 支付单号 + PayNo string `json:"pay_no,omitempty"` + // 订单支付成功时间 + SuccessTime time.Time `json:"success_time,omitempty"` + // 支付成功的订单拓展单ID + ExtensionID uint64 `json:"extension_id,omitempty"` + // 交易流水号,有一些平台可能会有 + TransactionID string `json:"transaction_id,omitempty"` + // 货币代码 + Currency string `json:"currency,omitempty"` + // 退款金额,单位为分 + RefundPrice uint64 `json:"refund_price,omitempty"` + // 渠道订单号 + ChannelOrderNo string `json:"channel_order_no,omitempty"` + // 渠道用户 ID + ChannelUserID string `json:"channel_user_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PayOrderQuery when eager-loading is set. + Edges PayOrderEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PayOrderEdges holds the relations/edges for other nodes in the graph. +type PayOrderEdges struct { + // Channel holds the value of the channel edge. + Channel *PayChannel `json:"channel,omitempty"` + // OrdersExtension holds the value of the orders_extension edge. + OrdersExtension []*PayOrderExtension `json:"orders_extension,omitempty"` + // NotifyTask holds the value of the notify_task edge. + NotifyTask []*PayNotifyTask `json:"notify_task,omitempty"` + // Refund holds the value of the refund edge. + Refund []*PayRefund `json:"refund,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// ChannelOrErr returns the Channel value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayOrderEdges) ChannelOrErr() (*PayChannel, error) { + if e.Channel != nil { + return e.Channel, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: paychannel.Label} + } + return nil, &NotLoadedError{edge: "channel"} +} + +// OrdersExtensionOrErr returns the OrdersExtension value or an error if the edge +// was not loaded in eager-loading. +func (e PayOrderEdges) OrdersExtensionOrErr() ([]*PayOrderExtension, error) { + if e.loadedTypes[1] { + return e.OrdersExtension, nil + } + return nil, &NotLoadedError{edge: "orders_extension"} +} + +// NotifyTaskOrErr returns the NotifyTask value or an error if the edge +// was not loaded in eager-loading. +func (e PayOrderEdges) NotifyTaskOrErr() ([]*PayNotifyTask, error) { + if e.loadedTypes[2] { + return e.NotifyTask, nil + } + return nil, &NotLoadedError{edge: "notify_task"} +} + +// RefundOrErr returns the Refund value or an error if the edge +// was not loaded in eager-loading. +func (e PayOrderEdges) RefundOrErr() ([]*PayRefund, error) { + if e.loadedTypes[3] { + return e.Refund, nil + } + return nil, &NotLoadedError{edge: "refund"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PayOrder) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case payorder.FieldID, payorder.FieldStatus, payorder.FieldTenantID, payorder.FieldChannelID, payorder.FieldUserID, payorder.FieldAmount, payorder.FieldChannelFee, payorder.FieldExtensionID, payorder.FieldRefundPrice: + values[i] = new(sql.NullInt64) + case payorder.FieldSubject, payorder.FieldBody, payorder.FieldNotifyURL, payorder.FieldPaySource, payorder.FieldChannelFeeRate, payorder.FieldOrderStatus, payorder.FieldUserIP, payorder.FieldPayNo, payorder.FieldTransactionID, payorder.FieldCurrency, payorder.FieldChannelOrderNo, payorder.FieldChannelUserID: + values[i] = new(sql.NullString) + case payorder.FieldCreatedAt, payorder.FieldUpdatedAt, payorder.FieldDeletedAt, payorder.FieldExpireTime, payorder.FieldSuccessTime: + 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 PayOrder fields. +func (_m *PayOrder) 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 payorder.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case payorder.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 payorder.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 + } + case payorder.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case payorder.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case payorder.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case payorder.FieldChannelID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field channel_id", values[i]) + } else if value.Valid { + _m.ChannelID = uint64(value.Int64) + } + case payorder.FieldUserID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + _m.UserID = uint64(value.Int64) + } + case payorder.FieldSubject: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field subject", values[i]) + } else if value.Valid { + _m.Subject = value.String + } + case payorder.FieldBody: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field body", values[i]) + } else if value.Valid { + _m.Body = value.String + } + case payorder.FieldNotifyURL: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field notify_url", values[i]) + } else if value.Valid { + _m.NotifyURL = value.String + } + case payorder.FieldAmount: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field amount", values[i]) + } else if value.Valid { + _m.Amount = uint64(value.Int64) + } + case payorder.FieldPaySource: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field pay_source", values[i]) + } else if value.Valid { + _m.PaySource = value.String + } + case payorder.FieldChannelFeeRate: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_fee_rate", values[i]) + } else if value.Valid { + _m.ChannelFeeRate = value.String + } + case payorder.FieldChannelFee: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field channel_fee", values[i]) + } else if value.Valid { + _m.ChannelFee = uint64(value.Int64) + } + case payorder.FieldOrderStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field order_status", values[i]) + } else if value.Valid { + _m.OrderStatus = value.String + } + case payorder.FieldUserIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field user_ip", values[i]) + } else if value.Valid { + _m.UserIP = value.String + } + case payorder.FieldExpireTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field expire_time", values[i]) + } else if value.Valid { + _m.ExpireTime = value.Time + } + case payorder.FieldPayNo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field pay_no", values[i]) + } else if value.Valid { + _m.PayNo = value.String + } + case payorder.FieldSuccessTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field success_time", values[i]) + } else if value.Valid { + _m.SuccessTime = value.Time + } + case payorder.FieldExtensionID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field extension_id", values[i]) + } else if value.Valid { + _m.ExtensionID = uint64(value.Int64) + } + case payorder.FieldTransactionID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field transaction_id", values[i]) + } else if value.Valid { + _m.TransactionID = value.String + } + case payorder.FieldCurrency: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field currency", values[i]) + } else if value.Valid { + _m.Currency = value.String + } + case payorder.FieldRefundPrice: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field refund_price", values[i]) + } else if value.Valid { + _m.RefundPrice = uint64(value.Int64) + } + case payorder.FieldChannelOrderNo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_order_no", values[i]) + } else if value.Valid { + _m.ChannelOrderNo = value.String + } + case payorder.FieldChannelUserID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_user_id", values[i]) + } else if value.Valid { + _m.ChannelUserID = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PayOrder. +// This includes values selected through modifiers, order, etc. +func (_m *PayOrder) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryChannel queries the "channel" edge of the PayOrder entity. +func (_m *PayOrder) QueryChannel() *PayChannelQuery { + return NewPayOrderClient(_m.config).QueryChannel(_m) +} + +// QueryOrdersExtension queries the "orders_extension" edge of the PayOrder entity. +func (_m *PayOrder) QueryOrdersExtension() *PayOrderExtensionQuery { + return NewPayOrderClient(_m.config).QueryOrdersExtension(_m) +} + +// QueryNotifyTask queries the "notify_task" edge of the PayOrder entity. +func (_m *PayOrder) QueryNotifyTask() *PayNotifyTaskQuery { + return NewPayOrderClient(_m.config).QueryNotifyTask(_m) +} + +// QueryRefund queries the "refund" edge of the PayOrder entity. +func (_m *PayOrder) QueryRefund() *PayRefundQuery { + return NewPayOrderClient(_m.config).QueryRefund(_m) +} + +// Update returns a builder for updating this PayOrder. +// Note that you need to call PayOrder.Unwrap() before calling this method if this PayOrder +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PayOrder) Update() *PayOrderUpdateOne { + return NewPayOrderClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PayOrder 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 *PayOrder) Unwrap() *PayOrder { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PayOrder is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PayOrder) String() string { + var builder strings.Builder + builder.WriteString("PayOrder(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + 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.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("channel_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ChannelID)) + builder.WriteString(", ") + builder.WriteString("user_id=") + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) + builder.WriteString(", ") + builder.WriteString("subject=") + builder.WriteString(_m.Subject) + builder.WriteString(", ") + builder.WriteString("body=") + builder.WriteString(_m.Body) + builder.WriteString(", ") + builder.WriteString("notify_url=") + builder.WriteString(_m.NotifyURL) + builder.WriteString(", ") + builder.WriteString("amount=") + builder.WriteString(fmt.Sprintf("%v", _m.Amount)) + builder.WriteString(", ") + builder.WriteString("pay_source=") + builder.WriteString(_m.PaySource) + builder.WriteString(", ") + builder.WriteString("channel_fee_rate=") + builder.WriteString(_m.ChannelFeeRate) + builder.WriteString(", ") + builder.WriteString("channel_fee=") + builder.WriteString(fmt.Sprintf("%v", _m.ChannelFee)) + builder.WriteString(", ") + builder.WriteString("order_status=") + builder.WriteString(_m.OrderStatus) + builder.WriteString(", ") + builder.WriteString("user_ip=") + builder.WriteString(_m.UserIP) + builder.WriteString(", ") + builder.WriteString("expire_time=") + builder.WriteString(_m.ExpireTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("pay_no=") + builder.WriteString(_m.PayNo) + builder.WriteString(", ") + builder.WriteString("success_time=") + builder.WriteString(_m.SuccessTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("extension_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ExtensionID)) + builder.WriteString(", ") + builder.WriteString("transaction_id=") + builder.WriteString(_m.TransactionID) + builder.WriteString(", ") + builder.WriteString("currency=") + builder.WriteString(_m.Currency) + builder.WriteString(", ") + builder.WriteString("refund_price=") + builder.WriteString(fmt.Sprintf("%v", _m.RefundPrice)) + builder.WriteString(", ") + builder.WriteString("channel_order_no=") + builder.WriteString(_m.ChannelOrderNo) + builder.WriteString(", ") + builder.WriteString("channel_user_id=") + builder.WriteString(_m.ChannelUserID) + builder.WriteByte(')') + return builder.String() +} + +// PayOrders is a parsable slice of PayOrder. +type PayOrders []*PayOrder diff --git a/rpc/ent/payorder/payorder.go b/rpc/ent/payorder/payorder.go new file mode 100644 index 0000000..1b37460 --- /dev/null +++ b/rpc/ent/payorder/payorder.go @@ -0,0 +1,380 @@ +// Code generated by ent, DO NOT EDIT. + +package payorder + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the payorder type in the database. + Label = "pay_order" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // 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" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldChannelID holds the string denoting the channel_id field in the database. + FieldChannelID = "channel_id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldSubject holds the string denoting the subject field in the database. + FieldSubject = "subject" + // FieldBody holds the string denoting the body field in the database. + FieldBody = "body" + // FieldNotifyURL holds the string denoting the notify_url field in the database. + FieldNotifyURL = "notify_url" + // FieldAmount holds the string denoting the amount field in the database. + FieldAmount = "amount" + // FieldPaySource holds the string denoting the pay_source field in the database. + FieldPaySource = "pay_source" + // FieldChannelFeeRate holds the string denoting the channel_fee_rate field in the database. + FieldChannelFeeRate = "channel_fee_rate" + // FieldChannelFee holds the string denoting the channel_fee field in the database. + FieldChannelFee = "channel_fee" + // FieldOrderStatus holds the string denoting the order_status field in the database. + FieldOrderStatus = "order_status" + // FieldUserIP holds the string denoting the user_ip field in the database. + FieldUserIP = "user_ip" + // FieldExpireTime holds the string denoting the expire_time field in the database. + FieldExpireTime = "expire_time" + // FieldPayNo holds the string denoting the pay_no field in the database. + FieldPayNo = "pay_no" + // FieldSuccessTime holds the string denoting the success_time field in the database. + FieldSuccessTime = "success_time" + // FieldExtensionID holds the string denoting the extension_id field in the database. + FieldExtensionID = "extension_id" + // FieldTransactionID holds the string denoting the transaction_id field in the database. + FieldTransactionID = "transaction_id" + // FieldCurrency holds the string denoting the currency field in the database. + FieldCurrency = "currency" + // FieldRefundPrice holds the string denoting the refund_price field in the database. + FieldRefundPrice = "refund_price" + // FieldChannelOrderNo holds the string denoting the channel_order_no field in the database. + FieldChannelOrderNo = "channel_order_no" + // FieldChannelUserID holds the string denoting the channel_user_id field in the database. + FieldChannelUserID = "channel_user_id" + // EdgeChannel holds the string denoting the channel edge name in mutations. + EdgeChannel = "channel" + // EdgeOrdersExtension holds the string denoting the orders_extension edge name in mutations. + EdgeOrdersExtension = "orders_extension" + // EdgeNotifyTask holds the string denoting the notify_task edge name in mutations. + EdgeNotifyTask = "notify_task" + // EdgeRefund holds the string denoting the refund edge name in mutations. + EdgeRefund = "refund" + // Table holds the table name of the payorder in the database. + Table = "pay_order" + // ChannelTable is the table that holds the channel relation/edge. + ChannelTable = "pay_order" + // ChannelInverseTable is the table name for the PayChannel entity. + // It exists in this package in order to avoid circular dependency with the "paychannel" package. + ChannelInverseTable = "pay_channel" + // ChannelColumn is the table column denoting the channel relation/edge. + ChannelColumn = "channel_id" + // OrdersExtensionTable is the table that holds the orders_extension relation/edge. + OrdersExtensionTable = "pay_order_extension" + // OrdersExtensionInverseTable is the table name for the PayOrderExtension entity. + // It exists in this package in order to avoid circular dependency with the "payorderextension" package. + OrdersExtensionInverseTable = "pay_order_extension" + // OrdersExtensionColumn is the table column denoting the orders_extension relation/edge. + OrdersExtensionColumn = "order_id" + // NotifyTaskTable is the table that holds the notify_task relation/edge. + NotifyTaskTable = "pay_notify_task" + // NotifyTaskInverseTable is the table name for the PayNotifyTask entity. + // It exists in this package in order to avoid circular dependency with the "paynotifytask" package. + NotifyTaskInverseTable = "pay_notify_task" + // NotifyTaskColumn is the table column denoting the notify_task relation/edge. + NotifyTaskColumn = "order_id" + // RefundTable is the table that holds the refund relation/edge. + RefundTable = "pay_refund" + // RefundInverseTable is the table name for the PayRefund entity. + // It exists in this package in order to avoid circular dependency with the "payrefund" package. + RefundInverseTable = "pay_refund" + // RefundColumn is the table column denoting the refund relation/edge. + RefundColumn = "order_id" +) + +// Columns holds all SQL columns for payorder fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldChannelID, + FieldUserID, + FieldSubject, + FieldBody, + FieldNotifyURL, + FieldAmount, + FieldPaySource, + FieldChannelFeeRate, + FieldChannelFee, + FieldOrderStatus, + FieldUserIP, + FieldExpireTime, + FieldPayNo, + FieldSuccessTime, + FieldExtensionID, + FieldTransactionID, + FieldCurrency, + FieldRefundPrice, + FieldChannelOrderNo, + FieldChannelUserID, +} + +// 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 ( + // 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 + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 + // DefaultAmount holds the default value on creation for the "amount" field. + DefaultAmount uint64 + // DefaultChannelFeeRate holds the default value on creation for the "channel_fee_rate" field. + DefaultChannelFeeRate string + // DefaultChannelFee holds the default value on creation for the "channel_fee" field. + DefaultChannelFee uint64 + // DefaultOrderStatus holds the default value on creation for the "order_status" field. + DefaultOrderStatus string + // DefaultCurrency holds the default value on creation for the "currency" field. + DefaultCurrency string + // DefaultRefundPrice holds the default value on creation for the "refund_price" field. + DefaultRefundPrice uint64 +) + +// OrderOption defines the ordering options for the PayOrder 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() +} + +// 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() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByChannelID orders the results by the channel_id field. +func ByChannelID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// BySubject orders the results by the subject field. +func BySubject(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubject, opts...).ToFunc() +} + +// ByBody orders the results by the body field. +func ByBody(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBody, opts...).ToFunc() +} + +// ByNotifyURL orders the results by the notify_url field. +func ByNotifyURL(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNotifyURL, opts...).ToFunc() +} + +// ByAmount orders the results by the amount field. +func ByAmount(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAmount, opts...).ToFunc() +} + +// ByPaySource orders the results by the pay_source field. +func ByPaySource(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPaySource, opts...).ToFunc() +} + +// ByChannelFeeRate orders the results by the channel_fee_rate field. +func ByChannelFeeRate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelFeeRate, opts...).ToFunc() +} + +// ByChannelFee orders the results by the channel_fee field. +func ByChannelFee(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelFee, opts...).ToFunc() +} + +// ByOrderStatus orders the results by the order_status field. +func ByOrderStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderStatus, opts...).ToFunc() +} + +// ByUserIP orders the results by the user_ip field. +func ByUserIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserIP, opts...).ToFunc() +} + +// ByExpireTime orders the results by the expire_time field. +func ByExpireTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExpireTime, opts...).ToFunc() +} + +// ByPayNo orders the results by the pay_no field. +func ByPayNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPayNo, opts...).ToFunc() +} + +// BySuccessTime orders the results by the success_time field. +func BySuccessTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSuccessTime, opts...).ToFunc() +} + +// ByExtensionID orders the results by the extension_id field. +func ByExtensionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExtensionID, opts...).ToFunc() +} + +// ByTransactionID orders the results by the transaction_id field. +func ByTransactionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTransactionID, opts...).ToFunc() +} + +// ByCurrency orders the results by the currency field. +func ByCurrency(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCurrency, opts...).ToFunc() +} + +// ByRefundPrice orders the results by the refund_price field. +func ByRefundPrice(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRefundPrice, opts...).ToFunc() +} + +// ByChannelOrderNo orders the results by the channel_order_no field. +func ByChannelOrderNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelOrderNo, opts...).ToFunc() +} + +// ByChannelUserID orders the results by the channel_user_id field. +func ByChannelUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelUserID, opts...).ToFunc() +} + +// ByChannelField orders the results by channel field. +func ByChannelField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChannelStep(), sql.OrderByField(field, opts...)) + } +} + +// ByOrdersExtensionCount orders the results by orders_extension count. +func ByOrdersExtensionCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newOrdersExtensionStep(), opts...) + } +} + +// ByOrdersExtension orders the results by orders_extension terms. +func ByOrdersExtension(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOrdersExtensionStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByNotifyTaskCount orders the results by notify_task count. +func ByNotifyTaskCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newNotifyTaskStep(), opts...) + } +} + +// ByNotifyTask orders the results by notify_task terms. +func ByNotifyTask(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newNotifyTaskStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByRefundCount orders the results by refund count. +func ByRefundCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRefundStep(), opts...) + } +} + +// ByRefund orders the results by refund terms. +func ByRefund(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRefundStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newChannelStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ChannelInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ChannelTable, ChannelColumn), + ) +} +func newOrdersExtensionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OrdersExtensionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, OrdersExtensionTable, OrdersExtensionColumn), + ) +} +func newNotifyTaskStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(NotifyTaskInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, NotifyTaskTable, NotifyTaskColumn), + ) +} +func newRefundStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RefundInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RefundTable, RefundColumn), + ) +} diff --git a/rpc/ent/payorder/where.go b/rpc/ent/payorder/where.go new file mode 100644 index 0000000..62fbcb0 --- /dev/null +++ b/rpc/ent/payorder/where.go @@ -0,0 +1,1648 @@ +// Code generated by ent, DO NOT EDIT. + +package payorder + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PayOrder { + return predicate.PayOrder(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.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldDeletedAt, v)) +} + +// ChannelID applies equality check predicate on the "channel_id" field. It's identical to ChannelIDEQ. +func ChannelID(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelID, v)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldUserID, v)) +} + +// Subject applies equality check predicate on the "subject" field. It's identical to SubjectEQ. +func Subject(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldSubject, v)) +} + +// Body applies equality check predicate on the "body" field. It's identical to BodyEQ. +func Body(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldBody, v)) +} + +// NotifyURL applies equality check predicate on the "notify_url" field. It's identical to NotifyURLEQ. +func NotifyURL(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldNotifyURL, v)) +} + +// Amount applies equality check predicate on the "amount" field. It's identical to AmountEQ. +func Amount(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldAmount, v)) +} + +// PaySource applies equality check predicate on the "pay_source" field. It's identical to PaySourceEQ. +func PaySource(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldPaySource, v)) +} + +// ChannelFeeRate applies equality check predicate on the "channel_fee_rate" field. It's identical to ChannelFeeRateEQ. +func ChannelFeeRate(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelFeeRate, v)) +} + +// ChannelFee applies equality check predicate on the "channel_fee" field. It's identical to ChannelFeeEQ. +func ChannelFee(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelFee, v)) +} + +// OrderStatus applies equality check predicate on the "order_status" field. It's identical to OrderStatusEQ. +func OrderStatus(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldOrderStatus, v)) +} + +// UserIP applies equality check predicate on the "user_ip" field. It's identical to UserIPEQ. +func UserIP(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldUserIP, v)) +} + +// ExpireTime applies equality check predicate on the "expire_time" field. It's identical to ExpireTimeEQ. +func ExpireTime(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldExpireTime, v)) +} + +// PayNo applies equality check predicate on the "pay_no" field. It's identical to PayNoEQ. +func PayNo(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldPayNo, v)) +} + +// SuccessTime applies equality check predicate on the "success_time" field. It's identical to SuccessTimeEQ. +func SuccessTime(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldSuccessTime, v)) +} + +// ExtensionID applies equality check predicate on the "extension_id" field. It's identical to ExtensionIDEQ. +func ExtensionID(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldExtensionID, v)) +} + +// TransactionID applies equality check predicate on the "transaction_id" field. It's identical to TransactionIDEQ. +func TransactionID(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldTransactionID, v)) +} + +// Currency applies equality check predicate on the "currency" field. It's identical to CurrencyEQ. +func Currency(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldCurrency, v)) +} + +// RefundPrice applies equality check predicate on the "refund_price" field. It's identical to RefundPriceEQ. +func RefundPrice(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldRefundPrice, v)) +} + +// ChannelOrderNo applies equality check predicate on the "channel_order_no" field. It's identical to ChannelOrderNoEQ. +func ChannelOrderNo(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelOrderNo, v)) +} + +// ChannelUserID applies equality check predicate on the "channel_user_id" field. It's identical to ChannelUserIDEQ. +func ChannelUserID(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelUserID, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldDeletedAt)) +} + +// ChannelIDEQ applies the EQ predicate on the "channel_id" field. +func ChannelIDEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelID, v)) +} + +// ChannelIDNEQ applies the NEQ predicate on the "channel_id" field. +func ChannelIDNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldChannelID, v)) +} + +// ChannelIDIn applies the In predicate on the "channel_id" field. +func ChannelIDIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldChannelID, vs...)) +} + +// ChannelIDNotIn applies the NotIn predicate on the "channel_id" field. +func ChannelIDNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldChannelID, vs...)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldUserID, vs...)) +} + +// UserIDGT applies the GT predicate on the "user_id" field. +func UserIDGT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldUserID, v)) +} + +// UserIDGTE applies the GTE predicate on the "user_id" field. +func UserIDGTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldUserID, v)) +} + +// UserIDLT applies the LT predicate on the "user_id" field. +func UserIDLT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldUserID, v)) +} + +// UserIDLTE applies the LTE predicate on the "user_id" field. +func UserIDLTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldUserID, v)) +} + +// SubjectEQ applies the EQ predicate on the "subject" field. +func SubjectEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldSubject, v)) +} + +// SubjectNEQ applies the NEQ predicate on the "subject" field. +func SubjectNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldSubject, v)) +} + +// SubjectIn applies the In predicate on the "subject" field. +func SubjectIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldSubject, vs...)) +} + +// SubjectNotIn applies the NotIn predicate on the "subject" field. +func SubjectNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldSubject, vs...)) +} + +// SubjectGT applies the GT predicate on the "subject" field. +func SubjectGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldSubject, v)) +} + +// SubjectGTE applies the GTE predicate on the "subject" field. +func SubjectGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldSubject, v)) +} + +// SubjectLT applies the LT predicate on the "subject" field. +func SubjectLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldSubject, v)) +} + +// SubjectLTE applies the LTE predicate on the "subject" field. +func SubjectLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldSubject, v)) +} + +// SubjectContains applies the Contains predicate on the "subject" field. +func SubjectContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldSubject, v)) +} + +// SubjectHasPrefix applies the HasPrefix predicate on the "subject" field. +func SubjectHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldSubject, v)) +} + +// SubjectHasSuffix applies the HasSuffix predicate on the "subject" field. +func SubjectHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldSubject, v)) +} + +// SubjectEqualFold applies the EqualFold predicate on the "subject" field. +func SubjectEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldSubject, v)) +} + +// SubjectContainsFold applies the ContainsFold predicate on the "subject" field. +func SubjectContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldSubject, v)) +} + +// BodyEQ applies the EQ predicate on the "body" field. +func BodyEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldBody, v)) +} + +// BodyNEQ applies the NEQ predicate on the "body" field. +func BodyNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldBody, v)) +} + +// BodyIn applies the In predicate on the "body" field. +func BodyIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldBody, vs...)) +} + +// BodyNotIn applies the NotIn predicate on the "body" field. +func BodyNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldBody, vs...)) +} + +// BodyGT applies the GT predicate on the "body" field. +func BodyGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldBody, v)) +} + +// BodyGTE applies the GTE predicate on the "body" field. +func BodyGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldBody, v)) +} + +// BodyLT applies the LT predicate on the "body" field. +func BodyLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldBody, v)) +} + +// BodyLTE applies the LTE predicate on the "body" field. +func BodyLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldBody, v)) +} + +// BodyContains applies the Contains predicate on the "body" field. +func BodyContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldBody, v)) +} + +// BodyHasPrefix applies the HasPrefix predicate on the "body" field. +func BodyHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldBody, v)) +} + +// BodyHasSuffix applies the HasSuffix predicate on the "body" field. +func BodyHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldBody, v)) +} + +// BodyEqualFold applies the EqualFold predicate on the "body" field. +func BodyEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldBody, v)) +} + +// BodyContainsFold applies the ContainsFold predicate on the "body" field. +func BodyContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldBody, v)) +} + +// NotifyURLEQ applies the EQ predicate on the "notify_url" field. +func NotifyURLEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldNotifyURL, v)) +} + +// NotifyURLNEQ applies the NEQ predicate on the "notify_url" field. +func NotifyURLNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldNotifyURL, v)) +} + +// NotifyURLIn applies the In predicate on the "notify_url" field. +func NotifyURLIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldNotifyURL, vs...)) +} + +// NotifyURLNotIn applies the NotIn predicate on the "notify_url" field. +func NotifyURLNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldNotifyURL, vs...)) +} + +// NotifyURLGT applies the GT predicate on the "notify_url" field. +func NotifyURLGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldNotifyURL, v)) +} + +// NotifyURLGTE applies the GTE predicate on the "notify_url" field. +func NotifyURLGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldNotifyURL, v)) +} + +// NotifyURLLT applies the LT predicate on the "notify_url" field. +func NotifyURLLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldNotifyURL, v)) +} + +// NotifyURLLTE applies the LTE predicate on the "notify_url" field. +func NotifyURLLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldNotifyURL, v)) +} + +// NotifyURLContains applies the Contains predicate on the "notify_url" field. +func NotifyURLContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldNotifyURL, v)) +} + +// NotifyURLHasPrefix applies the HasPrefix predicate on the "notify_url" field. +func NotifyURLHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldNotifyURL, v)) +} + +// NotifyURLHasSuffix applies the HasSuffix predicate on the "notify_url" field. +func NotifyURLHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldNotifyURL, v)) +} + +// NotifyURLEqualFold applies the EqualFold predicate on the "notify_url" field. +func NotifyURLEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldNotifyURL, v)) +} + +// NotifyURLContainsFold applies the ContainsFold predicate on the "notify_url" field. +func NotifyURLContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldNotifyURL, v)) +} + +// AmountEQ applies the EQ predicate on the "amount" field. +func AmountEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldAmount, v)) +} + +// AmountNEQ applies the NEQ predicate on the "amount" field. +func AmountNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldAmount, v)) +} + +// AmountIn applies the In predicate on the "amount" field. +func AmountIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldAmount, vs...)) +} + +// AmountNotIn applies the NotIn predicate on the "amount" field. +func AmountNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldAmount, vs...)) +} + +// AmountGT applies the GT predicate on the "amount" field. +func AmountGT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldAmount, v)) +} + +// AmountGTE applies the GTE predicate on the "amount" field. +func AmountGTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldAmount, v)) +} + +// AmountLT applies the LT predicate on the "amount" field. +func AmountLT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldAmount, v)) +} + +// AmountLTE applies the LTE predicate on the "amount" field. +func AmountLTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldAmount, v)) +} + +// PaySourceEQ applies the EQ predicate on the "pay_source" field. +func PaySourceEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldPaySource, v)) +} + +// PaySourceNEQ applies the NEQ predicate on the "pay_source" field. +func PaySourceNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldPaySource, v)) +} + +// PaySourceIn applies the In predicate on the "pay_source" field. +func PaySourceIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldPaySource, vs...)) +} + +// PaySourceNotIn applies the NotIn predicate on the "pay_source" field. +func PaySourceNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldPaySource, vs...)) +} + +// PaySourceGT applies the GT predicate on the "pay_source" field. +func PaySourceGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldPaySource, v)) +} + +// PaySourceGTE applies the GTE predicate on the "pay_source" field. +func PaySourceGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldPaySource, v)) +} + +// PaySourceLT applies the LT predicate on the "pay_source" field. +func PaySourceLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldPaySource, v)) +} + +// PaySourceLTE applies the LTE predicate on the "pay_source" field. +func PaySourceLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldPaySource, v)) +} + +// PaySourceContains applies the Contains predicate on the "pay_source" field. +func PaySourceContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldPaySource, v)) +} + +// PaySourceHasPrefix applies the HasPrefix predicate on the "pay_source" field. +func PaySourceHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldPaySource, v)) +} + +// PaySourceHasSuffix applies the HasSuffix predicate on the "pay_source" field. +func PaySourceHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldPaySource, v)) +} + +// PaySourceIsNil applies the IsNil predicate on the "pay_source" field. +func PaySourceIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldPaySource)) +} + +// PaySourceNotNil applies the NotNil predicate on the "pay_source" field. +func PaySourceNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldPaySource)) +} + +// PaySourceEqualFold applies the EqualFold predicate on the "pay_source" field. +func PaySourceEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldPaySource, v)) +} + +// PaySourceContainsFold applies the ContainsFold predicate on the "pay_source" field. +func PaySourceContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldPaySource, v)) +} + +// ChannelFeeRateEQ applies the EQ predicate on the "channel_fee_rate" field. +func ChannelFeeRateEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateNEQ applies the NEQ predicate on the "channel_fee_rate" field. +func ChannelFeeRateNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateIn applies the In predicate on the "channel_fee_rate" field. +func ChannelFeeRateIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldChannelFeeRate, vs...)) +} + +// ChannelFeeRateNotIn applies the NotIn predicate on the "channel_fee_rate" field. +func ChannelFeeRateNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldChannelFeeRate, vs...)) +} + +// ChannelFeeRateGT applies the GT predicate on the "channel_fee_rate" field. +func ChannelFeeRateGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateGTE applies the GTE predicate on the "channel_fee_rate" field. +func ChannelFeeRateGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateLT applies the LT predicate on the "channel_fee_rate" field. +func ChannelFeeRateLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateLTE applies the LTE predicate on the "channel_fee_rate" field. +func ChannelFeeRateLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateContains applies the Contains predicate on the "channel_fee_rate" field. +func ChannelFeeRateContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateHasPrefix applies the HasPrefix predicate on the "channel_fee_rate" field. +func ChannelFeeRateHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateHasSuffix applies the HasSuffix predicate on the "channel_fee_rate" field. +func ChannelFeeRateHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateEqualFold applies the EqualFold predicate on the "channel_fee_rate" field. +func ChannelFeeRateEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldChannelFeeRate, v)) +} + +// ChannelFeeRateContainsFold applies the ContainsFold predicate on the "channel_fee_rate" field. +func ChannelFeeRateContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldChannelFeeRate, v)) +} + +// ChannelFeeEQ applies the EQ predicate on the "channel_fee" field. +func ChannelFeeEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelFee, v)) +} + +// ChannelFeeNEQ applies the NEQ predicate on the "channel_fee" field. +func ChannelFeeNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldChannelFee, v)) +} + +// ChannelFeeIn applies the In predicate on the "channel_fee" field. +func ChannelFeeIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldChannelFee, vs...)) +} + +// ChannelFeeNotIn applies the NotIn predicate on the "channel_fee" field. +func ChannelFeeNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldChannelFee, vs...)) +} + +// ChannelFeeGT applies the GT predicate on the "channel_fee" field. +func ChannelFeeGT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldChannelFee, v)) +} + +// ChannelFeeGTE applies the GTE predicate on the "channel_fee" field. +func ChannelFeeGTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldChannelFee, v)) +} + +// ChannelFeeLT applies the LT predicate on the "channel_fee" field. +func ChannelFeeLT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldChannelFee, v)) +} + +// ChannelFeeLTE applies the LTE predicate on the "channel_fee" field. +func ChannelFeeLTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldChannelFee, v)) +} + +// OrderStatusEQ applies the EQ predicate on the "order_status" field. +func OrderStatusEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldOrderStatus, v)) +} + +// OrderStatusNEQ applies the NEQ predicate on the "order_status" field. +func OrderStatusNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldOrderStatus, v)) +} + +// OrderStatusIn applies the In predicate on the "order_status" field. +func OrderStatusIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldOrderStatus, vs...)) +} + +// OrderStatusNotIn applies the NotIn predicate on the "order_status" field. +func OrderStatusNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldOrderStatus, vs...)) +} + +// OrderStatusGT applies the GT predicate on the "order_status" field. +func OrderStatusGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldOrderStatus, v)) +} + +// OrderStatusGTE applies the GTE predicate on the "order_status" field. +func OrderStatusGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldOrderStatus, v)) +} + +// OrderStatusLT applies the LT predicate on the "order_status" field. +func OrderStatusLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldOrderStatus, v)) +} + +// OrderStatusLTE applies the LTE predicate on the "order_status" field. +func OrderStatusLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldOrderStatus, v)) +} + +// OrderStatusContains applies the Contains predicate on the "order_status" field. +func OrderStatusContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldOrderStatus, v)) +} + +// OrderStatusHasPrefix applies the HasPrefix predicate on the "order_status" field. +func OrderStatusHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldOrderStatus, v)) +} + +// OrderStatusHasSuffix applies the HasSuffix predicate on the "order_status" field. +func OrderStatusHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldOrderStatus, v)) +} + +// OrderStatusEqualFold applies the EqualFold predicate on the "order_status" field. +func OrderStatusEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldOrderStatus, v)) +} + +// OrderStatusContainsFold applies the ContainsFold predicate on the "order_status" field. +func OrderStatusContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldOrderStatus, v)) +} + +// UserIPEQ applies the EQ predicate on the "user_ip" field. +func UserIPEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldUserIP, v)) +} + +// UserIPNEQ applies the NEQ predicate on the "user_ip" field. +func UserIPNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldUserIP, v)) +} + +// UserIPIn applies the In predicate on the "user_ip" field. +func UserIPIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldUserIP, vs...)) +} + +// UserIPNotIn applies the NotIn predicate on the "user_ip" field. +func UserIPNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldUserIP, vs...)) +} + +// UserIPGT applies the GT predicate on the "user_ip" field. +func UserIPGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldUserIP, v)) +} + +// UserIPGTE applies the GTE predicate on the "user_ip" field. +func UserIPGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldUserIP, v)) +} + +// UserIPLT applies the LT predicate on the "user_ip" field. +func UserIPLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldUserIP, v)) +} + +// UserIPLTE applies the LTE predicate on the "user_ip" field. +func UserIPLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldUserIP, v)) +} + +// UserIPContains applies the Contains predicate on the "user_ip" field. +func UserIPContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldUserIP, v)) +} + +// UserIPHasPrefix applies the HasPrefix predicate on the "user_ip" field. +func UserIPHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldUserIP, v)) +} + +// UserIPHasSuffix applies the HasSuffix predicate on the "user_ip" field. +func UserIPHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldUserIP, v)) +} + +// UserIPIsNil applies the IsNil predicate on the "user_ip" field. +func UserIPIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldUserIP)) +} + +// UserIPNotNil applies the NotNil predicate on the "user_ip" field. +func UserIPNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldUserIP)) +} + +// UserIPEqualFold applies the EqualFold predicate on the "user_ip" field. +func UserIPEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldUserIP, v)) +} + +// UserIPContainsFold applies the ContainsFold predicate on the "user_ip" field. +func UserIPContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldUserIP, v)) +} + +// ExpireTimeEQ applies the EQ predicate on the "expire_time" field. +func ExpireTimeEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldExpireTime, v)) +} + +// ExpireTimeNEQ applies the NEQ predicate on the "expire_time" field. +func ExpireTimeNEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldExpireTime, v)) +} + +// ExpireTimeIn applies the In predicate on the "expire_time" field. +func ExpireTimeIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldExpireTime, vs...)) +} + +// ExpireTimeNotIn applies the NotIn predicate on the "expire_time" field. +func ExpireTimeNotIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldExpireTime, vs...)) +} + +// ExpireTimeGT applies the GT predicate on the "expire_time" field. +func ExpireTimeGT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldExpireTime, v)) +} + +// ExpireTimeGTE applies the GTE predicate on the "expire_time" field. +func ExpireTimeGTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldExpireTime, v)) +} + +// ExpireTimeLT applies the LT predicate on the "expire_time" field. +func ExpireTimeLT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldExpireTime, v)) +} + +// ExpireTimeLTE applies the LTE predicate on the "expire_time" field. +func ExpireTimeLTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldExpireTime, v)) +} + +// PayNoEQ applies the EQ predicate on the "pay_no" field. +func PayNoEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldPayNo, v)) +} + +// PayNoNEQ applies the NEQ predicate on the "pay_no" field. +func PayNoNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldPayNo, v)) +} + +// PayNoIn applies the In predicate on the "pay_no" field. +func PayNoIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldPayNo, vs...)) +} + +// PayNoNotIn applies the NotIn predicate on the "pay_no" field. +func PayNoNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldPayNo, vs...)) +} + +// PayNoGT applies the GT predicate on the "pay_no" field. +func PayNoGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldPayNo, v)) +} + +// PayNoGTE applies the GTE predicate on the "pay_no" field. +func PayNoGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldPayNo, v)) +} + +// PayNoLT applies the LT predicate on the "pay_no" field. +func PayNoLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldPayNo, v)) +} + +// PayNoLTE applies the LTE predicate on the "pay_no" field. +func PayNoLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldPayNo, v)) +} + +// PayNoContains applies the Contains predicate on the "pay_no" field. +func PayNoContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldPayNo, v)) +} + +// PayNoHasPrefix applies the HasPrefix predicate on the "pay_no" field. +func PayNoHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldPayNo, v)) +} + +// PayNoHasSuffix applies the HasSuffix predicate on the "pay_no" field. +func PayNoHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldPayNo, v)) +} + +// PayNoEqualFold applies the EqualFold predicate on the "pay_no" field. +func PayNoEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldPayNo, v)) +} + +// PayNoContainsFold applies the ContainsFold predicate on the "pay_no" field. +func PayNoContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldPayNo, v)) +} + +// SuccessTimeEQ applies the EQ predicate on the "success_time" field. +func SuccessTimeEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldSuccessTime, v)) +} + +// SuccessTimeNEQ applies the NEQ predicate on the "success_time" field. +func SuccessTimeNEQ(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldSuccessTime, v)) +} + +// SuccessTimeIn applies the In predicate on the "success_time" field. +func SuccessTimeIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldSuccessTime, vs...)) +} + +// SuccessTimeNotIn applies the NotIn predicate on the "success_time" field. +func SuccessTimeNotIn(vs ...time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldSuccessTime, vs...)) +} + +// SuccessTimeGT applies the GT predicate on the "success_time" field. +func SuccessTimeGT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldSuccessTime, v)) +} + +// SuccessTimeGTE applies the GTE predicate on the "success_time" field. +func SuccessTimeGTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldSuccessTime, v)) +} + +// SuccessTimeLT applies the LT predicate on the "success_time" field. +func SuccessTimeLT(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldSuccessTime, v)) +} + +// SuccessTimeLTE applies the LTE predicate on the "success_time" field. +func SuccessTimeLTE(v time.Time) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldSuccessTime, v)) +} + +// ExtensionIDEQ applies the EQ predicate on the "extension_id" field. +func ExtensionIDEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldExtensionID, v)) +} + +// ExtensionIDNEQ applies the NEQ predicate on the "extension_id" field. +func ExtensionIDNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldExtensionID, v)) +} + +// ExtensionIDIn applies the In predicate on the "extension_id" field. +func ExtensionIDIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldExtensionID, vs...)) +} + +// ExtensionIDNotIn applies the NotIn predicate on the "extension_id" field. +func ExtensionIDNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldExtensionID, vs...)) +} + +// ExtensionIDGT applies the GT predicate on the "extension_id" field. +func ExtensionIDGT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldExtensionID, v)) +} + +// ExtensionIDGTE applies the GTE predicate on the "extension_id" field. +func ExtensionIDGTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldExtensionID, v)) +} + +// ExtensionIDLT applies the LT predicate on the "extension_id" field. +func ExtensionIDLT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldExtensionID, v)) +} + +// ExtensionIDLTE applies the LTE predicate on the "extension_id" field. +func ExtensionIDLTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldExtensionID, v)) +} + +// ExtensionIDIsNil applies the IsNil predicate on the "extension_id" field. +func ExtensionIDIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldExtensionID)) +} + +// ExtensionIDNotNil applies the NotNil predicate on the "extension_id" field. +func ExtensionIDNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldExtensionID)) +} + +// TransactionIDEQ applies the EQ predicate on the "transaction_id" field. +func TransactionIDEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldTransactionID, v)) +} + +// TransactionIDNEQ applies the NEQ predicate on the "transaction_id" field. +func TransactionIDNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldTransactionID, v)) +} + +// TransactionIDIn applies the In predicate on the "transaction_id" field. +func TransactionIDIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldTransactionID, vs...)) +} + +// TransactionIDNotIn applies the NotIn predicate on the "transaction_id" field. +func TransactionIDNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldTransactionID, vs...)) +} + +// TransactionIDGT applies the GT predicate on the "transaction_id" field. +func TransactionIDGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldTransactionID, v)) +} + +// TransactionIDGTE applies the GTE predicate on the "transaction_id" field. +func TransactionIDGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldTransactionID, v)) +} + +// TransactionIDLT applies the LT predicate on the "transaction_id" field. +func TransactionIDLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldTransactionID, v)) +} + +// TransactionIDLTE applies the LTE predicate on the "transaction_id" field. +func TransactionIDLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldTransactionID, v)) +} + +// TransactionIDContains applies the Contains predicate on the "transaction_id" field. +func TransactionIDContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldTransactionID, v)) +} + +// TransactionIDHasPrefix applies the HasPrefix predicate on the "transaction_id" field. +func TransactionIDHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldTransactionID, v)) +} + +// TransactionIDHasSuffix applies the HasSuffix predicate on the "transaction_id" field. +func TransactionIDHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldTransactionID, v)) +} + +// TransactionIDIsNil applies the IsNil predicate on the "transaction_id" field. +func TransactionIDIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldTransactionID)) +} + +// TransactionIDNotNil applies the NotNil predicate on the "transaction_id" field. +func TransactionIDNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldTransactionID)) +} + +// TransactionIDEqualFold applies the EqualFold predicate on the "transaction_id" field. +func TransactionIDEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldTransactionID, v)) +} + +// TransactionIDContainsFold applies the ContainsFold predicate on the "transaction_id" field. +func TransactionIDContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldTransactionID, v)) +} + +// CurrencyEQ applies the EQ predicate on the "currency" field. +func CurrencyEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldCurrency, v)) +} + +// CurrencyNEQ applies the NEQ predicate on the "currency" field. +func CurrencyNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldCurrency, v)) +} + +// CurrencyIn applies the In predicate on the "currency" field. +func CurrencyIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldCurrency, vs...)) +} + +// CurrencyNotIn applies the NotIn predicate on the "currency" field. +func CurrencyNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldCurrency, vs...)) +} + +// CurrencyGT applies the GT predicate on the "currency" field. +func CurrencyGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldCurrency, v)) +} + +// CurrencyGTE applies the GTE predicate on the "currency" field. +func CurrencyGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldCurrency, v)) +} + +// CurrencyLT applies the LT predicate on the "currency" field. +func CurrencyLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldCurrency, v)) +} + +// CurrencyLTE applies the LTE predicate on the "currency" field. +func CurrencyLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldCurrency, v)) +} + +// CurrencyContains applies the Contains predicate on the "currency" field. +func CurrencyContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldCurrency, v)) +} + +// CurrencyHasPrefix applies the HasPrefix predicate on the "currency" field. +func CurrencyHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldCurrency, v)) +} + +// CurrencyHasSuffix applies the HasSuffix predicate on the "currency" field. +func CurrencyHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldCurrency, v)) +} + +// CurrencyEqualFold applies the EqualFold predicate on the "currency" field. +func CurrencyEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldCurrency, v)) +} + +// CurrencyContainsFold applies the ContainsFold predicate on the "currency" field. +func CurrencyContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldCurrency, v)) +} + +// RefundPriceEQ applies the EQ predicate on the "refund_price" field. +func RefundPriceEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldRefundPrice, v)) +} + +// RefundPriceNEQ applies the NEQ predicate on the "refund_price" field. +func RefundPriceNEQ(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldRefundPrice, v)) +} + +// RefundPriceIn applies the In predicate on the "refund_price" field. +func RefundPriceIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldRefundPrice, vs...)) +} + +// RefundPriceNotIn applies the NotIn predicate on the "refund_price" field. +func RefundPriceNotIn(vs ...uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldRefundPrice, vs...)) +} + +// RefundPriceGT applies the GT predicate on the "refund_price" field. +func RefundPriceGT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldRefundPrice, v)) +} + +// RefundPriceGTE applies the GTE predicate on the "refund_price" field. +func RefundPriceGTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldRefundPrice, v)) +} + +// RefundPriceLT applies the LT predicate on the "refund_price" field. +func RefundPriceLT(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldRefundPrice, v)) +} + +// RefundPriceLTE applies the LTE predicate on the "refund_price" field. +func RefundPriceLTE(v uint64) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldRefundPrice, v)) +} + +// ChannelOrderNoEQ applies the EQ predicate on the "channel_order_no" field. +func ChannelOrderNoEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoNEQ applies the NEQ predicate on the "channel_order_no" field. +func ChannelOrderNoNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoIn applies the In predicate on the "channel_order_no" field. +func ChannelOrderNoIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldChannelOrderNo, vs...)) +} + +// ChannelOrderNoNotIn applies the NotIn predicate on the "channel_order_no" field. +func ChannelOrderNoNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldChannelOrderNo, vs...)) +} + +// ChannelOrderNoGT applies the GT predicate on the "channel_order_no" field. +func ChannelOrderNoGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoGTE applies the GTE predicate on the "channel_order_no" field. +func ChannelOrderNoGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoLT applies the LT predicate on the "channel_order_no" field. +func ChannelOrderNoLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoLTE applies the LTE predicate on the "channel_order_no" field. +func ChannelOrderNoLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoContains applies the Contains predicate on the "channel_order_no" field. +func ChannelOrderNoContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoHasPrefix applies the HasPrefix predicate on the "channel_order_no" field. +func ChannelOrderNoHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoHasSuffix applies the HasSuffix predicate on the "channel_order_no" field. +func ChannelOrderNoHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoIsNil applies the IsNil predicate on the "channel_order_no" field. +func ChannelOrderNoIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldChannelOrderNo)) +} + +// ChannelOrderNoNotNil applies the NotNil predicate on the "channel_order_no" field. +func ChannelOrderNoNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldChannelOrderNo)) +} + +// ChannelOrderNoEqualFold applies the EqualFold predicate on the "channel_order_no" field. +func ChannelOrderNoEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldChannelOrderNo, v)) +} + +// ChannelOrderNoContainsFold applies the ContainsFold predicate on the "channel_order_no" field. +func ChannelOrderNoContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldChannelOrderNo, v)) +} + +// ChannelUserIDEQ applies the EQ predicate on the "channel_user_id" field. +func ChannelUserIDEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEQ(FieldChannelUserID, v)) +} + +// ChannelUserIDNEQ applies the NEQ predicate on the "channel_user_id" field. +func ChannelUserIDNEQ(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNEQ(FieldChannelUserID, v)) +} + +// ChannelUserIDIn applies the In predicate on the "channel_user_id" field. +func ChannelUserIDIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldIn(FieldChannelUserID, vs...)) +} + +// ChannelUserIDNotIn applies the NotIn predicate on the "channel_user_id" field. +func ChannelUserIDNotIn(vs ...string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotIn(FieldChannelUserID, vs...)) +} + +// ChannelUserIDGT applies the GT predicate on the "channel_user_id" field. +func ChannelUserIDGT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGT(FieldChannelUserID, v)) +} + +// ChannelUserIDGTE applies the GTE predicate on the "channel_user_id" field. +func ChannelUserIDGTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldGTE(FieldChannelUserID, v)) +} + +// ChannelUserIDLT applies the LT predicate on the "channel_user_id" field. +func ChannelUserIDLT(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLT(FieldChannelUserID, v)) +} + +// ChannelUserIDLTE applies the LTE predicate on the "channel_user_id" field. +func ChannelUserIDLTE(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldLTE(FieldChannelUserID, v)) +} + +// ChannelUserIDContains applies the Contains predicate on the "channel_user_id" field. +func ChannelUserIDContains(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContains(FieldChannelUserID, v)) +} + +// ChannelUserIDHasPrefix applies the HasPrefix predicate on the "channel_user_id" field. +func ChannelUserIDHasPrefix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasPrefix(FieldChannelUserID, v)) +} + +// ChannelUserIDHasSuffix applies the HasSuffix predicate on the "channel_user_id" field. +func ChannelUserIDHasSuffix(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldHasSuffix(FieldChannelUserID, v)) +} + +// ChannelUserIDIsNil applies the IsNil predicate on the "channel_user_id" field. +func ChannelUserIDIsNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldIsNull(FieldChannelUserID)) +} + +// ChannelUserIDNotNil applies the NotNil predicate on the "channel_user_id" field. +func ChannelUserIDNotNil() predicate.PayOrder { + return predicate.PayOrder(sql.FieldNotNull(FieldChannelUserID)) +} + +// ChannelUserIDEqualFold applies the EqualFold predicate on the "channel_user_id" field. +func ChannelUserIDEqualFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldEqualFold(FieldChannelUserID, v)) +} + +// ChannelUserIDContainsFold applies the ContainsFold predicate on the "channel_user_id" field. +func ChannelUserIDContainsFold(v string) predicate.PayOrder { + return predicate.PayOrder(sql.FieldContainsFold(FieldChannelUserID, v)) +} + +// HasChannel applies the HasEdge predicate on the "channel" edge. +func HasChannel() predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ChannelTable, ChannelColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChannelWith applies the HasEdge predicate on the "channel" edge with a given conditions (other predicates). +func HasChannelWith(preds ...predicate.PayChannel) predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := newChannelStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasOrdersExtension applies the HasEdge predicate on the "orders_extension" edge. +func HasOrdersExtension() predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, OrdersExtensionTable, OrdersExtensionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOrdersExtensionWith applies the HasEdge predicate on the "orders_extension" edge with a given conditions (other predicates). +func HasOrdersExtensionWith(preds ...predicate.PayOrderExtension) predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := newOrdersExtensionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasNotifyTask applies the HasEdge predicate on the "notify_task" edge. +func HasNotifyTask() predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, NotifyTaskTable, NotifyTaskColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasNotifyTaskWith applies the HasEdge predicate on the "notify_task" edge with a given conditions (other predicates). +func HasNotifyTaskWith(preds ...predicate.PayNotifyTask) predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := newNotifyTaskStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRefund applies the HasEdge predicate on the "refund" edge. +func HasRefund() predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RefundTable, RefundColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRefundWith applies the HasEdge predicate on the "refund" edge with a given conditions (other predicates). +func HasRefundWith(preds ...predicate.PayRefund) predicate.PayOrder { + return predicate.PayOrder(func(s *sql.Selector) { + step := newRefundStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PayOrder) predicate.PayOrder { + return predicate.PayOrder(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PayOrder) predicate.PayOrder { + return predicate.PayOrder(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PayOrder) predicate.PayOrder { + return predicate.PayOrder(sql.NotPredicates(p)) +} diff --git a/rpc/ent/payorder_create.go b/rpc/ent/payorder_create.go new file mode 100644 index 0000000..ef6a727 --- /dev/null +++ b/rpc/ent/payorder_create.go @@ -0,0 +1,784 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderCreate is the builder for creating a PayOrder entity. +type PayOrderCreate struct { + config + mutation *PayOrderMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *PayOrderCreate) SetCreatedAt(v time.Time) *PayOrderCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableCreatedAt(v *time.Time) *PayOrderCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *PayOrderCreate) SetUpdatedAt(v time.Time) *PayOrderCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableUpdatedAt(v *time.Time) *PayOrderCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *PayOrderCreate) SetStatus(v uint8) *PayOrderCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableStatus(v *uint8) *PayOrderCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *PayOrderCreate) SetTenantID(v uint64) *PayOrderCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableTenantID(v *uint64) *PayOrderCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *PayOrderCreate) SetDeletedAt(v time.Time) *PayOrderCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableDeletedAt(v *time.Time) *PayOrderCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetChannelID sets the "channel_id" field. +func (_c *PayOrderCreate) SetChannelID(v uint64) *PayOrderCreate { + _c.mutation.SetChannelID(v) + return _c +} + +// SetUserID sets the "user_id" field. +func (_c *PayOrderCreate) SetUserID(v uint64) *PayOrderCreate { + _c.mutation.SetUserID(v) + return _c +} + +// SetSubject sets the "subject" field. +func (_c *PayOrderCreate) SetSubject(v string) *PayOrderCreate { + _c.mutation.SetSubject(v) + return _c +} + +// SetBody sets the "body" field. +func (_c *PayOrderCreate) SetBody(v string) *PayOrderCreate { + _c.mutation.SetBody(v) + return _c +} + +// SetNotifyURL sets the "notify_url" field. +func (_c *PayOrderCreate) SetNotifyURL(v string) *PayOrderCreate { + _c.mutation.SetNotifyURL(v) + return _c +} + +// SetAmount sets the "amount" field. +func (_c *PayOrderCreate) SetAmount(v uint64) *PayOrderCreate { + _c.mutation.SetAmount(v) + return _c +} + +// SetNillableAmount sets the "amount" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableAmount(v *uint64) *PayOrderCreate { + if v != nil { + _c.SetAmount(*v) + } + return _c +} + +// SetPaySource sets the "pay_source" field. +func (_c *PayOrderCreate) SetPaySource(v string) *PayOrderCreate { + _c.mutation.SetPaySource(v) + return _c +} + +// SetNillablePaySource sets the "pay_source" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillablePaySource(v *string) *PayOrderCreate { + if v != nil { + _c.SetPaySource(*v) + } + return _c +} + +// SetChannelFeeRate sets the "channel_fee_rate" field. +func (_c *PayOrderCreate) SetChannelFeeRate(v string) *PayOrderCreate { + _c.mutation.SetChannelFeeRate(v) + return _c +} + +// SetNillableChannelFeeRate sets the "channel_fee_rate" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableChannelFeeRate(v *string) *PayOrderCreate { + if v != nil { + _c.SetChannelFeeRate(*v) + } + return _c +} + +// SetChannelFee sets the "channel_fee" field. +func (_c *PayOrderCreate) SetChannelFee(v uint64) *PayOrderCreate { + _c.mutation.SetChannelFee(v) + return _c +} + +// SetNillableChannelFee sets the "channel_fee" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableChannelFee(v *uint64) *PayOrderCreate { + if v != nil { + _c.SetChannelFee(*v) + } + return _c +} + +// SetOrderStatus sets the "order_status" field. +func (_c *PayOrderCreate) SetOrderStatus(v string) *PayOrderCreate { + _c.mutation.SetOrderStatus(v) + return _c +} + +// SetNillableOrderStatus sets the "order_status" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableOrderStatus(v *string) *PayOrderCreate { + if v != nil { + _c.SetOrderStatus(*v) + } + return _c +} + +// SetUserIP sets the "user_ip" field. +func (_c *PayOrderCreate) SetUserIP(v string) *PayOrderCreate { + _c.mutation.SetUserIP(v) + return _c +} + +// SetNillableUserIP sets the "user_ip" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableUserIP(v *string) *PayOrderCreate { + if v != nil { + _c.SetUserIP(*v) + } + return _c +} + +// SetExpireTime sets the "expire_time" field. +func (_c *PayOrderCreate) SetExpireTime(v time.Time) *PayOrderCreate { + _c.mutation.SetExpireTime(v) + return _c +} + +// SetPayNo sets the "pay_no" field. +func (_c *PayOrderCreate) SetPayNo(v string) *PayOrderCreate { + _c.mutation.SetPayNo(v) + return _c +} + +// SetSuccessTime sets the "success_time" field. +func (_c *PayOrderCreate) SetSuccessTime(v time.Time) *PayOrderCreate { + _c.mutation.SetSuccessTime(v) + return _c +} + +// SetExtensionID sets the "extension_id" field. +func (_c *PayOrderCreate) SetExtensionID(v uint64) *PayOrderCreate { + _c.mutation.SetExtensionID(v) + return _c +} + +// SetNillableExtensionID sets the "extension_id" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableExtensionID(v *uint64) *PayOrderCreate { + if v != nil { + _c.SetExtensionID(*v) + } + return _c +} + +// SetTransactionID sets the "transaction_id" field. +func (_c *PayOrderCreate) SetTransactionID(v string) *PayOrderCreate { + _c.mutation.SetTransactionID(v) + return _c +} + +// SetNillableTransactionID sets the "transaction_id" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableTransactionID(v *string) *PayOrderCreate { + if v != nil { + _c.SetTransactionID(*v) + } + return _c +} + +// SetCurrency sets the "currency" field. +func (_c *PayOrderCreate) SetCurrency(v string) *PayOrderCreate { + _c.mutation.SetCurrency(v) + return _c +} + +// SetNillableCurrency sets the "currency" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableCurrency(v *string) *PayOrderCreate { + if v != nil { + _c.SetCurrency(*v) + } + return _c +} + +// SetRefundPrice sets the "refund_price" field. +func (_c *PayOrderCreate) SetRefundPrice(v uint64) *PayOrderCreate { + _c.mutation.SetRefundPrice(v) + return _c +} + +// SetNillableRefundPrice sets the "refund_price" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableRefundPrice(v *uint64) *PayOrderCreate { + if v != nil { + _c.SetRefundPrice(*v) + } + return _c +} + +// SetChannelOrderNo sets the "channel_order_no" field. +func (_c *PayOrderCreate) SetChannelOrderNo(v string) *PayOrderCreate { + _c.mutation.SetChannelOrderNo(v) + return _c +} + +// SetNillableChannelOrderNo sets the "channel_order_no" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableChannelOrderNo(v *string) *PayOrderCreate { + if v != nil { + _c.SetChannelOrderNo(*v) + } + return _c +} + +// SetChannelUserID sets the "channel_user_id" field. +func (_c *PayOrderCreate) SetChannelUserID(v string) *PayOrderCreate { + _c.mutation.SetChannelUserID(v) + return _c +} + +// SetNillableChannelUserID sets the "channel_user_id" field if the given value is not nil. +func (_c *PayOrderCreate) SetNillableChannelUserID(v *string) *PayOrderCreate { + if v != nil { + _c.SetChannelUserID(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PayOrderCreate) SetID(v uint64) *PayOrderCreate { + _c.mutation.SetID(v) + return _c +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_c *PayOrderCreate) SetChannel(v *PayChannel) *PayOrderCreate { + return _c.SetChannelID(v.ID) +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (_c *PayOrderCreate) AddOrdersExtensionIDs(ids ...uint64) *PayOrderCreate { + _c.mutation.AddOrdersExtensionIDs(ids...) + return _c +} + +// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity. +func (_c *PayOrderCreate) AddOrdersExtension(v ...*PayOrderExtension) *PayOrderCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddOrdersExtensionIDs(ids...) +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by IDs. +func (_c *PayOrderCreate) AddNotifyTaskIDs(ids ...uint64) *PayOrderCreate { + _c.mutation.AddNotifyTaskIDs(ids...) + return _c +} + +// AddNotifyTask adds the "notify_task" edges to the PayNotifyTask entity. +func (_c *PayOrderCreate) AddNotifyTask(v ...*PayNotifyTask) *PayOrderCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddNotifyTaskIDs(ids...) +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs. +func (_c *PayOrderCreate) AddRefundIDs(ids ...uint64) *PayOrderCreate { + _c.mutation.AddRefundIDs(ids...) + return _c +} + +// AddRefund adds the "refund" edges to the PayRefund entity. +func (_c *PayOrderCreate) AddRefund(v ...*PayRefund) *PayOrderCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddRefundIDs(ids...) +} + +// Mutation returns the PayOrderMutation object of the builder. +func (_c *PayOrderCreate) Mutation() *PayOrderMutation { + return _c.mutation +} + +// Save creates the PayOrder in the database. +func (_c *PayOrderCreate) Save(ctx context.Context) (*PayOrder, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PayOrderCreate) SaveX(ctx context.Context) *PayOrder { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayOrderCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayOrderCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PayOrderCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := payorder.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := payorder.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := payorder.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := payorder.DefaultTenantID + _c.mutation.SetTenantID(v) + } + if _, ok := _c.mutation.Amount(); !ok { + v := payorder.DefaultAmount + _c.mutation.SetAmount(v) + } + if _, ok := _c.mutation.ChannelFeeRate(); !ok { + v := payorder.DefaultChannelFeeRate + _c.mutation.SetChannelFeeRate(v) + } + if _, ok := _c.mutation.ChannelFee(); !ok { + v := payorder.DefaultChannelFee + _c.mutation.SetChannelFee(v) + } + if _, ok := _c.mutation.OrderStatus(); !ok { + v := payorder.DefaultOrderStatus + _c.mutation.SetOrderStatus(v) + } + if _, ok := _c.mutation.Currency(); !ok { + v := payorder.DefaultCurrency + _c.mutation.SetCurrency(v) + } + if _, ok := _c.mutation.RefundPrice(); !ok { + v := payorder.DefaultRefundPrice + _c.mutation.SetRefundPrice(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PayOrderCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayOrder.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayOrder.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayOrder.tenant_id"`)} + } + if _, ok := _c.mutation.ChannelID(); !ok { + return &ValidationError{Name: "channel_id", err: errors.New(`ent: missing required field "PayOrder.channel_id"`)} + } + if _, ok := _c.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "PayOrder.user_id"`)} + } + if _, ok := _c.mutation.Subject(); !ok { + return &ValidationError{Name: "subject", err: errors.New(`ent: missing required field "PayOrder.subject"`)} + } + if _, ok := _c.mutation.Body(); !ok { + return &ValidationError{Name: "body", err: errors.New(`ent: missing required field "PayOrder.body"`)} + } + if _, ok := _c.mutation.NotifyURL(); !ok { + return &ValidationError{Name: "notify_url", err: errors.New(`ent: missing required field "PayOrder.notify_url"`)} + } + if _, ok := _c.mutation.Amount(); !ok { + return &ValidationError{Name: "amount", err: errors.New(`ent: missing required field "PayOrder.amount"`)} + } + if _, ok := _c.mutation.ChannelFeeRate(); !ok { + return &ValidationError{Name: "channel_fee_rate", err: errors.New(`ent: missing required field "PayOrder.channel_fee_rate"`)} + } + if _, ok := _c.mutation.ChannelFee(); !ok { + return &ValidationError{Name: "channel_fee", err: errors.New(`ent: missing required field "PayOrder.channel_fee"`)} + } + if _, ok := _c.mutation.OrderStatus(); !ok { + return &ValidationError{Name: "order_status", err: errors.New(`ent: missing required field "PayOrder.order_status"`)} + } + if _, ok := _c.mutation.ExpireTime(); !ok { + return &ValidationError{Name: "expire_time", err: errors.New(`ent: missing required field "PayOrder.expire_time"`)} + } + if _, ok := _c.mutation.PayNo(); !ok { + return &ValidationError{Name: "pay_no", err: errors.New(`ent: missing required field "PayOrder.pay_no"`)} + } + if _, ok := _c.mutation.SuccessTime(); !ok { + return &ValidationError{Name: "success_time", err: errors.New(`ent: missing required field "PayOrder.success_time"`)} + } + if _, ok := _c.mutation.Currency(); !ok { + return &ValidationError{Name: "currency", err: errors.New(`ent: missing required field "PayOrder.currency"`)} + } + if _, ok := _c.mutation.RefundPrice(); !ok { + return &ValidationError{Name: "refund_price", err: errors.New(`ent: missing required field "PayOrder.refund_price"`)} + } + if len(_c.mutation.ChannelIDs()) == 0 { + return &ValidationError{Name: "channel", err: errors.New(`ent: missing required edge "PayOrder.channel"`)} + } + return nil +} + +func (_c *PayOrderCreate) sqlSave(ctx context.Context) (*PayOrder, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PayOrderCreate) createSpec() (*PayOrder, *sqlgraph.CreateSpec) { + var ( + _node = &PayOrder{config: _c.config} + _spec = sqlgraph.NewCreateSpec(payorder.Table, sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(payorder.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(payorder.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(payorder.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(payorder.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(payorder.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.UserID(); ok { + _spec.SetField(payorder.FieldUserID, field.TypeUint64, value) + _node.UserID = value + } + if value, ok := _c.mutation.Subject(); ok { + _spec.SetField(payorder.FieldSubject, field.TypeString, value) + _node.Subject = value + } + if value, ok := _c.mutation.Body(); ok { + _spec.SetField(payorder.FieldBody, field.TypeString, value) + _node.Body = value + } + if value, ok := _c.mutation.NotifyURL(); ok { + _spec.SetField(payorder.FieldNotifyURL, field.TypeString, value) + _node.NotifyURL = value + } + if value, ok := _c.mutation.Amount(); ok { + _spec.SetField(payorder.FieldAmount, field.TypeUint64, value) + _node.Amount = value + } + if value, ok := _c.mutation.PaySource(); ok { + _spec.SetField(payorder.FieldPaySource, field.TypeString, value) + _node.PaySource = value + } + if value, ok := _c.mutation.ChannelFeeRate(); ok { + _spec.SetField(payorder.FieldChannelFeeRate, field.TypeString, value) + _node.ChannelFeeRate = value + } + if value, ok := _c.mutation.ChannelFee(); ok { + _spec.SetField(payorder.FieldChannelFee, field.TypeUint64, value) + _node.ChannelFee = value + } + if value, ok := _c.mutation.OrderStatus(); ok { + _spec.SetField(payorder.FieldOrderStatus, field.TypeString, value) + _node.OrderStatus = value + } + if value, ok := _c.mutation.UserIP(); ok { + _spec.SetField(payorder.FieldUserIP, field.TypeString, value) + _node.UserIP = value + } + if value, ok := _c.mutation.ExpireTime(); ok { + _spec.SetField(payorder.FieldExpireTime, field.TypeTime, value) + _node.ExpireTime = value + } + if value, ok := _c.mutation.PayNo(); ok { + _spec.SetField(payorder.FieldPayNo, field.TypeString, value) + _node.PayNo = value + } + if value, ok := _c.mutation.SuccessTime(); ok { + _spec.SetField(payorder.FieldSuccessTime, field.TypeTime, value) + _node.SuccessTime = value + } + if value, ok := _c.mutation.ExtensionID(); ok { + _spec.SetField(payorder.FieldExtensionID, field.TypeUint64, value) + _node.ExtensionID = value + } + if value, ok := _c.mutation.TransactionID(); ok { + _spec.SetField(payorder.FieldTransactionID, field.TypeString, value) + _node.TransactionID = value + } + if value, ok := _c.mutation.Currency(); ok { + _spec.SetField(payorder.FieldCurrency, field.TypeString, value) + _node.Currency = value + } + if value, ok := _c.mutation.RefundPrice(); ok { + _spec.SetField(payorder.FieldRefundPrice, field.TypeUint64, value) + _node.RefundPrice = value + } + if value, ok := _c.mutation.ChannelOrderNo(); ok { + _spec.SetField(payorder.FieldChannelOrderNo, field.TypeString, value) + _node.ChannelOrderNo = value + } + if value, ok := _c.mutation.ChannelUserID(); ok { + _spec.SetField(payorder.FieldChannelUserID, field.TypeString, value) + _node.ChannelUserID = value + } + if nodes := _c.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorder.ChannelTable, + Columns: []string{payorder.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ChannelID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.OrdersExtensionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.NotifyTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.RefundIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PayOrderCreateBulk is the builder for creating many PayOrder entities in bulk. +type PayOrderCreateBulk struct { + config + err error + builders []*PayOrderCreate +} + +// Save creates the PayOrder entities in the database. +func (_c *PayOrderCreateBulk) Save(ctx context.Context) ([]*PayOrder, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PayOrder, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PayOrderMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PayOrderCreateBulk) SaveX(ctx context.Context) []*PayOrder { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayOrderCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayOrderCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/payorder_delete.go b/rpc/ent/payorder_delete.go new file mode 100644 index 0000000..bb165ce --- /dev/null +++ b/rpc/ent/payorder_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderDelete is the builder for deleting a PayOrder entity. +type PayOrderDelete struct { + config + hooks []Hook + mutation *PayOrderMutation +} + +// Where appends a list predicates to the PayOrderDelete builder. +func (_d *PayOrderDelete) Where(ps ...predicate.PayOrder) *PayOrderDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PayOrderDelete) 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 *PayOrderDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PayOrderDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(payorder.Table, sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64)) + 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 +} + +// PayOrderDeleteOne is the builder for deleting a single PayOrder entity. +type PayOrderDeleteOne struct { + _d *PayOrderDelete +} + +// Where appends a list predicates to the PayOrderDelete builder. +func (_d *PayOrderDeleteOne) Where(ps ...predicate.PayOrder) *PayOrderDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PayOrderDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{payorder.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayOrderDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/payorder_query.go b/rpc/ent/payorder_query.go new file mode 100644 index 0000000..f61a1f5 --- /dev/null +++ b/rpc/ent/payorder_query.go @@ -0,0 +1,829 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderQuery is the builder for querying PayOrder entities. +type PayOrderQuery struct { + config + ctx *QueryContext + order []payorder.OrderOption + inters []Interceptor + predicates []predicate.PayOrder + withChannel *PayChannelQuery + withOrdersExtension *PayOrderExtensionQuery + withNotifyTask *PayNotifyTaskQuery + withRefund *PayRefundQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PayOrderQuery builder. +func (_q *PayOrderQuery) Where(ps ...predicate.PayOrder) *PayOrderQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PayOrderQuery) Limit(limit int) *PayOrderQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PayOrderQuery) Offset(offset int) *PayOrderQuery { + _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 *PayOrderQuery) Unique(unique bool) *PayOrderQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PayOrderQuery) Order(o ...payorder.OrderOption) *PayOrderQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryChannel chains the current query on the "channel" edge. +func (_q *PayOrderQuery) QueryChannel() *PayChannelQuery { + query := (&PayChannelClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, selector), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payorder.ChannelTable, payorder.ChannelColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryOrdersExtension chains the current query on the "orders_extension" edge. +func (_q *PayOrderQuery) QueryOrdersExtension() *PayOrderExtensionQuery { + query := (&PayOrderExtensionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, selector), + sqlgraph.To(payorderextension.Table, payorderextension.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, payorder.OrdersExtensionTable, payorder.OrdersExtensionColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryNotifyTask chains the current query on the "notify_task" edge. +func (_q *PayOrderQuery) QueryNotifyTask() *PayNotifyTaskQuery { + query := (&PayNotifyTaskClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, selector), + sqlgraph.To(paynotifytask.Table, paynotifytask.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, payorder.NotifyTaskTable, payorder.NotifyTaskColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRefund chains the current query on the "refund" edge. +func (_q *PayOrderQuery) QueryRefund() *PayRefundQuery { + query := (&PayRefundClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payorder.Table, payorder.FieldID, selector), + sqlgraph.To(payrefund.Table, payrefund.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, payorder.RefundTable, payorder.RefundColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PayOrder entity from the query. +// Returns a *NotFoundError when no PayOrder was found. +func (_q *PayOrderQuery) First(ctx context.Context) (*PayOrder, 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{payorder.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PayOrderQuery) FirstX(ctx context.Context) *PayOrder { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PayOrder ID from the query. +// Returns a *NotFoundError when no PayOrder ID was found. +func (_q *PayOrderQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{payorder.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PayOrderQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PayOrder entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PayOrder entity is found. +// Returns a *NotFoundError when no PayOrder entities are found. +func (_q *PayOrderQuery) Only(ctx context.Context) (*PayOrder, 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{payorder.Label} + default: + return nil, &NotSingularError{payorder.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PayOrderQuery) OnlyX(ctx context.Context) *PayOrder { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PayOrder ID in the query. +// Returns a *NotSingularError when more than one PayOrder ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PayOrderQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + 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{payorder.Label} + default: + err = &NotSingularError{payorder.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PayOrderQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PayOrders. +func (_q *PayOrderQuery) All(ctx context.Context) ([]*PayOrder, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PayOrder, *PayOrderQuery]() + return withInterceptors[[]*PayOrder](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PayOrderQuery) AllX(ctx context.Context) []*PayOrder { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PayOrder IDs. +func (_q *PayOrderQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(payorder.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PayOrderQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PayOrderQuery) 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[*PayOrderQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PayOrderQuery) 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 *PayOrderQuery) 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 *PayOrderQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PayOrderQuery 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 *PayOrderQuery) Clone() *PayOrderQuery { + if _q == nil { + return nil + } + return &PayOrderQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]payorder.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PayOrder{}, _q.predicates...), + withChannel: _q.withChannel.Clone(), + withOrdersExtension: _q.withOrdersExtension.Clone(), + withNotifyTask: _q.withNotifyTask.Clone(), + withRefund: _q.withRefund.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithChannel tells the query-builder to eager-load the nodes that are connected to +// the "channel" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayOrderQuery) WithChannel(opts ...func(*PayChannelQuery)) *PayOrderQuery { + query := (&PayChannelClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChannel = query + return _q +} + +// WithOrdersExtension tells the query-builder to eager-load the nodes that are connected to +// the "orders_extension" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayOrderQuery) WithOrdersExtension(opts ...func(*PayOrderExtensionQuery)) *PayOrderQuery { + query := (&PayOrderExtensionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withOrdersExtension = query + return _q +} + +// WithNotifyTask tells the query-builder to eager-load the nodes that are connected to +// the "notify_task" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayOrderQuery) WithNotifyTask(opts ...func(*PayNotifyTaskQuery)) *PayOrderQuery { + query := (&PayNotifyTaskClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withNotifyTask = query + return _q +} + +// WithRefund tells the query-builder to eager-load the nodes that are connected to +// the "refund" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayOrderQuery) WithRefund(opts ...func(*PayRefundQuery)) *PayOrderQuery { + query := (&PayRefundClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRefund = query + return _q +} + +// 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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PayOrder.Query(). +// GroupBy(payorder.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PayOrderQuery) GroupBy(field string, fields ...string) *PayOrderGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PayOrderGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = payorder.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.PayOrder.Query(). +// Select(payorder.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *PayOrderQuery) Select(fields ...string) *PayOrderSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PayOrderSelect{PayOrderQuery: _q} + sbuild.label = payorder.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PayOrderSelect configured with the given aggregations. +func (_q *PayOrderQuery) Aggregate(fns ...AggregateFunc) *PayOrderSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PayOrderQuery) 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 !payorder.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 *PayOrderQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PayOrder, error) { + var ( + nodes = []*PayOrder{} + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withChannel != nil, + _q.withOrdersExtension != nil, + _q.withNotifyTask != nil, + _q.withRefund != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PayOrder).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PayOrder{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + 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 + } + if query := _q.withChannel; query != nil { + if err := _q.loadChannel(ctx, query, nodes, nil, + func(n *PayOrder, e *PayChannel) { n.Edges.Channel = e }); err != nil { + return nil, err + } + } + if query := _q.withOrdersExtension; query != nil { + if err := _q.loadOrdersExtension(ctx, query, nodes, + func(n *PayOrder) { n.Edges.OrdersExtension = []*PayOrderExtension{} }, + func(n *PayOrder, e *PayOrderExtension) { n.Edges.OrdersExtension = append(n.Edges.OrdersExtension, e) }); err != nil { + return nil, err + } + } + if query := _q.withNotifyTask; query != nil { + if err := _q.loadNotifyTask(ctx, query, nodes, + func(n *PayOrder) { n.Edges.NotifyTask = []*PayNotifyTask{} }, + func(n *PayOrder, e *PayNotifyTask) { n.Edges.NotifyTask = append(n.Edges.NotifyTask, e) }); err != nil { + return nil, err + } + } + if query := _q.withRefund; query != nil { + if err := _q.loadRefund(ctx, query, nodes, + func(n *PayOrder) { n.Edges.Refund = []*PayRefund{} }, + func(n *PayOrder, e *PayRefund) { n.Edges.Refund = append(n.Edges.Refund, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PayOrderQuery) loadChannel(ctx context.Context, query *PayChannelQuery, nodes []*PayOrder, init func(*PayOrder), assign func(*PayOrder, *PayChannel)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayOrder) + for i := range nodes { + fk := nodes[i].ChannelID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(paychannel.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "channel_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *PayOrderQuery) loadOrdersExtension(ctx context.Context, query *PayOrderExtensionQuery, nodes []*PayOrder, init func(*PayOrder), assign func(*PayOrder, *PayOrderExtension)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayOrder) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(payorderextension.FieldOrderID) + } + query.Where(predicate.PayOrderExtension(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(payorder.OrdersExtensionColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.OrderID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "order_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *PayOrderQuery) loadNotifyTask(ctx context.Context, query *PayNotifyTaskQuery, nodes []*PayOrder, init func(*PayOrder), assign func(*PayOrder, *PayNotifyTask)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayOrder) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(paynotifytask.FieldOrderID) + } + query.Where(predicate.PayNotifyTask(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(payorder.NotifyTaskColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.OrderID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "order_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *PayOrderQuery) loadRefund(ctx context.Context, query *PayRefundQuery, nodes []*PayOrder, init func(*PayOrder), assign func(*PayOrder, *PayRefund)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[uint64]*PayOrder) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(payrefund.FieldOrderID) + } + query.Where(predicate.PayRefund(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(payorder.RefundColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.OrderID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "order_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *PayOrderQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _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 *PayOrderQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(payorder.Table, payorder.Columns, sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64)) + _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, payorder.FieldID) + for i := range fields { + if fields[i] != payorder.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withChannel != nil { + _spec.Node.AddColumnOnce(payorder.FieldChannelID) + } + } + 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 *PayOrderQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(payorder.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = payorder.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 _, 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 +} + +// PayOrderGroupBy is the group-by builder for PayOrder entities. +type PayOrderGroupBy struct { + selector + build *PayOrderQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PayOrderGroupBy) Aggregate(fns ...AggregateFunc) *PayOrderGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PayOrderGroupBy) 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[*PayOrderQuery, *PayOrderGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PayOrderGroupBy) sqlScan(ctx context.Context, root *PayOrderQuery, 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) +} + +// PayOrderSelect is the builder for selecting fields of PayOrder entities. +type PayOrderSelect struct { + *PayOrderQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PayOrderSelect) Aggregate(fns ...AggregateFunc) *PayOrderSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PayOrderSelect) 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[*PayOrderQuery, *PayOrderSelect](ctx, _s.PayOrderQuery, _s, _s.inters, v) +} + +func (_s *PayOrderSelect) sqlScan(ctx context.Context, root *PayOrderQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/payorder_update.go b/rpc/ent/payorder_update.go new file mode 100644 index 0000000..36ace21 --- /dev/null +++ b/rpc/ent/payorder_update.go @@ -0,0 +1,1810 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderUpdate is the builder for updating PayOrder entities. +type PayOrderUpdate struct { + config + hooks []Hook + mutation *PayOrderMutation +} + +// Where appends a list predicates to the PayOrderUpdate builder. +func (_u *PayOrderUpdate) Where(ps ...predicate.PayOrder) *PayOrderUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayOrderUpdate) SetUpdatedAt(v time.Time) *PayOrderUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayOrderUpdate) SetStatus(v uint8) *PayOrderUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableStatus(v *uint8) *PayOrderUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayOrderUpdate) AddStatus(v int8) *PayOrderUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayOrderUpdate) ClearStatus() *PayOrderUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayOrderUpdate) SetDeletedAt(v time.Time) *PayOrderUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableDeletedAt(v *time.Time) *PayOrderUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayOrderUpdate) ClearDeletedAt() *PayOrderUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetChannelID sets the "channel_id" field. +func (_u *PayOrderUpdate) SetChannelID(v uint64) *PayOrderUpdate { + _u.mutation.SetChannelID(v) + return _u +} + +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableChannelID(v *uint64) *PayOrderUpdate { + if v != nil { + _u.SetChannelID(*v) + } + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *PayOrderUpdate) SetUserID(v uint64) *PayOrderUpdate { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableUserID(v *uint64) *PayOrderUpdate { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *PayOrderUpdate) AddUserID(v int64) *PayOrderUpdate { + _u.mutation.AddUserID(v) + return _u +} + +// SetSubject sets the "subject" field. +func (_u *PayOrderUpdate) SetSubject(v string) *PayOrderUpdate { + _u.mutation.SetSubject(v) + return _u +} + +// SetNillableSubject sets the "subject" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableSubject(v *string) *PayOrderUpdate { + if v != nil { + _u.SetSubject(*v) + } + return _u +} + +// SetBody sets the "body" field. +func (_u *PayOrderUpdate) SetBody(v string) *PayOrderUpdate { + _u.mutation.SetBody(v) + return _u +} + +// SetNillableBody sets the "body" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableBody(v *string) *PayOrderUpdate { + if v != nil { + _u.SetBody(*v) + } + return _u +} + +// SetNotifyURL sets the "notify_url" field. +func (_u *PayOrderUpdate) SetNotifyURL(v string) *PayOrderUpdate { + _u.mutation.SetNotifyURL(v) + return _u +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableNotifyURL(v *string) *PayOrderUpdate { + if v != nil { + _u.SetNotifyURL(*v) + } + return _u +} + +// SetAmount sets the "amount" field. +func (_u *PayOrderUpdate) SetAmount(v uint64) *PayOrderUpdate { + _u.mutation.ResetAmount() + _u.mutation.SetAmount(v) + return _u +} + +// SetNillableAmount sets the "amount" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableAmount(v *uint64) *PayOrderUpdate { + if v != nil { + _u.SetAmount(*v) + } + return _u +} + +// AddAmount adds value to the "amount" field. +func (_u *PayOrderUpdate) AddAmount(v int64) *PayOrderUpdate { + _u.mutation.AddAmount(v) + return _u +} + +// SetPaySource sets the "pay_source" field. +func (_u *PayOrderUpdate) SetPaySource(v string) *PayOrderUpdate { + _u.mutation.SetPaySource(v) + return _u +} + +// SetNillablePaySource sets the "pay_source" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillablePaySource(v *string) *PayOrderUpdate { + if v != nil { + _u.SetPaySource(*v) + } + return _u +} + +// ClearPaySource clears the value of the "pay_source" field. +func (_u *PayOrderUpdate) ClearPaySource() *PayOrderUpdate { + _u.mutation.ClearPaySource() + return _u +} + +// SetChannelFeeRate sets the "channel_fee_rate" field. +func (_u *PayOrderUpdate) SetChannelFeeRate(v string) *PayOrderUpdate { + _u.mutation.SetChannelFeeRate(v) + return _u +} + +// SetNillableChannelFeeRate sets the "channel_fee_rate" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableChannelFeeRate(v *string) *PayOrderUpdate { + if v != nil { + _u.SetChannelFeeRate(*v) + } + return _u +} + +// SetChannelFee sets the "channel_fee" field. +func (_u *PayOrderUpdate) SetChannelFee(v uint64) *PayOrderUpdate { + _u.mutation.ResetChannelFee() + _u.mutation.SetChannelFee(v) + return _u +} + +// SetNillableChannelFee sets the "channel_fee" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableChannelFee(v *uint64) *PayOrderUpdate { + if v != nil { + _u.SetChannelFee(*v) + } + return _u +} + +// AddChannelFee adds value to the "channel_fee" field. +func (_u *PayOrderUpdate) AddChannelFee(v int64) *PayOrderUpdate { + _u.mutation.AddChannelFee(v) + return _u +} + +// SetOrderStatus sets the "order_status" field. +func (_u *PayOrderUpdate) SetOrderStatus(v string) *PayOrderUpdate { + _u.mutation.SetOrderStatus(v) + return _u +} + +// SetNillableOrderStatus sets the "order_status" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableOrderStatus(v *string) *PayOrderUpdate { + if v != nil { + _u.SetOrderStatus(*v) + } + return _u +} + +// SetUserIP sets the "user_ip" field. +func (_u *PayOrderUpdate) SetUserIP(v string) *PayOrderUpdate { + _u.mutation.SetUserIP(v) + return _u +} + +// SetNillableUserIP sets the "user_ip" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableUserIP(v *string) *PayOrderUpdate { + if v != nil { + _u.SetUserIP(*v) + } + return _u +} + +// ClearUserIP clears the value of the "user_ip" field. +func (_u *PayOrderUpdate) ClearUserIP() *PayOrderUpdate { + _u.mutation.ClearUserIP() + return _u +} + +// SetExpireTime sets the "expire_time" field. +func (_u *PayOrderUpdate) SetExpireTime(v time.Time) *PayOrderUpdate { + _u.mutation.SetExpireTime(v) + return _u +} + +// SetNillableExpireTime sets the "expire_time" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableExpireTime(v *time.Time) *PayOrderUpdate { + if v != nil { + _u.SetExpireTime(*v) + } + return _u +} + +// SetPayNo sets the "pay_no" field. +func (_u *PayOrderUpdate) SetPayNo(v string) *PayOrderUpdate { + _u.mutation.SetPayNo(v) + return _u +} + +// SetNillablePayNo sets the "pay_no" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillablePayNo(v *string) *PayOrderUpdate { + if v != nil { + _u.SetPayNo(*v) + } + return _u +} + +// SetSuccessTime sets the "success_time" field. +func (_u *PayOrderUpdate) SetSuccessTime(v time.Time) *PayOrderUpdate { + _u.mutation.SetSuccessTime(v) + return _u +} + +// SetNillableSuccessTime sets the "success_time" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableSuccessTime(v *time.Time) *PayOrderUpdate { + if v != nil { + _u.SetSuccessTime(*v) + } + return _u +} + +// SetExtensionID sets the "extension_id" field. +func (_u *PayOrderUpdate) SetExtensionID(v uint64) *PayOrderUpdate { + _u.mutation.ResetExtensionID() + _u.mutation.SetExtensionID(v) + return _u +} + +// SetNillableExtensionID sets the "extension_id" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableExtensionID(v *uint64) *PayOrderUpdate { + if v != nil { + _u.SetExtensionID(*v) + } + return _u +} + +// AddExtensionID adds value to the "extension_id" field. +func (_u *PayOrderUpdate) AddExtensionID(v int64) *PayOrderUpdate { + _u.mutation.AddExtensionID(v) + return _u +} + +// ClearExtensionID clears the value of the "extension_id" field. +func (_u *PayOrderUpdate) ClearExtensionID() *PayOrderUpdate { + _u.mutation.ClearExtensionID() + return _u +} + +// SetTransactionID sets the "transaction_id" field. +func (_u *PayOrderUpdate) SetTransactionID(v string) *PayOrderUpdate { + _u.mutation.SetTransactionID(v) + return _u +} + +// SetNillableTransactionID sets the "transaction_id" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableTransactionID(v *string) *PayOrderUpdate { + if v != nil { + _u.SetTransactionID(*v) + } + return _u +} + +// ClearTransactionID clears the value of the "transaction_id" field. +func (_u *PayOrderUpdate) ClearTransactionID() *PayOrderUpdate { + _u.mutation.ClearTransactionID() + return _u +} + +// SetCurrency sets the "currency" field. +func (_u *PayOrderUpdate) SetCurrency(v string) *PayOrderUpdate { + _u.mutation.SetCurrency(v) + return _u +} + +// SetNillableCurrency sets the "currency" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableCurrency(v *string) *PayOrderUpdate { + if v != nil { + _u.SetCurrency(*v) + } + return _u +} + +// SetRefundPrice sets the "refund_price" field. +func (_u *PayOrderUpdate) SetRefundPrice(v uint64) *PayOrderUpdate { + _u.mutation.ResetRefundPrice() + _u.mutation.SetRefundPrice(v) + return _u +} + +// SetNillableRefundPrice sets the "refund_price" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableRefundPrice(v *uint64) *PayOrderUpdate { + if v != nil { + _u.SetRefundPrice(*v) + } + return _u +} + +// AddRefundPrice adds value to the "refund_price" field. +func (_u *PayOrderUpdate) AddRefundPrice(v int64) *PayOrderUpdate { + _u.mutation.AddRefundPrice(v) + return _u +} + +// SetChannelOrderNo sets the "channel_order_no" field. +func (_u *PayOrderUpdate) SetChannelOrderNo(v string) *PayOrderUpdate { + _u.mutation.SetChannelOrderNo(v) + return _u +} + +// SetNillableChannelOrderNo sets the "channel_order_no" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableChannelOrderNo(v *string) *PayOrderUpdate { + if v != nil { + _u.SetChannelOrderNo(*v) + } + return _u +} + +// ClearChannelOrderNo clears the value of the "channel_order_no" field. +func (_u *PayOrderUpdate) ClearChannelOrderNo() *PayOrderUpdate { + _u.mutation.ClearChannelOrderNo() + return _u +} + +// SetChannelUserID sets the "channel_user_id" field. +func (_u *PayOrderUpdate) SetChannelUserID(v string) *PayOrderUpdate { + _u.mutation.SetChannelUserID(v) + return _u +} + +// SetNillableChannelUserID sets the "channel_user_id" field if the given value is not nil. +func (_u *PayOrderUpdate) SetNillableChannelUserID(v *string) *PayOrderUpdate { + if v != nil { + _u.SetChannelUserID(*v) + } + return _u +} + +// ClearChannelUserID clears the value of the "channel_user_id" field. +func (_u *PayOrderUpdate) ClearChannelUserID() *PayOrderUpdate { + _u.mutation.ClearChannelUserID() + return _u +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_u *PayOrderUpdate) SetChannel(v *PayChannel) *PayOrderUpdate { + return _u.SetChannelID(v.ID) +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (_u *PayOrderUpdate) AddOrdersExtensionIDs(ids ...uint64) *PayOrderUpdate { + _u.mutation.AddOrdersExtensionIDs(ids...) + return _u +} + +// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayOrderUpdate) AddOrdersExtension(v ...*PayOrderExtension) *PayOrderUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddOrdersExtensionIDs(ids...) +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by IDs. +func (_u *PayOrderUpdate) AddNotifyTaskIDs(ids ...uint64) *PayOrderUpdate { + _u.mutation.AddNotifyTaskIDs(ids...) + return _u +} + +// AddNotifyTask adds the "notify_task" edges to the PayNotifyTask entity. +func (_u *PayOrderUpdate) AddNotifyTask(v ...*PayNotifyTask) *PayOrderUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddNotifyTaskIDs(ids...) +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs. +func (_u *PayOrderUpdate) AddRefundIDs(ids ...uint64) *PayOrderUpdate { + _u.mutation.AddRefundIDs(ids...) + return _u +} + +// AddRefund adds the "refund" edges to the PayRefund entity. +func (_u *PayOrderUpdate) AddRefund(v ...*PayRefund) *PayOrderUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRefundIDs(ids...) +} + +// Mutation returns the PayOrderMutation object of the builder. +func (_u *PayOrderUpdate) Mutation() *PayOrderMutation { + return _u.mutation +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (_u *PayOrderUpdate) ClearChannel() *PayOrderUpdate { + _u.mutation.ClearChannel() + return _u +} + +// ClearOrdersExtension clears all "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayOrderUpdate) ClearOrdersExtension() *PayOrderUpdate { + _u.mutation.ClearOrdersExtension() + return _u +} + +// RemoveOrdersExtensionIDs removes the "orders_extension" edge to PayOrderExtension entities by IDs. +func (_u *PayOrderUpdate) RemoveOrdersExtensionIDs(ids ...uint64) *PayOrderUpdate { + _u.mutation.RemoveOrdersExtensionIDs(ids...) + return _u +} + +// RemoveOrdersExtension removes "orders_extension" edges to PayOrderExtension entities. +func (_u *PayOrderUpdate) RemoveOrdersExtension(v ...*PayOrderExtension) *PayOrderUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveOrdersExtensionIDs(ids...) +} + +// ClearNotifyTask clears all "notify_task" edges to the PayNotifyTask entity. +func (_u *PayOrderUpdate) ClearNotifyTask() *PayOrderUpdate { + _u.mutation.ClearNotifyTask() + return _u +} + +// RemoveNotifyTaskIDs removes the "notify_task" edge to PayNotifyTask entities by IDs. +func (_u *PayOrderUpdate) RemoveNotifyTaskIDs(ids ...uint64) *PayOrderUpdate { + _u.mutation.RemoveNotifyTaskIDs(ids...) + return _u +} + +// RemoveNotifyTask removes "notify_task" edges to PayNotifyTask entities. +func (_u *PayOrderUpdate) RemoveNotifyTask(v ...*PayNotifyTask) *PayOrderUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveNotifyTaskIDs(ids...) +} + +// ClearRefund clears all "refund" edges to the PayRefund entity. +func (_u *PayOrderUpdate) ClearRefund() *PayOrderUpdate { + _u.mutation.ClearRefund() + return _u +} + +// RemoveRefundIDs removes the "refund" edge to PayRefund entities by IDs. +func (_u *PayOrderUpdate) RemoveRefundIDs(ids ...uint64) *PayOrderUpdate { + _u.mutation.RemoveRefundIDs(ids...) + return _u +} + +// RemoveRefund removes "refund" edges to PayRefund entities. +func (_u *PayOrderUpdate) RemoveRefund(v ...*PayRefund) *PayOrderUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRefundIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PayOrderUpdate) 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 *PayOrderUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PayOrderUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayOrderUpdate) 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 *PayOrderUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := payorder.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayOrderUpdate) check() error { + if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayOrder.channel"`) + } + return nil +} + +func (_u *PayOrderUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(payorder.Table, payorder.Columns, sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(payorder.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(payorder.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(payorder.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(payorder.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(payorder.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(payorder.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(payorder.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(payorder.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.Subject(); ok { + _spec.SetField(payorder.FieldSubject, field.TypeString, value) + } + if value, ok := _u.mutation.Body(); ok { + _spec.SetField(payorder.FieldBody, field.TypeString, value) + } + if value, ok := _u.mutation.NotifyURL(); ok { + _spec.SetField(payorder.FieldNotifyURL, field.TypeString, value) + } + if value, ok := _u.mutation.Amount(); ok { + _spec.SetField(payorder.FieldAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedAmount(); ok { + _spec.AddField(payorder.FieldAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.PaySource(); ok { + _spec.SetField(payorder.FieldPaySource, field.TypeString, value) + } + if _u.mutation.PaySourceCleared() { + _spec.ClearField(payorder.FieldPaySource, field.TypeString) + } + if value, ok := _u.mutation.ChannelFeeRate(); ok { + _spec.SetField(payorder.FieldChannelFeeRate, field.TypeString, value) + } + if value, ok := _u.mutation.ChannelFee(); ok { + _spec.SetField(payorder.FieldChannelFee, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedChannelFee(); ok { + _spec.AddField(payorder.FieldChannelFee, field.TypeUint64, value) + } + if value, ok := _u.mutation.OrderStatus(); ok { + _spec.SetField(payorder.FieldOrderStatus, field.TypeString, value) + } + if value, ok := _u.mutation.UserIP(); ok { + _spec.SetField(payorder.FieldUserIP, field.TypeString, value) + } + if _u.mutation.UserIPCleared() { + _spec.ClearField(payorder.FieldUserIP, field.TypeString) + } + if value, ok := _u.mutation.ExpireTime(); ok { + _spec.SetField(payorder.FieldExpireTime, field.TypeTime, value) + } + if value, ok := _u.mutation.PayNo(); ok { + _spec.SetField(payorder.FieldPayNo, field.TypeString, value) + } + if value, ok := _u.mutation.SuccessTime(); ok { + _spec.SetField(payorder.FieldSuccessTime, field.TypeTime, value) + } + if value, ok := _u.mutation.ExtensionID(); ok { + _spec.SetField(payorder.FieldExtensionID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedExtensionID(); ok { + _spec.AddField(payorder.FieldExtensionID, field.TypeUint64, value) + } + if _u.mutation.ExtensionIDCleared() { + _spec.ClearField(payorder.FieldExtensionID, field.TypeUint64) + } + if value, ok := _u.mutation.TransactionID(); ok { + _spec.SetField(payorder.FieldTransactionID, field.TypeString, value) + } + if _u.mutation.TransactionIDCleared() { + _spec.ClearField(payorder.FieldTransactionID, field.TypeString) + } + if value, ok := _u.mutation.Currency(); ok { + _spec.SetField(payorder.FieldCurrency, field.TypeString, value) + } + if value, ok := _u.mutation.RefundPrice(); ok { + _spec.SetField(payorder.FieldRefundPrice, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedRefundPrice(); ok { + _spec.AddField(payorder.FieldRefundPrice, field.TypeUint64, value) + } + if value, ok := _u.mutation.ChannelOrderNo(); ok { + _spec.SetField(payorder.FieldChannelOrderNo, field.TypeString, value) + } + if _u.mutation.ChannelOrderNoCleared() { + _spec.ClearField(payorder.FieldChannelOrderNo, field.TypeString) + } + if value, ok := _u.mutation.ChannelUserID(); ok { + _spec.SetField(payorder.FieldChannelUserID, field.TypeString, value) + } + if _u.mutation.ChannelUserIDCleared() { + _spec.ClearField(payorder.FieldChannelUserID, field.TypeString) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorder.ChannelTable, + Columns: []string{payorder.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorder.ChannelTable, + Columns: []string{payorder.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedOrdersExtensionIDs(); len(nodes) > 0 && !_u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrdersExtensionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedNotifyTaskIDs(); len(nodes) > 0 && !_u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.NotifyTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRefundIDs(); len(nodes) > 0 && !_u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RefundIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{payorder.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PayOrderUpdateOne is the builder for updating a single PayOrder entity. +type PayOrderUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PayOrderMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayOrderUpdateOne) SetUpdatedAt(v time.Time) *PayOrderUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayOrderUpdateOne) SetStatus(v uint8) *PayOrderUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableStatus(v *uint8) *PayOrderUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayOrderUpdateOne) AddStatus(v int8) *PayOrderUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayOrderUpdateOne) ClearStatus() *PayOrderUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayOrderUpdateOne) SetDeletedAt(v time.Time) *PayOrderUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableDeletedAt(v *time.Time) *PayOrderUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayOrderUpdateOne) ClearDeletedAt() *PayOrderUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetChannelID sets the "channel_id" field. +func (_u *PayOrderUpdateOne) SetChannelID(v uint64) *PayOrderUpdateOne { + _u.mutation.SetChannelID(v) + return _u +} + +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableChannelID(v *uint64) *PayOrderUpdateOne { + if v != nil { + _u.SetChannelID(*v) + } + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *PayOrderUpdateOne) SetUserID(v uint64) *PayOrderUpdateOne { + _u.mutation.ResetUserID() + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableUserID(v *uint64) *PayOrderUpdateOne { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// AddUserID adds value to the "user_id" field. +func (_u *PayOrderUpdateOne) AddUserID(v int64) *PayOrderUpdateOne { + _u.mutation.AddUserID(v) + return _u +} + +// SetSubject sets the "subject" field. +func (_u *PayOrderUpdateOne) SetSubject(v string) *PayOrderUpdateOne { + _u.mutation.SetSubject(v) + return _u +} + +// SetNillableSubject sets the "subject" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableSubject(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetSubject(*v) + } + return _u +} + +// SetBody sets the "body" field. +func (_u *PayOrderUpdateOne) SetBody(v string) *PayOrderUpdateOne { + _u.mutation.SetBody(v) + return _u +} + +// SetNillableBody sets the "body" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableBody(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetBody(*v) + } + return _u +} + +// SetNotifyURL sets the "notify_url" field. +func (_u *PayOrderUpdateOne) SetNotifyURL(v string) *PayOrderUpdateOne { + _u.mutation.SetNotifyURL(v) + return _u +} + +// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableNotifyURL(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetNotifyURL(*v) + } + return _u +} + +// SetAmount sets the "amount" field. +func (_u *PayOrderUpdateOne) SetAmount(v uint64) *PayOrderUpdateOne { + _u.mutation.ResetAmount() + _u.mutation.SetAmount(v) + return _u +} + +// SetNillableAmount sets the "amount" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableAmount(v *uint64) *PayOrderUpdateOne { + if v != nil { + _u.SetAmount(*v) + } + return _u +} + +// AddAmount adds value to the "amount" field. +func (_u *PayOrderUpdateOne) AddAmount(v int64) *PayOrderUpdateOne { + _u.mutation.AddAmount(v) + return _u +} + +// SetPaySource sets the "pay_source" field. +func (_u *PayOrderUpdateOne) SetPaySource(v string) *PayOrderUpdateOne { + _u.mutation.SetPaySource(v) + return _u +} + +// SetNillablePaySource sets the "pay_source" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillablePaySource(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetPaySource(*v) + } + return _u +} + +// ClearPaySource clears the value of the "pay_source" field. +func (_u *PayOrderUpdateOne) ClearPaySource() *PayOrderUpdateOne { + _u.mutation.ClearPaySource() + return _u +} + +// SetChannelFeeRate sets the "channel_fee_rate" field. +func (_u *PayOrderUpdateOne) SetChannelFeeRate(v string) *PayOrderUpdateOne { + _u.mutation.SetChannelFeeRate(v) + return _u +} + +// SetNillableChannelFeeRate sets the "channel_fee_rate" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableChannelFeeRate(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetChannelFeeRate(*v) + } + return _u +} + +// SetChannelFee sets the "channel_fee" field. +func (_u *PayOrderUpdateOne) SetChannelFee(v uint64) *PayOrderUpdateOne { + _u.mutation.ResetChannelFee() + _u.mutation.SetChannelFee(v) + return _u +} + +// SetNillableChannelFee sets the "channel_fee" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableChannelFee(v *uint64) *PayOrderUpdateOne { + if v != nil { + _u.SetChannelFee(*v) + } + return _u +} + +// AddChannelFee adds value to the "channel_fee" field. +func (_u *PayOrderUpdateOne) AddChannelFee(v int64) *PayOrderUpdateOne { + _u.mutation.AddChannelFee(v) + return _u +} + +// SetOrderStatus sets the "order_status" field. +func (_u *PayOrderUpdateOne) SetOrderStatus(v string) *PayOrderUpdateOne { + _u.mutation.SetOrderStatus(v) + return _u +} + +// SetNillableOrderStatus sets the "order_status" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableOrderStatus(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetOrderStatus(*v) + } + return _u +} + +// SetUserIP sets the "user_ip" field. +func (_u *PayOrderUpdateOne) SetUserIP(v string) *PayOrderUpdateOne { + _u.mutation.SetUserIP(v) + return _u +} + +// SetNillableUserIP sets the "user_ip" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableUserIP(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetUserIP(*v) + } + return _u +} + +// ClearUserIP clears the value of the "user_ip" field. +func (_u *PayOrderUpdateOne) ClearUserIP() *PayOrderUpdateOne { + _u.mutation.ClearUserIP() + return _u +} + +// SetExpireTime sets the "expire_time" field. +func (_u *PayOrderUpdateOne) SetExpireTime(v time.Time) *PayOrderUpdateOne { + _u.mutation.SetExpireTime(v) + return _u +} + +// SetNillableExpireTime sets the "expire_time" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableExpireTime(v *time.Time) *PayOrderUpdateOne { + if v != nil { + _u.SetExpireTime(*v) + } + return _u +} + +// SetPayNo sets the "pay_no" field. +func (_u *PayOrderUpdateOne) SetPayNo(v string) *PayOrderUpdateOne { + _u.mutation.SetPayNo(v) + return _u +} + +// SetNillablePayNo sets the "pay_no" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillablePayNo(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetPayNo(*v) + } + return _u +} + +// SetSuccessTime sets the "success_time" field. +func (_u *PayOrderUpdateOne) SetSuccessTime(v time.Time) *PayOrderUpdateOne { + _u.mutation.SetSuccessTime(v) + return _u +} + +// SetNillableSuccessTime sets the "success_time" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableSuccessTime(v *time.Time) *PayOrderUpdateOne { + if v != nil { + _u.SetSuccessTime(*v) + } + return _u +} + +// SetExtensionID sets the "extension_id" field. +func (_u *PayOrderUpdateOne) SetExtensionID(v uint64) *PayOrderUpdateOne { + _u.mutation.ResetExtensionID() + _u.mutation.SetExtensionID(v) + return _u +} + +// SetNillableExtensionID sets the "extension_id" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableExtensionID(v *uint64) *PayOrderUpdateOne { + if v != nil { + _u.SetExtensionID(*v) + } + return _u +} + +// AddExtensionID adds value to the "extension_id" field. +func (_u *PayOrderUpdateOne) AddExtensionID(v int64) *PayOrderUpdateOne { + _u.mutation.AddExtensionID(v) + return _u +} + +// ClearExtensionID clears the value of the "extension_id" field. +func (_u *PayOrderUpdateOne) ClearExtensionID() *PayOrderUpdateOne { + _u.mutation.ClearExtensionID() + return _u +} + +// SetTransactionID sets the "transaction_id" field. +func (_u *PayOrderUpdateOne) SetTransactionID(v string) *PayOrderUpdateOne { + _u.mutation.SetTransactionID(v) + return _u +} + +// SetNillableTransactionID sets the "transaction_id" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableTransactionID(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetTransactionID(*v) + } + return _u +} + +// ClearTransactionID clears the value of the "transaction_id" field. +func (_u *PayOrderUpdateOne) ClearTransactionID() *PayOrderUpdateOne { + _u.mutation.ClearTransactionID() + return _u +} + +// SetCurrency sets the "currency" field. +func (_u *PayOrderUpdateOne) SetCurrency(v string) *PayOrderUpdateOne { + _u.mutation.SetCurrency(v) + return _u +} + +// SetNillableCurrency sets the "currency" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableCurrency(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetCurrency(*v) + } + return _u +} + +// SetRefundPrice sets the "refund_price" field. +func (_u *PayOrderUpdateOne) SetRefundPrice(v uint64) *PayOrderUpdateOne { + _u.mutation.ResetRefundPrice() + _u.mutation.SetRefundPrice(v) + return _u +} + +// SetNillableRefundPrice sets the "refund_price" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableRefundPrice(v *uint64) *PayOrderUpdateOne { + if v != nil { + _u.SetRefundPrice(*v) + } + return _u +} + +// AddRefundPrice adds value to the "refund_price" field. +func (_u *PayOrderUpdateOne) AddRefundPrice(v int64) *PayOrderUpdateOne { + _u.mutation.AddRefundPrice(v) + return _u +} + +// SetChannelOrderNo sets the "channel_order_no" field. +func (_u *PayOrderUpdateOne) SetChannelOrderNo(v string) *PayOrderUpdateOne { + _u.mutation.SetChannelOrderNo(v) + return _u +} + +// SetNillableChannelOrderNo sets the "channel_order_no" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableChannelOrderNo(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetChannelOrderNo(*v) + } + return _u +} + +// ClearChannelOrderNo clears the value of the "channel_order_no" field. +func (_u *PayOrderUpdateOne) ClearChannelOrderNo() *PayOrderUpdateOne { + _u.mutation.ClearChannelOrderNo() + return _u +} + +// SetChannelUserID sets the "channel_user_id" field. +func (_u *PayOrderUpdateOne) SetChannelUserID(v string) *PayOrderUpdateOne { + _u.mutation.SetChannelUserID(v) + return _u +} + +// SetNillableChannelUserID sets the "channel_user_id" field if the given value is not nil. +func (_u *PayOrderUpdateOne) SetNillableChannelUserID(v *string) *PayOrderUpdateOne { + if v != nil { + _u.SetChannelUserID(*v) + } + return _u +} + +// ClearChannelUserID clears the value of the "channel_user_id" field. +func (_u *PayOrderUpdateOne) ClearChannelUserID() *PayOrderUpdateOne { + _u.mutation.ClearChannelUserID() + return _u +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_u *PayOrderUpdateOne) SetChannel(v *PayChannel) *PayOrderUpdateOne { + return _u.SetChannelID(v.ID) +} + +// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs. +func (_u *PayOrderUpdateOne) AddOrdersExtensionIDs(ids ...uint64) *PayOrderUpdateOne { + _u.mutation.AddOrdersExtensionIDs(ids...) + return _u +} + +// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayOrderUpdateOne) AddOrdersExtension(v ...*PayOrderExtension) *PayOrderUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddOrdersExtensionIDs(ids...) +} + +// AddNotifyTaskIDs adds the "notify_task" edge to the PayNotifyTask entity by IDs. +func (_u *PayOrderUpdateOne) AddNotifyTaskIDs(ids ...uint64) *PayOrderUpdateOne { + _u.mutation.AddNotifyTaskIDs(ids...) + return _u +} + +// AddNotifyTask adds the "notify_task" edges to the PayNotifyTask entity. +func (_u *PayOrderUpdateOne) AddNotifyTask(v ...*PayNotifyTask) *PayOrderUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddNotifyTaskIDs(ids...) +} + +// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs. +func (_u *PayOrderUpdateOne) AddRefundIDs(ids ...uint64) *PayOrderUpdateOne { + _u.mutation.AddRefundIDs(ids...) + return _u +} + +// AddRefund adds the "refund" edges to the PayRefund entity. +func (_u *PayOrderUpdateOne) AddRefund(v ...*PayRefund) *PayOrderUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRefundIDs(ids...) +} + +// Mutation returns the PayOrderMutation object of the builder. +func (_u *PayOrderUpdateOne) Mutation() *PayOrderMutation { + return _u.mutation +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (_u *PayOrderUpdateOne) ClearChannel() *PayOrderUpdateOne { + _u.mutation.ClearChannel() + return _u +} + +// ClearOrdersExtension clears all "orders_extension" edges to the PayOrderExtension entity. +func (_u *PayOrderUpdateOne) ClearOrdersExtension() *PayOrderUpdateOne { + _u.mutation.ClearOrdersExtension() + return _u +} + +// RemoveOrdersExtensionIDs removes the "orders_extension" edge to PayOrderExtension entities by IDs. +func (_u *PayOrderUpdateOne) RemoveOrdersExtensionIDs(ids ...uint64) *PayOrderUpdateOne { + _u.mutation.RemoveOrdersExtensionIDs(ids...) + return _u +} + +// RemoveOrdersExtension removes "orders_extension" edges to PayOrderExtension entities. +func (_u *PayOrderUpdateOne) RemoveOrdersExtension(v ...*PayOrderExtension) *PayOrderUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveOrdersExtensionIDs(ids...) +} + +// ClearNotifyTask clears all "notify_task" edges to the PayNotifyTask entity. +func (_u *PayOrderUpdateOne) ClearNotifyTask() *PayOrderUpdateOne { + _u.mutation.ClearNotifyTask() + return _u +} + +// RemoveNotifyTaskIDs removes the "notify_task" edge to PayNotifyTask entities by IDs. +func (_u *PayOrderUpdateOne) RemoveNotifyTaskIDs(ids ...uint64) *PayOrderUpdateOne { + _u.mutation.RemoveNotifyTaskIDs(ids...) + return _u +} + +// RemoveNotifyTask removes "notify_task" edges to PayNotifyTask entities. +func (_u *PayOrderUpdateOne) RemoveNotifyTask(v ...*PayNotifyTask) *PayOrderUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveNotifyTaskIDs(ids...) +} + +// ClearRefund clears all "refund" edges to the PayRefund entity. +func (_u *PayOrderUpdateOne) ClearRefund() *PayOrderUpdateOne { + _u.mutation.ClearRefund() + return _u +} + +// RemoveRefundIDs removes the "refund" edge to PayRefund entities by IDs. +func (_u *PayOrderUpdateOne) RemoveRefundIDs(ids ...uint64) *PayOrderUpdateOne { + _u.mutation.RemoveRefundIDs(ids...) + return _u +} + +// RemoveRefund removes "refund" edges to PayRefund entities. +func (_u *PayOrderUpdateOne) RemoveRefund(v ...*PayRefund) *PayOrderUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRefundIDs(ids...) +} + +// Where appends a list predicates to the PayOrderUpdate builder. +func (_u *PayOrderUpdateOne) Where(ps ...predicate.PayOrder) *PayOrderUpdateOne { + _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 *PayOrderUpdateOne) Select(field string, fields ...string) *PayOrderUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PayOrder entity. +func (_u *PayOrderUpdateOne) Save(ctx context.Context) (*PayOrder, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PayOrderUpdateOne) SaveX(ctx context.Context) *PayOrder { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PayOrderUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayOrderUpdateOne) 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 *PayOrderUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := payorder.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayOrderUpdateOne) check() error { + if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayOrder.channel"`) + } + return nil +} + +func (_u *PayOrderUpdateOne) sqlSave(ctx context.Context) (_node *PayOrder, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(payorder.Table, payorder.Columns, sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayOrder.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, payorder.FieldID) + for _, f := range fields { + if !payorder.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != payorder.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.UpdatedAt(); ok { + _spec.SetField(payorder.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(payorder.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(payorder.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(payorder.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(payorder.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(payorder.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.UserID(); ok { + _spec.SetField(payorder.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedUserID(); ok { + _spec.AddField(payorder.FieldUserID, field.TypeUint64, value) + } + if value, ok := _u.mutation.Subject(); ok { + _spec.SetField(payorder.FieldSubject, field.TypeString, value) + } + if value, ok := _u.mutation.Body(); ok { + _spec.SetField(payorder.FieldBody, field.TypeString, value) + } + if value, ok := _u.mutation.NotifyURL(); ok { + _spec.SetField(payorder.FieldNotifyURL, field.TypeString, value) + } + if value, ok := _u.mutation.Amount(); ok { + _spec.SetField(payorder.FieldAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedAmount(); ok { + _spec.AddField(payorder.FieldAmount, field.TypeUint64, value) + } + if value, ok := _u.mutation.PaySource(); ok { + _spec.SetField(payorder.FieldPaySource, field.TypeString, value) + } + if _u.mutation.PaySourceCleared() { + _spec.ClearField(payorder.FieldPaySource, field.TypeString) + } + if value, ok := _u.mutation.ChannelFeeRate(); ok { + _spec.SetField(payorder.FieldChannelFeeRate, field.TypeString, value) + } + if value, ok := _u.mutation.ChannelFee(); ok { + _spec.SetField(payorder.FieldChannelFee, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedChannelFee(); ok { + _spec.AddField(payorder.FieldChannelFee, field.TypeUint64, value) + } + if value, ok := _u.mutation.OrderStatus(); ok { + _spec.SetField(payorder.FieldOrderStatus, field.TypeString, value) + } + if value, ok := _u.mutation.UserIP(); ok { + _spec.SetField(payorder.FieldUserIP, field.TypeString, value) + } + if _u.mutation.UserIPCleared() { + _spec.ClearField(payorder.FieldUserIP, field.TypeString) + } + if value, ok := _u.mutation.ExpireTime(); ok { + _spec.SetField(payorder.FieldExpireTime, field.TypeTime, value) + } + if value, ok := _u.mutation.PayNo(); ok { + _spec.SetField(payorder.FieldPayNo, field.TypeString, value) + } + if value, ok := _u.mutation.SuccessTime(); ok { + _spec.SetField(payorder.FieldSuccessTime, field.TypeTime, value) + } + if value, ok := _u.mutation.ExtensionID(); ok { + _spec.SetField(payorder.FieldExtensionID, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedExtensionID(); ok { + _spec.AddField(payorder.FieldExtensionID, field.TypeUint64, value) + } + if _u.mutation.ExtensionIDCleared() { + _spec.ClearField(payorder.FieldExtensionID, field.TypeUint64) + } + if value, ok := _u.mutation.TransactionID(); ok { + _spec.SetField(payorder.FieldTransactionID, field.TypeString, value) + } + if _u.mutation.TransactionIDCleared() { + _spec.ClearField(payorder.FieldTransactionID, field.TypeString) + } + if value, ok := _u.mutation.Currency(); ok { + _spec.SetField(payorder.FieldCurrency, field.TypeString, value) + } + if value, ok := _u.mutation.RefundPrice(); ok { + _spec.SetField(payorder.FieldRefundPrice, field.TypeUint64, value) + } + if value, ok := _u.mutation.AddedRefundPrice(); ok { + _spec.AddField(payorder.FieldRefundPrice, field.TypeUint64, value) + } + if value, ok := _u.mutation.ChannelOrderNo(); ok { + _spec.SetField(payorder.FieldChannelOrderNo, field.TypeString, value) + } + if _u.mutation.ChannelOrderNoCleared() { + _spec.ClearField(payorder.FieldChannelOrderNo, field.TypeString) + } + if value, ok := _u.mutation.ChannelUserID(); ok { + _spec.SetField(payorder.FieldChannelUserID, field.TypeString, value) + } + if _u.mutation.ChannelUserIDCleared() { + _spec.ClearField(payorder.FieldChannelUserID, field.TypeString) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorder.ChannelTable, + Columns: []string{payorder.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorder.ChannelTable, + Columns: []string{payorder.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedOrdersExtensionIDs(); len(nodes) > 0 && !_u.mutation.OrdersExtensionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrdersExtensionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.OrdersExtensionTable, + Columns: []string{payorder.OrdersExtensionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedNotifyTaskIDs(); len(nodes) > 0 && !_u.mutation.NotifyTaskCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.NotifyTaskIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.NotifyTaskTable, + Columns: []string{payorder.NotifyTaskColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paynotifytask.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRefundIDs(); len(nodes) > 0 && !_u.mutation.RefundCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RefundIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: payorder.RefundTable, + Columns: []string{payorder.RefundColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PayOrder{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{payorder.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/payorderextension.go b/rpc/ent/payorderextension.go new file mode 100644 index 0000000..c47b50e --- /dev/null +++ b/rpc/ent/payorderextension.go @@ -0,0 +1,269 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// PayOrderExtension Table | 支付订单拓展表 +type PayOrderExtension struct { + config `json:"-"` + // ID of the ent. + ID uint64 `json:"id,omitempty"` + // Create Time | 创建日期 + CreatedAt time.Time `json:"created_at,omitempty"` + // Update Time | 修改日期 + UpdatedAt time.Time `json:"updated_at,omitempty"` + // Status 1: normal 2: ban | 状态 1 正常 2 禁用 + Status uint8 `json:"status,omitempty"` + // Tenant ID | 租户 ID + TenantID uint64 `json:"tenant_id,omitempty"` + // Delete Time | 删除日期 + DeletedAt time.Time `json:"deleted_at,omitempty"` + // Order ID | 订单ID + OrderID uint64 `json:"order_id,omitempty"` + // Channel ID | 渠道ID + ChannelID uint64 `json:"channel_id,omitempty"` + // Channel Extras | 渠道参数 + ChannelExtras map[string]interface{} `json:"channel_extras,omitempty"` + // Channel Error Code | 渠道错误码 + ChannelErrorCode string `json:"channel_error_code,omitempty"` + // Channel Error Msg | 渠道错误信息 + ChannelErrorMsg string `json:"channel_error_msg,omitempty"` + // Channel Notify Data | 渠道回调数据 + ChannelNotifyData string `json:"channel_notify_data,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PayOrderExtensionQuery when eager-loading is set. + Edges PayOrderExtensionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PayOrderExtensionEdges holds the relations/edges for other nodes in the graph. +type PayOrderExtensionEdges struct { + // Channel holds the value of the channel edge. + Channel *PayChannel `json:"channel,omitempty"` + // Order holds the value of the order edge. + Order *PayOrder `json:"order,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ChannelOrErr returns the Channel value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayOrderExtensionEdges) ChannelOrErr() (*PayChannel, error) { + if e.Channel != nil { + return e.Channel, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: paychannel.Label} + } + return nil, &NotLoadedError{edge: "channel"} +} + +// OrderOrErr returns the Order value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PayOrderExtensionEdges) OrderOrErr() (*PayOrder, error) { + if e.Order != nil { + return e.Order, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: payorder.Label} + } + return nil, &NotLoadedError{edge: "order"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PayOrderExtension) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case payorderextension.FieldChannelExtras: + values[i] = new([]byte) + case payorderextension.FieldID, payorderextension.FieldStatus, payorderextension.FieldTenantID, payorderextension.FieldOrderID, payorderextension.FieldChannelID: + values[i] = new(sql.NullInt64) + case payorderextension.FieldChannelErrorCode, payorderextension.FieldChannelErrorMsg, payorderextension.FieldChannelNotifyData: + values[i] = new(sql.NullString) + case payorderextension.FieldCreatedAt, payorderextension.FieldUpdatedAt, payorderextension.FieldDeletedAt: + 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 PayOrderExtension fields. +func (_m *PayOrderExtension) 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 payorderextension.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = uint64(value.Int64) + case payorderextension.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 payorderextension.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 + } + case payorderextension.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = uint8(value.Int64) + } + case payorderextension.FieldTenantID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field tenant_id", values[i]) + } else if value.Valid { + _m.TenantID = uint64(value.Int64) + } + case payorderextension.FieldDeletedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) + } else if value.Valid { + _m.DeletedAt = value.Time + } + case payorderextension.FieldOrderID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field order_id", values[i]) + } else if value.Valid { + _m.OrderID = uint64(value.Int64) + } + case payorderextension.FieldChannelID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field channel_id", values[i]) + } else if value.Valid { + _m.ChannelID = uint64(value.Int64) + } + case payorderextension.FieldChannelExtras: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field channel_extras", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.ChannelExtras); err != nil { + return fmt.Errorf("unmarshal field channel_extras: %w", err) + } + } + case payorderextension.FieldChannelErrorCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_error_code", values[i]) + } else if value.Valid { + _m.ChannelErrorCode = value.String + } + case payorderextension.FieldChannelErrorMsg: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_error_msg", values[i]) + } else if value.Valid { + _m.ChannelErrorMsg = value.String + } + case payorderextension.FieldChannelNotifyData: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field channel_notify_data", values[i]) + } else if value.Valid { + _m.ChannelNotifyData = value.String + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PayOrderExtension. +// This includes values selected through modifiers, order, etc. +func (_m *PayOrderExtension) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryChannel queries the "channel" edge of the PayOrderExtension entity. +func (_m *PayOrderExtension) QueryChannel() *PayChannelQuery { + return NewPayOrderExtensionClient(_m.config).QueryChannel(_m) +} + +// QueryOrder queries the "order" edge of the PayOrderExtension entity. +func (_m *PayOrderExtension) QueryOrder() *PayOrderQuery { + return NewPayOrderExtensionClient(_m.config).QueryOrder(_m) +} + +// Update returns a builder for updating this PayOrderExtension. +// Note that you need to call PayOrderExtension.Unwrap() before calling this method if this PayOrderExtension +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PayOrderExtension) Update() *PayOrderExtensionUpdateOne { + return NewPayOrderExtensionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PayOrderExtension 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 *PayOrderExtension) Unwrap() *PayOrderExtension { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PayOrderExtension is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PayOrderExtension) String() string { + var builder strings.Builder + builder.WriteString("PayOrderExtension(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + 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.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("tenant_id=") + builder.WriteString(fmt.Sprintf("%v", _m.TenantID)) + builder.WriteString(", ") + builder.WriteString("deleted_at=") + builder.WriteString(_m.DeletedAt.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("order_id=") + builder.WriteString(fmt.Sprintf("%v", _m.OrderID)) + builder.WriteString(", ") + builder.WriteString("channel_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ChannelID)) + builder.WriteString(", ") + builder.WriteString("channel_extras=") + builder.WriteString(fmt.Sprintf("%v", _m.ChannelExtras)) + builder.WriteString(", ") + builder.WriteString("channel_error_code=") + builder.WriteString(_m.ChannelErrorCode) + builder.WriteString(", ") + builder.WriteString("channel_error_msg=") + builder.WriteString(_m.ChannelErrorMsg) + builder.WriteString(", ") + builder.WriteString("channel_notify_data=") + builder.WriteString(_m.ChannelNotifyData) + builder.WriteByte(')') + return builder.String() +} + +// PayOrderExtensions is a parsable slice of PayOrderExtension. +type PayOrderExtensions []*PayOrderExtension diff --git a/rpc/ent/payorderextension/payorderextension.go b/rpc/ent/payorderextension/payorderextension.go new file mode 100644 index 0000000..f7bdfd3 --- /dev/null +++ b/rpc/ent/payorderextension/payorderextension.go @@ -0,0 +1,184 @@ +// Code generated by ent, DO NOT EDIT. + +package payorderextension + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the payorderextension type in the database. + Label = "pay_order_extension" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // 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" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldTenantID holds the string denoting the tenant_id field in the database. + FieldTenantID = "tenant_id" + // FieldDeletedAt holds the string denoting the deleted_at field in the database. + FieldDeletedAt = "deleted_at" + // FieldOrderID holds the string denoting the order_id field in the database. + FieldOrderID = "order_id" + // FieldChannelID holds the string denoting the channel_id field in the database. + FieldChannelID = "channel_id" + // FieldChannelExtras holds the string denoting the channel_extras field in the database. + FieldChannelExtras = "channel_extras" + // FieldChannelErrorCode holds the string denoting the channel_error_code field in the database. + FieldChannelErrorCode = "channel_error_code" + // FieldChannelErrorMsg holds the string denoting the channel_error_msg field in the database. + FieldChannelErrorMsg = "channel_error_msg" + // FieldChannelNotifyData holds the string denoting the channel_notify_data field in the database. + FieldChannelNotifyData = "channel_notify_data" + // EdgeChannel holds the string denoting the channel edge name in mutations. + EdgeChannel = "channel" + // EdgeOrder holds the string denoting the order edge name in mutations. + EdgeOrder = "order" + // Table holds the table name of the payorderextension in the database. + Table = "pay_order_extension" + // ChannelTable is the table that holds the channel relation/edge. + ChannelTable = "pay_order_extension" + // ChannelInverseTable is the table name for the PayChannel entity. + // It exists in this package in order to avoid circular dependency with the "paychannel" package. + ChannelInverseTable = "pay_channel" + // ChannelColumn is the table column denoting the channel relation/edge. + ChannelColumn = "channel_id" + // OrderTable is the table that holds the order relation/edge. + OrderTable = "pay_order_extension" + // OrderInverseTable is the table name for the PayOrder entity. + // It exists in this package in order to avoid circular dependency with the "payorder" package. + OrderInverseTable = "pay_order" + // OrderColumn is the table column denoting the order relation/edge. + OrderColumn = "order_id" +) + +// Columns holds all SQL columns for payorderextension fields. +var Columns = []string{ + FieldID, + FieldCreatedAt, + FieldUpdatedAt, + FieldStatus, + FieldTenantID, + FieldDeletedAt, + FieldOrderID, + FieldChannelID, + FieldChannelExtras, + FieldChannelErrorCode, + FieldChannelErrorMsg, + FieldChannelNotifyData, +} + +// 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 ( + // 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 + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus uint8 + // DefaultTenantID holds the default value on creation for the "tenant_id" field. + DefaultTenantID uint64 +) + +// OrderOption defines the ordering options for the PayOrderExtension 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() +} + +// 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() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByTenantID orders the results by the tenant_id field. +func ByTenantID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTenantID, opts...).ToFunc() +} + +// ByDeletedAt orders the results by the deleted_at field. +func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeletedAt, opts...).ToFunc() +} + +// ByOrderID orders the results by the order_id field. +func ByOrderID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderID, opts...).ToFunc() +} + +// ByChannelID orders the results by the channel_id field. +func ByChannelID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelID, opts...).ToFunc() +} + +// ByChannelErrorCode orders the results by the channel_error_code field. +func ByChannelErrorCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelErrorCode, opts...).ToFunc() +} + +// ByChannelErrorMsg orders the results by the channel_error_msg field. +func ByChannelErrorMsg(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelErrorMsg, opts...).ToFunc() +} + +// ByChannelNotifyData orders the results by the channel_notify_data field. +func ByChannelNotifyData(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChannelNotifyData, opts...).ToFunc() +} + +// ByChannelField orders the results by channel field. +func ByChannelField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChannelStep(), sql.OrderByField(field, opts...)) + } +} + +// ByOrderField orders the results by order field. +func ByOrderField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newOrderStep(), sql.OrderByField(field, opts...)) + } +} +func newChannelStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ChannelInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ChannelTable, ChannelColumn), + ) +} +func newOrderStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(OrderInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OrderTable, OrderColumn), + ) +} diff --git a/rpc/ent/payorderextension/where.go b/rpc/ent/payorderextension/where.go new file mode 100644 index 0000000..dd83d3e --- /dev/null +++ b/rpc/ent/payorderextension/where.go @@ -0,0 +1,662 @@ +// Code generated by ent, DO NOT EDIT. + +package payorderextension + +import ( + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldID, id)) +} + +// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(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.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldStatus, v)) +} + +// TenantID applies equality check predicate on the "tenant_id" field. It's identical to TenantIDEQ. +func TenantID(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldTenantID, v)) +} + +// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. +func DeletedAt(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldDeletedAt, v)) +} + +// OrderID applies equality check predicate on the "order_id" field. It's identical to OrderIDEQ. +func OrderID(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldOrderID, v)) +} + +// ChannelID applies equality check predicate on the "channel_id" field. It's identical to ChannelIDEQ. +func ChannelID(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelID, v)) +} + +// ChannelErrorCode applies equality check predicate on the "channel_error_code" field. It's identical to ChannelErrorCodeEQ. +func ChannelErrorCode(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelErrorCode, v)) +} + +// ChannelErrorMsg applies equality check predicate on the "channel_error_msg" field. It's identical to ChannelErrorMsgEQ. +func ChannelErrorMsg(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelErrorMsg, v)) +} + +// ChannelNotifyData applies equality check predicate on the "channel_notify_data" field. It's identical to ChannelNotifyDataEQ. +func ChannelNotifyData(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelNotifyData, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "created_at" field. +func CreatedAtEQ(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. +func CreatedAtNEQ(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "created_at" field. +func CreatedAtIn(vs ...time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. +func CreatedAtNotIn(vs ...time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "created_at" field. +func CreatedAtGT(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "created_at" field. +func CreatedAtGTE(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "created_at" field. +func CreatedAtLT(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "created_at" field. +func CreatedAtLTE(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldCreatedAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. +func UpdatedAtEQ(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. +func UpdatedAtNEQ(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updated_at" field. +func UpdatedAtIn(vs ...time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. +func UpdatedAtNotIn(vs ...time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updated_at" field. +func UpdatedAtGT(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. +func UpdatedAtGTE(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updated_at" field. +func UpdatedAtLT(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. +func UpdatedAtLTE(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v uint8) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldStatus, v)) +} + +// StatusIsNil applies the IsNil predicate on the "status" field. +func StatusIsNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIsNull(FieldStatus)) +} + +// StatusNotNil applies the NotNil predicate on the "status" field. +func StatusNotNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotNull(FieldStatus)) +} + +// TenantIDEQ applies the EQ predicate on the "tenant_id" field. +func TenantIDEQ(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldTenantID, v)) +} + +// TenantIDNEQ applies the NEQ predicate on the "tenant_id" field. +func TenantIDNEQ(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldTenantID, v)) +} + +// TenantIDIn applies the In predicate on the "tenant_id" field. +func TenantIDIn(vs ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldTenantID, vs...)) +} + +// TenantIDNotIn applies the NotIn predicate on the "tenant_id" field. +func TenantIDNotIn(vs ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldTenantID, vs...)) +} + +// TenantIDGT applies the GT predicate on the "tenant_id" field. +func TenantIDGT(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldTenantID, v)) +} + +// TenantIDGTE applies the GTE predicate on the "tenant_id" field. +func TenantIDGTE(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldTenantID, v)) +} + +// TenantIDLT applies the LT predicate on the "tenant_id" field. +func TenantIDLT(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldTenantID, v)) +} + +// TenantIDLTE applies the LTE predicate on the "tenant_id" field. +func TenantIDLTE(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldTenantID, v)) +} + +// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. +func DeletedAtEQ(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldDeletedAt, v)) +} + +// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. +func DeletedAtNEQ(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldDeletedAt, v)) +} + +// DeletedAtIn applies the In predicate on the "deleted_at" field. +func DeletedAtIn(vs ...time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldDeletedAt, vs...)) +} + +// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. +func DeletedAtNotIn(vs ...time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldDeletedAt, vs...)) +} + +// DeletedAtGT applies the GT predicate on the "deleted_at" field. +func DeletedAtGT(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldDeletedAt, v)) +} + +// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. +func DeletedAtGTE(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldDeletedAt, v)) +} + +// DeletedAtLT applies the LT predicate on the "deleted_at" field. +func DeletedAtLT(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldDeletedAt, v)) +} + +// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. +func DeletedAtLTE(v time.Time) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldDeletedAt, v)) +} + +// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. +func DeletedAtIsNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIsNull(FieldDeletedAt)) +} + +// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. +func DeletedAtNotNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotNull(FieldDeletedAt)) +} + +// OrderIDEQ applies the EQ predicate on the "order_id" field. +func OrderIDEQ(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldOrderID, v)) +} + +// OrderIDNEQ applies the NEQ predicate on the "order_id" field. +func OrderIDNEQ(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldOrderID, v)) +} + +// OrderIDIn applies the In predicate on the "order_id" field. +func OrderIDIn(vs ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldOrderID, vs...)) +} + +// OrderIDNotIn applies the NotIn predicate on the "order_id" field. +func OrderIDNotIn(vs ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldOrderID, vs...)) +} + +// ChannelIDEQ applies the EQ predicate on the "channel_id" field. +func ChannelIDEQ(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelID, v)) +} + +// ChannelIDNEQ applies the NEQ predicate on the "channel_id" field. +func ChannelIDNEQ(v uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldChannelID, v)) +} + +// ChannelIDIn applies the In predicate on the "channel_id" field. +func ChannelIDIn(vs ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldChannelID, vs...)) +} + +// ChannelIDNotIn applies the NotIn predicate on the "channel_id" field. +func ChannelIDNotIn(vs ...uint64) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldChannelID, vs...)) +} + +// ChannelExtrasIsNil applies the IsNil predicate on the "channel_extras" field. +func ChannelExtrasIsNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIsNull(FieldChannelExtras)) +} + +// ChannelExtrasNotNil applies the NotNil predicate on the "channel_extras" field. +func ChannelExtrasNotNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotNull(FieldChannelExtras)) +} + +// ChannelErrorCodeEQ applies the EQ predicate on the "channel_error_code" field. +func ChannelErrorCodeEQ(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeNEQ applies the NEQ predicate on the "channel_error_code" field. +func ChannelErrorCodeNEQ(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeIn applies the In predicate on the "channel_error_code" field. +func ChannelErrorCodeIn(vs ...string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldChannelErrorCode, vs...)) +} + +// ChannelErrorCodeNotIn applies the NotIn predicate on the "channel_error_code" field. +func ChannelErrorCodeNotIn(vs ...string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldChannelErrorCode, vs...)) +} + +// ChannelErrorCodeGT applies the GT predicate on the "channel_error_code" field. +func ChannelErrorCodeGT(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeGTE applies the GTE predicate on the "channel_error_code" field. +func ChannelErrorCodeGTE(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeLT applies the LT predicate on the "channel_error_code" field. +func ChannelErrorCodeLT(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeLTE applies the LTE predicate on the "channel_error_code" field. +func ChannelErrorCodeLTE(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeContains applies the Contains predicate on the "channel_error_code" field. +func ChannelErrorCodeContains(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldContains(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeHasPrefix applies the HasPrefix predicate on the "channel_error_code" field. +func ChannelErrorCodeHasPrefix(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldHasPrefix(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeHasSuffix applies the HasSuffix predicate on the "channel_error_code" field. +func ChannelErrorCodeHasSuffix(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldHasSuffix(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeIsNil applies the IsNil predicate on the "channel_error_code" field. +func ChannelErrorCodeIsNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIsNull(FieldChannelErrorCode)) +} + +// ChannelErrorCodeNotNil applies the NotNil predicate on the "channel_error_code" field. +func ChannelErrorCodeNotNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotNull(FieldChannelErrorCode)) +} + +// ChannelErrorCodeEqualFold applies the EqualFold predicate on the "channel_error_code" field. +func ChannelErrorCodeEqualFold(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEqualFold(FieldChannelErrorCode, v)) +} + +// ChannelErrorCodeContainsFold applies the ContainsFold predicate on the "channel_error_code" field. +func ChannelErrorCodeContainsFold(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldContainsFold(FieldChannelErrorCode, v)) +} + +// ChannelErrorMsgEQ applies the EQ predicate on the "channel_error_msg" field. +func ChannelErrorMsgEQ(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgNEQ applies the NEQ predicate on the "channel_error_msg" field. +func ChannelErrorMsgNEQ(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgIn applies the In predicate on the "channel_error_msg" field. +func ChannelErrorMsgIn(vs ...string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldChannelErrorMsg, vs...)) +} + +// ChannelErrorMsgNotIn applies the NotIn predicate on the "channel_error_msg" field. +func ChannelErrorMsgNotIn(vs ...string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldChannelErrorMsg, vs...)) +} + +// ChannelErrorMsgGT applies the GT predicate on the "channel_error_msg" field. +func ChannelErrorMsgGT(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgGTE applies the GTE predicate on the "channel_error_msg" field. +func ChannelErrorMsgGTE(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgLT applies the LT predicate on the "channel_error_msg" field. +func ChannelErrorMsgLT(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgLTE applies the LTE predicate on the "channel_error_msg" field. +func ChannelErrorMsgLTE(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgContains applies the Contains predicate on the "channel_error_msg" field. +func ChannelErrorMsgContains(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldContains(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgHasPrefix applies the HasPrefix predicate on the "channel_error_msg" field. +func ChannelErrorMsgHasPrefix(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldHasPrefix(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgHasSuffix applies the HasSuffix predicate on the "channel_error_msg" field. +func ChannelErrorMsgHasSuffix(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldHasSuffix(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgIsNil applies the IsNil predicate on the "channel_error_msg" field. +func ChannelErrorMsgIsNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIsNull(FieldChannelErrorMsg)) +} + +// ChannelErrorMsgNotNil applies the NotNil predicate on the "channel_error_msg" field. +func ChannelErrorMsgNotNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotNull(FieldChannelErrorMsg)) +} + +// ChannelErrorMsgEqualFold applies the EqualFold predicate on the "channel_error_msg" field. +func ChannelErrorMsgEqualFold(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEqualFold(FieldChannelErrorMsg, v)) +} + +// ChannelErrorMsgContainsFold applies the ContainsFold predicate on the "channel_error_msg" field. +func ChannelErrorMsgContainsFold(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldContainsFold(FieldChannelErrorMsg, v)) +} + +// ChannelNotifyDataEQ applies the EQ predicate on the "channel_notify_data" field. +func ChannelNotifyDataEQ(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEQ(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataNEQ applies the NEQ predicate on the "channel_notify_data" field. +func ChannelNotifyDataNEQ(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNEQ(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataIn applies the In predicate on the "channel_notify_data" field. +func ChannelNotifyDataIn(vs ...string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIn(FieldChannelNotifyData, vs...)) +} + +// ChannelNotifyDataNotIn applies the NotIn predicate on the "channel_notify_data" field. +func ChannelNotifyDataNotIn(vs ...string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotIn(FieldChannelNotifyData, vs...)) +} + +// ChannelNotifyDataGT applies the GT predicate on the "channel_notify_data" field. +func ChannelNotifyDataGT(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGT(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataGTE applies the GTE predicate on the "channel_notify_data" field. +func ChannelNotifyDataGTE(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldGTE(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataLT applies the LT predicate on the "channel_notify_data" field. +func ChannelNotifyDataLT(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLT(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataLTE applies the LTE predicate on the "channel_notify_data" field. +func ChannelNotifyDataLTE(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldLTE(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataContains applies the Contains predicate on the "channel_notify_data" field. +func ChannelNotifyDataContains(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldContains(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataHasPrefix applies the HasPrefix predicate on the "channel_notify_data" field. +func ChannelNotifyDataHasPrefix(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldHasPrefix(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataHasSuffix applies the HasSuffix predicate on the "channel_notify_data" field. +func ChannelNotifyDataHasSuffix(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldHasSuffix(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataIsNil applies the IsNil predicate on the "channel_notify_data" field. +func ChannelNotifyDataIsNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldIsNull(FieldChannelNotifyData)) +} + +// ChannelNotifyDataNotNil applies the NotNil predicate on the "channel_notify_data" field. +func ChannelNotifyDataNotNil() predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldNotNull(FieldChannelNotifyData)) +} + +// ChannelNotifyDataEqualFold applies the EqualFold predicate on the "channel_notify_data" field. +func ChannelNotifyDataEqualFold(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldEqualFold(FieldChannelNotifyData, v)) +} + +// ChannelNotifyDataContainsFold applies the ContainsFold predicate on the "channel_notify_data" field. +func ChannelNotifyDataContainsFold(v string) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.FieldContainsFold(FieldChannelNotifyData, v)) +} + +// HasChannel applies the HasEdge predicate on the "channel" edge. +func HasChannel() predicate.PayOrderExtension { + return predicate.PayOrderExtension(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ChannelTable, ChannelColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChannelWith applies the HasEdge predicate on the "channel" edge with a given conditions (other predicates). +func HasChannelWith(preds ...predicate.PayChannel) predicate.PayOrderExtension { + return predicate.PayOrderExtension(func(s *sql.Selector) { + step := newChannelStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasOrder applies the HasEdge predicate on the "order" edge. +func HasOrder() predicate.PayOrderExtension { + return predicate.PayOrderExtension(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, OrderTable, OrderColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasOrderWith applies the HasEdge predicate on the "order" edge with a given conditions (other predicates). +func HasOrderWith(preds ...predicate.PayOrder) predicate.PayOrderExtension { + return predicate.PayOrderExtension(func(s *sql.Selector) { + step := newOrderStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PayOrderExtension) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PayOrderExtension) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PayOrderExtension) predicate.PayOrderExtension { + return predicate.PayOrderExtension(sql.NotPredicates(p)) +} diff --git a/rpc/ent/payorderextension_create.go b/rpc/ent/payorderextension_create.go new file mode 100644 index 0000000..d78fdc2 --- /dev/null +++ b/rpc/ent/payorderextension_create.go @@ -0,0 +1,438 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderExtensionCreate is the builder for creating a PayOrderExtension entity. +type PayOrderExtensionCreate struct { + config + mutation *PayOrderExtensionMutation + hooks []Hook +} + +// SetCreatedAt sets the "created_at" field. +func (_c *PayOrderExtensionCreate) SetCreatedAt(v time.Time) *PayOrderExtensionCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableCreatedAt(v *time.Time) *PayOrderExtensionCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updated_at" field. +func (_c *PayOrderExtensionCreate) SetUpdatedAt(v time.Time) *PayOrderExtensionCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableUpdatedAt(v *time.Time) *PayOrderExtensionCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *PayOrderExtensionCreate) SetStatus(v uint8) *PayOrderExtensionCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableStatus(v *uint8) *PayOrderExtensionCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetTenantID sets the "tenant_id" field. +func (_c *PayOrderExtensionCreate) SetTenantID(v uint64) *PayOrderExtensionCreate { + _c.mutation.SetTenantID(v) + return _c +} + +// SetNillableTenantID sets the "tenant_id" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableTenantID(v *uint64) *PayOrderExtensionCreate { + if v != nil { + _c.SetTenantID(*v) + } + return _c +} + +// SetDeletedAt sets the "deleted_at" field. +func (_c *PayOrderExtensionCreate) SetDeletedAt(v time.Time) *PayOrderExtensionCreate { + _c.mutation.SetDeletedAt(v) + return _c +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableDeletedAt(v *time.Time) *PayOrderExtensionCreate { + if v != nil { + _c.SetDeletedAt(*v) + } + return _c +} + +// SetOrderID sets the "order_id" field. +func (_c *PayOrderExtensionCreate) SetOrderID(v uint64) *PayOrderExtensionCreate { + _c.mutation.SetOrderID(v) + return _c +} + +// SetChannelID sets the "channel_id" field. +func (_c *PayOrderExtensionCreate) SetChannelID(v uint64) *PayOrderExtensionCreate { + _c.mutation.SetChannelID(v) + return _c +} + +// SetChannelExtras sets the "channel_extras" field. +func (_c *PayOrderExtensionCreate) SetChannelExtras(v map[string]interface{}) *PayOrderExtensionCreate { + _c.mutation.SetChannelExtras(v) + return _c +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (_c *PayOrderExtensionCreate) SetChannelErrorCode(v string) *PayOrderExtensionCreate { + _c.mutation.SetChannelErrorCode(v) + return _c +} + +// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableChannelErrorCode(v *string) *PayOrderExtensionCreate { + if v != nil { + _c.SetChannelErrorCode(*v) + } + return _c +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (_c *PayOrderExtensionCreate) SetChannelErrorMsg(v string) *PayOrderExtensionCreate { + _c.mutation.SetChannelErrorMsg(v) + return _c +} + +// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableChannelErrorMsg(v *string) *PayOrderExtensionCreate { + if v != nil { + _c.SetChannelErrorMsg(*v) + } + return _c +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (_c *PayOrderExtensionCreate) SetChannelNotifyData(v string) *PayOrderExtensionCreate { + _c.mutation.SetChannelNotifyData(v) + return _c +} + +// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil. +func (_c *PayOrderExtensionCreate) SetNillableChannelNotifyData(v *string) *PayOrderExtensionCreate { + if v != nil { + _c.SetChannelNotifyData(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PayOrderExtensionCreate) SetID(v uint64) *PayOrderExtensionCreate { + _c.mutation.SetID(v) + return _c +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_c *PayOrderExtensionCreate) SetChannel(v *PayChannel) *PayOrderExtensionCreate { + return _c.SetChannelID(v.ID) +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_c *PayOrderExtensionCreate) SetOrder(v *PayOrder) *PayOrderExtensionCreate { + return _c.SetOrderID(v.ID) +} + +// Mutation returns the PayOrderExtensionMutation object of the builder. +func (_c *PayOrderExtensionCreate) Mutation() *PayOrderExtensionMutation { + return _c.mutation +} + +// Save creates the PayOrderExtension in the database. +func (_c *PayOrderExtensionCreate) Save(ctx context.Context) (*PayOrderExtension, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PayOrderExtensionCreate) SaveX(ctx context.Context) *PayOrderExtension { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayOrderExtensionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayOrderExtensionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PayOrderExtensionCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := payorderextension.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := payorderextension.DefaultUpdatedAt() + _c.mutation.SetUpdatedAt(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := payorderextension.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.TenantID(); !ok { + v := payorderextension.DefaultTenantID + _c.mutation.SetTenantID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PayOrderExtensionCreate) check() error { + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayOrderExtension.created_at"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayOrderExtension.updated_at"`)} + } + if _, ok := _c.mutation.TenantID(); !ok { + return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayOrderExtension.tenant_id"`)} + } + if _, ok := _c.mutation.OrderID(); !ok { + return &ValidationError{Name: "order_id", err: errors.New(`ent: missing required field "PayOrderExtension.order_id"`)} + } + if _, ok := _c.mutation.ChannelID(); !ok { + return &ValidationError{Name: "channel_id", err: errors.New(`ent: missing required field "PayOrderExtension.channel_id"`)} + } + if len(_c.mutation.ChannelIDs()) == 0 { + return &ValidationError{Name: "channel", err: errors.New(`ent: missing required edge "PayOrderExtension.channel"`)} + } + if len(_c.mutation.OrderIDs()) == 0 { + return &ValidationError{Name: "order", err: errors.New(`ent: missing required edge "PayOrderExtension.order"`)} + } + return nil +} + +func (_c *PayOrderExtensionCreate) sqlSave(ctx context.Context) (*PayOrderExtension, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = uint64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PayOrderExtensionCreate) createSpec() (*PayOrderExtension, *sqlgraph.CreateSpec) { + var ( + _node = &PayOrderExtension{config: _c.config} + _spec = sqlgraph.NewCreateSpec(payorderextension.Table, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(payorderextension.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(payorderextension.FieldUpdatedAt, field.TypeTime, value) + _node.UpdatedAt = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(payorderextension.FieldStatus, field.TypeUint8, value) + _node.Status = value + } + if value, ok := _c.mutation.TenantID(); ok { + _spec.SetField(payorderextension.FieldTenantID, field.TypeUint64, value) + _node.TenantID = value + } + if value, ok := _c.mutation.DeletedAt(); ok { + _spec.SetField(payorderextension.FieldDeletedAt, field.TypeTime, value) + _node.DeletedAt = value + } + if value, ok := _c.mutation.ChannelExtras(); ok { + _spec.SetField(payorderextension.FieldChannelExtras, field.TypeJSON, value) + _node.ChannelExtras = value + } + if value, ok := _c.mutation.ChannelErrorCode(); ok { + _spec.SetField(payorderextension.FieldChannelErrorCode, field.TypeString, value) + _node.ChannelErrorCode = value + } + if value, ok := _c.mutation.ChannelErrorMsg(); ok { + _spec.SetField(payorderextension.FieldChannelErrorMsg, field.TypeString, value) + _node.ChannelErrorMsg = value + } + if value, ok := _c.mutation.ChannelNotifyData(); ok { + _spec.SetField(payorderextension.FieldChannelNotifyData, field.TypeString, value) + _node.ChannelNotifyData = value + } + if nodes := _c.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.ChannelTable, + Columns: []string{payorderextension.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ChannelID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.OrderTable, + Columns: []string{payorderextension.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.OrderID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// PayOrderExtensionCreateBulk is the builder for creating many PayOrderExtension entities in bulk. +type PayOrderExtensionCreateBulk struct { + config + err error + builders []*PayOrderExtensionCreate +} + +// Save creates the PayOrderExtension entities in the database. +func (_c *PayOrderExtensionCreateBulk) Save(ctx context.Context) ([]*PayOrderExtension, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PayOrderExtension, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PayOrderExtensionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = uint64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PayOrderExtensionCreateBulk) SaveX(ctx context.Context) []*PayOrderExtension { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PayOrderExtensionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PayOrderExtensionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/payorderextension_delete.go b/rpc/ent/payorderextension_delete.go new file mode 100644 index 0000000..b2c5331 --- /dev/null +++ b/rpc/ent/payorderextension_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderExtensionDelete is the builder for deleting a PayOrderExtension entity. +type PayOrderExtensionDelete struct { + config + hooks []Hook + mutation *PayOrderExtensionMutation +} + +// Where appends a list predicates to the PayOrderExtensionDelete builder. +func (_d *PayOrderExtensionDelete) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PayOrderExtensionDelete) 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 *PayOrderExtensionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PayOrderExtensionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(payorderextension.Table, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64)) + 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 +} + +// PayOrderExtensionDeleteOne is the builder for deleting a single PayOrderExtension entity. +type PayOrderExtensionDeleteOne struct { + _d *PayOrderExtensionDelete +} + +// Where appends a list predicates to the PayOrderExtensionDelete builder. +func (_d *PayOrderExtensionDeleteOne) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PayOrderExtensionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{payorderextension.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PayOrderExtensionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/rpc/ent/payorderextension_query.go b/rpc/ent/payorderextension_query.go new file mode 100644 index 0000000..c4d5841 --- /dev/null +++ b/rpc/ent/payorderextension_query.go @@ -0,0 +1,681 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderExtensionQuery is the builder for querying PayOrderExtension entities. +type PayOrderExtensionQuery struct { + config + ctx *QueryContext + order []payorderextension.OrderOption + inters []Interceptor + predicates []predicate.PayOrderExtension + withChannel *PayChannelQuery + withOrder *PayOrderQuery + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PayOrderExtensionQuery builder. +func (_q *PayOrderExtensionQuery) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PayOrderExtensionQuery) Limit(limit int) *PayOrderExtensionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PayOrderExtensionQuery) Offset(offset int) *PayOrderExtensionQuery { + _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 *PayOrderExtensionQuery) Unique(unique bool) *PayOrderExtensionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PayOrderExtensionQuery) Order(o ...payorderextension.OrderOption) *PayOrderExtensionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryChannel chains the current query on the "channel" edge. +func (_q *PayOrderExtensionQuery) QueryChannel() *PayChannelQuery { + query := (&PayChannelClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payorderextension.Table, payorderextension.FieldID, selector), + sqlgraph.To(paychannel.Table, paychannel.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payorderextension.ChannelTable, payorderextension.ChannelColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryOrder chains the current query on the "order" edge. +func (_q *PayOrderExtensionQuery) QueryOrder() *PayOrderQuery { + query := (&PayOrderClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(payorderextension.Table, payorderextension.FieldID, selector), + sqlgraph.To(payorder.Table, payorder.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, payorderextension.OrderTable, payorderextension.OrderColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PayOrderExtension entity from the query. +// Returns a *NotFoundError when no PayOrderExtension was found. +func (_q *PayOrderExtensionQuery) First(ctx context.Context) (*PayOrderExtension, 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{payorderextension.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) FirstX(ctx context.Context) *PayOrderExtension { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PayOrderExtension ID from the query. +// Returns a *NotFoundError when no PayOrderExtension ID was found. +func (_q *PayOrderExtensionQuery) FirstID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{payorderextension.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PayOrderExtension entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PayOrderExtension entity is found. +// Returns a *NotFoundError when no PayOrderExtension entities are found. +func (_q *PayOrderExtensionQuery) Only(ctx context.Context) (*PayOrderExtension, 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{payorderextension.Label} + default: + return nil, &NotSingularError{payorderextension.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) OnlyX(ctx context.Context) *PayOrderExtension { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PayOrderExtension ID in the query. +// Returns a *NotSingularError when more than one PayOrderExtension ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PayOrderExtensionQuery) OnlyID(ctx context.Context) (id uint64, err error) { + var ids []uint64 + 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{payorderextension.Label} + default: + err = &NotSingularError{payorderextension.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PayOrderExtensions. +func (_q *PayOrderExtensionQuery) All(ctx context.Context) ([]*PayOrderExtension, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PayOrderExtension, *PayOrderExtensionQuery]() + return withInterceptors[[]*PayOrderExtension](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) AllX(ctx context.Context) []*PayOrderExtension { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PayOrderExtension IDs. +func (_q *PayOrderExtensionQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(payorderextension.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PayOrderExtensionQuery) 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[*PayOrderExtensionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PayOrderExtensionQuery) 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 *PayOrderExtensionQuery) 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 *PayOrderExtensionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PayOrderExtensionQuery 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 *PayOrderExtensionQuery) Clone() *PayOrderExtensionQuery { + if _q == nil { + return nil + } + return &PayOrderExtensionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]payorderextension.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PayOrderExtension{}, _q.predicates...), + withChannel: _q.withChannel.Clone(), + withOrder: _q.withOrder.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + } +} + +// WithChannel tells the query-builder to eager-load the nodes that are connected to +// the "channel" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayOrderExtensionQuery) WithChannel(opts ...func(*PayChannelQuery)) *PayOrderExtensionQuery { + query := (&PayChannelClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChannel = query + return _q +} + +// WithOrder tells the query-builder to eager-load the nodes that are connected to +// the "order" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PayOrderExtensionQuery) WithOrder(opts ...func(*PayOrderQuery)) *PayOrderExtensionQuery { + query := (&PayOrderClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withOrder = query + return _q +} + +// 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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PayOrderExtension.Query(). +// GroupBy(payorderextension.FieldCreatedAt). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PayOrderExtensionQuery) GroupBy(field string, fields ...string) *PayOrderExtensionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PayOrderExtensionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = payorderextension.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 { +// CreatedAt time.Time `json:"created_at,omitempty"` +// } +// +// client.PayOrderExtension.Query(). +// Select(payorderextension.FieldCreatedAt). +// Scan(ctx, &v) +func (_q *PayOrderExtensionQuery) Select(fields ...string) *PayOrderExtensionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PayOrderExtensionSelect{PayOrderExtensionQuery: _q} + sbuild.label = payorderextension.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PayOrderExtensionSelect configured with the given aggregations. +func (_q *PayOrderExtensionQuery) Aggregate(fns ...AggregateFunc) *PayOrderExtensionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PayOrderExtensionQuery) 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 !payorderextension.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 *PayOrderExtensionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PayOrderExtension, error) { + var ( + nodes = []*PayOrderExtension{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withChannel != nil, + _q.withOrder != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PayOrderExtension).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PayOrderExtension{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + 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 + } + if query := _q.withChannel; query != nil { + if err := _q.loadChannel(ctx, query, nodes, nil, + func(n *PayOrderExtension, e *PayChannel) { n.Edges.Channel = e }); err != nil { + return nil, err + } + } + if query := _q.withOrder; query != nil { + if err := _q.loadOrder(ctx, query, nodes, nil, + func(n *PayOrderExtension, e *PayOrder) { n.Edges.Order = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PayOrderExtensionQuery) loadChannel(ctx context.Context, query *PayChannelQuery, nodes []*PayOrderExtension, init func(*PayOrderExtension), assign func(*PayOrderExtension, *PayChannel)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayOrderExtension) + for i := range nodes { + fk := nodes[i].ChannelID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(paychannel.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "channel_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *PayOrderExtensionQuery) loadOrder(ctx context.Context, query *PayOrderQuery, nodes []*PayOrderExtension, init func(*PayOrderExtension), assign func(*PayOrderExtension, *PayOrder)) error { + ids := make([]uint64, 0, len(nodes)) + nodeids := make(map[uint64][]*PayOrderExtension) + for i := range nodes { + fk := nodes[i].OrderID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(payorder.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "order_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *PayOrderExtensionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + _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 *PayOrderExtensionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(payorderextension.Table, payorderextension.Columns, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64)) + _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, payorderextension.FieldID) + for i := range fields { + if fields[i] != payorderextension.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withChannel != nil { + _spec.Node.AddColumnOnce(payorderextension.FieldChannelID) + } + if _q.withOrder != nil { + _spec.Node.AddColumnOnce(payorderextension.FieldOrderID) + } + } + 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 *PayOrderExtensionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(payorderextension.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = payorderextension.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 _, 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 +} + +// PayOrderExtensionGroupBy is the group-by builder for PayOrderExtension entities. +type PayOrderExtensionGroupBy struct { + selector + build *PayOrderExtensionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PayOrderExtensionGroupBy) Aggregate(fns ...AggregateFunc) *PayOrderExtensionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PayOrderExtensionGroupBy) 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[*PayOrderExtensionQuery, *PayOrderExtensionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PayOrderExtensionGroupBy) sqlScan(ctx context.Context, root *PayOrderExtensionQuery, 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) +} + +// PayOrderExtensionSelect is the builder for selecting fields of PayOrderExtension entities. +type PayOrderExtensionSelect struct { + *PayOrderExtensionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PayOrderExtensionSelect) Aggregate(fns ...AggregateFunc) *PayOrderExtensionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PayOrderExtensionSelect) 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[*PayOrderExtensionQuery, *PayOrderExtensionSelect](ctx, _s.PayOrderExtensionQuery, _s, _s.inters, v) +} + +func (_s *PayOrderExtensionSelect) sqlScan(ctx context.Context, root *PayOrderExtensionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/rpc/ent/payorderextension_update.go b/rpc/ent/payorderextension_update.go new file mode 100644 index 0000000..76dd1aa --- /dev/null +++ b/rpc/ent/payorderextension_update.go @@ -0,0 +1,774 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PayOrderExtensionUpdate is the builder for updating PayOrderExtension entities. +type PayOrderExtensionUpdate struct { + config + hooks []Hook + mutation *PayOrderExtensionMutation +} + +// Where appends a list predicates to the PayOrderExtensionUpdate builder. +func (_u *PayOrderExtensionUpdate) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayOrderExtensionUpdate) SetUpdatedAt(v time.Time) *PayOrderExtensionUpdate { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayOrderExtensionUpdate) SetStatus(v uint8) *PayOrderExtensionUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableStatus(v *uint8) *PayOrderExtensionUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayOrderExtensionUpdate) AddStatus(v int8) *PayOrderExtensionUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayOrderExtensionUpdate) ClearStatus() *PayOrderExtensionUpdate { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayOrderExtensionUpdate) SetDeletedAt(v time.Time) *PayOrderExtensionUpdate { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableDeletedAt(v *time.Time) *PayOrderExtensionUpdate { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayOrderExtensionUpdate) ClearDeletedAt() *PayOrderExtensionUpdate { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetOrderID sets the "order_id" field. +func (_u *PayOrderExtensionUpdate) SetOrderID(v uint64) *PayOrderExtensionUpdate { + _u.mutation.SetOrderID(v) + return _u +} + +// SetNillableOrderID sets the "order_id" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableOrderID(v *uint64) *PayOrderExtensionUpdate { + if v != nil { + _u.SetOrderID(*v) + } + return _u +} + +// SetChannelID sets the "channel_id" field. +func (_u *PayOrderExtensionUpdate) SetChannelID(v uint64) *PayOrderExtensionUpdate { + _u.mutation.SetChannelID(v) + return _u +} + +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableChannelID(v *uint64) *PayOrderExtensionUpdate { + if v != nil { + _u.SetChannelID(*v) + } + return _u +} + +// SetChannelExtras sets the "channel_extras" field. +func (_u *PayOrderExtensionUpdate) SetChannelExtras(v map[string]interface{}) *PayOrderExtensionUpdate { + _u.mutation.SetChannelExtras(v) + return _u +} + +// ClearChannelExtras clears the value of the "channel_extras" field. +func (_u *PayOrderExtensionUpdate) ClearChannelExtras() *PayOrderExtensionUpdate { + _u.mutation.ClearChannelExtras() + return _u +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (_u *PayOrderExtensionUpdate) SetChannelErrorCode(v string) *PayOrderExtensionUpdate { + _u.mutation.SetChannelErrorCode(v) + return _u +} + +// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableChannelErrorCode(v *string) *PayOrderExtensionUpdate { + if v != nil { + _u.SetChannelErrorCode(*v) + } + return _u +} + +// ClearChannelErrorCode clears the value of the "channel_error_code" field. +func (_u *PayOrderExtensionUpdate) ClearChannelErrorCode() *PayOrderExtensionUpdate { + _u.mutation.ClearChannelErrorCode() + return _u +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (_u *PayOrderExtensionUpdate) SetChannelErrorMsg(v string) *PayOrderExtensionUpdate { + _u.mutation.SetChannelErrorMsg(v) + return _u +} + +// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableChannelErrorMsg(v *string) *PayOrderExtensionUpdate { + if v != nil { + _u.SetChannelErrorMsg(*v) + } + return _u +} + +// ClearChannelErrorMsg clears the value of the "channel_error_msg" field. +func (_u *PayOrderExtensionUpdate) ClearChannelErrorMsg() *PayOrderExtensionUpdate { + _u.mutation.ClearChannelErrorMsg() + return _u +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (_u *PayOrderExtensionUpdate) SetChannelNotifyData(v string) *PayOrderExtensionUpdate { + _u.mutation.SetChannelNotifyData(v) + return _u +} + +// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil. +func (_u *PayOrderExtensionUpdate) SetNillableChannelNotifyData(v *string) *PayOrderExtensionUpdate { + if v != nil { + _u.SetChannelNotifyData(*v) + } + return _u +} + +// ClearChannelNotifyData clears the value of the "channel_notify_data" field. +func (_u *PayOrderExtensionUpdate) ClearChannelNotifyData() *PayOrderExtensionUpdate { + _u.mutation.ClearChannelNotifyData() + return _u +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_u *PayOrderExtensionUpdate) SetChannel(v *PayChannel) *PayOrderExtensionUpdate { + return _u.SetChannelID(v.ID) +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_u *PayOrderExtensionUpdate) SetOrder(v *PayOrder) *PayOrderExtensionUpdate { + return _u.SetOrderID(v.ID) +} + +// Mutation returns the PayOrderExtensionMutation object of the builder. +func (_u *PayOrderExtensionUpdate) Mutation() *PayOrderExtensionMutation { + return _u.mutation +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (_u *PayOrderExtensionUpdate) ClearChannel() *PayOrderExtensionUpdate { + _u.mutation.ClearChannel() + return _u +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (_u *PayOrderExtensionUpdate) ClearOrder() *PayOrderExtensionUpdate { + _u.mutation.ClearOrder() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PayOrderExtensionUpdate) 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 *PayOrderExtensionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PayOrderExtensionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayOrderExtensionUpdate) 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 *PayOrderExtensionUpdate) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := payorderextension.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayOrderExtensionUpdate) check() error { + if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayOrderExtension.channel"`) + } + if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayOrderExtension.order"`) + } + return nil +} + +func (_u *PayOrderExtensionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(payorderextension.Table, payorderextension.Columns, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64)) + 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.UpdatedAt(); ok { + _spec.SetField(payorderextension.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(payorderextension.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(payorderextension.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(payorderextension.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(payorderextension.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(payorderextension.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.ChannelExtras(); ok { + _spec.SetField(payorderextension.FieldChannelExtras, field.TypeJSON, value) + } + if _u.mutation.ChannelExtrasCleared() { + _spec.ClearField(payorderextension.FieldChannelExtras, field.TypeJSON) + } + if value, ok := _u.mutation.ChannelErrorCode(); ok { + _spec.SetField(payorderextension.FieldChannelErrorCode, field.TypeString, value) + } + if _u.mutation.ChannelErrorCodeCleared() { + _spec.ClearField(payorderextension.FieldChannelErrorCode, field.TypeString) + } + if value, ok := _u.mutation.ChannelErrorMsg(); ok { + _spec.SetField(payorderextension.FieldChannelErrorMsg, field.TypeString, value) + } + if _u.mutation.ChannelErrorMsgCleared() { + _spec.ClearField(payorderextension.FieldChannelErrorMsg, field.TypeString) + } + if value, ok := _u.mutation.ChannelNotifyData(); ok { + _spec.SetField(payorderextension.FieldChannelNotifyData, field.TypeString, value) + } + if _u.mutation.ChannelNotifyDataCleared() { + _spec.ClearField(payorderextension.FieldChannelNotifyData, field.TypeString) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.ChannelTable, + Columns: []string{payorderextension.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.ChannelTable, + Columns: []string{payorderextension.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.OrderTable, + Columns: []string{payorderextension.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.OrderTable, + Columns: []string{payorderextension.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{payorderextension.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PayOrderExtensionUpdateOne is the builder for updating a single PayOrderExtension entity. +type PayOrderExtensionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PayOrderExtensionMutation +} + +// SetUpdatedAt sets the "updated_at" field. +func (_u *PayOrderExtensionUpdateOne) SetUpdatedAt(v time.Time) *PayOrderExtensionUpdateOne { + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *PayOrderExtensionUpdateOne) SetStatus(v uint8) *PayOrderExtensionUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableStatus(v *uint8) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *PayOrderExtensionUpdateOne) AddStatus(v int8) *PayOrderExtensionUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// ClearStatus clears the value of the "status" field. +func (_u *PayOrderExtensionUpdateOne) ClearStatus() *PayOrderExtensionUpdateOne { + _u.mutation.ClearStatus() + return _u +} + +// SetDeletedAt sets the "deleted_at" field. +func (_u *PayOrderExtensionUpdateOne) SetDeletedAt(v time.Time) *PayOrderExtensionUpdateOne { + _u.mutation.SetDeletedAt(v) + return _u +} + +// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableDeletedAt(v *time.Time) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetDeletedAt(*v) + } + return _u +} + +// ClearDeletedAt clears the value of the "deleted_at" field. +func (_u *PayOrderExtensionUpdateOne) ClearDeletedAt() *PayOrderExtensionUpdateOne { + _u.mutation.ClearDeletedAt() + return _u +} + +// SetOrderID sets the "order_id" field. +func (_u *PayOrderExtensionUpdateOne) SetOrderID(v uint64) *PayOrderExtensionUpdateOne { + _u.mutation.SetOrderID(v) + return _u +} + +// SetNillableOrderID sets the "order_id" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableOrderID(v *uint64) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetOrderID(*v) + } + return _u +} + +// SetChannelID sets the "channel_id" field. +func (_u *PayOrderExtensionUpdateOne) SetChannelID(v uint64) *PayOrderExtensionUpdateOne { + _u.mutation.SetChannelID(v) + return _u +} + +// SetNillableChannelID sets the "channel_id" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableChannelID(v *uint64) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetChannelID(*v) + } + return _u +} + +// SetChannelExtras sets the "channel_extras" field. +func (_u *PayOrderExtensionUpdateOne) SetChannelExtras(v map[string]interface{}) *PayOrderExtensionUpdateOne { + _u.mutation.SetChannelExtras(v) + return _u +} + +// ClearChannelExtras clears the value of the "channel_extras" field. +func (_u *PayOrderExtensionUpdateOne) ClearChannelExtras() *PayOrderExtensionUpdateOne { + _u.mutation.ClearChannelExtras() + return _u +} + +// SetChannelErrorCode sets the "channel_error_code" field. +func (_u *PayOrderExtensionUpdateOne) SetChannelErrorCode(v string) *PayOrderExtensionUpdateOne { + _u.mutation.SetChannelErrorCode(v) + return _u +} + +// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableChannelErrorCode(v *string) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetChannelErrorCode(*v) + } + return _u +} + +// ClearChannelErrorCode clears the value of the "channel_error_code" field. +func (_u *PayOrderExtensionUpdateOne) ClearChannelErrorCode() *PayOrderExtensionUpdateOne { + _u.mutation.ClearChannelErrorCode() + return _u +} + +// SetChannelErrorMsg sets the "channel_error_msg" field. +func (_u *PayOrderExtensionUpdateOne) SetChannelErrorMsg(v string) *PayOrderExtensionUpdateOne { + _u.mutation.SetChannelErrorMsg(v) + return _u +} + +// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableChannelErrorMsg(v *string) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetChannelErrorMsg(*v) + } + return _u +} + +// ClearChannelErrorMsg clears the value of the "channel_error_msg" field. +func (_u *PayOrderExtensionUpdateOne) ClearChannelErrorMsg() *PayOrderExtensionUpdateOne { + _u.mutation.ClearChannelErrorMsg() + return _u +} + +// SetChannelNotifyData sets the "channel_notify_data" field. +func (_u *PayOrderExtensionUpdateOne) SetChannelNotifyData(v string) *PayOrderExtensionUpdateOne { + _u.mutation.SetChannelNotifyData(v) + return _u +} + +// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil. +func (_u *PayOrderExtensionUpdateOne) SetNillableChannelNotifyData(v *string) *PayOrderExtensionUpdateOne { + if v != nil { + _u.SetChannelNotifyData(*v) + } + return _u +} + +// ClearChannelNotifyData clears the value of the "channel_notify_data" field. +func (_u *PayOrderExtensionUpdateOne) ClearChannelNotifyData() *PayOrderExtensionUpdateOne { + _u.mutation.ClearChannelNotifyData() + return _u +} + +// SetChannel sets the "channel" edge to the PayChannel entity. +func (_u *PayOrderExtensionUpdateOne) SetChannel(v *PayChannel) *PayOrderExtensionUpdateOne { + return _u.SetChannelID(v.ID) +} + +// SetOrder sets the "order" edge to the PayOrder entity. +func (_u *PayOrderExtensionUpdateOne) SetOrder(v *PayOrder) *PayOrderExtensionUpdateOne { + return _u.SetOrderID(v.ID) +} + +// Mutation returns the PayOrderExtensionMutation object of the builder. +func (_u *PayOrderExtensionUpdateOne) Mutation() *PayOrderExtensionMutation { + return _u.mutation +} + +// ClearChannel clears the "channel" edge to the PayChannel entity. +func (_u *PayOrderExtensionUpdateOne) ClearChannel() *PayOrderExtensionUpdateOne { + _u.mutation.ClearChannel() + return _u +} + +// ClearOrder clears the "order" edge to the PayOrder entity. +func (_u *PayOrderExtensionUpdateOne) ClearOrder() *PayOrderExtensionUpdateOne { + _u.mutation.ClearOrder() + return _u +} + +// Where appends a list predicates to the PayOrderExtensionUpdate builder. +func (_u *PayOrderExtensionUpdateOne) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionUpdateOne { + _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 *PayOrderExtensionUpdateOne) Select(field string, fields ...string) *PayOrderExtensionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PayOrderExtension entity. +func (_u *PayOrderExtensionUpdateOne) Save(ctx context.Context) (*PayOrderExtension, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PayOrderExtensionUpdateOne) SaveX(ctx context.Context) *PayOrderExtension { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PayOrderExtensionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PayOrderExtensionUpdateOne) 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 *PayOrderExtensionUpdateOne) defaults() { + if _, ok := _u.mutation.UpdatedAt(); !ok { + v := payorderextension.UpdateDefaultUpdatedAt() + _u.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PayOrderExtensionUpdateOne) check() error { + if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayOrderExtension.channel"`) + } + if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PayOrderExtension.order"`) + } + return nil +} + +func (_u *PayOrderExtensionUpdateOne) sqlSave(ctx context.Context) (_node *PayOrderExtension, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(payorderextension.Table, payorderextension.Columns, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayOrderExtension.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, payorderextension.FieldID) + for _, f := range fields { + if !payorderextension.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != payorderextension.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.UpdatedAt(); ok { + _spec.SetField(payorderextension.FieldUpdatedAt, field.TypeTime, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(payorderextension.FieldStatus, field.TypeUint8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(payorderextension.FieldStatus, field.TypeUint8, value) + } + if _u.mutation.StatusCleared() { + _spec.ClearField(payorderextension.FieldStatus, field.TypeUint8) + } + if value, ok := _u.mutation.DeletedAt(); ok { + _spec.SetField(payorderextension.FieldDeletedAt, field.TypeTime, value) + } + if _u.mutation.DeletedAtCleared() { + _spec.ClearField(payorderextension.FieldDeletedAt, field.TypeTime) + } + if value, ok := _u.mutation.ChannelExtras(); ok { + _spec.SetField(payorderextension.FieldChannelExtras, field.TypeJSON, value) + } + if _u.mutation.ChannelExtrasCleared() { + _spec.ClearField(payorderextension.FieldChannelExtras, field.TypeJSON) + } + if value, ok := _u.mutation.ChannelErrorCode(); ok { + _spec.SetField(payorderextension.FieldChannelErrorCode, field.TypeString, value) + } + if _u.mutation.ChannelErrorCodeCleared() { + _spec.ClearField(payorderextension.FieldChannelErrorCode, field.TypeString) + } + if value, ok := _u.mutation.ChannelErrorMsg(); ok { + _spec.SetField(payorderextension.FieldChannelErrorMsg, field.TypeString, value) + } + if _u.mutation.ChannelErrorMsgCleared() { + _spec.ClearField(payorderextension.FieldChannelErrorMsg, field.TypeString) + } + if value, ok := _u.mutation.ChannelNotifyData(); ok { + _spec.SetField(payorderextension.FieldChannelNotifyData, field.TypeString, value) + } + if _u.mutation.ChannelNotifyDataCleared() { + _spec.ClearField(payorderextension.FieldChannelNotifyData, field.TypeString) + } + if _u.mutation.ChannelCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.ChannelTable, + Columns: []string{payorderextension.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.ChannelTable, + Columns: []string{payorderextension.ChannelColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.OrderCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.OrderTable, + Columns: []string{payorderextension.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: payorderextension.OrderTable, + Columns: []string{payorderextension.OrderColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _node = &PayOrderExtension{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{payorderextension.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/rpc/ent/predicate/predicate.go b/rpc/ent/predicate/predicate.go new file mode 100644 index 0000000..1f61380 --- /dev/null +++ b/rpc/ent/predicate/predicate.go @@ -0,0 +1,28 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// App is the predicate function for app builders. +type App func(*sql.Selector) + +// PayChannel is the predicate function for paychannel builders. +type PayChannel func(*sql.Selector) + +// PayNotifyLog is the predicate function for paynotifylog builders. +type PayNotifyLog func(*sql.Selector) + +// PayNotifyTask is the predicate function for paynotifytask builders. +type PayNotifyTask func(*sql.Selector) + +// PayOrder is the predicate function for payorder builders. +type PayOrder func(*sql.Selector) + +// PayOrderExtension is the predicate function for payorderextension builders. +type PayOrderExtension func(*sql.Selector) + +// PayRefund is the predicate function for payrefund builders. +type PayRefund func(*sql.Selector) diff --git a/rpc/ent/runtime.go b/rpc/ent/runtime.go new file mode 100644 index 0000000..906db1d --- /dev/null +++ b/rpc/ent/runtime.go @@ -0,0 +1,266 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "mingyang-admin-pay/rpc/ent/app" + "mingyang-admin-pay/rpc/ent/paychannel" + "mingyang-admin-pay/rpc/ent/paynotifylog" + "mingyang-admin-pay/rpc/ent/paynotifytask" + "mingyang-admin-pay/rpc/ent/payorder" + "mingyang-admin-pay/rpc/ent/payorderextension" + "mingyang-admin-pay/rpc/ent/payrefund" + "mingyang-admin-pay/rpc/ent/schema" + "time" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + appMixin := schema.App{}.Mixin() + appMixinFields0 := appMixin[0].Fields() + _ = appMixinFields0 + appMixinFields1 := appMixin[1].Fields() + _ = appMixinFields1 + appMixinFields2 := appMixin[2].Fields() + _ = appMixinFields2 + appFields := schema.App{}.Fields() + _ = appFields + // appDescCreatedAt is the schema descriptor for created_at field. + appDescCreatedAt := appMixinFields0[1].Descriptor() + // app.DefaultCreatedAt holds the default value on creation for the created_at field. + app.DefaultCreatedAt = appDescCreatedAt.Default.(func() time.Time) + // appDescUpdatedAt is the schema descriptor for updated_at field. + appDescUpdatedAt := appMixinFields0[2].Descriptor() + // app.DefaultUpdatedAt holds the default value on creation for the updated_at field. + app.DefaultUpdatedAt = appDescUpdatedAt.Default.(func() time.Time) + // app.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + app.UpdateDefaultUpdatedAt = appDescUpdatedAt.UpdateDefault.(func() time.Time) + // appDescStatus is the schema descriptor for status field. + appDescStatus := appMixinFields1[0].Descriptor() + // app.DefaultStatus holds the default value on creation for the status field. + app.DefaultStatus = appDescStatus.Default.(uint8) + // appDescTenantID is the schema descriptor for tenant_id field. + appDescTenantID := appMixinFields2[0].Descriptor() + // app.DefaultTenantID holds the default value on creation for the tenant_id field. + app.DefaultTenantID = appDescTenantID.Default.(uint64) + paychannelMixin := schema.PayChannel{}.Mixin() + paychannelMixinFields0 := paychannelMixin[0].Fields() + _ = paychannelMixinFields0 + paychannelMixinFields1 := paychannelMixin[1].Fields() + _ = paychannelMixinFields1 + paychannelMixinFields2 := paychannelMixin[2].Fields() + _ = paychannelMixinFields2 + paychannelFields := schema.PayChannel{}.Fields() + _ = paychannelFields + // paychannelDescCreatedAt is the schema descriptor for created_at field. + paychannelDescCreatedAt := paychannelMixinFields0[1].Descriptor() + // paychannel.DefaultCreatedAt holds the default value on creation for the created_at field. + paychannel.DefaultCreatedAt = paychannelDescCreatedAt.Default.(func() time.Time) + // paychannelDescUpdatedAt is the schema descriptor for updated_at field. + paychannelDescUpdatedAt := paychannelMixinFields0[2].Descriptor() + // paychannel.DefaultUpdatedAt holds the default value on creation for the updated_at field. + paychannel.DefaultUpdatedAt = paychannelDescUpdatedAt.Default.(func() time.Time) + // paychannel.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + paychannel.UpdateDefaultUpdatedAt = paychannelDescUpdatedAt.UpdateDefault.(func() time.Time) + // paychannelDescStatus is the schema descriptor for status field. + paychannelDescStatus := paychannelMixinFields1[0].Descriptor() + // paychannel.DefaultStatus holds the default value on creation for the status field. + paychannel.DefaultStatus = paychannelDescStatus.Default.(uint8) + // paychannelDescTenantID is the schema descriptor for tenant_id field. + paychannelDescTenantID := paychannelMixinFields2[0].Descriptor() + // paychannel.DefaultTenantID holds the default value on creation for the tenant_id field. + paychannel.DefaultTenantID = paychannelDescTenantID.Default.(uint64) + // paychannelDescFreeRate is the schema descriptor for free_rate field. + paychannelDescFreeRate := paychannelFields[3].Descriptor() + // paychannel.DefaultFreeRate holds the default value on creation for the free_rate field. + paychannel.DefaultFreeRate = paychannelDescFreeRate.Default.(string) + // paychannelDescOrderTimeOut is the schema descriptor for order_time_out field. + paychannelDescOrderTimeOut := paychannelFields[8].Descriptor() + // paychannel.DefaultOrderTimeOut holds the default value on creation for the order_time_out field. + paychannel.DefaultOrderTimeOut = paychannelDescOrderTimeOut.Default.(string) + // paychannelDescSupportCurrency is the schema descriptor for support_currency field. + paychannelDescSupportCurrency := paychannelFields[9].Descriptor() + // paychannel.DefaultSupportCurrency holds the default value on creation for the support_currency field. + paychannel.DefaultSupportCurrency = paychannelDescSupportCurrency.Default.(string) + paynotifylogMixin := schema.PayNotifyLog{}.Mixin() + paynotifylogMixinFields0 := paynotifylogMixin[0].Fields() + _ = paynotifylogMixinFields0 + paynotifylogMixinFields1 := paynotifylogMixin[1].Fields() + _ = paynotifylogMixinFields1 + paynotifylogMixinFields2 := paynotifylogMixin[2].Fields() + _ = paynotifylogMixinFields2 + paynotifylogFields := schema.PayNotifyLog{}.Fields() + _ = paynotifylogFields + // paynotifylogDescCreatedAt is the schema descriptor for created_at field. + paynotifylogDescCreatedAt := paynotifylogMixinFields0[1].Descriptor() + // paynotifylog.DefaultCreatedAt holds the default value on creation for the created_at field. + paynotifylog.DefaultCreatedAt = paynotifylogDescCreatedAt.Default.(func() time.Time) + // paynotifylogDescUpdatedAt is the schema descriptor for updated_at field. + paynotifylogDescUpdatedAt := paynotifylogMixinFields0[2].Descriptor() + // paynotifylog.DefaultUpdatedAt holds the default value on creation for the updated_at field. + paynotifylog.DefaultUpdatedAt = paynotifylogDescUpdatedAt.Default.(func() time.Time) + // paynotifylog.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + paynotifylog.UpdateDefaultUpdatedAt = paynotifylogDescUpdatedAt.UpdateDefault.(func() time.Time) + // paynotifylogDescStatus is the schema descriptor for status field. + paynotifylogDescStatus := paynotifylogMixinFields1[0].Descriptor() + // paynotifylog.DefaultStatus holds the default value on creation for the status field. + paynotifylog.DefaultStatus = paynotifylogDescStatus.Default.(uint8) + // paynotifylogDescTenantID is the schema descriptor for tenant_id field. + paynotifylogDescTenantID := paynotifylogMixinFields2[0].Descriptor() + // paynotifylog.DefaultTenantID holds the default value on creation for the tenant_id field. + paynotifylog.DefaultTenantID = paynotifylogDescTenantID.Default.(uint64) + // paynotifylogDescNotifyCount is the schema descriptor for notify_count field. + paynotifylogDescNotifyCount := paynotifylogFields[1].Descriptor() + // paynotifylog.DefaultNotifyCount holds the default value on creation for the notify_count field. + paynotifylog.DefaultNotifyCount = paynotifylogDescNotifyCount.Default.(uint32) + paynotifytaskMixin := schema.PayNotifyTask{}.Mixin() + paynotifytaskMixinFields0 := paynotifytaskMixin[0].Fields() + _ = paynotifytaskMixinFields0 + paynotifytaskMixinFields1 := paynotifytaskMixin[1].Fields() + _ = paynotifytaskMixinFields1 + paynotifytaskMixinFields2 := paynotifytaskMixin[2].Fields() + _ = paynotifytaskMixinFields2 + paynotifytaskFields := schema.PayNotifyTask{}.Fields() + _ = paynotifytaskFields + // paynotifytaskDescCreatedAt is the schema descriptor for created_at field. + paynotifytaskDescCreatedAt := paynotifytaskMixinFields0[1].Descriptor() + // paynotifytask.DefaultCreatedAt holds the default value on creation for the created_at field. + paynotifytask.DefaultCreatedAt = paynotifytaskDescCreatedAt.Default.(func() time.Time) + // paynotifytaskDescUpdatedAt is the schema descriptor for updated_at field. + paynotifytaskDescUpdatedAt := paynotifytaskMixinFields0[2].Descriptor() + // paynotifytask.DefaultUpdatedAt holds the default value on creation for the updated_at field. + paynotifytask.DefaultUpdatedAt = paynotifytaskDescUpdatedAt.Default.(func() time.Time) + // paynotifytask.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + paynotifytask.UpdateDefaultUpdatedAt = paynotifytaskDescUpdatedAt.UpdateDefault.(func() time.Time) + // paynotifytaskDescStatus is the schema descriptor for status field. + paynotifytaskDescStatus := paynotifytaskMixinFields1[0].Descriptor() + // paynotifytask.DefaultStatus holds the default value on creation for the status field. + paynotifytask.DefaultStatus = paynotifytaskDescStatus.Default.(uint8) + // paynotifytaskDescTenantID is the schema descriptor for tenant_id field. + paynotifytaskDescTenantID := paynotifytaskMixinFields2[0].Descriptor() + // paynotifytask.DefaultTenantID holds the default value on creation for the tenant_id field. + paynotifytask.DefaultTenantID = paynotifytaskDescTenantID.Default.(uint64) + // paynotifytaskDescType is the schema descriptor for type field. + paynotifytaskDescType := paynotifytaskFields[0].Descriptor() + // paynotifytask.DefaultType holds the default value on creation for the type field. + paynotifytask.DefaultType = paynotifytaskDescType.Default.(uint8) + payorderMixin := schema.PayOrder{}.Mixin() + payorderMixinFields0 := payorderMixin[0].Fields() + _ = payorderMixinFields0 + payorderMixinFields1 := payorderMixin[1].Fields() + _ = payorderMixinFields1 + payorderMixinFields2 := payorderMixin[2].Fields() + _ = payorderMixinFields2 + payorderFields := schema.PayOrder{}.Fields() + _ = payorderFields + // payorderDescCreatedAt is the schema descriptor for created_at field. + payorderDescCreatedAt := payorderMixinFields0[1].Descriptor() + // payorder.DefaultCreatedAt holds the default value on creation for the created_at field. + payorder.DefaultCreatedAt = payorderDescCreatedAt.Default.(func() time.Time) + // payorderDescUpdatedAt is the schema descriptor for updated_at field. + payorderDescUpdatedAt := payorderMixinFields0[2].Descriptor() + // payorder.DefaultUpdatedAt holds the default value on creation for the updated_at field. + payorder.DefaultUpdatedAt = payorderDescUpdatedAt.Default.(func() time.Time) + // payorder.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + payorder.UpdateDefaultUpdatedAt = payorderDescUpdatedAt.UpdateDefault.(func() time.Time) + // payorderDescStatus is the schema descriptor for status field. + payorderDescStatus := payorderMixinFields1[0].Descriptor() + // payorder.DefaultStatus holds the default value on creation for the status field. + payorder.DefaultStatus = payorderDescStatus.Default.(uint8) + // payorderDescTenantID is the schema descriptor for tenant_id field. + payorderDescTenantID := payorderMixinFields2[0].Descriptor() + // payorder.DefaultTenantID holds the default value on creation for the tenant_id field. + payorder.DefaultTenantID = payorderDescTenantID.Default.(uint64) + // payorderDescAmount is the schema descriptor for amount field. + payorderDescAmount := payorderFields[5].Descriptor() + // payorder.DefaultAmount holds the default value on creation for the amount field. + payorder.DefaultAmount = payorderDescAmount.Default.(uint64) + // payorderDescChannelFeeRate is the schema descriptor for channel_fee_rate field. + payorderDescChannelFeeRate := payorderFields[7].Descriptor() + // payorder.DefaultChannelFeeRate holds the default value on creation for the channel_fee_rate field. + payorder.DefaultChannelFeeRate = payorderDescChannelFeeRate.Default.(string) + // payorderDescChannelFee is the schema descriptor for channel_fee field. + payorderDescChannelFee := payorderFields[8].Descriptor() + // payorder.DefaultChannelFee holds the default value on creation for the channel_fee field. + payorder.DefaultChannelFee = payorderDescChannelFee.Default.(uint64) + // payorderDescOrderStatus is the schema descriptor for order_status field. + payorderDescOrderStatus := payorderFields[9].Descriptor() + // payorder.DefaultOrderStatus holds the default value on creation for the order_status field. + payorder.DefaultOrderStatus = payorderDescOrderStatus.Default.(string) + // payorderDescCurrency is the schema descriptor for currency field. + payorderDescCurrency := payorderFields[16].Descriptor() + // payorder.DefaultCurrency holds the default value on creation for the currency field. + payorder.DefaultCurrency = payorderDescCurrency.Default.(string) + // payorderDescRefundPrice is the schema descriptor for refund_price field. + payorderDescRefundPrice := payorderFields[17].Descriptor() + // payorder.DefaultRefundPrice holds the default value on creation for the refund_price field. + payorder.DefaultRefundPrice = payorderDescRefundPrice.Default.(uint64) + payorderextensionMixin := schema.PayOrderExtension{}.Mixin() + payorderextensionMixinFields0 := payorderextensionMixin[0].Fields() + _ = payorderextensionMixinFields0 + payorderextensionMixinFields1 := payorderextensionMixin[1].Fields() + _ = payorderextensionMixinFields1 + payorderextensionMixinFields2 := payorderextensionMixin[2].Fields() + _ = payorderextensionMixinFields2 + payorderextensionFields := schema.PayOrderExtension{}.Fields() + _ = payorderextensionFields + // payorderextensionDescCreatedAt is the schema descriptor for created_at field. + payorderextensionDescCreatedAt := payorderextensionMixinFields0[1].Descriptor() + // payorderextension.DefaultCreatedAt holds the default value on creation for the created_at field. + payorderextension.DefaultCreatedAt = payorderextensionDescCreatedAt.Default.(func() time.Time) + // payorderextensionDescUpdatedAt is the schema descriptor for updated_at field. + payorderextensionDescUpdatedAt := payorderextensionMixinFields0[2].Descriptor() + // payorderextension.DefaultUpdatedAt holds the default value on creation for the updated_at field. + payorderextension.DefaultUpdatedAt = payorderextensionDescUpdatedAt.Default.(func() time.Time) + // payorderextension.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + payorderextension.UpdateDefaultUpdatedAt = payorderextensionDescUpdatedAt.UpdateDefault.(func() time.Time) + // payorderextensionDescStatus is the schema descriptor for status field. + payorderextensionDescStatus := payorderextensionMixinFields1[0].Descriptor() + // payorderextension.DefaultStatus holds the default value on creation for the status field. + payorderextension.DefaultStatus = payorderextensionDescStatus.Default.(uint8) + // payorderextensionDescTenantID is the schema descriptor for tenant_id field. + payorderextensionDescTenantID := payorderextensionMixinFields2[0].Descriptor() + // payorderextension.DefaultTenantID holds the default value on creation for the tenant_id field. + payorderextension.DefaultTenantID = payorderextensionDescTenantID.Default.(uint64) + payrefundMixin := schema.PayRefund{}.Mixin() + payrefundMixinFields0 := payrefundMixin[0].Fields() + _ = payrefundMixinFields0 + payrefundMixinFields1 := payrefundMixin[1].Fields() + _ = payrefundMixinFields1 + payrefundMixinFields2 := payrefundMixin[2].Fields() + _ = payrefundMixinFields2 + payrefundFields := schema.PayRefund{}.Fields() + _ = payrefundFields + // payrefundDescCreatedAt is the schema descriptor for created_at field. + payrefundDescCreatedAt := payrefundMixinFields0[1].Descriptor() + // payrefund.DefaultCreatedAt holds the default value on creation for the created_at field. + payrefund.DefaultCreatedAt = payrefundDescCreatedAt.Default.(func() time.Time) + // payrefundDescUpdatedAt is the schema descriptor for updated_at field. + payrefundDescUpdatedAt := payrefundMixinFields0[2].Descriptor() + // payrefund.DefaultUpdatedAt holds the default value on creation for the updated_at field. + payrefund.DefaultUpdatedAt = payrefundDescUpdatedAt.Default.(func() time.Time) + // payrefund.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. + payrefund.UpdateDefaultUpdatedAt = payrefundDescUpdatedAt.UpdateDefault.(func() time.Time) + // payrefundDescStatus is the schema descriptor for status field. + payrefundDescStatus := payrefundMixinFields1[0].Descriptor() + // payrefund.DefaultStatus holds the default value on creation for the status field. + payrefund.DefaultStatus = payrefundDescStatus.Default.(uint8) + // payrefundDescTenantID is the schema descriptor for tenant_id field. + payrefundDescTenantID := payrefundMixinFields2[0].Descriptor() + // payrefund.DefaultTenantID holds the default value on creation for the tenant_id field. + payrefund.DefaultTenantID = payrefundDescTenantID.Default.(uint64) + // payrefundDescRefundStatus is the schema descriptor for refund_status field. + payrefundDescRefundStatus := payrefundFields[4].Descriptor() + // payrefund.DefaultRefundStatus holds the default value on creation for the refund_status field. + payrefund.DefaultRefundStatus = payrefundDescRefundStatus.Default.(uint8) + // payrefundDescRefundAmount is the schema descriptor for refund_amount field. + payrefundDescRefundAmount := payrefundFields[5].Descriptor() + // payrefund.DefaultRefundAmount holds the default value on creation for the refund_amount field. + payrefund.DefaultRefundAmount = payrefundDescRefundAmount.Default.(uint64) + // payrefundDescPayAmount is the schema descriptor for pay_amount field. + payrefundDescPayAmount := payrefundFields[6].Descriptor() + // payrefund.DefaultPayAmount holds the default value on creation for the pay_amount field. + payrefund.DefaultPayAmount = payrefundDescPayAmount.Default.(uint64) +} diff --git a/rpc/ent/runtime/runtime.go b/rpc/ent/runtime/runtime.go new file mode 100644 index 0000000..6f90de3 --- /dev/null +++ b/rpc/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in mingyang-admin-pay/rpc/ent/runtime.go + +const ( + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. +) diff --git a/rpc/ent/schema/pay_app.go b/rpc/ent/schema/pay_app.go index e3eef16..5ca89dd 100644 --- a/rpc/ent/schema/pay_app.go +++ b/rpc/ent/schema/pay_app.go @@ -1,11 +1,51 @@ package schema -import "entgo.io/ent" +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) type App struct { ent.Schema } +// Fields of the App. func (App) Fields() []ent.Field { - return []ent.Field{} + return []ent.Field{ + field.String("app_key").Comment("appKey 应用标识"), + field.String("app_name").Comment("应用名称"), + field.String("order_notify_url").Optional().Comment("支付成功回调地址"), + field.String("refund_notify_url").Optional().Comment("退款成功回调地址"), + } +} + +func (App) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (App) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("channel", PayChannel.Type). + Ref("app"), + edge.From("notify_task", PayNotifyTask.Type). + Ref("app"), + } +} + +func (App) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayApp Table | 支付应用表"), + entsql.Annotation{Table: "pay_app"}, + } } diff --git a/rpc/ent/schema/pay_channel.go b/rpc/ent/schema/pay_channel.go new file mode 100644 index 0000000..68721eb --- /dev/null +++ b/rpc/ent/schema/pay_channel.go @@ -0,0 +1,71 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) + +type PayChannel struct { + ent.Schema +} + +// Fields of the PayChannel. +func (PayChannel) Fields() []ent.Field { + return []ent.Field{ + field.String("code").Comment("Pay channel code | 支付渠道编码"), + field.String("name_en").Comment("Pay channel name | 支付渠道英文名称"), + field.String("name_zh").Comment("Pay channel name | 支付渠道中文名称"), + field.String("free_rate").Comment("Free rate | 手续费比例").Default("0"), + field.Uint64("app_id").Comment("App ID | 应用ID"), + field.JSON("config", map[string]interface{}{}).Comment("Config | 配置信息"), + field.String("remake").Optional().Comment("Remark | 备注"), + field.Uint64("icon").Optional().Comment("Icon | 图标"), + field.String("order_time_out").Comment("Order time out | 订单超时时间").Default("10m"), + field.String("support_currency").Comment("Support currency | 支持币种").Default("CNY,USD"), + } +} + +func (PayChannel) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (PayChannel) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("app_id", "code").Unique(), + } +} + +func (PayChannel) Edges() []ent.Edge { + return []ent.Edge{ + // 使用 edge.From 而不是 edge.To + edge.From("orders", PayOrder.Type). + Ref("channel"), + edge.From("orders_extension", PayOrderExtension.Type). + Ref("channel"), + edge.From("refund", PayRefund.Type). + Ref("channel"), + edge.To("app", App.Type). + Field("app_id"). + Unique(). + Required(), + } +} + +func (PayChannel) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayChannel Table | 支付渠道表"), + entsql.Annotation{Table: "pay_channel"}, + } +} diff --git a/rpc/ent/schema/pay_notify_log.go b/rpc/ent/schema/pay_notify_log.go new file mode 100644 index 0000000..fd314f5 --- /dev/null +++ b/rpc/ent/schema/pay_notify_log.go @@ -0,0 +1,58 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) + +type PayNotifyLog struct { + ent.Schema +} + +// Fields of the PayNotifyLog. +func (PayNotifyLog) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("task_id").Comment("任务ID | 任务ID"), + field.Uint32("notify_count").Comment("通知次数 | 通知次数").Default(0), + field.String("response").Optional().Comment("响应内容 | 响应内容"), + field.String("notify_status").Optional().Comment("通知状态 | 通知状态"), + } +} + +func (PayNotifyLog) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } + +} +func (PayNotifyLog) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("task", PayNotifyTask.Type). + Field("task_id"). + Unique(). + Required(), + } +} + +func (PayNotifyLog) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("task_id"), + } +} + +func (PayNotifyLog) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayNotifyLog Table | 异步通知日志表"), + entsql.Annotation{Table: "pay_notify_log"}, + } +} diff --git a/rpc/ent/schema/pay_notify_task.go b/rpc/ent/schema/pay_notify_task.go new file mode 100644 index 0000000..f9edf65 --- /dev/null +++ b/rpc/ent/schema/pay_notify_task.go @@ -0,0 +1,71 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) + +type PayNotifyTask struct { + ent.Schema +} + +// Fields of the PayNotifyTask. +func (PayNotifyTask) Fields() []ent.Field { + return []ent.Field{ + field.Uint8("type").Comment("通知类型").Default(1), + field.Uint64("data_id").Comment("数据 ID"), + field.Uint64("order_id").Comment("订单 ID"), + field.Uint64("app_id").Comment("应用 ID"), + field.Uint8("notify_status").Comment("通知状态"), + field.Time("next_notify_time").Optional().Comment("下次通知时间"), + field.Time("last_execute_time").Optional().Comment("最后一次执行时间"), + field.Uint32("retry_count").Optional().Comment("重试次数"), + field.Uint32("max_retry_count").Optional().Comment("最大重试次数"), + field.String("notify_url").Optional().Comment("通知地址"), + } +} + +func (PayNotifyTask) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } + +} +func (PayNotifyTask) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("app", App.Type). + Field("app_id"). + Unique(). + Required(), + edge.To("order", PayOrder.Type). + Field("order_id"). + Unique(). + Required(), + edge.From("notify_log", PayNotifyLog.Type). + Ref("task"), + } +} + +func (PayNotifyTask) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("order_id"), + index.Fields("data_id"), + } +} + +func (PayNotifyTask) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayNotifyTask Table | 异步通知任务表"), + entsql.Annotation{Table: "pay_notify_task"}, + } +} diff --git a/rpc/ent/schema/pay_order.go b/rpc/ent/schema/pay_order.go new file mode 100644 index 0000000..40de53f --- /dev/null +++ b/rpc/ent/schema/pay_order.go @@ -0,0 +1,86 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) + +type PayOrder struct { + ent.Schema +} + +// Fields of the PayOrder. +func (PayOrder) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("channel_id").Comment("支付渠道 ID"), + field.Uint64("user_id").Comment("用户 ID"), + field.String("subject").Comment("商品标题"), + field.String("body").Comment("商品描述"), + field.String("notify_url").Comment("异步通知地址"), + field.Uint64("amount").Comment("金额,单位为分").Default(0), + field.String("pay_source").Comment("支付来源").Optional(), + field.String("channel_fee_rate").Comment("本次渠道费率,百分比").Default("0.00"), + field.Uint64("channel_fee").Comment("本次渠道实际收取费y").Default(0), + field.String("order_status").Comment("订单状态").Default("WAIT"), + field.String("user_ip").Comment("用户 IP").Optional(), + field.Time("expire_time").Comment("订单过期时间"), + field.String("pay_no").Comment("支付单号"), + field.Time("success_time").Comment("订单支付成功时间"), + field.Uint64("extension_id").Comment("支付成功的订单拓展单ID").Optional(), + field.String("transaction_id").Comment("交易流水号,有一些平台可能会有").Optional(), + field.String("currency").Comment("货币代码").Default("USD"), + field.Uint64("refund_price").Comment("退款金额,单位为分").Default(0), + field.String("channel_order_no").Comment("渠道订单号").Optional(), + field.String("channel_user_id").Comment("渠道用户 ID").Optional(), + } +} + +func (PayOrder) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (PayOrder) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("channel", PayChannel.Type). + Field("channel_id"). + Unique(). + Required(), + edge.From("orders_extension", PayOrderExtension.Type). + Ref("order"), + edge.From("notify_task", PayNotifyTask.Type). + Ref("order"), + edge.From("refund", PayRefund.Type). + Ref("order"), + } +} + +func (PayOrder) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("extension_id"), + index.Fields("channel_order_no").Unique(), + index.Fields("pay_no").Unique(), + index.Fields("transaction_id"), + index.Fields("user_id"), + index.Fields("channel_id"), + index.Fields("order_status"), + } +} + +func (PayOrder) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayOrder Table | 支付订单表"), + entsql.Annotation{Table: "pay_order"}, + } +} diff --git a/rpc/ent/schema/pay_order_extension.go b/rpc/ent/schema/pay_order_extension.go new file mode 100644 index 0000000..cd4242b --- /dev/null +++ b/rpc/ent/schema/pay_order_extension.go @@ -0,0 +1,67 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) + +type PayOrderExtension struct { + ent.Schema +} + +// Fields of the PayOrder. +func (PayOrderExtension) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("order_id"). + Comment("Order ID | 订单ID"), + field.Uint64("channel_id").Comment("Channel ID | 渠道ID"), + field.JSON("channel_extras", map[string]interface{}{}). + Optional().Comment("Channel Extras | 渠道参数"), + field.String("channel_error_code").Optional().Comment("Channel Error Code | 渠道错误码"), + field.String("channel_error_msg").Optional().Comment("Channel Error Msg | 渠道错误信息"), + field.String("channel_notify_data").Optional().Comment("Channel Notify Data | 渠道回调数据"), + } +} + +func (PayOrderExtension) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (PayOrderExtension) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("channel", PayChannel.Type). + Field("channel_id"). + Unique(). + Required(), + edge.To("order", PayOrder.Type). + Field("order_id"). + Unique(). + Required(), + } +} + +func (PayOrderExtension) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("order_id"), + index.Fields("channel_id"), + } +} + +func (PayOrderExtension) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayOrderExtension Table | 支付订单拓展表"), + entsql.Annotation{Table: "pay_order_extension"}, + } +} diff --git a/rpc/ent/schema/pay_refund.go b/rpc/ent/schema/pay_refund.go new file mode 100644 index 0000000..865d8d8 --- /dev/null +++ b/rpc/ent/schema/pay_refund.go @@ -0,0 +1,78 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins" + mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins" +) + +type PayRefund struct { + ent.Schema +} + +// Fields of the PayOrder. +func (PayRefund) Fields() []ent.Field { + return []ent.Field{ + field.Uint64("channel_id").Comment("支付渠道 ID"), + field.Uint64("user_id").Comment("用户 ID"), + field.Uint64("order_id").Comment("订单 ID"), + field.String("notify_url").Comment("回调地址").Optional(), + field.Uint8("refund_status").Comment("退款状态").Default(0), + field.Uint64("refund_amount").Comment("退款金额").Default(0), + field.Uint64("pay_amount").Comment("支付金额").Default(0), + field.String("refund_no").Comment("退款单号"), + field.String("refund_reason").Comment("退款原因"), + field.String("user_ip").Optional().Comment("用户 IP"), + field.String("channel_refund_no").Comment("渠道退款单号"), + field.Time("refund_time").Comment("退款成功时间"), + field.String("channel_error_code").Comment("渠道错误码").Optional(), + field.String("channel_error_msg").Comment("渠道错误信息").Optional(), + field.String("channel_notify_data").Comment("渠道回调数据").Optional(), + } +} + +func (PayRefund) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixins.IDMixin{}, + mixins.StatusMixin{}, + mixins.TenantMixin{}, + mixins2.SoftDeleteMixin{}, + } +} + +func (PayRefund) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("order", PayOrder.Type). + Field("order_id"). + Unique(). + Required(), + edge.To("channel", PayChannel.Type). + Field("channel_id"). + Unique(). + Required(), + } +} + +func (PayRefund) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("user_id"), + index.Fields("order_id"), + index.Fields("channel_id"), + index.Fields("refund_status"), + index.Fields("refund_no"), + index.Fields("channel_refund_no"), + } +} + +func (PayRefund) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.WithComments(true), + schema.Comment("PayRefund Table | 退款订单表"), + entsql.Annotation{Table: "pay_refund"}, + } +} diff --git a/rpc/ent/set_not_nil.go b/rpc/ent/set_not_nil.go new file mode 100644 index 0000000..fa552eb --- /dev/null +++ b/rpc/ent/set_not_nil.go @@ -0,0 +1,2165 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import "time" + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilUpdatedAt(value *time.Time) *AppUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilUpdatedAt(value *time.Time) *AppUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilUpdatedAt(value *time.Time) *AppCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilStatus(value *uint8) *AppUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilStatus(value *uint8) *AppUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilStatus(value *uint8) *AppCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilDeletedAt(value *time.Time) *AppUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilDeletedAt(value *time.Time) *AppUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilDeletedAt(value *time.Time) *AppCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilAppKey(value *string) *AppUpdate { + if value != nil { + return _m.SetAppKey(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilAppKey(value *string) *AppUpdateOne { + if value != nil { + return _m.SetAppKey(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilAppKey(value *string) *AppCreate { + if value != nil { + return _m.SetAppKey(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilAppName(value *string) *AppUpdate { + if value != nil { + return _m.SetAppName(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilAppName(value *string) *AppUpdateOne { + if value != nil { + return _m.SetAppName(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilAppName(value *string) *AppCreate { + if value != nil { + return _m.SetAppName(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilOrderNotifyURL(value *string) *AppUpdate { + if value != nil { + return _m.SetOrderNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilOrderNotifyURL(value *string) *AppUpdateOne { + if value != nil { + return _m.SetOrderNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilOrderNotifyURL(value *string) *AppCreate { + if value != nil { + return _m.SetOrderNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdate) SetNotNilRefundNotifyURL(value *string) *AppUpdate { + if value != nil { + return _m.SetRefundNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppUpdateOne) SetNotNilRefundNotifyURL(value *string) *AppUpdateOne { + if value != nil { + return _m.SetRefundNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *AppCreate) SetNotNilRefundNotifyURL(value *string) *AppCreate { + if value != nil { + return _m.SetRefundNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilUpdatedAt(value *time.Time) *PayChannelUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilUpdatedAt(value *time.Time) *PayChannelUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilUpdatedAt(value *time.Time) *PayChannelCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilStatus(value *uint8) *PayChannelUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilStatus(value *uint8) *PayChannelUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilStatus(value *uint8) *PayChannelCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilDeletedAt(value *time.Time) *PayChannelUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilDeletedAt(value *time.Time) *PayChannelUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilDeletedAt(value *time.Time) *PayChannelCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilCode(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilCode(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilCode(value *string) *PayChannelCreate { + if value != nil { + return _m.SetCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilNameEn(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetNameEn(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilNameEn(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetNameEn(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilNameEn(value *string) *PayChannelCreate { + if value != nil { + return _m.SetNameEn(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilNameZh(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetNameZh(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilNameZh(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetNameZh(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilNameZh(value *string) *PayChannelCreate { + if value != nil { + return _m.SetNameZh(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilFreeRate(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetFreeRate(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilFreeRate(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetFreeRate(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilFreeRate(value *string) *PayChannelCreate { + if value != nil { + return _m.SetFreeRate(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilAppID(value *uint64) *PayChannelUpdate { + if value != nil { + return _m.SetAppID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilAppID(value *uint64) *PayChannelUpdateOne { + if value != nil { + return _m.SetAppID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilAppID(value *uint64) *PayChannelCreate { + if value != nil { + return _m.SetAppID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilConfig(value *map[string]interface{}) *PayChannelUpdate { + if value != nil { + return _m.SetConfig(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilConfig(value *map[string]interface{}) *PayChannelUpdateOne { + if value != nil { + return _m.SetConfig(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilConfig(value *map[string]interface{}) *PayChannelCreate { + if value != nil { + return _m.SetConfig(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilRemake(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetRemake(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilRemake(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetRemake(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilRemake(value *string) *PayChannelCreate { + if value != nil { + return _m.SetRemake(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilIcon(value *uint64) *PayChannelUpdate { + if value != nil { + return _m.SetIcon(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilIcon(value *uint64) *PayChannelUpdateOne { + if value != nil { + return _m.SetIcon(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilIcon(value *uint64) *PayChannelCreate { + if value != nil { + return _m.SetIcon(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilOrderTimeOut(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetOrderTimeOut(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilOrderTimeOut(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetOrderTimeOut(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilOrderTimeOut(value *string) *PayChannelCreate { + if value != nil { + return _m.SetOrderTimeOut(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdate) SetNotNilSupportCurrency(value *string) *PayChannelUpdate { + if value != nil { + return _m.SetSupportCurrency(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelUpdateOne) SetNotNilSupportCurrency(value *string) *PayChannelUpdateOne { + if value != nil { + return _m.SetSupportCurrency(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayChannelCreate) SetNotNilSupportCurrency(value *string) *PayChannelCreate { + if value != nil { + return _m.SetSupportCurrency(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilUpdatedAt(value *time.Time) *PayNotifyLogUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilUpdatedAt(value *time.Time) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilUpdatedAt(value *time.Time) *PayNotifyLogCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilStatus(value *uint8) *PayNotifyLogUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilStatus(value *uint8) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilStatus(value *uint8) *PayNotifyLogCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilDeletedAt(value *time.Time) *PayNotifyLogUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilDeletedAt(value *time.Time) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilDeletedAt(value *time.Time) *PayNotifyLogCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilTaskID(value *uint64) *PayNotifyLogUpdate { + if value != nil { + return _m.SetTaskID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilTaskID(value *uint64) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetTaskID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilTaskID(value *uint64) *PayNotifyLogCreate { + if value != nil { + return _m.SetTaskID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilNotifyCount(value *uint32) *PayNotifyLogUpdate { + if value != nil { + return _m.SetNotifyCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilNotifyCount(value *uint32) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetNotifyCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilNotifyCount(value *uint32) *PayNotifyLogCreate { + if value != nil { + return _m.SetNotifyCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilResponse(value *string) *PayNotifyLogUpdate { + if value != nil { + return _m.SetResponse(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilResponse(value *string) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetResponse(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilResponse(value *string) *PayNotifyLogCreate { + if value != nil { + return _m.SetResponse(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdate) SetNotNilNotifyStatus(value *string) *PayNotifyLogUpdate { + if value != nil { + return _m.SetNotifyStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogUpdateOne) SetNotNilNotifyStatus(value *string) *PayNotifyLogUpdateOne { + if value != nil { + return _m.SetNotifyStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyLogCreate) SetNotNilNotifyStatus(value *string) *PayNotifyLogCreate { + if value != nil { + return _m.SetNotifyStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilUpdatedAt(value *time.Time) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilUpdatedAt(value *time.Time) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilUpdatedAt(value *time.Time) *PayNotifyTaskCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilStatus(value *uint8) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilStatus(value *uint8) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilStatus(value *uint8) *PayNotifyTaskCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilDeletedAt(value *time.Time) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilDeletedAt(value *time.Time) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilDeletedAt(value *time.Time) *PayNotifyTaskCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilType(value *uint8) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetType(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilType(value *uint8) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetType(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilType(value *uint8) *PayNotifyTaskCreate { + if value != nil { + return _m.SetType(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilDataID(value *uint64) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetDataID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilDataID(value *uint64) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetDataID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilDataID(value *uint64) *PayNotifyTaskCreate { + if value != nil { + return _m.SetDataID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilOrderID(value *uint64) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilOrderID(value *uint64) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilOrderID(value *uint64) *PayNotifyTaskCreate { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilAppID(value *uint64) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetAppID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilAppID(value *uint64) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetAppID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilAppID(value *uint64) *PayNotifyTaskCreate { + if value != nil { + return _m.SetAppID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilNotifyStatus(value *uint8) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetNotifyStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilNotifyStatus(value *uint8) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetNotifyStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilNotifyStatus(value *uint8) *PayNotifyTaskCreate { + if value != nil { + return _m.SetNotifyStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilNextNotifyTime(value *time.Time) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetNextNotifyTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilNextNotifyTime(value *time.Time) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetNextNotifyTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilNextNotifyTime(value *time.Time) *PayNotifyTaskCreate { + if value != nil { + return _m.SetNextNotifyTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilLastExecuteTime(value *time.Time) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetLastExecuteTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilLastExecuteTime(value *time.Time) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetLastExecuteTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilLastExecuteTime(value *time.Time) *PayNotifyTaskCreate { + if value != nil { + return _m.SetLastExecuteTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilRetryCount(value *uint32) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetRetryCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilRetryCount(value *uint32) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetRetryCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilRetryCount(value *uint32) *PayNotifyTaskCreate { + if value != nil { + return _m.SetRetryCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilMaxRetryCount(value *uint32) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetMaxRetryCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilMaxRetryCount(value *uint32) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetMaxRetryCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilMaxRetryCount(value *uint32) *PayNotifyTaskCreate { + if value != nil { + return _m.SetMaxRetryCount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdate) SetNotNilNotifyURL(value *string) *PayNotifyTaskUpdate { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskUpdateOne) SetNotNilNotifyURL(value *string) *PayNotifyTaskUpdateOne { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayNotifyTaskCreate) SetNotNilNotifyURL(value *string) *PayNotifyTaskCreate { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilUpdatedAt(value *time.Time) *PayOrderUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilUpdatedAt(value *time.Time) *PayOrderUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilUpdatedAt(value *time.Time) *PayOrderCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilStatus(value *uint8) *PayOrderUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilStatus(value *uint8) *PayOrderUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilStatus(value *uint8) *PayOrderCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilDeletedAt(value *time.Time) *PayOrderUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilDeletedAt(value *time.Time) *PayOrderUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilDeletedAt(value *time.Time) *PayOrderCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilChannelID(value *uint64) *PayOrderUpdate { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilChannelID(value *uint64) *PayOrderUpdateOne { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilChannelID(value *uint64) *PayOrderCreate { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilUserID(value *uint64) *PayOrderUpdate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilUserID(value *uint64) *PayOrderUpdateOne { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilUserID(value *uint64) *PayOrderCreate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilSubject(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetSubject(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilSubject(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetSubject(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilSubject(value *string) *PayOrderCreate { + if value != nil { + return _m.SetSubject(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilBody(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetBody(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilBody(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetBody(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilBody(value *string) *PayOrderCreate { + if value != nil { + return _m.SetBody(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilNotifyURL(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilNotifyURL(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilNotifyURL(value *string) *PayOrderCreate { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilAmount(value *uint64) *PayOrderUpdate { + if value != nil { + return _m.SetAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilAmount(value *uint64) *PayOrderUpdateOne { + if value != nil { + return _m.SetAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilAmount(value *uint64) *PayOrderCreate { + if value != nil { + return _m.SetAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilPaySource(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetPaySource(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilPaySource(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetPaySource(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilPaySource(value *string) *PayOrderCreate { + if value != nil { + return _m.SetPaySource(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilChannelFeeRate(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetChannelFeeRate(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilChannelFeeRate(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetChannelFeeRate(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilChannelFeeRate(value *string) *PayOrderCreate { + if value != nil { + return _m.SetChannelFeeRate(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilChannelFee(value *uint64) *PayOrderUpdate { + if value != nil { + return _m.SetChannelFee(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilChannelFee(value *uint64) *PayOrderUpdateOne { + if value != nil { + return _m.SetChannelFee(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilChannelFee(value *uint64) *PayOrderCreate { + if value != nil { + return _m.SetChannelFee(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilOrderStatus(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetOrderStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilOrderStatus(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetOrderStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilOrderStatus(value *string) *PayOrderCreate { + if value != nil { + return _m.SetOrderStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilUserIP(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetUserIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilUserIP(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetUserIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilUserIP(value *string) *PayOrderCreate { + if value != nil { + return _m.SetUserIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilExpireTime(value *time.Time) *PayOrderUpdate { + if value != nil { + return _m.SetExpireTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilExpireTime(value *time.Time) *PayOrderUpdateOne { + if value != nil { + return _m.SetExpireTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilExpireTime(value *time.Time) *PayOrderCreate { + if value != nil { + return _m.SetExpireTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilPayNo(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetPayNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilPayNo(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetPayNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilPayNo(value *string) *PayOrderCreate { + if value != nil { + return _m.SetPayNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilSuccessTime(value *time.Time) *PayOrderUpdate { + if value != nil { + return _m.SetSuccessTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilSuccessTime(value *time.Time) *PayOrderUpdateOne { + if value != nil { + return _m.SetSuccessTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilSuccessTime(value *time.Time) *PayOrderCreate { + if value != nil { + return _m.SetSuccessTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilExtensionID(value *uint64) *PayOrderUpdate { + if value != nil { + return _m.SetExtensionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilExtensionID(value *uint64) *PayOrderUpdateOne { + if value != nil { + return _m.SetExtensionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilExtensionID(value *uint64) *PayOrderCreate { + if value != nil { + return _m.SetExtensionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilTransactionID(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetTransactionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilTransactionID(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetTransactionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilTransactionID(value *string) *PayOrderCreate { + if value != nil { + return _m.SetTransactionID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilCurrency(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetCurrency(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilCurrency(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetCurrency(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilCurrency(value *string) *PayOrderCreate { + if value != nil { + return _m.SetCurrency(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilRefundPrice(value *uint64) *PayOrderUpdate { + if value != nil { + return _m.SetRefundPrice(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilRefundPrice(value *uint64) *PayOrderUpdateOne { + if value != nil { + return _m.SetRefundPrice(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilRefundPrice(value *uint64) *PayOrderCreate { + if value != nil { + return _m.SetRefundPrice(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilChannelOrderNo(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetChannelOrderNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilChannelOrderNo(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetChannelOrderNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilChannelOrderNo(value *string) *PayOrderCreate { + if value != nil { + return _m.SetChannelOrderNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdate) SetNotNilChannelUserID(value *string) *PayOrderUpdate { + if value != nil { + return _m.SetChannelUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderUpdateOne) SetNotNilChannelUserID(value *string) *PayOrderUpdateOne { + if value != nil { + return _m.SetChannelUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderCreate) SetNotNilChannelUserID(value *string) *PayOrderCreate { + if value != nil { + return _m.SetChannelUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilUpdatedAt(value *time.Time) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilUpdatedAt(value *time.Time) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilUpdatedAt(value *time.Time) *PayOrderExtensionCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilStatus(value *uint8) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilStatus(value *uint8) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilStatus(value *uint8) *PayOrderExtensionCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilDeletedAt(value *time.Time) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilDeletedAt(value *time.Time) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilDeletedAt(value *time.Time) *PayOrderExtensionCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilOrderID(value *uint64) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilOrderID(value *uint64) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilOrderID(value *uint64) *PayOrderExtensionCreate { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilChannelID(value *uint64) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilChannelID(value *uint64) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilChannelID(value *uint64) *PayOrderExtensionCreate { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilChannelExtras(value *map[string]interface{}) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetChannelExtras(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilChannelExtras(value *map[string]interface{}) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetChannelExtras(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilChannelExtras(value *map[string]interface{}) *PayOrderExtensionCreate { + if value != nil { + return _m.SetChannelExtras(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilChannelErrorCode(value *string) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetChannelErrorCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilChannelErrorCode(value *string) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetChannelErrorCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilChannelErrorCode(value *string) *PayOrderExtensionCreate { + if value != nil { + return _m.SetChannelErrorCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilChannelErrorMsg(value *string) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetChannelErrorMsg(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilChannelErrorMsg(value *string) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetChannelErrorMsg(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilChannelErrorMsg(value *string) *PayOrderExtensionCreate { + if value != nil { + return _m.SetChannelErrorMsg(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdate) SetNotNilChannelNotifyData(value *string) *PayOrderExtensionUpdate { + if value != nil { + return _m.SetChannelNotifyData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionUpdateOne) SetNotNilChannelNotifyData(value *string) *PayOrderExtensionUpdateOne { + if value != nil { + return _m.SetChannelNotifyData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayOrderExtensionCreate) SetNotNilChannelNotifyData(value *string) *PayOrderExtensionCreate { + if value != nil { + return _m.SetChannelNotifyData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilUpdatedAt(value *time.Time) *PayRefundUpdate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilUpdatedAt(value *time.Time) *PayRefundUpdateOne { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilUpdatedAt(value *time.Time) *PayRefundCreate { + if value != nil { + return _m.SetUpdatedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilStatus(value *uint8) *PayRefundUpdate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilStatus(value *uint8) *PayRefundUpdateOne { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilStatus(value *uint8) *PayRefundCreate { + if value != nil { + return _m.SetStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilDeletedAt(value *time.Time) *PayRefundUpdate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilDeletedAt(value *time.Time) *PayRefundUpdateOne { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilDeletedAt(value *time.Time) *PayRefundCreate { + if value != nil { + return _m.SetDeletedAt(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilChannelID(value *uint64) *PayRefundUpdate { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilChannelID(value *uint64) *PayRefundUpdateOne { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilChannelID(value *uint64) *PayRefundCreate { + if value != nil { + return _m.SetChannelID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilUserID(value *uint64) *PayRefundUpdate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilUserID(value *uint64) *PayRefundUpdateOne { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilUserID(value *uint64) *PayRefundCreate { + if value != nil { + return _m.SetUserID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilOrderID(value *uint64) *PayRefundUpdate { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilOrderID(value *uint64) *PayRefundUpdateOne { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilOrderID(value *uint64) *PayRefundCreate { + if value != nil { + return _m.SetOrderID(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilNotifyURL(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilNotifyURL(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilNotifyURL(value *string) *PayRefundCreate { + if value != nil { + return _m.SetNotifyURL(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilRefundStatus(value *uint8) *PayRefundUpdate { + if value != nil { + return _m.SetRefundStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilRefundStatus(value *uint8) *PayRefundUpdateOne { + if value != nil { + return _m.SetRefundStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilRefundStatus(value *uint8) *PayRefundCreate { + if value != nil { + return _m.SetRefundStatus(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilRefundAmount(value *uint64) *PayRefundUpdate { + if value != nil { + return _m.SetRefundAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilRefundAmount(value *uint64) *PayRefundUpdateOne { + if value != nil { + return _m.SetRefundAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilRefundAmount(value *uint64) *PayRefundCreate { + if value != nil { + return _m.SetRefundAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilPayAmount(value *uint64) *PayRefundUpdate { + if value != nil { + return _m.SetPayAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilPayAmount(value *uint64) *PayRefundUpdateOne { + if value != nil { + return _m.SetPayAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilPayAmount(value *uint64) *PayRefundCreate { + if value != nil { + return _m.SetPayAmount(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilRefundNo(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetRefundNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilRefundNo(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetRefundNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilRefundNo(value *string) *PayRefundCreate { + if value != nil { + return _m.SetRefundNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilRefundReason(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetRefundReason(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilRefundReason(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetRefundReason(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilRefundReason(value *string) *PayRefundCreate { + if value != nil { + return _m.SetRefundReason(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilUserIP(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetUserIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilUserIP(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetUserIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilUserIP(value *string) *PayRefundCreate { + if value != nil { + return _m.SetUserIP(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilChannelRefundNo(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetChannelRefundNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilChannelRefundNo(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetChannelRefundNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilChannelRefundNo(value *string) *PayRefundCreate { + if value != nil { + return _m.SetChannelRefundNo(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilRefundTime(value *time.Time) *PayRefundUpdate { + if value != nil { + return _m.SetRefundTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilRefundTime(value *time.Time) *PayRefundUpdateOne { + if value != nil { + return _m.SetRefundTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilRefundTime(value *time.Time) *PayRefundCreate { + if value != nil { + return _m.SetRefundTime(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilChannelErrorCode(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetChannelErrorCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilChannelErrorCode(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetChannelErrorCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilChannelErrorCode(value *string) *PayRefundCreate { + if value != nil { + return _m.SetChannelErrorCode(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilChannelErrorMsg(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetChannelErrorMsg(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilChannelErrorMsg(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetChannelErrorMsg(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilChannelErrorMsg(value *string) *PayRefundCreate { + if value != nil { + return _m.SetChannelErrorMsg(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdate) SetNotNilChannelNotifyData(value *string) *PayRefundUpdate { + if value != nil { + return _m.SetChannelNotifyData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundUpdateOne) SetNotNilChannelNotifyData(value *string) *PayRefundUpdateOne { + if value != nil { + return _m.SetChannelNotifyData(*value) + } + return _m +} + +// set field if value's pointer is not nil. +func (_m *PayRefundCreate) SetNotNilChannelNotifyData(value *string) *PayRefundCreate { + if value != nil { + return _m.SetChannelNotifyData(*value) + } + return _m +} diff --git a/rpc/ent/tx.go b/rpc/ent/tx.go new file mode 100644 index 0000000..649081b --- /dev/null +++ b/rpc/ent/tx.go @@ -0,0 +1,254 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + stdsql "database/sql" + "fmt" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // App is the client for interacting with the App builders. + App *AppClient + // PayChannel is the client for interacting with the PayChannel builders. + PayChannel *PayChannelClient + // PayNotifyLog is the client for interacting with the PayNotifyLog builders. + PayNotifyLog *PayNotifyLogClient + // PayNotifyTask is the client for interacting with the PayNotifyTask builders. + PayNotifyTask *PayNotifyTaskClient + // PayOrder is the client for interacting with the PayOrder builders. + PayOrder *PayOrderClient + // PayOrderExtension is the client for interacting with the PayOrderExtension builders. + PayOrderExtension *PayOrderExtensionClient + // PayRefund is the client for interacting with the PayRefund builders. + PayRefund *PayRefundClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.App = NewAppClient(tx.config) + tx.PayChannel = NewPayChannelClient(tx.config) + tx.PayNotifyLog = NewPayNotifyLogClient(tx.config) + tx.PayNotifyTask = NewPayNotifyTaskClient(tx.config) + tx.PayOrder = NewPayOrderClient(tx.config) + tx.PayOrderExtension = NewPayOrderExtensionClient(tx.config) + tx.PayRefund = NewPayRefundClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: App.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) + +// ExecContext allows calling the underlying ExecContext method of the transaction if it is supported by it. +// See, database/sql#Tx.ExecContext for more information. +func (tx *txDriver) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) { + ex, ok := tx.tx.(interface { + ExecContext(context.Context, string, ...any) (stdsql.Result, error) + }) + if !ok { + return nil, fmt.Errorf("Tx.ExecContext is not supported") + } + return ex.ExecContext(ctx, query, args...) +} + +// QueryContext allows calling the underlying QueryContext method of the transaction if it is supported by it. +// See, database/sql#Tx.QueryContext for more information. +func (tx *txDriver) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) { + q, ok := tx.tx.(interface { + QueryContext(context.Context, string, ...any) (*stdsql.Rows, error) + }) + if !ok { + return nil, fmt.Errorf("Tx.QueryContext is not supported") + } + return q.QueryContext(ctx, query, args...) +} diff --git a/rpc/go.mod b/rpc/go.mod index ad99926..3e8dd1f 100644 --- a/rpc/go.mod +++ b/rpc/go.mod @@ -3,42 +3,62 @@ module mingyang-admin-pay/rpc go 1.25.3 require ( + entgo.io/ent v0.14.5 + github.com/saas-mingyang/mingyang-admin-common v0.3.3 github.com/zeromicro/go-zero v1.9.1 google.golang.org/grpc v1.76.0 google.golang.org/protobuf v1.36.10 ) +require github.com/redis/go-redis/v9 v9.16.0 // indirect + require ( - entgo.io/ent v0.14.5 // indirect + ariga.io/atlas v0.38.0 // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/coreos/go-semver v0.3.1 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/coreos/go-systemd/v22 v22.6.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/fatih/color v1.18.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.4 // indirect + github.com/go-openapi/inflect v0.21.3 // indirect; indirectf + github.com/go-openapi/jsonpointer v0.22.1 // indirect + github.com/go-openapi/jsonreference v0.21.2 // indirect + github.com/go-openapi/swag v0.25.1 // indirect + github.com/go-openapi/swag/cmdutils v0.25.1 // indirect + github.com/go-openapi/swag/conv v0.25.1 // indirect + github.com/go-openapi/swag/fileutils v0.25.1 // indirect + github.com/go-openapi/swag/jsonname v0.25.1 // indirect + github.com/go-openapi/swag/jsonutils v0.25.1 // indirect + github.com/go-openapi/swag/loading v0.25.1 // indirect + github.com/go-openapi/swag/mangling v0.25.1 // indirect + github.com/go-openapi/swag/netutils v0.25.1 // indirect + github.com/go-openapi/swag/stringutils v0.25.1 // indirect + github.com/go-openapi/swag/typeutils v0.25.1 // indirect + github.com/go-openapi/swag/yamlutils v0.25.1 // indirect + github.com/gofrs/uuid/v5 v5.4.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grafana/pyroscope-go v1.2.7 // indirect github.com/grafana/pyroscope-go/godeltaprof v0.1.9 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect - github.com/josharian/intern v1.0.0 // indirect + github.com/hashicorp/hcl/v2 v2.24.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.18.1 // indirect - github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -49,14 +69,16 @@ require ( github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.67.2 // indirect github.com/prometheus/procfs v0.19.2 // indirect - github.com/redis/go-redis/v9 v9.16.0 // indirect + github.com/saas-mingyang/mingyang-admin-core v0.0.0-20251107040124-c97a0a448793 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - go.etcd.io/etcd/api/v3 v3.5.15 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect - go.etcd.io/etcd/client/v3 v3.5.15 // indirect + github.com/x448/float16 v0.8.4 // indirect + github.com/zclconf/go-cty v1.17.0 // indirect + github.com/zclconf/go-cty-yaml v1.1.0 // indirect + go.etcd.io/etcd/api/v3 v3.6.5 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.6.5 // indirect + go.etcd.io/etcd/client/v3 v3.6.5 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/otel v1.38.0 // indirect - go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect @@ -65,32 +87,40 @@ require ( go.opentelemetry.io/otel/metric v1.38.0 // indirect go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect - go.opentelemetry.io/proto/otlp v1.8.0 // indirect - go.uber.org/atomic v1.11.0 // indirect + go.opentelemetry.io/proto/otlp v1.9.0 // indirect go.uber.org/automaxprocs v1.6.0 // indirect - go.uber.org/mock v0.4.0 // indirect - go.uber.org/multierr v1.9.0 // indirect - go.uber.org/zap v1.24.0 // indirect + go.uber.org/mock v0.6.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect - golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/net v0.47.0 // indirect golang.org/x/oauth2 v0.32.0 // indirect - golang.org/x/sys v0.37.0 // indirect - golang.org/x/term v0.36.0 // indirect - golang.org/x/text v0.30.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect + golang.org/x/text v0.31.0 // indirect golang.org/x/time v0.14.0 // indirect - golang.org/x/tools v0.38.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251103181224-f26f9409b101 // indirect + golang.org/x/tools v0.39.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba // indirect + gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.29.3 // indirect - k8s.io/apimachinery v0.29.4 // indirect - k8s.io/client-go v0.29.3 // indirect - k8s.io/klog/v2 v2.110.1 // indirect - k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect - k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + k8s.io/api v0.34.1 // indirect + k8s.io/apimachinery v0.34.1 // indirect + k8s.io/client-go v0.34.1 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect + k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) + +replace github.com/zeromicro/go-zero v1.9.1 => github.com/suyuan32/simple-admin-tools v1.9.1 + +replace mingyang-admin-simple-admin-message v0.0.1 => ../../simple-admin-message-center-tenant diff --git a/rpc/go.sum b/rpc/go.sum index a222fa2..c76551b 100644 --- a/rpc/go.sum +++ b/rpc/go.sum @@ -1,15 +1,15 @@ -ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNGMytJN8afmIWXJVMi4cc= -ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= +ariga.io/atlas v0.38.0 h1:MwbtwVtDWJFq+ECyeTAz2ArvewDnpeiw/t/sgNdDsdo= +ariga.io/atlas v0.38.0/go.mod h1:D7XMK6ei3GvfDqvzk+2VId78j77LdqHrqPOWamn51/s= entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U= +github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU= +github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI= github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= @@ -22,53 +22,79 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY= +github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= -github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/coreos/go-systemd/v22 v22.6.0 h1:aGVa/v8B7hpb0TKl0MWoAavPDmHvobFe5R5zn0bCJWo= +github.com/coreos/go-systemd/v22 v22.6.0/go.mod h1:iG+pp635Fo7ZmV/j14KUcmEyWF+0X7Lua8rrTWzYgWU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= -github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= +github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= -github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= -github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/inflect v0.21.3 h1:TmQvw+9eLrsNp4X0BBQacEZZtAnzk2z1FaLdQQJsDiU= +github.com/go-openapi/inflect v0.21.3/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= +github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk= +github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM= +github.com/go-openapi/jsonreference v0.21.2 h1:Wxjda4M/BBQllegefXrY/9aq1fxBA8sI5M/lFU6tSWU= +github.com/go-openapi/jsonreference v0.21.2/go.mod h1:pp3PEjIsJ9CZDGCNOyXIQxsNuroxm8FAJ/+quA0yKzQ= +github.com/go-openapi/swag v0.25.1 h1:6uwVsx+/OuvFVPqfQmOOPsqTcm5/GkBhNwLqIR916n8= +github.com/go-openapi/swag v0.25.1/go.mod h1:bzONdGlT0fkStgGPd3bhZf1MnuPkf2YAys6h+jZipOo= +github.com/go-openapi/swag/cmdutils v0.25.1 h1:nDke3nAFDArAa631aitksFGj2omusks88GF1VwdYqPY= +github.com/go-openapi/swag/cmdutils v0.25.1/go.mod h1:pdae/AFo6WxLl5L0rq87eRzVPm/XRHM3MoYgRMvG4A0= +github.com/go-openapi/swag/conv v0.25.1 h1:+9o8YUg6QuqqBM5X6rYL/p1dpWeZRhoIt9x7CCP+he0= +github.com/go-openapi/swag/conv v0.25.1/go.mod h1:Z1mFEGPfyIKPu0806khI3zF+/EUXde+fdeksUl2NiDs= +github.com/go-openapi/swag/fileutils v0.25.1 h1:rSRXapjQequt7kqalKXdcpIegIShhTPXx7yw0kek2uU= +github.com/go-openapi/swag/fileutils v0.25.1/go.mod h1:+NXtt5xNZZqmpIpjqcujqojGFek9/w55b3ecmOdtg8M= +github.com/go-openapi/swag/jsonname v0.25.1 h1:Sgx+qbwa4ej6AomWC6pEfXrA6uP2RkaNjA9BR8a1RJU= +github.com/go-openapi/swag/jsonname v0.25.1/go.mod h1:71Tekow6UOLBD3wS7XhdT98g5J5GR13NOTQ9/6Q11Zo= +github.com/go-openapi/swag/jsonutils v0.25.1 h1:AihLHaD0brrkJoMqEZOBNzTLnk81Kg9cWr+SPtxtgl8= +github.com/go-openapi/swag/jsonutils v0.25.1/go.mod h1:JpEkAjxQXpiaHmRO04N1zE4qbUEg3b7Udll7AMGTNOo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.1 h1:DSQGcdB6G0N9c/KhtpYc71PzzGEIc/fZ1no35x4/XBY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.1/go.mod h1:kjmweouyPwRUEYMSrbAidoLMGeJ5p6zdHi9BgZiqmsg= +github.com/go-openapi/swag/loading v0.25.1 h1:6OruqzjWoJyanZOim58iG2vj934TysYVptyaoXS24kw= +github.com/go-openapi/swag/loading v0.25.1/go.mod h1:xoIe2EG32NOYYbqxvXgPzne989bWvSNoWoyQVWEZicc= +github.com/go-openapi/swag/mangling v0.25.1 h1:XzILnLzhZPZNtmxKaz/2xIGPQsBsvmCjrJOWGNz/ync= +github.com/go-openapi/swag/mangling v0.25.1/go.mod h1:CdiMQ6pnfAgyQGSOIYnZkXvqhnnwOn997uXZMAd/7mQ= +github.com/go-openapi/swag/netutils v0.25.1 h1:2wFLYahe40tDUHfKT1GRC4rfa5T1B4GWZ+msEFA4Fl4= +github.com/go-openapi/swag/netutils v0.25.1/go.mod h1:CAkkvqnUJX8NV96tNhEQvKz8SQo2KF0f7LleiJwIeRE= +github.com/go-openapi/swag/stringutils v0.25.1 h1:Xasqgjvk30eUe8VKdmyzKtjkVjeiXx1Iz0zDfMNpPbw= +github.com/go-openapi/swag/stringutils v0.25.1/go.mod h1:JLdSAq5169HaiDUbTvArA2yQxmgn4D6h4A+4HqVvAYg= +github.com/go-openapi/swag/typeutils v0.25.1 h1:rD/9HsEQieewNt6/k+JBwkxuAHktFtH3I3ysiFZqukA= +github.com/go-openapi/swag/typeutils v0.25.1/go.mod h1:9McMC/oCdS4BKwk2shEB7x17P6HmMmA6dQRtAkSnNb8= +github.com/go-openapi/swag/yamlutils v0.25.1 h1:mry5ez8joJwzvMbaTGLhw8pXUnhDK91oSJLDPF1bmGk= +github.com/go-openapi/swag/yamlutils v0.25.1/go.mod h1:cm9ywbzncy3y6uPm/97ysW8+wZ09qsks+9RS8fLWKqg= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0= +github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grafana/pyroscope-go v1.2.7 h1:VWBBlqxjyR0Cwk2W6UrE8CdcdD80GOFNutj0Kb1T8ac= @@ -79,35 +105,30 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLW github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= -github.com/hashicorp/hcl/v2 v2.18.1 h1:6nxnOJFku1EuSawSD81fuviYUV8DxFr3fp2dUi3ZYSo= -github.com/hashicorp/hcl/v2 v2.18.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= +github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE= +github.com/hashicorp/hcl/v2 v2.24.0/go.mod h1:oGoO1FIQYfn/AgyOhlg9qLC6/nOJPX3qGbkZpYAcqfM= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= +github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= +github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -120,16 +141,14 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= -github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= +github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= +github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= +github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7sjsSdg= github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -145,49 +164,48 @@ github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4 github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw= github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4= github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/saas-mingyang/mingyang-admin-common v0.3.3 h1:Pe1IYBaE7v541WKnEFPwiOC9yMzhmvVQ4+rSfRdEC1M= +github.com/saas-mingyang/mingyang-admin-common v0.3.3/go.mod h1:mAweT+3C08LGdr14AQNz9Sx5COPEpTtL6dr5fQAKqWc= +github.com/saas-mingyang/mingyang-admin-core v0.0.0-20251107040124-c97a0a448793 h1:wSJjRdeAIX++S1lDSInYlIPg6OyPKCakHBJTNG683RI= +github.com/saas-mingyang/mingyang-admin-core v0.0.0-20251107040124-c97a0a448793/go.mod h1:wMcbdgNDZ+ZNB4inJb68MD2vAJ2iintwm3EYQn4F7Sc= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/suyuan32/simple-admin-tools v1.9.1 h1:RRFT2Dn22H/b0A4aB+ixul/6xzmTFXG10ER64DuCS0A= +github.com/suyuan32/simple-admin-tools v1.9.1/go.mod h1:v3y8WAJTCt+g/+Ve0BZuSga38gwdDh/2WNuvve9Tz2Y= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.17.0 h1:seZvECve6XX4tmnvRzWtJNHdscMtYEx5R7bnnVyd/d0= +github.com/zclconf/go-cty v1.17.0/go.mod h1:wqFzcImaLTI6A5HfsRwB0nj5n0MRZFwmey8YoFPPs3U= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0= github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= -github.com/zeromicro/go-zero v1.9.1 h1:GZCl4jun/ZgZHnSvX3SSNDHf+tEGmEQ8x2Z23xjHa9g= -github.com/zeromicro/go-zero v1.9.1/go.mod h1:bHOl7Xr7EV/iHZWEqsUNJwFc/9WgAMrPpPagYvOaMtY= -go.etcd.io/etcd/api/v3 v3.5.15 h1:3KpLJir1ZEBrYuV2v+Twaa/e2MdDCEZ/70H+lzEiwsk= -go.etcd.io/etcd/api/v3 v3.5.15/go.mod h1:N9EhGzXq58WuMllgH9ZvnEr7SI9pS0k0+DHZezGp7jM= -go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5fWlA= -go.etcd.io/etcd/client/pkg/v3 v3.5.15/go.mod h1:mXDI4NAOwEiszrHCb0aqfAYNCrZP4e9hRca3d1YK8EU= -go.etcd.io/etcd/client/v3 v3.5.15 h1:23M0eY4Fd/inNv1ZfU3AxrbbOdW79r9V9Rl62Nm6ip4= -go.etcd.io/etcd/client/v3 v3.5.15/go.mod h1:CLSJxrYjvLtHsrPKsy7LmZEE+DK2ktfd2bN4RhBMwlU= +go.etcd.io/etcd/api/v3 v3.6.5 h1:pMMc42276sgR1j1raO/Qv3QI9Af/AuyQUW6CBAWuntA= +go.etcd.io/etcd/api/v3 v3.6.5/go.mod h1:ob0/oWA/UQQlT1BmaEkWQzI0sJ1M0Et0mMpaABxguOQ= +go.etcd.io/etcd/client/pkg/v3 v3.6.5 h1:Duz9fAzIZFhYWgRjp/FgNq2gO1jId9Yae/rLn3RrBP8= +go.etcd.io/etcd/client/pkg/v3 v3.6.5/go.mod h1:8Wx3eGRPiy0qOFMZT/hfvdos+DjEaPxdIDiCDUv/FQk= +go.etcd.io/etcd/client/v3 v3.6.5 h1:yRwZNFBx/35VKHTcLDeO7XVLbCBFbPi+XV4OC3QJf2U= +go.etcd.io/etcd/client/v3 v3.6.5/go.mod h1:ZqwG/7TAFZ0BJ0jXRPoJjKQJtbFo/9NIY8uoFFKcCyo= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= -go.opentelemetry.io/otel/exporters/jaeger v1.17.0 h1:D7UpUy2Xc2wsi1Ras6V40q806WM07rqoCWzXu7Sqy+4= -go.opentelemetry.io/otel/exporters/jaeger v1.17.0/go.mod h1:nPCqOnEH9rNLKqH/+rrUjiMzHJdV1BlpKcTwRTyKkKI= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.38.0 h1:lwI4Dc5leUqENgGuQImwLo4WnuXFPetmPpkLi2IrX54= @@ -206,72 +224,72 @@ go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6 go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= -go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE= -go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A= +go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4= go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= -golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82 h1:6/3JGEh1C88g7m+qzzTbl3A0FtsLguXieqofVLU/JAo= -golang.org/x/net v0.46.1-0.20251013234738-63d1a5100f82/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/oauth2 v0.32.0 h1:jsCblLleRMDrxMN29H3z/k1KliIvpLgCkE6R8FXXNgY= golang.org/x/oauth2 v0.32.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= -golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= -golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= -golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= -golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= -google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda h1:+2XxjfsAu6vqFxwGBRcHiMaDCuZiqXGDUDVWVtrFAnE= -google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251103181224-f26f9409b101 h1:tRPGkdGHuewF4UisLzzHHr1spKw92qLM98nIzxbC0wY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251103181224-f26f9409b101/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba h1:B14OtaXuMaCQsl2deSvNkyPKIzq3BjfxQp8d00QyWx4= +google.golang.org/genproto/googleapis/api v0.0.0-20251111163417-95abcf5c77ba/go.mod h1:G5IanEx8/PgI9w6CFcYQf7jMtHQhZruvfM1i3qOqk5U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba h1:UKgtfRM7Yh93Sya0Fo8ZzhDP4qBckrrxEr2oF5UIVb8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251111163417-95abcf5c77ba/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A= google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= @@ -279,31 +297,33 @@ google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= +gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw= -k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80= -k8s.io/apimachinery v0.29.4 h1:RaFdJiDmuKs/8cm1M6Dh1Kvyh59YQFDcFuFTSmXes6Q= -k8s.io/apimachinery v0.29.4/go.mod h1:i3FJVwhvSp/6n8Fl4K97PJEP8C+MM+aoDq4+ZJBf70Y= -k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg= -k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0= -k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= -k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= -k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= -k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= -k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= -k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= -sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM= +k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk= +k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4= +k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY= +k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE= +k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ= +k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck= +k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=