669 lines
22 KiB
Go
669 lines
22 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"epic-ent/internal/ent/epicherouserbuild"
|
|
"epic-ent/internal/ent/predicate"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// EpicHeroUserBuildUpdate is the builder for updating EpicHeroUserBuild entities.
|
|
type EpicHeroUserBuildUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *EpicHeroUserBuildMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EpicHeroUserBuildUpdate builder.
|
|
func (_u *EpicHeroUserBuildUpdate) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetArtifactCode sets the "artifact_code" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetArtifactCode(v string) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetArtifactCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableArtifactCode(v *string) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetArtifactCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetHeroCode sets the "hero_code" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetHeroCode(v string) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetHeroCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroCode sets the "hero_code" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableHeroCode(v *string) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetHeroCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetHeroHeathBuild sets the "hero_heath_build" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetHeroHeathBuild(v float64) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.ResetHeroHeathBuild()
|
|
_u.mutation.SetHeroHeathBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroHeathBuild sets the "hero_heath_build" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableHeroHeathBuild(v *float64) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetHeroHeathBuild(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddHeroHeathBuild adds value to the "hero_heath_build" field.
|
|
func (_u *EpicHeroUserBuildUpdate) AddHeroHeathBuild(v float64) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.AddHeroHeathBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetHeroAttackBuild sets the "hero_attack_build" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetHeroAttackBuild(v float64) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.ResetHeroAttackBuild()
|
|
_u.mutation.SetHeroAttackBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroAttackBuild sets the "hero_attack_build" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableHeroAttackBuild(v *float64) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetHeroAttackBuild(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddHeroAttackBuild adds value to the "hero_attack_build" field.
|
|
func (_u *EpicHeroUserBuildUpdate) AddHeroAttackBuild(v float64) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.AddHeroAttackBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetHeroDefBuild sets the "hero_def_build" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetHeroDefBuild(v float64) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.ResetHeroDefBuild()
|
|
_u.mutation.SetHeroDefBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroDefBuild sets the "hero_def_build" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableHeroDefBuild(v *float64) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetHeroDefBuild(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddHeroDefBuild adds value to the "hero_def_build" field.
|
|
func (_u *EpicHeroUserBuildUpdate) AddHeroDefBuild(v float64) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.AddHeroDefBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetCreator(v string) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetCreator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreator sets the "creator" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableCreator(v *string) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetCreator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetCreateTime(v time.Time) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetCreateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableCreateTime(v *time.Time) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetCreateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (_u *EpicHeroUserBuildUpdate) ClearCreateTime() *EpicHeroUserBuildUpdate {
|
|
_u.mutation.ClearCreateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdater sets the "updater" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetUpdater(v string) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetUpdater(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdater sets the "updater" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableUpdater(v *string) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetUpdater(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetUpdateTime(v time.Time) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableUpdateTime(v *time.Time) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetUpdateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdateTime clears the value of the "update_time" field.
|
|
func (_u *EpicHeroUserBuildUpdate) ClearUpdateTime() *EpicHeroUserBuildUpdate {
|
|
_u.mutation.ClearUpdateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (_u *EpicHeroUserBuildUpdate) SetDeleted(v bool) *EpicHeroUserBuildUpdate {
|
|
_u.mutation.SetDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdate) SetNillableDeleted(v *bool) *EpicHeroUserBuildUpdate {
|
|
if v != nil {
|
|
_u.SetDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the EpicHeroUserBuildMutation object of the builder.
|
|
func (_u *EpicHeroUserBuildUpdate) Mutation() *EpicHeroUserBuildMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *EpicHeroUserBuildUpdate) 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 *EpicHeroUserBuildUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *EpicHeroUserBuildUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EpicHeroUserBuildUpdate) 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 *EpicHeroUserBuildUpdate) check() error {
|
|
if v, ok := _u.mutation.ArtifactCode(); ok {
|
|
if err := epicherouserbuild.ArtifactCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.artifact_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.HeroCode(); ok {
|
|
if err := epicherouserbuild.HeroCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.hero_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Creator(); ok {
|
|
if err := epicherouserbuild.CreatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.creator": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Updater(); ok {
|
|
if err := epicherouserbuild.UpdaterValidator(v); err != nil {
|
|
return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.updater": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EpicHeroUserBuildUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(epicherouserbuild.Table, epicherouserbuild.Columns, sqlgraph.NewFieldSpec(epicherouserbuild.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.ArtifactCode(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldArtifactCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroCode(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroHeathBuild(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedHeroHeathBuild(); ok {
|
|
_spec.AddField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroAttackBuild(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedHeroAttackBuild(); ok {
|
|
_spec.AddField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroDefBuild(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedHeroDefBuild(); ok {
|
|
_spec.AddField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.Creator(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldCreator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreateTime(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldCreateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(epicherouserbuild.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Updater(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldUpdater, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldUpdateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdateTimeCleared() {
|
|
_spec.ClearField(epicherouserbuild.FieldUpdateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Deleted(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldDeleted, field.TypeBool, value)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{epicherouserbuild.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// EpicHeroUserBuildUpdateOne is the builder for updating a single EpicHeroUserBuild entity.
|
|
type EpicHeroUserBuildUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *EpicHeroUserBuildMutation
|
|
}
|
|
|
|
// SetArtifactCode sets the "artifact_code" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetArtifactCode(v string) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetArtifactCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableArtifactCode sets the "artifact_code" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableArtifactCode(v *string) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetArtifactCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetHeroCode sets the "hero_code" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetHeroCode(v string) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetHeroCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroCode sets the "hero_code" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroCode(v *string) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetHeroCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetHeroHeathBuild sets the "hero_heath_build" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetHeroHeathBuild(v float64) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.ResetHeroHeathBuild()
|
|
_u.mutation.SetHeroHeathBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroHeathBuild sets the "hero_heath_build" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroHeathBuild(v *float64) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetHeroHeathBuild(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddHeroHeathBuild adds value to the "hero_heath_build" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) AddHeroHeathBuild(v float64) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.AddHeroHeathBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetHeroAttackBuild sets the "hero_attack_build" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetHeroAttackBuild(v float64) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.ResetHeroAttackBuild()
|
|
_u.mutation.SetHeroAttackBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroAttackBuild sets the "hero_attack_build" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroAttackBuild(v *float64) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetHeroAttackBuild(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddHeroAttackBuild adds value to the "hero_attack_build" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) AddHeroAttackBuild(v float64) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.AddHeroAttackBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetHeroDefBuild sets the "hero_def_build" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetHeroDefBuild(v float64) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.ResetHeroDefBuild()
|
|
_u.mutation.SetHeroDefBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableHeroDefBuild sets the "hero_def_build" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableHeroDefBuild(v *float64) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetHeroDefBuild(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddHeroDefBuild adds value to the "hero_def_build" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) AddHeroDefBuild(v float64) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.AddHeroDefBuild(v)
|
|
return _u
|
|
}
|
|
|
|
// SetCreator sets the "creator" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetCreator(v string) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetCreator(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreator sets the "creator" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableCreator(v *string) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreator(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCreateTime sets the "create_time" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetCreateTime(v time.Time) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetCreateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableCreateTime(v *time.Time) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetCreateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCreateTime clears the value of the "create_time" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) ClearCreateTime() *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.ClearCreateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetUpdater sets the "updater" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetUpdater(v string) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetUpdater(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdater sets the "updater" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableUpdater(v *string) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdater(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdateTime sets the "update_time" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetUpdateTime(v time.Time) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetUpdateTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableUpdateTime(v *time.Time) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetUpdateTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdateTime clears the value of the "update_time" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) ClearUpdateTime() *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.ClearUpdateTime()
|
|
return _u
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetDeleted(v bool) *EpicHeroUserBuildUpdateOne {
|
|
_u.mutation.SetDeleted(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SetNillableDeleted(v *bool) *EpicHeroUserBuildUpdateOne {
|
|
if v != nil {
|
|
_u.SetDeleted(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the EpicHeroUserBuildMutation object of the builder.
|
|
func (_u *EpicHeroUserBuildUpdateOne) Mutation() *EpicHeroUserBuildMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EpicHeroUserBuildUpdate builder.
|
|
func (_u *EpicHeroUserBuildUpdateOne) Where(ps ...predicate.EpicHeroUserBuild) *EpicHeroUserBuildUpdateOne {
|
|
_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 *EpicHeroUserBuildUpdateOne) Select(field string, fields ...string) *EpicHeroUserBuildUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated EpicHeroUserBuild entity.
|
|
func (_u *EpicHeroUserBuildUpdateOne) Save(ctx context.Context) (*EpicHeroUserBuild, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *EpicHeroUserBuildUpdateOne) SaveX(ctx context.Context) *EpicHeroUserBuild {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *EpicHeroUserBuildUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EpicHeroUserBuildUpdateOne) 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 *EpicHeroUserBuildUpdateOne) check() error {
|
|
if v, ok := _u.mutation.ArtifactCode(); ok {
|
|
if err := epicherouserbuild.ArtifactCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "artifact_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.artifact_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.HeroCode(); ok {
|
|
if err := epicherouserbuild.HeroCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "hero_code", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.hero_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Creator(); ok {
|
|
if err := epicherouserbuild.CreatorValidator(v); err != nil {
|
|
return &ValidationError{Name: "creator", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.creator": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Updater(); ok {
|
|
if err := epicherouserbuild.UpdaterValidator(v); err != nil {
|
|
return &ValidationError{Name: "updater", err: fmt.Errorf(`ent: validator failed for field "EpicHeroUserBuild.updater": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EpicHeroUserBuildUpdateOne) sqlSave(ctx context.Context) (_node *EpicHeroUserBuild, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(epicherouserbuild.Table, epicherouserbuild.Columns, sqlgraph.NewFieldSpec(epicherouserbuild.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "EpicHeroUserBuild.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, epicherouserbuild.FieldID)
|
|
for _, f := range fields {
|
|
if !epicherouserbuild.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != epicherouserbuild.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.ArtifactCode(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldArtifactCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroCode(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroHeathBuild(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedHeroHeathBuild(); ok {
|
|
_spec.AddField(epicherouserbuild.FieldHeroHeathBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroAttackBuild(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedHeroAttackBuild(); ok {
|
|
_spec.AddField(epicherouserbuild.FieldHeroAttackBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.HeroDefBuild(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedHeroDefBuild(); ok {
|
|
_spec.AddField(epicherouserbuild.FieldHeroDefBuild, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.Creator(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldCreator, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CreateTime(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldCreateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CreateTimeCleared() {
|
|
_spec.ClearField(epicherouserbuild.FieldCreateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Updater(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldUpdater, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdateTime(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldUpdateTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdateTimeCleared() {
|
|
_spec.ClearField(epicherouserbuild.FieldUpdateTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.Deleted(); ok {
|
|
_spec.SetField(epicherouserbuild.FieldDeleted, field.TypeBool, value)
|
|
}
|
|
_node = &EpicHeroUserBuild{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{epicherouserbuild.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|