regenerate ent

This commit is contained in:
2025-10-26 05:09:47 +01:00
parent 5358d9dd0f
commit ab8b0b983c
46 changed files with 6050 additions and 5607 deletions

View File

@@ -21,61 +21,61 @@ type WeaponCreate struct {
}
// SetVictim sets the "victim" field.
func (wc *WeaponCreate) SetVictim(u uint64) *WeaponCreate {
wc.mutation.SetVictim(u)
return wc
func (_c *WeaponCreate) SetVictim(v uint64) *WeaponCreate {
_c.mutation.SetVictim(v)
return _c
}
// SetDmg sets the "dmg" field.
func (wc *WeaponCreate) SetDmg(u uint) *WeaponCreate {
wc.mutation.SetDmg(u)
return wc
func (_c *WeaponCreate) SetDmg(v uint) *WeaponCreate {
_c.mutation.SetDmg(v)
return _c
}
// SetEqType sets the "eq_type" field.
func (wc *WeaponCreate) SetEqType(i int) *WeaponCreate {
wc.mutation.SetEqType(i)
return wc
func (_c *WeaponCreate) SetEqType(v int) *WeaponCreate {
_c.mutation.SetEqType(v)
return _c
}
// SetHitGroup sets the "hit_group" field.
func (wc *WeaponCreate) SetHitGroup(i int) *WeaponCreate {
wc.mutation.SetHitGroup(i)
return wc
func (_c *WeaponCreate) SetHitGroup(v int) *WeaponCreate {
_c.mutation.SetHitGroup(v)
return _c
}
// SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
func (wc *WeaponCreate) SetStatID(id int) *WeaponCreate {
wc.mutation.SetStatID(id)
return wc
func (_c *WeaponCreate) SetStatID(id int) *WeaponCreate {
_c.mutation.SetStatID(id)
return _c
}
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil.
func (wc *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate {
func (_c *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate {
if id != nil {
wc = wc.SetStatID(*id)
_c = _c.SetStatID(*id)
}
return wc
return _c
}
// SetStat sets the "stat" edge to the MatchPlayer entity.
func (wc *WeaponCreate) SetStat(m *MatchPlayer) *WeaponCreate {
return wc.SetStatID(m.ID)
func (_c *WeaponCreate) SetStat(v *MatchPlayer) *WeaponCreate {
return _c.SetStatID(v.ID)
}
// Mutation returns the WeaponMutation object of the builder.
func (wc *WeaponCreate) Mutation() *WeaponMutation {
return wc.mutation
func (_c *WeaponCreate) Mutation() *WeaponMutation {
return _c.mutation
}
// Save creates the Weapon in the database.
func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
func (_c *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon {
v, err := wc.Save(ctx)
func (_c *WeaponCreate) SaveX(ctx context.Context) *Weapon {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
@@ -83,41 +83,41 @@ func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon {
}
// Exec executes the query.
func (wc *WeaponCreate) Exec(ctx context.Context) error {
_, err := wc.Save(ctx)
func (_c *WeaponCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (wc *WeaponCreate) ExecX(ctx context.Context) {
if err := wc.Exec(ctx); err != nil {
func (_c *WeaponCreate) 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 (wc *WeaponCreate) check() error {
if _, ok := wc.mutation.Victim(); !ok {
func (_c *WeaponCreate) check() error {
if _, ok := _c.mutation.Victim(); !ok {
return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "Weapon.victim"`)}
}
if _, ok := wc.mutation.Dmg(); !ok {
if _, ok := _c.mutation.Dmg(); !ok {
return &ValidationError{Name: "dmg", err: errors.New(`ent: missing required field "Weapon.dmg"`)}
}
if _, ok := wc.mutation.EqType(); !ok {
if _, ok := _c.mutation.EqType(); !ok {
return &ValidationError{Name: "eq_type", err: errors.New(`ent: missing required field "Weapon.eq_type"`)}
}
if _, ok := wc.mutation.HitGroup(); !ok {
if _, ok := _c.mutation.HitGroup(); !ok {
return &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "Weapon.hit_group"`)}
}
return nil
}
func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
if err := wc.check(); err != nil {
func (_c *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := wc.createSpec()
if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
_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}
}
@@ -125,33 +125,33 @@ func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
}
id := _spec.ID.Value.(int64)
_node.ID = int(id)
wc.mutation.id = &_node.ID
wc.mutation.done = true
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
func (_c *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
var (
_node = &Weapon{config: wc.config}
_node = &Weapon{config: _c.config}
_spec = sqlgraph.NewCreateSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
)
if value, ok := wc.mutation.Victim(); ok {
if value, ok := _c.mutation.Victim(); ok {
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
_node.Victim = value
}
if value, ok := wc.mutation.Dmg(); ok {
if value, ok := _c.mutation.Dmg(); ok {
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
_node.Dmg = value
}
if value, ok := wc.mutation.EqType(); ok {
if value, ok := _c.mutation.EqType(); ok {
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
_node.EqType = value
}
if value, ok := wc.mutation.HitGroup(); ok {
if value, ok := _c.mutation.HitGroup(); ok {
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
_node.HitGroup = value
}
if nodes := wc.mutation.StatIDs(); len(nodes) > 0 {
if nodes := _c.mutation.StatIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
@@ -174,17 +174,21 @@ func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
// WeaponCreateBulk is the builder for creating many Weapon entities in bulk.
type WeaponCreateBulk struct {
config
err error
builders []*WeaponCreate
}
// Save creates the Weapon entities in the database.
func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
nodes := make([]*Weapon, len(wcb.builders))
mutators := make([]Mutator, len(wcb.builders))
for i := range wcb.builders {
func (_c *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*Weapon, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := wcb.builders[i]
builder := _c.builders[i]
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*WeaponMutation)
if !ok {
@@ -197,11 +201,11 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
_, 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, wcb.driver, spec); err != nil {
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
@@ -225,7 +229,7 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
@@ -233,8 +237,8 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
}
// SaveX is like Save, but panics if an error occurs.
func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
v, err := wcb.Save(ctx)
func (_c *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
@@ -242,14 +246,14 @@ func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
}
// Exec executes the query.
func (wcb *WeaponCreateBulk) Exec(ctx context.Context) error {
_, err := wcb.Save(ctx)
func (_c *WeaponCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (wcb *WeaponCreateBulk) ExecX(ctx context.Context) {
if err := wcb.Exec(ctx); err != nil {
func (_c *WeaponCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}