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

10631 lines
318 KiB
Go

// 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)
}