2024-02-03 06:48:28 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
2024-02-21 09:16:45 +00:00
|
|
|
"api/ent/ue"
|
|
|
|
"api/ent/user"
|
2024-02-03 06:48:28 +00:00
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
)
|
|
|
|
|
|
|
|
// UeCreate is the builder for creating a Ue entity.
|
|
|
|
type UeCreate struct {
|
|
|
|
config
|
|
|
|
mutation *UeMutation
|
|
|
|
hooks []Hook
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLimit sets the "limit" field.
|
|
|
|
func (uc *UeCreate) SetLimit(b bool) *UeCreate {
|
|
|
|
uc.mutation.SetLimit(b)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLimit sets the "limit" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLimit(b *bool) *UeCreate {
|
|
|
|
if b != nil {
|
|
|
|
uc.SetLimit(*b)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLimitBoss sets the "limit_boss" field.
|
|
|
|
func (uc *UeCreate) SetLimitBoss(b bool) *UeCreate {
|
|
|
|
uc.mutation.SetLimitBoss(b)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLimitBoss sets the "limit_boss" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLimitBoss(b *bool) *UeCreate {
|
|
|
|
if b != nil {
|
|
|
|
uc.SetLimitBoss(*b)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLimitItem sets the "limit_item" field.
|
|
|
|
func (uc *UeCreate) SetLimitItem(b bool) *UeCreate {
|
|
|
|
uc.mutation.SetLimitItem(b)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLimitItem sets the "limit_item" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLimitItem(b *bool) *UeCreate {
|
|
|
|
if b != nil {
|
|
|
|
uc.SetLimitItem(*b)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetPassword sets the "password" field.
|
|
|
|
func (uc *UeCreate) SetPassword(s string) *UeCreate {
|
|
|
|
uc.mutation.SetPassword(s)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLv sets the "lv" field.
|
|
|
|
func (uc *UeCreate) SetLv(i int) *UeCreate {
|
|
|
|
uc.mutation.SetLv(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLv sets the "lv" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLv(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetLv(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLvPoint sets the "lv_point" field.
|
|
|
|
func (uc *UeCreate) SetLvPoint(i int) *UeCreate {
|
|
|
|
uc.mutation.SetLvPoint(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLvPoint sets the "lv_point" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLvPoint(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetLvPoint(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetModel sets the "model" field.
|
|
|
|
func (uc *UeCreate) SetModel(i int) *UeCreate {
|
|
|
|
uc.mutation.SetModel(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableModel sets the "model" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableModel(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetModel(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetSword sets the "sword" field.
|
|
|
|
func (uc *UeCreate) SetSword(i int) *UeCreate {
|
|
|
|
uc.mutation.SetSword(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableSword sets the "sword" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableSword(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetSword(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCard sets the "card" field.
|
|
|
|
func (uc *UeCreate) SetCard(i int) *UeCreate {
|
|
|
|
uc.mutation.SetCard(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableCard sets the "card" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableCard(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetCard(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMode sets the "mode" field.
|
|
|
|
func (uc *UeCreate) SetMode(s string) *UeCreate {
|
|
|
|
uc.mutation.SetMode(s)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableMode sets the "mode" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableMode(s *string) *UeCreate {
|
|
|
|
if s != nil {
|
|
|
|
uc.SetMode(*s)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetToken sets the "token" field.
|
|
|
|
func (uc *UeCreate) SetToken(s string) *UeCreate {
|
|
|
|
uc.mutation.SetToken(s)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableToken sets the "token" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableToken(s *string) *UeCreate {
|
|
|
|
if s != nil {
|
|
|
|
uc.SetToken(*s)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCp sets the "cp" field.
|
|
|
|
func (uc *UeCreate) SetCp(i int) *UeCreate {
|
|
|
|
uc.mutation.SetCp(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableCp sets the "cp" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableCp(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetCp(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCount sets the "count" field.
|
|
|
|
func (uc *UeCreate) SetCount(i int) *UeCreate {
|
|
|
|
uc.mutation.SetCount(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableCount sets the "count" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableCount(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetCount(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLocationX sets the "location_x" field.
|
|
|
|
func (uc *UeCreate) SetLocationX(i int) *UeCreate {
|
|
|
|
uc.mutation.SetLocationX(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLocationX sets the "location_x" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLocationX(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetLocationX(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLocationY sets the "location_y" field.
|
|
|
|
func (uc *UeCreate) SetLocationY(i int) *UeCreate {
|
|
|
|
uc.mutation.SetLocationY(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLocationY sets the "location_y" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLocationY(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetLocationY(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLocationZ sets the "location_z" field.
|
|
|
|
func (uc *UeCreate) SetLocationZ(i int) *UeCreate {
|
|
|
|
uc.mutation.SetLocationZ(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLocationZ sets the "location_z" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLocationZ(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetLocationZ(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLocationN sets the "location_n" field.
|
|
|
|
func (uc *UeCreate) SetLocationN(i int) *UeCreate {
|
|
|
|
uc.mutation.SetLocationN(i)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableLocationN sets the "location_n" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableLocationN(i *int) *UeCreate {
|
|
|
|
if i != nil {
|
|
|
|
uc.SetLocationN(*i)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAuthor sets the "author" field.
|
|
|
|
func (uc *UeCreate) SetAuthor(s string) *UeCreate {
|
|
|
|
uc.mutation.SetAuthor(s)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableAuthor sets the "author" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableAuthor(s *string) *UeCreate {
|
|
|
|
if s != nil {
|
|
|
|
uc.SetAuthor(*s)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
|
|
func (uc *UeCreate) SetCreatedAt(t time.Time) *UeCreate {
|
|
|
|
uc.mutation.SetCreatedAt(t)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
|
|
func (uc *UeCreate) SetNillableCreatedAt(t *time.Time) *UeCreate {
|
|
|
|
if t != nil {
|
|
|
|
uc.SetCreatedAt(*t)
|
|
|
|
}
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOwnerID sets the "owner" edge to the User entity by ID.
|
|
|
|
func (uc *UeCreate) SetOwnerID(id int) *UeCreate {
|
|
|
|
uc.mutation.SetOwnerID(id)
|
|
|
|
return uc
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOwner sets the "owner" edge to the User entity.
|
|
|
|
func (uc *UeCreate) SetOwner(u *User) *UeCreate {
|
|
|
|
return uc.SetOwnerID(u.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mutation returns the UeMutation object of the builder.
|
|
|
|
func (uc *UeCreate) Mutation() *UeMutation {
|
|
|
|
return uc.mutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save creates the Ue in the database.
|
|
|
|
func (uc *UeCreate) Save(ctx context.Context) (*Ue, error) {
|
|
|
|
uc.defaults()
|
|
|
|
return withHooks[*Ue, UeMutation](ctx, uc.sqlSave, uc.mutation, uc.hooks)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
|
|
func (uc *UeCreate) SaveX(ctx context.Context) *Ue {
|
|
|
|
v, err := uc.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query.
|
|
|
|
func (uc *UeCreate) Exec(ctx context.Context) error {
|
|
|
|
_, err := uc.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (uc *UeCreate) ExecX(ctx context.Context) {
|
|
|
|
if err := uc.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
|
|
func (uc *UeCreate) defaults() {
|
|
|
|
if _, ok := uc.mutation.Limit(); !ok {
|
|
|
|
v := ue.DefaultLimit
|
|
|
|
uc.mutation.SetLimit(v)
|
|
|
|
}
|
|
|
|
if _, ok := uc.mutation.LimitBoss(); !ok {
|
|
|
|
v := ue.DefaultLimitBoss
|
|
|
|
uc.mutation.SetLimitBoss(v)
|
|
|
|
}
|
|
|
|
if _, ok := uc.mutation.LimitItem(); !ok {
|
|
|
|
v := ue.DefaultLimitItem
|
|
|
|
uc.mutation.SetLimitItem(v)
|
|
|
|
}
|
|
|
|
if _, ok := uc.mutation.CreatedAt(); !ok {
|
|
|
|
v := ue.DefaultCreatedAt()
|
|
|
|
uc.mutation.SetCreatedAt(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
|
|
func (uc *UeCreate) check() error {
|
|
|
|
if _, ok := uc.mutation.Password(); !ok {
|
|
|
|
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Ue.password"`)}
|
|
|
|
}
|
|
|
|
if v, ok := uc.mutation.Password(); ok {
|
|
|
|
if err := ue.PasswordValidator(v); err != nil {
|
|
|
|
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "Ue.password": %w`, err)}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if _, ok := uc.mutation.OwnerID(); !ok {
|
|
|
|
return &ValidationError{Name: "owner", err: errors.New(`ent: missing required edge "Ue.owner"`)}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (uc *UeCreate) sqlSave(ctx context.Context) (*Ue, error) {
|
|
|
|
if err := uc.check(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
_node, _spec := uc.createSpec()
|
|
|
|
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
|
|
|
|
if sqlgraph.IsConstraintError(err) {
|
|
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
id := _spec.ID.Value.(int64)
|
|
|
|
_node.ID = int(id)
|
|
|
|
uc.mutation.id = &_node.ID
|
|
|
|
uc.mutation.done = true
|
|
|
|
return _node, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (uc *UeCreate) createSpec() (*Ue, *sqlgraph.CreateSpec) {
|
|
|
|
var (
|
|
|
|
_node = &Ue{config: uc.config}
|
|
|
|
_spec = sqlgraph.NewCreateSpec(ue.Table, sqlgraph.NewFieldSpec(ue.FieldID, field.TypeInt))
|
|
|
|
)
|
|
|
|
if value, ok := uc.mutation.Limit(); ok {
|
|
|
|
_spec.SetField(ue.FieldLimit, field.TypeBool, value)
|
|
|
|
_node.Limit = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LimitBoss(); ok {
|
|
|
|
_spec.SetField(ue.FieldLimitBoss, field.TypeBool, value)
|
|
|
|
_node.LimitBoss = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LimitItem(); ok {
|
|
|
|
_spec.SetField(ue.FieldLimitItem, field.TypeBool, value)
|
|
|
|
_node.LimitItem = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Password(); ok {
|
|
|
|
_spec.SetField(ue.FieldPassword, field.TypeString, value)
|
|
|
|
_node.Password = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Lv(); ok {
|
|
|
|
_spec.SetField(ue.FieldLv, field.TypeInt, value)
|
|
|
|
_node.Lv = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LvPoint(); ok {
|
|
|
|
_spec.SetField(ue.FieldLvPoint, field.TypeInt, value)
|
|
|
|
_node.LvPoint = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Model(); ok {
|
|
|
|
_spec.SetField(ue.FieldModel, field.TypeInt, value)
|
|
|
|
_node.Model = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Sword(); ok {
|
|
|
|
_spec.SetField(ue.FieldSword, field.TypeInt, value)
|
|
|
|
_node.Sword = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Card(); ok {
|
|
|
|
_spec.SetField(ue.FieldCard, field.TypeInt, value)
|
|
|
|
_node.Card = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Mode(); ok {
|
|
|
|
_spec.SetField(ue.FieldMode, field.TypeString, value)
|
|
|
|
_node.Mode = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Token(); ok {
|
|
|
|
_spec.SetField(ue.FieldToken, field.TypeString, value)
|
|
|
|
_node.Token = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Cp(); ok {
|
|
|
|
_spec.SetField(ue.FieldCp, field.TypeInt, value)
|
|
|
|
_node.Cp = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Count(); ok {
|
|
|
|
_spec.SetField(ue.FieldCount, field.TypeInt, value)
|
|
|
|
_node.Count = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LocationX(); ok {
|
|
|
|
_spec.SetField(ue.FieldLocationX, field.TypeInt, value)
|
|
|
|
_node.LocationX = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LocationY(); ok {
|
|
|
|
_spec.SetField(ue.FieldLocationY, field.TypeInt, value)
|
|
|
|
_node.LocationY = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LocationZ(); ok {
|
|
|
|
_spec.SetField(ue.FieldLocationZ, field.TypeInt, value)
|
|
|
|
_node.LocationZ = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.LocationN(); ok {
|
|
|
|
_spec.SetField(ue.FieldLocationN, field.TypeInt, value)
|
|
|
|
_node.LocationN = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.Author(); ok {
|
|
|
|
_spec.SetField(ue.FieldAuthor, field.TypeString, value)
|
|
|
|
_node.Author = value
|
|
|
|
}
|
|
|
|
if value, ok := uc.mutation.CreatedAt(); ok {
|
|
|
|
_spec.SetField(ue.FieldCreatedAt, field.TypeTime, value)
|
|
|
|
_node.CreatedAt = value
|
|
|
|
}
|
|
|
|
if nodes := uc.mutation.OwnerIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2O,
|
|
|
|
Inverse: true,
|
|
|
|
Table: ue.OwnerTable,
|
|
|
|
Columns: []string{ue.OwnerColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_node.user_ue = &nodes[0]
|
|
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
|
|
}
|
|
|
|
return _node, _spec
|
|
|
|
}
|
|
|
|
|
|
|
|
// UeCreateBulk is the builder for creating many Ue entities in bulk.
|
|
|
|
type UeCreateBulk struct {
|
|
|
|
config
|
|
|
|
builders []*UeCreate
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save creates the Ue entities in the database.
|
|
|
|
func (ucb *UeCreateBulk) Save(ctx context.Context) ([]*Ue, error) {
|
|
|
|
specs := make([]*sqlgraph.CreateSpec, len(ucb.builders))
|
|
|
|
nodes := make([]*Ue, len(ucb.builders))
|
|
|
|
mutators := make([]Mutator, len(ucb.builders))
|
|
|
|
for i := range ucb.builders {
|
|
|
|
func(i int, root context.Context) {
|
|
|
|
builder := ucb.builders[i]
|
|
|
|
builder.defaults()
|
|
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
|
|
mutation, ok := m.(*UeMutation)
|
|
|
|
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
|
2024-03-28 11:42:01 +00:00
|
|
|
nodes[i], specs[i] = builder.createSpec()
|
2024-02-03 06:48:28 +00:00
|
|
|
if i < len(mutators)-1 {
|
|
|
|
_, err = mutators[i+1].Mutate(root, ucb.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, ucb.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 {
|
|
|
|
id := specs[i].ID.Value.(int64)
|
|
|
|
nodes[i].ID = int(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, ucb.builders[0].mutation); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nodes, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (ucb *UeCreateBulk) SaveX(ctx context.Context) []*Ue {
|
|
|
|
v, err := ucb.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query.
|
|
|
|
func (ucb *UeCreateBulk) Exec(ctx context.Context) error {
|
|
|
|
_, err := ucb.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (ucb *UeCreateBulk) ExecX(ctx context.Context) {
|
|
|
|
if err := ucb.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|