599 lines
17 KiB
Go
599 lines
17 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/payorder"
|
|
"mingyang-admin-pay/rpc/ent/payorderextension"
|
|
"mingyang-admin-pay/rpc/ent/payrefund"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// PayChannelCreate is the builder for creating a PayChannel entity.
|
|
type PayChannelCreate struct {
|
|
config
|
|
mutation *PayChannelMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *PayChannelCreate) SetCreatedAt(v time.Time) *PayChannelCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableCreatedAt(v *time.Time) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *PayChannelCreate) SetUpdatedAt(v time.Time) *PayChannelCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableUpdatedAt(v *time.Time) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *PayChannelCreate) SetStatus(v uint8) *PayChannelCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableStatus(v *uint8) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetStatus(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (_c *PayChannelCreate) SetTenantID(v uint64) *PayChannelCreate {
|
|
_c.mutation.SetTenantID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableTenantID(v *uint64) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetTenantID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *PayChannelCreate) SetDeletedAt(v time.Time) *PayChannelCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableDeletedAt(v *time.Time) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (_c *PayChannelCreate) SetCode(v string) *PayChannelCreate {
|
|
_c.mutation.SetCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNameEn sets the "name_en" field.
|
|
func (_c *PayChannelCreate) SetNameEn(v string) *PayChannelCreate {
|
|
_c.mutation.SetNameEn(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNameZh sets the "name_zh" field.
|
|
func (_c *PayChannelCreate) SetNameZh(v string) *PayChannelCreate {
|
|
_c.mutation.SetNameZh(v)
|
|
return _c
|
|
}
|
|
|
|
// SetFreeRate sets the "free_rate" field.
|
|
func (_c *PayChannelCreate) SetFreeRate(v string) *PayChannelCreate {
|
|
_c.mutation.SetFreeRate(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFreeRate sets the "free_rate" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableFreeRate(v *string) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetFreeRate(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAppID sets the "app_id" field.
|
|
func (_c *PayChannelCreate) SetAppID(v uint64) *PayChannelCreate {
|
|
_c.mutation.SetAppID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetConfig sets the "config" field.
|
|
func (_c *PayChannelCreate) SetConfig(v map[string]interface{}) *PayChannelCreate {
|
|
_c.mutation.SetConfig(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRemake sets the "remake" field.
|
|
func (_c *PayChannelCreate) SetRemake(v string) *PayChannelCreate {
|
|
_c.mutation.SetRemake(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRemake sets the "remake" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableRemake(v *string) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetRemake(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIcon sets the "icon" field.
|
|
func (_c *PayChannelCreate) SetIcon(v uint64) *PayChannelCreate {
|
|
_c.mutation.SetIcon(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIcon sets the "icon" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableIcon(v *uint64) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetIcon(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetOrderTimeOut sets the "order_time_out" field.
|
|
func (_c *PayChannelCreate) SetOrderTimeOut(v string) *PayChannelCreate {
|
|
_c.mutation.SetOrderTimeOut(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableOrderTimeOut sets the "order_time_out" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableOrderTimeOut(v *string) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetOrderTimeOut(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSupportCurrency sets the "support_currency" field.
|
|
func (_c *PayChannelCreate) SetSupportCurrency(v string) *PayChannelCreate {
|
|
_c.mutation.SetSupportCurrency(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSupportCurrency sets the "support_currency" field if the given value is not nil.
|
|
func (_c *PayChannelCreate) SetNillableSupportCurrency(v *string) *PayChannelCreate {
|
|
if v != nil {
|
|
_c.SetSupportCurrency(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *PayChannelCreate) SetID(v uint64) *PayChannelCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// AddOrderIDs adds the "orders" edge to the PayOrder entity by IDs.
|
|
func (_c *PayChannelCreate) AddOrderIDs(ids ...uint64) *PayChannelCreate {
|
|
_c.mutation.AddOrderIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddOrders adds the "orders" edges to the PayOrder entity.
|
|
func (_c *PayChannelCreate) AddOrders(v ...*PayOrder) *PayChannelCreate {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddOrderIDs(ids...)
|
|
}
|
|
|
|
// AddOrdersExtensionIDs adds the "orders_extension" edge to the PayOrderExtension entity by IDs.
|
|
func (_c *PayChannelCreate) AddOrdersExtensionIDs(ids ...uint64) *PayChannelCreate {
|
|
_c.mutation.AddOrdersExtensionIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddOrdersExtension adds the "orders_extension" edges to the PayOrderExtension entity.
|
|
func (_c *PayChannelCreate) AddOrdersExtension(v ...*PayOrderExtension) *PayChannelCreate {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddOrdersExtensionIDs(ids...)
|
|
}
|
|
|
|
// AddRefundIDs adds the "refund" edge to the PayRefund entity by IDs.
|
|
func (_c *PayChannelCreate) AddRefundIDs(ids ...uint64) *PayChannelCreate {
|
|
_c.mutation.AddRefundIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddRefund adds the "refund" edges to the PayRefund entity.
|
|
func (_c *PayChannelCreate) AddRefund(v ...*PayRefund) *PayChannelCreate {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddRefundIDs(ids...)
|
|
}
|
|
|
|
// SetApp sets the "app" edge to the App entity.
|
|
func (_c *PayChannelCreate) SetApp(v *App) *PayChannelCreate {
|
|
return _c.SetAppID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the PayChannelMutation object of the builder.
|
|
func (_c *PayChannelCreate) Mutation() *PayChannelMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the PayChannel in the database.
|
|
func (_c *PayChannelCreate) Save(ctx context.Context) (*PayChannel, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *PayChannelCreate) SaveX(ctx context.Context) *PayChannel {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *PayChannelCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *PayChannelCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *PayChannelCreate) defaults() {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := paychannel.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := paychannel.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
v := paychannel.DefaultStatus
|
|
_c.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := _c.mutation.TenantID(); !ok {
|
|
v := paychannel.DefaultTenantID
|
|
_c.mutation.SetTenantID(v)
|
|
}
|
|
if _, ok := _c.mutation.FreeRate(); !ok {
|
|
v := paychannel.DefaultFreeRate
|
|
_c.mutation.SetFreeRate(v)
|
|
}
|
|
if _, ok := _c.mutation.OrderTimeOut(); !ok {
|
|
v := paychannel.DefaultOrderTimeOut
|
|
_c.mutation.SetOrderTimeOut(v)
|
|
}
|
|
if _, ok := _c.mutation.SupportCurrency(); !ok {
|
|
v := paychannel.DefaultSupportCurrency
|
|
_c.mutation.SetSupportCurrency(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *PayChannelCreate) check() error {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayChannel.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayChannel.updated_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.TenantID(); !ok {
|
|
return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "PayChannel.tenant_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Code(); !ok {
|
|
return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "PayChannel.code"`)}
|
|
}
|
|
if _, ok := _c.mutation.NameEn(); !ok {
|
|
return &ValidationError{Name: "name_en", err: errors.New(`ent: missing required field "PayChannel.name_en"`)}
|
|
}
|
|
if _, ok := _c.mutation.NameZh(); !ok {
|
|
return &ValidationError{Name: "name_zh", err: errors.New(`ent: missing required field "PayChannel.name_zh"`)}
|
|
}
|
|
if _, ok := _c.mutation.FreeRate(); !ok {
|
|
return &ValidationError{Name: "free_rate", err: errors.New(`ent: missing required field "PayChannel.free_rate"`)}
|
|
}
|
|
if _, ok := _c.mutation.AppID(); !ok {
|
|
return &ValidationError{Name: "app_id", err: errors.New(`ent: missing required field "PayChannel.app_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Config(); !ok {
|
|
return &ValidationError{Name: "config", err: errors.New(`ent: missing required field "PayChannel.config"`)}
|
|
}
|
|
if _, ok := _c.mutation.OrderTimeOut(); !ok {
|
|
return &ValidationError{Name: "order_time_out", err: errors.New(`ent: missing required field "PayChannel.order_time_out"`)}
|
|
}
|
|
if _, ok := _c.mutation.SupportCurrency(); !ok {
|
|
return &ValidationError{Name: "support_currency", err: errors.New(`ent: missing required field "PayChannel.support_currency"`)}
|
|
}
|
|
if len(_c.mutation.AppIDs()) == 0 {
|
|
return &ValidationError{Name: "app", err: errors.New(`ent: missing required edge "PayChannel.app"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *PayChannelCreate) sqlSave(ctx context.Context) (*PayChannel, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != _node.ID {
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = uint64(id)
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *PayChannelCreate) createSpec() (*PayChannel, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &PayChannel{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(paychannel.Table, sqlgraph.NewFieldSpec(paychannel.FieldID, field.TypeUint64))
|
|
)
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = id
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(paychannel.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(paychannel.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(paychannel.FieldStatus, field.TypeUint8, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.TenantID(); ok {
|
|
_spec.SetField(paychannel.FieldTenantID, field.TypeUint64, value)
|
|
_node.TenantID = value
|
|
}
|
|
if value, ok := _c.mutation.DeletedAt(); ok {
|
|
_spec.SetField(paychannel.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Code(); ok {
|
|
_spec.SetField(paychannel.FieldCode, field.TypeString, value)
|
|
_node.Code = value
|
|
}
|
|
if value, ok := _c.mutation.NameEn(); ok {
|
|
_spec.SetField(paychannel.FieldNameEn, field.TypeString, value)
|
|
_node.NameEn = value
|
|
}
|
|
if value, ok := _c.mutation.NameZh(); ok {
|
|
_spec.SetField(paychannel.FieldNameZh, field.TypeString, value)
|
|
_node.NameZh = value
|
|
}
|
|
if value, ok := _c.mutation.FreeRate(); ok {
|
|
_spec.SetField(paychannel.FieldFreeRate, field.TypeString, value)
|
|
_node.FreeRate = value
|
|
}
|
|
if value, ok := _c.mutation.Config(); ok {
|
|
_spec.SetField(paychannel.FieldConfig, field.TypeJSON, value)
|
|
_node.Config = value
|
|
}
|
|
if value, ok := _c.mutation.Remake(); ok {
|
|
_spec.SetField(paychannel.FieldRemake, field.TypeString, value)
|
|
_node.Remake = value
|
|
}
|
|
if value, ok := _c.mutation.Icon(); ok {
|
|
_spec.SetField(paychannel.FieldIcon, field.TypeUint64, value)
|
|
_node.Icon = value
|
|
}
|
|
if value, ok := _c.mutation.OrderTimeOut(); ok {
|
|
_spec.SetField(paychannel.FieldOrderTimeOut, field.TypeString, value)
|
|
_node.OrderTimeOut = value
|
|
}
|
|
if value, ok := _c.mutation.SupportCurrency(); ok {
|
|
_spec.SetField(paychannel.FieldSupportCurrency, field.TypeString, value)
|
|
_node.SupportCurrency = value
|
|
}
|
|
if nodes := _c.mutation.OrdersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: paychannel.OrdersTable,
|
|
Columns: []string{paychannel.OrdersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorder.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.OrdersExtensionIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: paychannel.OrdersExtensionTable,
|
|
Columns: []string{paychannel.OrdersExtensionColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payorderextension.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.RefundIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: paychannel.RefundTable,
|
|
Columns: []string{paychannel.RefundColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(payrefund.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.AppIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
Table: paychannel.AppTable,
|
|
Columns: []string{paychannel.AppColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(app.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_node.AppID = nodes[0]
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// PayChannelCreateBulk is the builder for creating many PayChannel entities in bulk.
|
|
type PayChannelCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*PayChannelCreate
|
|
}
|
|
|
|
// Save creates the PayChannel entities in the database.
|
|
func (_c *PayChannelCreateBulk) Save(ctx context.Context) ([]*PayChannel, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*PayChannel, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*PayChannelMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = uint64(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *PayChannelCreateBulk) SaveX(ctx context.Context) []*PayChannel {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *PayChannelCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *PayChannelCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|