Files
likedream/internal/ent/sysrole_create.go
T
2025-10-26 18:57:08 +08:00

803 lines
22 KiB
Go

// ENT数据库文件,请勿编辑。
package ent
import (
"context"
"errors"
"fmt"
"likedream-goframe/internal/ent/sysmenu"
"likedream-goframe/internal/ent/sysrole"
"likedream-goframe/internal/ent/sysuser"
"likedream-goframe/internal/framework/ent2"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// SysRoleCreate is the builder for creating a SysRole entity.
type SysRoleCreate struct {
config
mutation *SysRoleMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreateTime sets the "create_time" field.
func (_c *SysRoleCreate) SetCreateTime(v *ent2.CustomTime) *SysRoleCreate {
_c.mutation.SetCreateTime(v)
return _c
}
// SetUpdateTime sets the "update_time" field.
func (_c *SysRoleCreate) SetUpdateTime(v *ent2.CustomTime) *SysRoleCreate {
_c.mutation.SetUpdateTime(v)
return _c
}
// SetLabel sets the "label" field.
func (_c *SysRoleCreate) SetLabel(v string) *SysRoleCreate {
_c.mutation.SetLabel(v)
return _c
}
// SetName sets the "name" field.
func (_c *SysRoleCreate) SetName(v string) *SysRoleCreate {
_c.mutation.SetName(v)
return _c
}
// SetDescription sets the "description" field.
func (_c *SysRoleCreate) SetDescription(v string) *SysRoleCreate {
_c.mutation.SetDescription(v)
return _c
}
// SetOrder sets the "order" field.
func (_c *SysRoleCreate) SetOrder(v uint) *SysRoleCreate {
_c.mutation.SetOrder(v)
return _c
}
// AddMenuIDs adds the "menus" edge to the SysMenu entity by IDs.
func (_c *SysRoleCreate) AddMenuIDs(ids ...int64) *SysRoleCreate {
_c.mutation.AddMenuIDs(ids...)
return _c
}
// AddMenus adds the "menus" edges to the SysMenu entity.
func (_c *SysRoleCreate) AddMenus(v ...*SysMenu) *SysRoleCreate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddMenuIDs(ids...)
}
// AddUserIDs adds the "users" edge to the SysUser entity by IDs.
func (_c *SysRoleCreate) AddUserIDs(ids ...int64) *SysRoleCreate {
_c.mutation.AddUserIDs(ids...)
return _c
}
// AddUsers adds the "users" edges to the SysUser entity.
func (_c *SysRoleCreate) AddUsers(v ...*SysUser) *SysRoleCreate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddUserIDs(ids...)
}
// Mutation returns the SysRoleMutation object of the builder.
func (_c *SysRoleCreate) Mutation() *SysRoleMutation {
return _c.mutation
}
// Save creates the SysRole in the database.
func (_c *SysRoleCreate) Save(ctx context.Context) (*SysRole, error) {
if err := _c.defaults(); err != nil {
return nil, err
}
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *SysRoleCreate) SaveX(ctx context.Context) *SysRole {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SysRoleCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SysRoleCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *SysRoleCreate) defaults() error {
if _, ok := _c.mutation.CreateTime(); !ok {
if sysrole.DefaultCreateTime == nil {
return fmt.Errorf("ent: uninitialized sysrole.DefaultCreateTime (forgotten import ent/runtime?)")
}
v := sysrole.DefaultCreateTime()
_c.mutation.SetCreateTime(v)
}
if _, ok := _c.mutation.UpdateTime(); !ok {
if sysrole.DefaultUpdateTime == nil {
return fmt.Errorf("ent: uninitialized sysrole.DefaultUpdateTime (forgotten import ent/runtime?)")
}
v := sysrole.DefaultUpdateTime()
_c.mutation.SetUpdateTime(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (_c *SysRoleCreate) check() error {
if _, ok := _c.mutation.CreateTime(); !ok {
return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "SysRole.create_time"`)}
}
if _, ok := _c.mutation.UpdateTime(); !ok {
return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "SysRole.update_time"`)}
}
if _, ok := _c.mutation.Label(); !ok {
return &ValidationError{Name: "label", err: errors.New(`ent: missing required field "SysRole.label"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "SysRole.name"`)}
}
if _, ok := _c.mutation.Description(); !ok {
return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "SysRole.description"`)}
}
if _, ok := _c.mutation.Order(); !ok {
return &ValidationError{Name: "order", err: errors.New(`ent: missing required field "SysRole.order"`)}
}
return nil
}
func (_c *SysRoleCreate) sqlSave(ctx context.Context) (*SysRole, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *SysRoleCreate) createSpec() (*SysRole, *sqlgraph.CreateSpec) {
var (
_node = &SysRole{config: _c.config}
_spec = sqlgraph.NewCreateSpec(sysrole.Table, sqlgraph.NewFieldSpec(sysrole.FieldID, field.TypeInt64))
)
_spec.Schema = _c.schemaConfig.SysRole
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.CreateTime(); ok {
_spec.SetField(sysrole.FieldCreateTime, field.TypeString, value)
_node.CreateTime = value
}
if value, ok := _c.mutation.UpdateTime(); ok {
_spec.SetField(sysrole.FieldUpdateTime, field.TypeString, value)
_node.UpdateTime = value
}
if value, ok := _c.mutation.Label(); ok {
_spec.SetField(sysrole.FieldLabel, field.TypeString, value)
_node.Label = value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(sysrole.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Description(); ok {
_spec.SetField(sysrole.FieldDescription, field.TypeString, value)
_node.Description = value
}
if value, ok := _c.mutation.Order(); ok {
_spec.SetField(sysrole.FieldOrder, field.TypeUint, value)
_node.Order = value
}
if nodes := _c.mutation.MenusIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: sysrole.MenusTable,
Columns: sysrole.MenusPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(sysmenu.FieldID, field.TypeInt64),
},
}
edge.Schema = _c.schemaConfig.SysRoleMenus
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: true,
Table: sysrole.UsersTable,
Columns: sysrole.UsersPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(sysuser.FieldID, field.TypeInt64),
},
}
edge.Schema = _c.schemaConfig.SysUserRoles
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SysRole.Create().
// SetCreateTime(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.SysRoleUpsert) {
// SetCreateTime(v+v).
// }).
// Exec(ctx)
func (_c *SysRoleCreate) OnConflict(opts ...sql.ConflictOption) *SysRoleUpsertOne {
_c.conflict = opts
return &SysRoleUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SysRole.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SysRoleCreate) OnConflictColumns(columns ...string) *SysRoleUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SysRoleUpsertOne{
create: _c,
}
}
type (
// SysRoleUpsertOne is the builder for "upsert"-ing
// one SysRole node.
SysRoleUpsertOne struct {
create *SysRoleCreate
}
// SysRoleUpsert is the "OnConflict" setter.
SysRoleUpsert struct {
*sql.UpdateSet
}
)
// SetUpdateTime sets the "update_time" field.
func (u *SysRoleUpsert) SetUpdateTime(v *ent2.CustomTime) *SysRoleUpsert {
u.Set(sysrole.FieldUpdateTime, v)
return u
}
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *SysRoleUpsert) UpdateUpdateTime() *SysRoleUpsert {
u.SetExcluded(sysrole.FieldUpdateTime)
return u
}
// SetLabel sets the "label" field.
func (u *SysRoleUpsert) SetLabel(v string) *SysRoleUpsert {
u.Set(sysrole.FieldLabel, v)
return u
}
// UpdateLabel sets the "label" field to the value that was provided on create.
func (u *SysRoleUpsert) UpdateLabel() *SysRoleUpsert {
u.SetExcluded(sysrole.FieldLabel)
return u
}
// SetName sets the "name" field.
func (u *SysRoleUpsert) SetName(v string) *SysRoleUpsert {
u.Set(sysrole.FieldName, v)
return u
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *SysRoleUpsert) UpdateName() *SysRoleUpsert {
u.SetExcluded(sysrole.FieldName)
return u
}
// SetDescription sets the "description" field.
func (u *SysRoleUpsert) SetDescription(v string) *SysRoleUpsert {
u.Set(sysrole.FieldDescription, v)
return u
}
// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *SysRoleUpsert) UpdateDescription() *SysRoleUpsert {
u.SetExcluded(sysrole.FieldDescription)
return u
}
// SetOrder sets the "order" field.
func (u *SysRoleUpsert) SetOrder(v uint) *SysRoleUpsert {
u.Set(sysrole.FieldOrder, v)
return u
}
// UpdateOrder sets the "order" field to the value that was provided on create.
func (u *SysRoleUpsert) UpdateOrder() *SysRoleUpsert {
u.SetExcluded(sysrole.FieldOrder)
return u
}
// AddOrder adds v to the "order" field.
func (u *SysRoleUpsert) AddOrder(v uint) *SysRoleUpsert {
u.Add(sysrole.FieldOrder, v)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.SysRole.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SysRoleUpsertOne) UpdateNewValues() *SysRoleUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.CreateTime(); exists {
s.SetIgnore(sysrole.FieldCreateTime)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SysRole.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SysRoleUpsertOne) Ignore() *SysRoleUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *SysRoleUpsertOne) DoNothing() *SysRoleUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SysRoleCreate.OnConflict
// documentation for more info.
func (u *SysRoleUpsertOne) Update(set func(*SysRoleUpsert)) *SysRoleUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SysRoleUpsert{UpdateSet: update})
}))
return u
}
// SetUpdateTime sets the "update_time" field.
func (u *SysRoleUpsertOne) SetUpdateTime(v *ent2.CustomTime) *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.SetUpdateTime(v)
})
}
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *SysRoleUpsertOne) UpdateUpdateTime() *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateUpdateTime()
})
}
// SetLabel sets the "label" field.
func (u *SysRoleUpsertOne) SetLabel(v string) *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.SetLabel(v)
})
}
// UpdateLabel sets the "label" field to the value that was provided on create.
func (u *SysRoleUpsertOne) UpdateLabel() *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateLabel()
})
}
// SetName sets the "name" field.
func (u *SysRoleUpsertOne) SetName(v string) *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.SetName(v)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *SysRoleUpsertOne) UpdateName() *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateName()
})
}
// SetDescription sets the "description" field.
func (u *SysRoleUpsertOne) SetDescription(v string) *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.SetDescription(v)
})
}
// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *SysRoleUpsertOne) UpdateDescription() *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateDescription()
})
}
// SetOrder sets the "order" field.
func (u *SysRoleUpsertOne) SetOrder(v uint) *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.SetOrder(v)
})
}
// AddOrder adds v to the "order" field.
func (u *SysRoleUpsertOne) AddOrder(v uint) *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.AddOrder(v)
})
}
// UpdateOrder sets the "order" field to the value that was provided on create.
func (u *SysRoleUpsertOne) UpdateOrder() *SysRoleUpsertOne {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateOrder()
})
}
// Exec executes the query.
func (u *SysRoleUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SysRoleCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SysRoleUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *SysRoleUpsertOne) ID(ctx context.Context) (id int64, err error) {
node, err := u.create.Save(ctx)
if err != nil {
return id, err
}
return node.ID, nil
}
// IDX is like ID, but panics if an error occurs.
func (u *SysRoleUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// SysRoleCreateBulk is the builder for creating many SysRole entities in bulk.
type SysRoleCreateBulk struct {
config
err error
builders []*SysRoleCreate
conflict []sql.ConflictOption
}
// Save creates the SysRole entities in the database.
func (_c *SysRoleCreateBulk) Save(ctx context.Context) ([]*SysRole, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*SysRole, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SysRoleMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *SysRoleCreateBulk) SaveX(ctx context.Context) []*SysRole {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SysRoleCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SysRoleCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SysRole.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.SysRoleUpsert) {
// SetCreateTime(v+v).
// }).
// Exec(ctx)
func (_c *SysRoleCreateBulk) OnConflict(opts ...sql.ConflictOption) *SysRoleUpsertBulk {
_c.conflict = opts
return &SysRoleUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SysRole.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SysRoleCreateBulk) OnConflictColumns(columns ...string) *SysRoleUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SysRoleUpsertBulk{
create: _c,
}
}
// SysRoleUpsertBulk is the builder for "upsert"-ing
// a bulk of SysRole nodes.
type SysRoleUpsertBulk struct {
create *SysRoleCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.SysRole.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SysRoleUpsertBulk) UpdateNewValues() *SysRoleUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders {
if _, exists := b.mutation.CreateTime(); exists {
s.SetIgnore(sysrole.FieldCreateTime)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SysRole.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SysRoleUpsertBulk) Ignore() *SysRoleUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *SysRoleUpsertBulk) DoNothing() *SysRoleUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SysRoleCreateBulk.OnConflict
// documentation for more info.
func (u *SysRoleUpsertBulk) Update(set func(*SysRoleUpsert)) *SysRoleUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SysRoleUpsert{UpdateSet: update})
}))
return u
}
// SetUpdateTime sets the "update_time" field.
func (u *SysRoleUpsertBulk) SetUpdateTime(v *ent2.CustomTime) *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.SetUpdateTime(v)
})
}
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *SysRoleUpsertBulk) UpdateUpdateTime() *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateUpdateTime()
})
}
// SetLabel sets the "label" field.
func (u *SysRoleUpsertBulk) SetLabel(v string) *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.SetLabel(v)
})
}
// UpdateLabel sets the "label" field to the value that was provided on create.
func (u *SysRoleUpsertBulk) UpdateLabel() *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateLabel()
})
}
// SetName sets the "name" field.
func (u *SysRoleUpsertBulk) SetName(v string) *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.SetName(v)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *SysRoleUpsertBulk) UpdateName() *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateName()
})
}
// SetDescription sets the "description" field.
func (u *SysRoleUpsertBulk) SetDescription(v string) *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.SetDescription(v)
})
}
// UpdateDescription sets the "description" field to the value that was provided on create.
func (u *SysRoleUpsertBulk) UpdateDescription() *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateDescription()
})
}
// SetOrder sets the "order" field.
func (u *SysRoleUpsertBulk) SetOrder(v uint) *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.SetOrder(v)
})
}
// AddOrder adds v to the "order" field.
func (u *SysRoleUpsertBulk) AddOrder(v uint) *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.AddOrder(v)
})
}
// UpdateOrder sets the "order" field to the value that was provided on create.
func (u *SysRoleUpsertBulk) UpdateOrder() *SysRoleUpsertBulk {
return u.Update(func(s *SysRoleUpsert) {
s.UpdateOrder()
})
}
// Exec executes the query.
func (u *SysRoleUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil {
return u.create.err
}
for i, b := range u.create.builders {
if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the SysRoleCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SysRoleCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SysRoleUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}