1257 lines
40 KiB
Go
1257 lines
40 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"epic-ent/internal/ent/gearsetinfo"
|
|
"epic-ent/internal/ent/predicate"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// GearSetInfoUpdate is the builder for updating GearSetInfo entities.
|
|
type GearSetInfoUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *GearSetInfoMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the GearSetInfoUpdate builder.
|
|
func (_u *GearSetInfoUpdate) Where(ps ...predicate.GearSetInfo) *GearSetInfoUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetLevel sets the "level" field.
|
|
func (_u *GearSetInfoUpdate) SetLevel(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetLevel()
|
|
_u.mutation.SetLevel(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLevel sets the "level" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableLevel(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetLevel(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLevel adds value to the "level" field.
|
|
func (_u *GearSetInfoUpdate) AddLevel(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddLevel(v)
|
|
return _u
|
|
}
|
|
|
|
// SetGearID sets the "gear_id" field.
|
|
func (_u *GearSetInfoUpdate) SetGearID(v int64) *GearSetInfoUpdate {
|
|
_u.mutation.ResetGearID()
|
|
_u.mutation.SetGearID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGearID sets the "gear_id" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableGearID(v *int64) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetGearID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddGearID adds value to the "gear_id" field.
|
|
func (_u *GearSetInfoUpdate) AddGearID(v int64) *GearSetInfoUpdate {
|
|
_u.mutation.AddGearID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetEnhance sets the "enhance" field.
|
|
func (_u *GearSetInfoUpdate) SetEnhance(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetEnhance()
|
|
_u.mutation.SetEnhance(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEnhance sets the "enhance" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableEnhance(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetEnhance(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddEnhance adds value to the "enhance" field.
|
|
func (_u *GearSetInfoUpdate) AddEnhance(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddEnhance(v)
|
|
return _u
|
|
}
|
|
|
|
// SetGearType sets the "gear_type" field.
|
|
func (_u *GearSetInfoUpdate) SetGearType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetGearType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGearType sets the "gear_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableGearType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetGearType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGearSetType sets the "gear_set_type" field.
|
|
func (_u *GearSetInfoUpdate) SetGearSetType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetGearSetType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGearSetType sets the "gear_set_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableGearSetType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetGearSetType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMainStatType sets the "main_stat_type" field.
|
|
func (_u *GearSetInfoUpdate) SetMainStatType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetMainStatType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMainStatType sets the "main_stat_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableMainStatType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetMainStatType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMainStatValue sets the "main_stat_value" field.
|
|
func (_u *GearSetInfoUpdate) SetMainStatValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetMainStatValue()
|
|
_u.mutation.SetMainStatValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMainStatValue sets the "main_stat_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableMainStatValue(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetMainStatValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddMainStatValue adds value to the "main_stat_value" field.
|
|
func (_u *GearSetInfoUpdate) AddMainStatValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddMainStatValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatOneType sets the "sub_stat_one_type" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatOneType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetSubStatOneType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatOneType sets the "sub_stat_one_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatOneType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatOneType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatOneValue sets the "sub_stat_one_value" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatOneValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetSubStatOneValue()
|
|
_u.mutation.SetSubStatOneValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatOneValue sets the "sub_stat_one_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatOneValue(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatOneValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatOneValue adds value to the "sub_stat_one_value" field.
|
|
func (_u *GearSetInfoUpdate) AddSubStatOneValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddSubStatOneValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatTwoType sets the "sub_stat_two_type" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatTwoType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetSubStatTwoType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatTwoType sets the "sub_stat_two_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatTwoType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatTwoType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatTwoValue sets the "sub_stat_two_value" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatTwoValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetSubStatTwoValue()
|
|
_u.mutation.SetSubStatTwoValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatTwoValue sets the "sub_stat_two_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatTwoValue(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatTwoValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatTwoValue adds value to the "sub_stat_two_value" field.
|
|
func (_u *GearSetInfoUpdate) AddSubStatTwoValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddSubStatTwoValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatThreeType sets the "sub_stat_three_type" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatThreeType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetSubStatThreeType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatThreeType sets the "sub_stat_three_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatThreeType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatThreeType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatThreeValue sets the "sub_stat_three_value" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatThreeValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetSubStatThreeValue()
|
|
_u.mutation.SetSubStatThreeValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatThreeValue sets the "sub_stat_three_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatThreeValue(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatThreeValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatThreeValue adds value to the "sub_stat_three_value" field.
|
|
func (_u *GearSetInfoUpdate) AddSubStatThreeValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddSubStatThreeValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatFourType sets the "sub_stat_four_type" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatFourType(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetSubStatFourType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatFourType sets the "sub_stat_four_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatFourType(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatFourType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatFourValue sets the "sub_stat_four_value" field.
|
|
func (_u *GearSetInfoUpdate) SetSubStatFourValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.ResetSubStatFourValue()
|
|
_u.mutation.SetSubStatFourValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatFourValue sets the "sub_stat_four_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableSubStatFourValue(v *int) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetSubStatFourValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatFourValue adds value to the "sub_stat_four_value" field.
|
|
func (_u *GearSetInfoUpdate) AddSubStatFourValue(v int) *GearSetInfoUpdate {
|
|
_u.mutation.AddSubStatFourValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetAccountCode sets the "account_code" field.
|
|
func (_u *GearSetInfoUpdate) SetAccountCode(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetAccountCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAccountCode sets the "account_code" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableAccountCode(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetAccountCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (_u *GearSetInfoUpdate) SetCreator(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetCreator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreator sets the "creator" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableCreator(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetCreator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_u *GearSetInfoUpdate) SetCreateTime(v time.Time) *GearSetInfoUpdate {
|
|
_u.mutation.SetCreateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableCreateTime(v *time.Time) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetCreateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (_u *GearSetInfoUpdate) ClearCreateTime() *GearSetInfoUpdate {
|
|
_u.mutation.ClearCreateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdater sets the "updater" field.
|
|
func (_u *GearSetInfoUpdate) SetUpdater(v string) *GearSetInfoUpdate {
|
|
_u.mutation.SetUpdater(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdater sets the "updater" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableUpdater(v *string) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetUpdater(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *GearSetInfoUpdate) SetUpdateTime(v time.Time) *GearSetInfoUpdate {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableUpdateTime(v *time.Time) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetUpdateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdateTime clears the value of the "update_time" field.
|
|
func (_u *GearSetInfoUpdate) ClearUpdateTime() *GearSetInfoUpdate {
|
|
_u.mutation.ClearUpdateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (_u *GearSetInfoUpdate) SetDeleted(v bool) *GearSetInfoUpdate {
|
|
_u.mutation.SetDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableDeleted(v *bool) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (_u *GearSetInfoUpdate) SetTenantID(v int64) *GearSetInfoUpdate {
|
|
_u.mutation.ResetTenantID()
|
|
_u.mutation.SetTenantID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdate) SetNillableTenantID(v *int64) *GearSetInfoUpdate {
|
|
if v != nil {
|
|
_u.SetTenantID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddTenantID adds value to the "tenant_id" field.
|
|
func (_u *GearSetInfoUpdate) AddTenantID(v int64) *GearSetInfoUpdate {
|
|
_u.mutation.AddTenantID(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the GearSetInfoMutation object of the builder.
|
|
func (_u *GearSetInfoUpdate) Mutation() *GearSetInfoMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *GearSetInfoUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *GearSetInfoUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *GearSetInfoUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *GearSetInfoUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *GearSetInfoUpdate) check() error {
|
|
if v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *GearSetInfoUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(gearsetinfo.Table, gearsetinfo.Columns, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64))
|
|
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.Level(); ok {
|
|
_spec.SetField(gearsetinfo.FieldLevel, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLevel(); ok {
|
|
_spec.AddField(gearsetinfo.FieldLevel, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.GearID(); ok {
|
|
_spec.SetField(gearsetinfo.FieldGearID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedGearID(); ok {
|
|
_spec.AddField(gearsetinfo.FieldGearID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.Enhance(); ok {
|
|
_spec.SetField(gearsetinfo.FieldEnhance, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedEnhance(); ok {
|
|
_spec.AddField(gearsetinfo.FieldEnhance, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.GearType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldGearType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.GearSetType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldGearSetType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MainStatType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldMainStatType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MainStatValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldMainStatValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedMainStatValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldMainStatValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatOneType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatOneType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatOneValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatOneValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatTwoType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatTwoType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatTwoValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatTwoValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatThreeType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatThreeType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatThreeValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatThreeValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatFourType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatFourType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatFourValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatFourValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AccountCode(); ok {
|
|
_spec.SetField(gearsetinfo.FieldAccountCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Creator(); ok {
|
|
_spec.SetField(gearsetinfo.FieldCreator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreateTime(); ok {
|
|
_spec.SetField(gearsetinfo.FieldCreateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(gearsetinfo.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Updater(); ok {
|
|
_spec.SetField(gearsetinfo.FieldUpdater, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(gearsetinfo.FieldUpdateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdateTimeCleared() {
|
|
_spec.ClearField(gearsetinfo.FieldUpdateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Deleted(); ok {
|
|
_spec.SetField(gearsetinfo.FieldDeleted, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.TenantID(); ok {
|
|
_spec.SetField(gearsetinfo.FieldTenantID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedTenantID(); ok {
|
|
_spec.AddField(gearsetinfo.FieldTenantID, field.TypeInt64, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{gearsetinfo.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// GearSetInfoUpdateOne is the builder for updating a single GearSetInfo entity.
|
|
type GearSetInfoUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *GearSetInfoMutation
|
|
}
|
|
|
|
// SetLevel sets the "level" field.
|
|
func (_u *GearSetInfoUpdateOne) SetLevel(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetLevel()
|
|
_u.mutation.SetLevel(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLevel sets the "level" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableLevel(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetLevel(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddLevel adds value to the "level" field.
|
|
func (_u *GearSetInfoUpdateOne) AddLevel(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddLevel(v)
|
|
return _u
|
|
}
|
|
|
|
// SetGearID sets the "gear_id" field.
|
|
func (_u *GearSetInfoUpdateOne) SetGearID(v int64) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetGearID()
|
|
_u.mutation.SetGearID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGearID sets the "gear_id" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableGearID(v *int64) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetGearID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddGearID adds value to the "gear_id" field.
|
|
func (_u *GearSetInfoUpdateOne) AddGearID(v int64) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddGearID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetEnhance sets the "enhance" field.
|
|
func (_u *GearSetInfoUpdateOne) SetEnhance(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetEnhance()
|
|
_u.mutation.SetEnhance(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEnhance sets the "enhance" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableEnhance(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetEnhance(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddEnhance adds value to the "enhance" field.
|
|
func (_u *GearSetInfoUpdateOne) AddEnhance(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddEnhance(v)
|
|
return _u
|
|
}
|
|
|
|
// SetGearType sets the "gear_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetGearType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetGearType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGearType sets the "gear_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableGearType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetGearType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGearSetType sets the "gear_set_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetGearSetType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetGearSetType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGearSetType sets the "gear_set_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableGearSetType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetGearSetType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMainStatType sets the "main_stat_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetMainStatType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetMainStatType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMainStatType sets the "main_stat_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableMainStatType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetMainStatType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMainStatValue sets the "main_stat_value" field.
|
|
func (_u *GearSetInfoUpdateOne) SetMainStatValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetMainStatValue()
|
|
_u.mutation.SetMainStatValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMainStatValue sets the "main_stat_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableMainStatValue(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetMainStatValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddMainStatValue adds value to the "main_stat_value" field.
|
|
func (_u *GearSetInfoUpdateOne) AddMainStatValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddMainStatValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatOneType sets the "sub_stat_one_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatOneType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetSubStatOneType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatOneType sets the "sub_stat_one_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatOneType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatOneType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatOneValue sets the "sub_stat_one_value" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatOneValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetSubStatOneValue()
|
|
_u.mutation.SetSubStatOneValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatOneValue sets the "sub_stat_one_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatOneValue(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatOneValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatOneValue adds value to the "sub_stat_one_value" field.
|
|
func (_u *GearSetInfoUpdateOne) AddSubStatOneValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddSubStatOneValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatTwoType sets the "sub_stat_two_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatTwoType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetSubStatTwoType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatTwoType sets the "sub_stat_two_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatTwoType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatTwoType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatTwoValue sets the "sub_stat_two_value" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatTwoValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetSubStatTwoValue()
|
|
_u.mutation.SetSubStatTwoValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatTwoValue sets the "sub_stat_two_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatTwoValue(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatTwoValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatTwoValue adds value to the "sub_stat_two_value" field.
|
|
func (_u *GearSetInfoUpdateOne) AddSubStatTwoValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddSubStatTwoValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatThreeType sets the "sub_stat_three_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatThreeType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetSubStatThreeType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatThreeType sets the "sub_stat_three_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatThreeType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatThreeType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatThreeValue sets the "sub_stat_three_value" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatThreeValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetSubStatThreeValue()
|
|
_u.mutation.SetSubStatThreeValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatThreeValue sets the "sub_stat_three_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatThreeValue(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatThreeValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatThreeValue adds value to the "sub_stat_three_value" field.
|
|
func (_u *GearSetInfoUpdateOne) AddSubStatThreeValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddSubStatThreeValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatFourType sets the "sub_stat_four_type" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatFourType(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetSubStatFourType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatFourType sets the "sub_stat_four_type" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatFourType(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatFourType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSubStatFourValue sets the "sub_stat_four_value" field.
|
|
func (_u *GearSetInfoUpdateOne) SetSubStatFourValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetSubStatFourValue()
|
|
_u.mutation.SetSubStatFourValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSubStatFourValue sets the "sub_stat_four_value" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableSubStatFourValue(v *int) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetSubStatFourValue(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSubStatFourValue adds value to the "sub_stat_four_value" field.
|
|
func (_u *GearSetInfoUpdateOne) AddSubStatFourValue(v int) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddSubStatFourValue(v)
|
|
return _u
|
|
}
|
|
|
|
// SetAccountCode sets the "account_code" field.
|
|
func (_u *GearSetInfoUpdateOne) SetAccountCode(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetAccountCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAccountCode sets the "account_code" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableAccountCode(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetAccountCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (_u *GearSetInfoUpdateOne) SetCreator(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetCreator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreator sets the "creator" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableCreator(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_u *GearSetInfoUpdateOne) SetCreateTime(v time.Time) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetCreateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableCreateTime(v *time.Time) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (_u *GearSetInfoUpdateOne) ClearCreateTime() *GearSetInfoUpdateOne {
|
|
_u.mutation.ClearCreateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdater sets the "updater" field.
|
|
func (_u *GearSetInfoUpdateOne) SetUpdater(v string) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetUpdater(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdater sets the "updater" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableUpdater(v *string) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdater(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *GearSetInfoUpdateOne) SetUpdateTime(v time.Time) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableUpdateTime(v *time.Time) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdateTime clears the value of the "update_time" field.
|
|
func (_u *GearSetInfoUpdateOne) ClearUpdateTime() *GearSetInfoUpdateOne {
|
|
_u.mutation.ClearUpdateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (_u *GearSetInfoUpdateOne) SetDeleted(v bool) *GearSetInfoUpdateOne {
|
|
_u.mutation.SetDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableDeleted(v *bool) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTenantID sets the "tenant_id" field.
|
|
func (_u *GearSetInfoUpdateOne) SetTenantID(v int64) *GearSetInfoUpdateOne {
|
|
_u.mutation.ResetTenantID()
|
|
_u.mutation.SetTenantID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTenantID sets the "tenant_id" field if the given value is not nil.
|
|
func (_u *GearSetInfoUpdateOne) SetNillableTenantID(v *int64) *GearSetInfoUpdateOne {
|
|
if v != nil {
|
|
_u.SetTenantID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddTenantID adds value to the "tenant_id" field.
|
|
func (_u *GearSetInfoUpdateOne) AddTenantID(v int64) *GearSetInfoUpdateOne {
|
|
_u.mutation.AddTenantID(v)
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the GearSetInfoMutation object of the builder.
|
|
func (_u *GearSetInfoUpdateOne) Mutation() *GearSetInfoMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the GearSetInfoUpdate builder.
|
|
func (_u *GearSetInfoUpdateOne) Where(ps ...predicate.GearSetInfo) *GearSetInfoUpdateOne {
|
|
_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 *GearSetInfoUpdateOne) Select(field string, fields ...string) *GearSetInfoUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated GearSetInfo entity.
|
|
func (_u *GearSetInfoUpdateOne) Save(ctx context.Context) (*GearSetInfo, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *GearSetInfoUpdateOne) SaveX(ctx context.Context) *GearSetInfo {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *GearSetInfoUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *GearSetInfoUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *GearSetInfoUpdateOne) check() error {
|
|
if v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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 v, ok := _u.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)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *GearSetInfoUpdateOne) sqlSave(ctx context.Context) (_node *GearSetInfo, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(gearsetinfo.Table, gearsetinfo.Columns, sqlgraph.NewFieldSpec(gearsetinfo.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "GearSetInfo.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, gearsetinfo.FieldID)
|
|
for _, f := range fields {
|
|
if !gearsetinfo.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != gearsetinfo.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.Level(); ok {
|
|
_spec.SetField(gearsetinfo.FieldLevel, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedLevel(); ok {
|
|
_spec.AddField(gearsetinfo.FieldLevel, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.GearID(); ok {
|
|
_spec.SetField(gearsetinfo.FieldGearID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedGearID(); ok {
|
|
_spec.AddField(gearsetinfo.FieldGearID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.Enhance(); ok {
|
|
_spec.SetField(gearsetinfo.FieldEnhance, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedEnhance(); ok {
|
|
_spec.AddField(gearsetinfo.FieldEnhance, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.GearType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldGearType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.GearSetType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldGearSetType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MainStatType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldMainStatType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.MainStatValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldMainStatValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedMainStatValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldMainStatValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatOneType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatOneType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatOneValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatOneValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatOneValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatTwoType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatTwoType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatTwoValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatTwoValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatTwoValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatThreeType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatThreeType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatThreeValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatThreeValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatThreeValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatFourType(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatFourType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.SubStatFourValue(); ok {
|
|
_spec.SetField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSubStatFourValue(); ok {
|
|
_spec.AddField(gearsetinfo.FieldSubStatFourValue, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AccountCode(); ok {
|
|
_spec.SetField(gearsetinfo.FieldAccountCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Creator(); ok {
|
|
_spec.SetField(gearsetinfo.FieldCreator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreateTime(); ok {
|
|
_spec.SetField(gearsetinfo.FieldCreateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(gearsetinfo.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Updater(); ok {
|
|
_spec.SetField(gearsetinfo.FieldUpdater, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(gearsetinfo.FieldUpdateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdateTimeCleared() {
|
|
_spec.ClearField(gearsetinfo.FieldUpdateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Deleted(); ok {
|
|
_spec.SetField(gearsetinfo.FieldDeleted, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.TenantID(); ok {
|
|
_spec.SetField(gearsetinfo.FieldTenantID, field.TypeInt64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedTenantID(); ok {
|
|
_spec.AddField(gearsetinfo.FieldTenantID, field.TypeInt64, value)
|
|
}
|
|
_node = &GearSetInfo{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{gearsetinfo.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|