775 lines
25 KiB
Go
775 lines
25 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"mingyang-admin-pay/rpc/ent/paychannel"
|
|
"mingyang-admin-pay/rpc/ent/payorder"
|
|
"mingyang-admin-pay/rpc/ent/payorderextension"
|
|
"mingyang-admin-pay/rpc/ent/predicate"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// PayOrderExtensionUpdate is the builder for updating PayOrderExtension entities.
|
|
type PayOrderExtensionUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *PayOrderExtensionMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the PayOrderExtensionUpdate builder.
|
|
func (_u *PayOrderExtensionUpdate) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *PayOrderExtensionUpdate) SetUpdatedAt(v time.Time) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *PayOrderExtensionUpdate) SetStatus(v uint8) *PayOrderExtensionUpdate {
|
|
_u.mutation.ResetStatus()
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableStatus(v *uint8) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddStatus adds value to the "status" field.
|
|
func (_u *PayOrderExtensionUpdate) AddStatus(v int8) *PayOrderExtensionUpdate {
|
|
_u.mutation.AddStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearStatus clears the value of the "status" field.
|
|
func (_u *PayOrderExtensionUpdate) ClearStatus() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearStatus()
|
|
return _u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *PayOrderExtensionUpdate) SetDeletedAt(v time.Time) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableDeletedAt(v *time.Time) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *PayOrderExtensionUpdate) ClearDeletedAt() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetOrderID sets the "order_id" field.
|
|
func (_u *PayOrderExtensionUpdate) SetOrderID(v uint64) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetOrderID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderID sets the "order_id" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableOrderID(v *uint64) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetOrderID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetChannelID sets the "channel_id" field.
|
|
func (_u *PayOrderExtensionUpdate) SetChannelID(v uint64) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetChannelID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelID sets the "channel_id" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableChannelID(v *uint64) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetChannelID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetChannelExtras sets the "channel_extras" field.
|
|
func (_u *PayOrderExtensionUpdate) SetChannelExtras(v map[string]interface{}) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetChannelExtras(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelExtras clears the value of the "channel_extras" field.
|
|
func (_u *PayOrderExtensionUpdate) ClearChannelExtras() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearChannelExtras()
|
|
return _u
|
|
}
|
|
|
|
// SetChannelErrorCode sets the "channel_error_code" field.
|
|
func (_u *PayOrderExtensionUpdate) SetChannelErrorCode(v string) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetChannelErrorCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableChannelErrorCode(v *string) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetChannelErrorCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelErrorCode clears the value of the "channel_error_code" field.
|
|
func (_u *PayOrderExtensionUpdate) ClearChannelErrorCode() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearChannelErrorCode()
|
|
return _u
|
|
}
|
|
|
|
// SetChannelErrorMsg sets the "channel_error_msg" field.
|
|
func (_u *PayOrderExtensionUpdate) SetChannelErrorMsg(v string) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetChannelErrorMsg(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableChannelErrorMsg(v *string) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetChannelErrorMsg(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelErrorMsg clears the value of the "channel_error_msg" field.
|
|
func (_u *PayOrderExtensionUpdate) ClearChannelErrorMsg() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearChannelErrorMsg()
|
|
return _u
|
|
}
|
|
|
|
// SetChannelNotifyData sets the "channel_notify_data" field.
|
|
func (_u *PayOrderExtensionUpdate) SetChannelNotifyData(v string) *PayOrderExtensionUpdate {
|
|
_u.mutation.SetChannelNotifyData(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdate) SetNillableChannelNotifyData(v *string) *PayOrderExtensionUpdate {
|
|
if v != nil {
|
|
_u.SetChannelNotifyData(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelNotifyData clears the value of the "channel_notify_data" field.
|
|
func (_u *PayOrderExtensionUpdate) ClearChannelNotifyData() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearChannelNotifyData()
|
|
return _u
|
|
}
|
|
|
|
// SetChannel sets the "channel" edge to the PayChannel entity.
|
|
func (_u *PayOrderExtensionUpdate) SetChannel(v *PayChannel) *PayOrderExtensionUpdate {
|
|
return _u.SetChannelID(v.ID)
|
|
}
|
|
|
|
// SetOrder sets the "order" edge to the PayOrder entity.
|
|
func (_u *PayOrderExtensionUpdate) SetOrder(v *PayOrder) *PayOrderExtensionUpdate {
|
|
return _u.SetOrderID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the PayOrderExtensionMutation object of the builder.
|
|
func (_u *PayOrderExtensionUpdate) Mutation() *PayOrderExtensionMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearChannel clears the "channel" edge to the PayChannel entity.
|
|
func (_u *PayOrderExtensionUpdate) ClearChannel() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearChannel()
|
|
return _u
|
|
}
|
|
|
|
// ClearOrder clears the "order" edge to the PayOrder entity.
|
|
func (_u *PayOrderExtensionUpdate) ClearOrder() *PayOrderExtensionUpdate {
|
|
_u.mutation.ClearOrder()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *PayOrderExtensionUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *PayOrderExtensionUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *PayOrderExtensionUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *PayOrderExtensionUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *PayOrderExtensionUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := payorderextension.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *PayOrderExtensionUpdate) check() error {
|
|
if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "PayOrderExtension.channel"`)
|
|
}
|
|
if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "PayOrderExtension.order"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *PayOrderExtensionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(payorderextension.Table, payorderextension.Columns, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(payorderextension.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(payorderextension.FieldStatus, field.TypeUint8, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedStatus(); ok {
|
|
_spec.AddField(payorderextension.FieldStatus, field.TypeUint8, value)
|
|
}
|
|
if _u.mutation.StatusCleared() {
|
|
_spec.ClearField(payorderextension.FieldStatus, field.TypeUint8)
|
|
}
|
|
if value, ok := _u.mutation.DeletedAt(); ok {
|
|
_spec.SetField(payorderextension.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(payorderextension.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.ChannelExtras(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelExtras, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.ChannelExtrasCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelExtras, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.ChannelErrorCode(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelErrorCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ChannelErrorCodeCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelErrorCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ChannelErrorMsg(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelErrorMsg, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ChannelErrorMsgCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelErrorMsg, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ChannelNotifyData(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelNotifyData, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ChannelNotifyDataCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelNotifyData, field.TypeString)
|
|
}
|
|
if _u.mutation.ChannelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.ChannelTable,
|
|
Columns: []string{payorderextension.ChannelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.ChannelTable,
|
|
Columns: []string{payorderextension.ChannelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.OrderCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.OrderTable,
|
|
Columns: []string{payorderextension.OrderColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.OrderTable,
|
|
Columns: []string{payorderextension.OrderColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{payorderextension.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// PayOrderExtensionUpdateOne is the builder for updating a single PayOrderExtension entity.
|
|
type PayOrderExtensionUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *PayOrderExtensionMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetUpdatedAt(v time.Time) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetStatus(v uint8) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ResetStatus()
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableStatus(v *uint8) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddStatus adds value to the "status" field.
|
|
func (_u *PayOrderExtensionUpdateOne) AddStatus(v int8) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.AddStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearStatus clears the value of the "status" field.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearStatus() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearStatus()
|
|
return _u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetDeletedAt(v time.Time) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetDeletedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableDeletedAt(v *time.Time) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeletedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearDeletedAt() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearDeletedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetOrderID sets the "order_id" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetOrderID(v uint64) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetOrderID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableOrderID sets the "order_id" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableOrderID(v *uint64) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetOrderID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetChannelID sets the "channel_id" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetChannelID(v uint64) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetChannelID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelID sets the "channel_id" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableChannelID(v *uint64) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetChannelID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetChannelExtras sets the "channel_extras" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetChannelExtras(v map[string]interface{}) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetChannelExtras(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelExtras clears the value of the "channel_extras" field.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearChannelExtras() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearChannelExtras()
|
|
return _u
|
|
}
|
|
|
|
// SetChannelErrorCode sets the "channel_error_code" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetChannelErrorCode(v string) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetChannelErrorCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableChannelErrorCode(v *string) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetChannelErrorCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelErrorCode clears the value of the "channel_error_code" field.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearChannelErrorCode() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearChannelErrorCode()
|
|
return _u
|
|
}
|
|
|
|
// SetChannelErrorMsg sets the "channel_error_msg" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetChannelErrorMsg(v string) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetChannelErrorMsg(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableChannelErrorMsg(v *string) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetChannelErrorMsg(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelErrorMsg clears the value of the "channel_error_msg" field.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearChannelErrorMsg() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearChannelErrorMsg()
|
|
return _u
|
|
}
|
|
|
|
// SetChannelNotifyData sets the "channel_notify_data" field.
|
|
func (_u *PayOrderExtensionUpdateOne) SetChannelNotifyData(v string) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.SetChannelNotifyData(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil.
|
|
func (_u *PayOrderExtensionUpdateOne) SetNillableChannelNotifyData(v *string) *PayOrderExtensionUpdateOne {
|
|
if v != nil {
|
|
_u.SetChannelNotifyData(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearChannelNotifyData clears the value of the "channel_notify_data" field.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearChannelNotifyData() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearChannelNotifyData()
|
|
return _u
|
|
}
|
|
|
|
// SetChannel sets the "channel" edge to the PayChannel entity.
|
|
func (_u *PayOrderExtensionUpdateOne) SetChannel(v *PayChannel) *PayOrderExtensionUpdateOne {
|
|
return _u.SetChannelID(v.ID)
|
|
}
|
|
|
|
// SetOrder sets the "order" edge to the PayOrder entity.
|
|
func (_u *PayOrderExtensionUpdateOne) SetOrder(v *PayOrder) *PayOrderExtensionUpdateOne {
|
|
return _u.SetOrderID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the PayOrderExtensionMutation object of the builder.
|
|
func (_u *PayOrderExtensionUpdateOne) Mutation() *PayOrderExtensionMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearChannel clears the "channel" edge to the PayChannel entity.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearChannel() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearChannel()
|
|
return _u
|
|
}
|
|
|
|
// ClearOrder clears the "order" edge to the PayOrder entity.
|
|
func (_u *PayOrderExtensionUpdateOne) ClearOrder() *PayOrderExtensionUpdateOne {
|
|
_u.mutation.ClearOrder()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the PayOrderExtensionUpdate builder.
|
|
func (_u *PayOrderExtensionUpdateOne) Where(ps ...predicate.PayOrderExtension) *PayOrderExtensionUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *PayOrderExtensionUpdateOne) Select(field string, fields ...string) *PayOrderExtensionUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated PayOrderExtension entity.
|
|
func (_u *PayOrderExtensionUpdateOne) Save(ctx context.Context) (*PayOrderExtension, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *PayOrderExtensionUpdateOne) SaveX(ctx context.Context) *PayOrderExtension {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *PayOrderExtensionUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *PayOrderExtensionUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *PayOrderExtensionUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := payorderextension.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *PayOrderExtensionUpdateOne) check() error {
|
|
if _u.mutation.ChannelCleared() && len(_u.mutation.ChannelIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "PayOrderExtension.channel"`)
|
|
}
|
|
if _u.mutation.OrderCleared() && len(_u.mutation.OrderIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "PayOrderExtension.order"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *PayOrderExtensionUpdateOne) sqlSave(ctx context.Context) (_node *PayOrderExtension, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(payorderextension.Table, payorderextension.Columns, sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PayOrderExtension.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, payorderextension.FieldID)
|
|
for _, f := range fields {
|
|
if !payorderextension.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != payorderextension.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(payorderextension.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(payorderextension.FieldStatus, field.TypeUint8, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedStatus(); ok {
|
|
_spec.AddField(payorderextension.FieldStatus, field.TypeUint8, value)
|
|
}
|
|
if _u.mutation.StatusCleared() {
|
|
_spec.ClearField(payorderextension.FieldStatus, field.TypeUint8)
|
|
}
|
|
if value, ok := _u.mutation.DeletedAt(); ok {
|
|
_spec.SetField(payorderextension.FieldDeletedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.DeletedAtCleared() {
|
|
_spec.ClearField(payorderextension.FieldDeletedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.ChannelExtras(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelExtras, field.TypeJSON, value)
|
|
}
|
|
if _u.mutation.ChannelExtrasCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelExtras, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.ChannelErrorCode(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelErrorCode, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ChannelErrorCodeCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelErrorCode, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ChannelErrorMsg(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelErrorMsg, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ChannelErrorMsgCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelErrorMsg, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ChannelNotifyData(); ok {
|
|
_spec.SetField(payorderextension.FieldChannelNotifyData, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ChannelNotifyDataCleared() {
|
|
_spec.ClearField(payorderextension.FieldChannelNotifyData, field.TypeString)
|
|
}
|
|
if _u.mutation.ChannelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.ChannelTable,
|
|
Columns: []string{payorderextension.ChannelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.ChannelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.ChannelTable,
|
|
Columns: []string{payorderextension.ChannelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.OrderCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.OrderTable,
|
|
Columns: []string{payorderextension.OrderColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.OrderIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payorderextension.OrderTable,
|
|
Columns: []string{payorderextension.OrderColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &PayOrderExtension{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{payorderextension.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|