add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
529
internal/ent/gearsetinfo_create.go
Normal file
529
internal/ent/gearsetinfo_create.go
Normal file
@@ -0,0 +1,529 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"epic-ent/internal/ent/gearsetinfo"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// GearSetInfoCreate is the builder for creating a GearSetInfo entity.
|
||||
type GearSetInfoCreate struct {
|
||||
config
|
||||
mutation *GearSetInfoMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetLevel sets the "level" field.
|
||||
func (_c *GearSetInfoCreate) SetLevel(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetLevel(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGearID sets the "gear_id" field.
|
||||
func (_c *GearSetInfoCreate) SetGearID(v int64) *GearSetInfoCreate {
|
||||
_c.mutation.SetGearID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEnhance sets the "enhance" field.
|
||||
func (_c *GearSetInfoCreate) SetEnhance(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetEnhance(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGearType sets the "gear_type" field.
|
||||
func (_c *GearSetInfoCreate) SetGearType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetGearType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGearSetType sets the "gear_set_type" field.
|
||||
func (_c *GearSetInfoCreate) SetGearSetType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetGearSetType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMainStatType sets the "main_stat_type" field.
|
||||
func (_c *GearSetInfoCreate) SetMainStatType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetMainStatType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMainStatValue sets the "main_stat_value" field.
|
||||
func (_c *GearSetInfoCreate) SetMainStatValue(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetMainStatValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatOneType sets the "sub_stat_one_type" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatOneType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatOneType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatOneValue sets the "sub_stat_one_value" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatOneValue(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatOneValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatTwoType sets the "sub_stat_two_type" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatTwoType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatTwoType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatTwoValue sets the "sub_stat_two_value" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatTwoValue(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatTwoValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatThreeType sets the "sub_stat_three_type" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatThreeType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatThreeType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatThreeValue sets the "sub_stat_three_value" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatThreeValue(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatThreeValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatFourType sets the "sub_stat_four_type" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatFourType(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatFourType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSubStatFourValue sets the "sub_stat_four_value" field.
|
||||
func (_c *GearSetInfoCreate) SetSubStatFourValue(v int) *GearSetInfoCreate {
|
||||
_c.mutation.SetSubStatFourValue(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetAccountCode sets the "account_code" field.
|
||||
func (_c *GearSetInfoCreate) SetAccountCode(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetAccountCode(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreator sets the "creator" field.
|
||||
func (_c *GearSetInfoCreate) SetCreator(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetCreator(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (_c *GearSetInfoCreate) SetCreateTime(v time.Time) *GearSetInfoCreate {
|
||||
_c.mutation.SetCreateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
||||
func (_c *GearSetInfoCreate) SetNillableCreateTime(v *time.Time) *GearSetInfoCreate {
|
||||
if v != nil {
|
||||
_c.SetCreateTime(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdater sets the "updater" field.
|
||||
func (_c *GearSetInfoCreate) SetUpdater(v string) *GearSetInfoCreate {
|
||||
_c.mutation.SetUpdater(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_c *GearSetInfoCreate) SetUpdateTime(v time.Time) *GearSetInfoCreate {
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
||||
func (_c *GearSetInfoCreate) SetNillableUpdateTime(v *time.Time) *GearSetInfoCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdateTime(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDeleted sets the "deleted" field.
|
||||
func (_c *GearSetInfoCreate) SetDeleted(v bool) *GearSetInfoCreate {
|
||||
_c.mutation.SetDeleted(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTenantID sets the "tenant_id" field.
|
||||
func (_c *GearSetInfoCreate) SetTenantID(v int64) *GearSetInfoCreate {
|
||||
_c.mutation.SetTenantID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *GearSetInfoCreate) SetID(v int64) *GearSetInfoCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Mutation returns the GearSetInfoMutation object of the builder.
|
||||
func (_c *GearSetInfoCreate) Mutation() *GearSetInfoMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the GearSetInfo in the database.
|
||||
func (_c *GearSetInfoCreate) Save(ctx context.Context) (*GearSetInfo, error) {
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *GearSetInfoCreate) SaveX(ctx context.Context) *GearSetInfo {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *GearSetInfoCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *GearSetInfoCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *GearSetInfoCreate) check() error {
|
||||
if _, ok := _c.mutation.Level(); !ok {
|
||||
return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "GearSetInfo.level"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.GearID(); !ok {
|
||||
return &ValidationError{Name: "gear_id", err: errors.New(`ent: missing required field "GearSetInfo.gear_id"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Enhance(); !ok {
|
||||
return &ValidationError{Name: "enhance", err: errors.New(`ent: missing required field "GearSetInfo.enhance"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.GearType(); !ok {
|
||||
return &ValidationError{Name: "gear_type", err: errors.New(`ent: missing required field "GearSetInfo.gear_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.GearType(); ok {
|
||||
if err := gearsetinfo.GearTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "gear_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.GearSetType(); !ok {
|
||||
return &ValidationError{Name: "gear_set_type", err: errors.New(`ent: missing required field "GearSetInfo.gear_set_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.GearSetType(); ok {
|
||||
if err := gearsetinfo.GearSetTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "gear_set_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.gear_set_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.MainStatType(); !ok {
|
||||
return &ValidationError{Name: "main_stat_type", err: errors.New(`ent: missing required field "GearSetInfo.main_stat_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.MainStatType(); ok {
|
||||
if err := gearsetinfo.MainStatTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "main_stat_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.main_stat_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.MainStatValue(); !ok {
|
||||
return &ValidationError{Name: "main_stat_value", err: errors.New(`ent: missing required field "GearSetInfo.main_stat_value"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatOneType(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_one_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_one_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.SubStatOneType(); ok {
|
||||
if err := gearsetinfo.SubStatOneTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "sub_stat_one_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_one_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatOneValue(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_one_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_one_value"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatTwoType(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_two_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_two_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.SubStatTwoType(); ok {
|
||||
if err := gearsetinfo.SubStatTwoTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "sub_stat_two_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_two_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatTwoValue(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_two_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_two_value"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatThreeType(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_three_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_three_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.SubStatThreeType(); ok {
|
||||
if err := gearsetinfo.SubStatThreeTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "sub_stat_three_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_three_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatThreeValue(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_three_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_three_value"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatFourType(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_four_type", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_four_type"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.SubStatFourType(); ok {
|
||||
if err := gearsetinfo.SubStatFourTypeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "sub_stat_four_type", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.sub_stat_four_type": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.SubStatFourValue(); !ok {
|
||||
return &ValidationError{Name: "sub_stat_four_value", err: errors.New(`ent: missing required field "GearSetInfo.sub_stat_four_value"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.AccountCode(); !ok {
|
||||
return &ValidationError{Name: "account_code", err: errors.New(`ent: missing required field "GearSetInfo.account_code"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.AccountCode(); ok {
|
||||
if err := gearsetinfo.AccountCodeValidator(v); err != nil {
|
||||
return &ValidationError{Name: "account_code", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.account_code": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.Creator(); !ok {
|
||||
return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "GearSetInfo.creator"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Creator(); ok {
|
||||
if err := gearsetinfo.CreatorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.creator": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.Updater(); !ok {
|
||||
return &ValidationError{Name: "updater", err: errors.New(`ent: missing required field "GearSetInfo.updater"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Updater(); ok {
|
||||
if err := gearsetinfo.UpdaterValidator(v); err != nil {
|
||||
return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "GearSetInfo.updater": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.Deleted(); !ok {
|
||||
return &ValidationError{Name: "deleted", err: errors.New(`ent: missing required field "GearSetInfo.deleted"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.TenantID(); !ok {
|
||||
return &ValidationError{Name: "tenant_id", err: errors.New(`ent: missing required field "GearSetInfo.tenant_id"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *GearSetInfoCreate) sqlSave(ctx context.Context) (*GearSetInfo, 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 = int64(id)
|
||||
}
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *GearSetInfoCreate) createSpec() (*GearSetInfo, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &GearSetInfo{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(gearsetinfo.Table, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := _c.mutation.Level(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldLevel, field.TypeInt, value)
|
||||
_node.Level = value
|
||||
}
|
||||
if value, ok := _c.mutation.GearID(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldGearID, field.TypeInt64, value)
|
||||
_node.GearID = value
|
||||
}
|
||||
if value, ok := _c.mutation.Enhance(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldEnhance, field.TypeInt, value)
|
||||
_node.Enhance = value
|
||||
}
|
||||
if value, ok := _c.mutation.GearType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldGearType, field.TypeString, value)
|
||||
_node.GearType = value
|
||||
}
|
||||
if value, ok := _c.mutation.GearSetType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldGearSetType, field.TypeString, value)
|
||||
_node.GearSetType = value
|
||||
}
|
||||
if value, ok := _c.mutation.MainStatType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldMainStatType, field.TypeString, value)
|
||||
_node.MainStatType = value
|
||||
}
|
||||
if value, ok := _c.mutation.MainStatValue(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldMainStatValue, field.TypeInt, value)
|
||||
_node.MainStatValue = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatOneType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatOneType, field.TypeString, value)
|
||||
_node.SubStatOneType = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatOneValue(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value)
|
||||
_node.SubStatOneValue = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatTwoType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatTwoType, field.TypeString, value)
|
||||
_node.SubStatTwoType = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatTwoValue(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value)
|
||||
_node.SubStatTwoValue = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatThreeType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatThreeType, field.TypeString, value)
|
||||
_node.SubStatThreeType = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatThreeValue(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value)
|
||||
_node.SubStatThreeValue = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatFourType(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatFourType, field.TypeString, value)
|
||||
_node.SubStatFourType = value
|
||||
}
|
||||
if value, ok := _c.mutation.SubStatFourValue(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value)
|
||||
_node.SubStatFourValue = value
|
||||
}
|
||||
if value, ok := _c.mutation.AccountCode(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldAccountCode, field.TypeString, value)
|
||||
_node.AccountCode = value
|
||||
}
|
||||
if value, ok := _c.mutation.Creator(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldCreator, field.TypeString, value)
|
||||
_node.Creator = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreateTime(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldCreateTime, field.TypeTime, value)
|
||||
_node.CreateTime = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Updater(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldUpdater, field.TypeString, value)
|
||||
_node.Updater = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldUpdateTime, field.TypeTime, value)
|
||||
_node.UpdateTime = &value
|
||||
}
|
||||
if value, ok := _c.mutation.Deleted(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldDeleted, field.TypeBool, value)
|
||||
_node.Deleted = value
|
||||
}
|
||||
if value, ok := _c.mutation.TenantID(); ok {
|
||||
_spec.SetField(gearsetinfo.FieldTenantID, field.TypeInt64, value)
|
||||
_node.TenantID = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// GearSetInfoCreateBulk is the builder for creating many GearSetInfo entities in bulk.
|
||||
type GearSetInfoCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*GearSetInfoCreate
|
||||
}
|
||||
|
||||
// Save creates the GearSetInfo entities in the database.
|
||||
func (_c *GearSetInfoCreateBulk) Save(ctx context.Context) ([]*GearSetInfo, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*GearSetInfo, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*GearSetInfoMutation)
|
||||
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 = int64(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 *GearSetInfoCreateBulk) SaveX(ctx context.Context) []*GearSetInfo {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *GearSetInfoCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *GearSetInfoCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user