605 lines
18 KiB
Go
605 lines
18 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/payrefund"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// PayRefundCreate is the builder for creating a PayRefund entity.
|
|
type PayRefundCreate struct {
|
|
config
|
|
mutation *PayRefundMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *PayRefundCreate) SetCreatedAt(v time.Time) *PayRefundCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableCreatedAt(v *time.Time) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *PayRefundCreate) SetUpdatedAt(v time.Time) *PayRefundCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableUpdatedAt(v *time.Time) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *PayRefundCreate) SetStatus(v uint8) *PayRefundCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableStatus(v *uint8) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (_c *PayRefundCreate) SetTenantID(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetTenantID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableTenantID(v *uint64) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetTenantID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *PayRefundCreate) SetDeletedAt(v time.Time) *PayRefundCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableDeletedAt(v *time.Time) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetChannelID sets the "channel_id" field.
|
|
func (_c *PayRefundCreate) SetChannelID(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetChannelID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *PayRefundCreate) SetUserID(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetOrderID sets the "order_id" field.
|
|
func (_c *PayRefundCreate) SetOrderID(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetOrderID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNotifyURL sets the "notify_url" field.
|
|
func (_c *PayRefundCreate) SetNotifyURL(v string) *PayRefundCreate {
|
|
_c.mutation.SetNotifyURL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableNotifyURL sets the "notify_url" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableNotifyURL(v *string) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetNotifyURL(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRefundStatus sets the "refund_status" field.
|
|
func (_c *PayRefundCreate) SetRefundStatus(v uint8) *PayRefundCreate {
|
|
_c.mutation.SetRefundStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRefundStatus sets the "refund_status" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableRefundStatus(v *uint8) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetRefundStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRefundAmount sets the "refund_amount" field.
|
|
func (_c *PayRefundCreate) SetRefundAmount(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetRefundAmount(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRefundAmount sets the "refund_amount" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableRefundAmount(v *uint64) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetRefundAmount(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPayAmount sets the "pay_amount" field.
|
|
func (_c *PayRefundCreate) SetPayAmount(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetPayAmount(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePayAmount sets the "pay_amount" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillablePayAmount(v *uint64) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetPayAmount(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRefundNo sets the "refund_no" field.
|
|
func (_c *PayRefundCreate) SetRefundNo(v string) *PayRefundCreate {
|
|
_c.mutation.SetRefundNo(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRefundReason sets the "refund_reason" field.
|
|
func (_c *PayRefundCreate) SetRefundReason(v string) *PayRefundCreate {
|
|
_c.mutation.SetRefundReason(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUserIP sets the "user_ip" field.
|
|
func (_c *PayRefundCreate) SetUserIP(v string) *PayRefundCreate {
|
|
_c.mutation.SetUserIP(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUserIP sets the "user_ip" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableUserIP(v *string) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetUserIP(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetChannelRefundNo sets the "channel_refund_no" field.
|
|
func (_c *PayRefundCreate) SetChannelRefundNo(v string) *PayRefundCreate {
|
|
_c.mutation.SetChannelRefundNo(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRefundTime sets the "refund_time" field.
|
|
func (_c *PayRefundCreate) SetRefundTime(v time.Time) *PayRefundCreate {
|
|
_c.mutation.SetRefundTime(v)
|
|
return _c
|
|
}
|
|
|
|
// SetChannelErrorCode sets the "channel_error_code" field.
|
|
func (_c *PayRefundCreate) SetChannelErrorCode(v string) *PayRefundCreate {
|
|
_c.mutation.SetChannelErrorCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableChannelErrorCode sets the "channel_error_code" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableChannelErrorCode(v *string) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetChannelErrorCode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetChannelErrorMsg sets the "channel_error_msg" field.
|
|
func (_c *PayRefundCreate) SetChannelErrorMsg(v string) *PayRefundCreate {
|
|
_c.mutation.SetChannelErrorMsg(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableChannelErrorMsg sets the "channel_error_msg" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableChannelErrorMsg(v *string) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetChannelErrorMsg(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetChannelNotifyData sets the "channel_notify_data" field.
|
|
func (_c *PayRefundCreate) SetChannelNotifyData(v string) *PayRefundCreate {
|
|
_c.mutation.SetChannelNotifyData(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableChannelNotifyData sets the "channel_notify_data" field if the given value is not nil.
|
|
func (_c *PayRefundCreate) SetNillableChannelNotifyData(v *string) *PayRefundCreate {
|
|
if v != nil {
|
|
_c.SetChannelNotifyData(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *PayRefundCreate) SetID(v uint64) *PayRefundCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetOrder sets the "order" edge to the PayOrder entity.
|
|
func (_c *PayRefundCreate) SetOrder(v *PayOrder) *PayRefundCreate {
|
|
return _c.SetOrderID(v.ID)
|
|
}
|
|
|
|
// SetChannel sets the "channel" edge to the PayChannel entity.
|
|
func (_c *PayRefundCreate) SetChannel(v *PayChannel) *PayRefundCreate {
|
|
return _c.SetChannelID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the PayRefundMutation object of the builder.
|
|
func (_c *PayRefundCreate) Mutation() *PayRefundMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the PayRefund in the database.
|
|
func (_c *PayRefundCreate) Save(ctx context.Context) (*PayRefund, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *PayRefundCreate) SaveX(ctx context.Context) *PayRefund {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *PayRefundCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *PayRefundCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *PayRefundCreate) defaults() {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := payrefund.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := payrefund.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
v := payrefund.DefaultStatus
|
|
_c.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.TenantID(); !ok {
|
|
v := payrefund.DefaultTenantID
|
|
_c.mutation.SetTenantID(v)
|
|
}
|
|
if _, ok := _c.mutation.RefundStatus(); !ok {
|
|
v := payrefund.DefaultRefundStatus
|
|
_c.mutation.SetRefundStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.RefundAmount(); !ok {
|
|
v := payrefund.DefaultRefundAmount
|
|
_c.mutation.SetRefundAmount(v)
|
|
}
|
|
if _, ok := _c.mutation.PayAmount(); !ok {
|
|
v := payrefund.DefaultPayAmount
|
|
_c.mutation.SetPayAmount(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *PayRefundCreate) check() error {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayRefund.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayRefund.updated_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.TenantID(); !ok {
|
|
return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayRefund.tenant_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.ChannelID(); !ok {
|
|
return &ValidationError{Name: "channel_id", err: errors.New(`ent: missing required field "PayRefund.channel_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.UserID(); !ok {
|
|
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "PayRefund.user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.OrderID(); !ok {
|
|
return &ValidationError{Name: "order_id", err: errors.New(`ent: missing required field "PayRefund.order_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.RefundStatus(); !ok {
|
|
return &ValidationError{Name: "refund_status", err: errors.New(`ent: missing required field "PayRefund.refund_status"`)}
|
|
}
|
|
if _, ok := _c.mutation.RefundAmount(); !ok {
|
|
return &ValidationError{Name: "refund_amount", err: errors.New(`ent: missing required field "PayRefund.refund_amount"`)}
|
|
}
|
|
if _, ok := _c.mutation.PayAmount(); !ok {
|
|
return &ValidationError{Name: "pay_amount", err: errors.New(`ent: missing required field "PayRefund.pay_amount"`)}
|
|
}
|
|
if _, ok := _c.mutation.RefundNo(); !ok {
|
|
return &ValidationError{Name: "refund_no", err: errors.New(`ent: missing required field "PayRefund.refund_no"`)}
|
|
}
|
|
if _, ok := _c.mutation.RefundReason(); !ok {
|
|
return &ValidationError{Name: "refund_reason", err: errors.New(`ent: missing required field "PayRefund.refund_reason"`)}
|
|
}
|
|
if _, ok := _c.mutation.ChannelRefundNo(); !ok {
|
|
return &ValidationError{Name: "channel_refund_no", err: errors.New(`ent: missing required field "PayRefund.channel_refund_no"`)}
|
|
}
|
|
if _, ok := _c.mutation.RefundTime(); !ok {
|
|
return &ValidationError{Name: "refund_time", err: errors.New(`ent: missing required field "PayRefund.refund_time"`)}
|
|
}
|
|
if len(_c.mutation.OrderIDs()) == 0 {
|
|
return &ValidationError{Name: "order", err: errors.New(`ent: missing required edge "PayRefund.order"`)}
|
|
}
|
|
if len(_c.mutation.ChannelIDs()) == 0 {
|
|
return &ValidationError{Name: "channel", err: errors.New(`ent: missing required edge "PayRefund.channel"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *PayRefundCreate) sqlSave(ctx context.Context) (*PayRefund, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != _node.ID {
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = uint64(id)
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *PayRefundCreate) createSpec() (*PayRefund, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &PayRefund{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(payrefund.Table, sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64))
|
|
)
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = id
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(payrefund.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(payrefund.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(payrefund.FieldStatus, field.TypeUint8, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.TenantID(); ok {
|
|
_spec.SetField(payrefund.FieldTenantID, field.TypeUint64, value)
|
|
_node.TenantID = value
|
|
}
|
|
if value, ok := _c.mutation.DeletedAt(); ok {
|
|
_spec.SetField(payrefund.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UserID(); ok {
|
|
_spec.SetField(payrefund.FieldUserID, field.TypeUint64, value)
|
|
_node.UserID = value
|
|
}
|
|
if value, ok := _c.mutation.NotifyURL(); ok {
|
|
_spec.SetField(payrefund.FieldNotifyURL, field.TypeString, value)
|
|
_node.NotifyURL = value
|
|
}
|
|
if value, ok := _c.mutation.RefundStatus(); ok {
|
|
_spec.SetField(payrefund.FieldRefundStatus, field.TypeUint8, value)
|
|
_node.RefundStatus = value
|
|
}
|
|
if value, ok := _c.mutation.RefundAmount(); ok {
|
|
_spec.SetField(payrefund.FieldRefundAmount, field.TypeUint64, value)
|
|
_node.RefundAmount = value
|
|
}
|
|
if value, ok := _c.mutation.PayAmount(); ok {
|
|
_spec.SetField(payrefund.FieldPayAmount, field.TypeUint64, value)
|
|
_node.PayAmount = value
|
|
}
|
|
if value, ok := _c.mutation.RefundNo(); ok {
|
|
_spec.SetField(payrefund.FieldRefundNo, field.TypeString, value)
|
|
_node.RefundNo = value
|
|
}
|
|
if value, ok := _c.mutation.RefundReason(); ok {
|
|
_spec.SetField(payrefund.FieldRefundReason, field.TypeString, value)
|
|
_node.RefundReason = value
|
|
}
|
|
if value, ok := _c.mutation.UserIP(); ok {
|
|
_spec.SetField(payrefund.FieldUserIP, field.TypeString, value)
|
|
_node.UserIP = value
|
|
}
|
|
if value, ok := _c.mutation.ChannelRefundNo(); ok {
|
|
_spec.SetField(payrefund.FieldChannelRefundNo, field.TypeString, value)
|
|
_node.ChannelRefundNo = value
|
|
}
|
|
if value, ok := _c.mutation.RefundTime(); ok {
|
|
_spec.SetField(payrefund.FieldRefundTime, field.TypeTime, value)
|
|
_node.RefundTime = value
|
|
}
|
|
if value, ok := _c.mutation.ChannelErrorCode(); ok {
|
|
_spec.SetField(payrefund.FieldChannelErrorCode, field.TypeString, value)
|
|
_node.ChannelErrorCode = value
|
|
}
|
|
if value, ok := _c.mutation.ChannelErrorMsg(); ok {
|
|
_spec.SetField(payrefund.FieldChannelErrorMsg, field.TypeString, value)
|
|
_node.ChannelErrorMsg = value
|
|
}
|
|
if value, ok := _c.mutation.ChannelNotifyData(); ok {
|
|
_spec.SetField(payrefund.FieldChannelNotifyData, field.TypeString, value)
|
|
_node.ChannelNotifyData = value
|
|
}
|
|
if nodes := _c.mutation.OrderIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payrefund.OrderTable,
|
|
Columns: []string{payrefund.OrderColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.OrderID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.ChannelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: payrefund.ChannelTable,
|
|
Columns: []string{payrefund.ChannelColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.ChannelID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// PayRefundCreateBulk is the builder for creating many PayRefund entities in bulk.
|
|
type PayRefundCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*PayRefundCreate
|
|
}
|
|
|
|
// Save creates the PayRefund entities in the database.
|
|
func (_c *PayRefundCreateBulk) Save(ctx context.Context) ([]*PayRefund, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*PayRefund, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*PayRefundMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = uint64(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *PayRefundCreateBulk) SaveX(ctx context.Context) []*PayRefund {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *PayRefundCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *PayRefundCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|