本次提交包含多模块功能更新: 1. 权限系统重构:移除硬编码admin放行逻辑,新增精细化权限控制,完善权限树形结构与用户/角色保护 2. 新增物料导入导出接口,补充台账查询条件 3. 优化列表查询排序逻辑,新增区域编码大小写不敏感搜索 4. 修复帮助抽屉重复弹出问题,补充页面权限控制 5. 新增弱密码提示逻辑,优化MES/WMS用户/角色管理权限 6. 调整路由结构,新增权限校验脚本与前端权限树重构 7. 补充数据库字段与依赖包更新
1214 lines
34 KiB
Go
1214 lines
34 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_wms/ent/permission"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// PermissionCreate is the builder for creating a Permission entity.
|
|
type PermissionCreate struct {
|
|
config
|
|
mutation *PermissionMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (_c *PermissionCreate) SetCode(v string) *PermissionCreate {
|
|
_c.mutation.SetCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *PermissionCreate) SetName(v string) *PermissionCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (_c *PermissionCreate) SetType(v string) *PermissionCreate {
|
|
_c.mutation.SetType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableType sets the "type" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableType(v *string) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetParentCode sets the "parent_code" field.
|
|
func (_c *PermissionCreate) SetParentCode(v string) *PermissionCreate {
|
|
_c.mutation.SetParentCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableParentCode sets the "parent_code" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableParentCode(v *string) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetParentCode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPath sets the "path" field.
|
|
func (_c *PermissionCreate) SetPath(v string) *PermissionCreate {
|
|
_c.mutation.SetPath(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePath sets the "path" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillablePath(v *string) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetPath(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetIcon sets the "icon" field.
|
|
func (_c *PermissionCreate) SetIcon(v string) *PermissionCreate {
|
|
_c.mutation.SetIcon(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIcon sets the "icon" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableIcon(v *string) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetIcon(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSort sets the "sort" field.
|
|
func (_c *PermissionCreate) SetSort(v int) *PermissionCreate {
|
|
_c.mutation.SetSort(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSort sets the "sort" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableSort(v *int) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetSort(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_c *PermissionCreate) SetRemark(v string) *PermissionCreate {
|
|
_c.mutation.SetRemark(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableRemark(v *string) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetRemark(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *PermissionCreate) SetCreatedAt(v int64) *PermissionCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableCreatedAt(v *int64) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *PermissionCreate) SetUpdatedAt(v int64) *PermissionCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *PermissionCreate) SetNillableUpdatedAt(v *int64) *PermissionCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the PermissionMutation object of the builder.
|
|
func (_c *PermissionCreate) Mutation() *PermissionMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the Permission in the database.
|
|
func (_c *PermissionCreate) Save(ctx context.Context) (*Permission, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *PermissionCreate) SaveX(ctx context.Context) *Permission {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *PermissionCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *PermissionCreate) 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 *PermissionCreate) defaults() {
|
|
if _, ok := _c.mutation.GetType(); !ok {
|
|
v := permission.DefaultType
|
|
_c.mutation.SetType(v)
|
|
}
|
|
if _, ok := _c.mutation.ParentCode(); !ok {
|
|
v := permission.DefaultParentCode
|
|
_c.mutation.SetParentCode(v)
|
|
}
|
|
if _, ok := _c.mutation.Path(); !ok {
|
|
v := permission.DefaultPath
|
|
_c.mutation.SetPath(v)
|
|
}
|
|
if _, ok := _c.mutation.Icon(); !ok {
|
|
v := permission.DefaultIcon
|
|
_c.mutation.SetIcon(v)
|
|
}
|
|
if _, ok := _c.mutation.Sort(); !ok {
|
|
v := permission.DefaultSort
|
|
_c.mutation.SetSort(v)
|
|
}
|
|
if _, ok := _c.mutation.Remark(); !ok {
|
|
v := permission.DefaultRemark
|
|
_c.mutation.SetRemark(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := permission.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := permission.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *PermissionCreate) check() error {
|
|
if _, ok := _c.mutation.Code(); !ok {
|
|
return &ValidationError{Name: "code", err: errors.New(`ent: missing required field "Permission.code"`)}
|
|
}
|
|
if v, ok := _c.mutation.Code(); ok {
|
|
if err := permission.CodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "code", err: fmt.Errorf(`ent: validator failed for field "Permission.code": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Permission.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := permission.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.GetType(); !ok {
|
|
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Permission.type"`)}
|
|
}
|
|
if v, ok := _c.mutation.GetType(); ok {
|
|
if err := permission.TypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Permission.type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _c.mutation.ParentCode(); ok {
|
|
if err := permission.ParentCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "parent_code", err: fmt.Errorf(`ent: validator failed for field "Permission.parent_code": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _c.mutation.Path(); ok {
|
|
if err := permission.PathValidator(v); err != nil {
|
|
return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Permission.path": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _c.mutation.Icon(); ok {
|
|
if err := permission.IconValidator(v); err != nil {
|
|
return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Permission.icon": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _c.mutation.Remark(); ok {
|
|
if err := permission.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "Permission.remark": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Permission.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Permission.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *PermissionCreate) sqlSave(ctx context.Context) (*Permission, 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 = int(id)
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &Permission{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if value, ok := _c.mutation.Code(); ok {
|
|
_spec.SetField(permission.FieldCode, field.TypeString, value)
|
|
_node.Code = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(permission.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.GetType(); ok {
|
|
_spec.SetField(permission.FieldType, field.TypeString, value)
|
|
_node.Type = value
|
|
}
|
|
if value, ok := _c.mutation.ParentCode(); ok {
|
|
_spec.SetField(permission.FieldParentCode, field.TypeString, value)
|
|
_node.ParentCode = value
|
|
}
|
|
if value, ok := _c.mutation.Path(); ok {
|
|
_spec.SetField(permission.FieldPath, field.TypeString, value)
|
|
_node.Path = value
|
|
}
|
|
if value, ok := _c.mutation.Icon(); ok {
|
|
_spec.SetField(permission.FieldIcon, field.TypeString, value)
|
|
_node.Icon = value
|
|
}
|
|
if value, ok := _c.mutation.Sort(); ok {
|
|
_spec.SetField(permission.FieldSort, field.TypeInt, value)
|
|
_node.Sort = value
|
|
}
|
|
if value, ok := _c.mutation.Remark(); ok {
|
|
_spec.SetField(permission.FieldRemark, field.TypeString, value)
|
|
_node.Remark = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(permission.FieldCreatedAt, field.TypeInt64, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(permission.FieldUpdatedAt, field.TypeInt64, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.Permission.Create().
|
|
// SetCode(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.PermissionUpsert) {
|
|
// SetCode(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *PermissionCreate) OnConflict(opts ...sql.ConflictOption) *PermissionUpsertOne {
|
|
_c.conflict = opts
|
|
return &PermissionUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Permission.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *PermissionCreate) OnConflictColumns(columns ...string) *PermissionUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &PermissionUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// PermissionUpsertOne is the builder for "upsert"-ing
|
|
// one Permission node.
|
|
PermissionUpsertOne struct {
|
|
create *PermissionCreate
|
|
}
|
|
|
|
// PermissionUpsert is the "OnConflict" setter.
|
|
PermissionUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetCode sets the "code" field.
|
|
func (u *PermissionUpsert) SetCode(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCode sets the "code" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateCode() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldCode)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *PermissionUpsert) SetName(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateName() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (u *PermissionUpsert) SetType(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateType sets the "type" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateType() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldType)
|
|
return u
|
|
}
|
|
|
|
// SetParentCode sets the "parent_code" field.
|
|
func (u *PermissionUpsert) SetParentCode(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldParentCode, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateParentCode sets the "parent_code" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateParentCode() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldParentCode)
|
|
return u
|
|
}
|
|
|
|
// ClearParentCode clears the value of the "parent_code" field.
|
|
func (u *PermissionUpsert) ClearParentCode() *PermissionUpsert {
|
|
u.SetNull(permission.FieldParentCode)
|
|
return u
|
|
}
|
|
|
|
// SetPath sets the "path" field.
|
|
func (u *PermissionUpsert) SetPath(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldPath, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePath sets the "path" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdatePath() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldPath)
|
|
return u
|
|
}
|
|
|
|
// ClearPath clears the value of the "path" field.
|
|
func (u *PermissionUpsert) ClearPath() *PermissionUpsert {
|
|
u.SetNull(permission.FieldPath)
|
|
return u
|
|
}
|
|
|
|
// SetIcon sets the "icon" field.
|
|
func (u *PermissionUpsert) SetIcon(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldIcon, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIcon sets the "icon" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateIcon() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldIcon)
|
|
return u
|
|
}
|
|
|
|
// ClearIcon clears the value of the "icon" field.
|
|
func (u *PermissionUpsert) ClearIcon() *PermissionUpsert {
|
|
u.SetNull(permission.FieldIcon)
|
|
return u
|
|
}
|
|
|
|
// SetSort sets the "sort" field.
|
|
func (u *PermissionUpsert) SetSort(v int) *PermissionUpsert {
|
|
u.Set(permission.FieldSort, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateSort sets the "sort" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateSort() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldSort)
|
|
return u
|
|
}
|
|
|
|
// AddSort adds v to the "sort" field.
|
|
func (u *PermissionUpsert) AddSort(v int) *PermissionUpsert {
|
|
u.Add(permission.FieldSort, v)
|
|
return u
|
|
}
|
|
|
|
// ClearSort clears the value of the "sort" field.
|
|
func (u *PermissionUpsert) ClearSort() *PermissionUpsert {
|
|
u.SetNull(permission.FieldSort)
|
|
return u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (u *PermissionUpsert) SetRemark(v string) *PermissionUpsert {
|
|
u.Set(permission.FieldRemark, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRemark sets the "remark" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateRemark() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldRemark)
|
|
return u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (u *PermissionUpsert) ClearRemark() *PermissionUpsert {
|
|
u.SetNull(permission.FieldRemark)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *PermissionUpsert) SetCreatedAt(v int64) *PermissionUpsert {
|
|
u.Set(permission.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateCreatedAt() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *PermissionUpsert) AddCreatedAt(v int64) *PermissionUpsert {
|
|
u.Add(permission.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *PermissionUpsert) SetUpdatedAt(v int64) *PermissionUpsert {
|
|
u.Set(permission.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *PermissionUpsert) UpdateUpdatedAt() *PermissionUpsert {
|
|
u.SetExcluded(permission.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *PermissionUpsert) AddUpdatedAt(v int64) *PermissionUpsert {
|
|
u.Add(permission.FieldUpdatedAt, 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.Permission.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *PermissionUpsertOne) UpdateNewValues() *PermissionUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Permission.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *PermissionUpsertOne) Ignore() *PermissionUpsertOne {
|
|
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 *PermissionUpsertOne) DoNothing() *PermissionUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the PermissionCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *PermissionUpsertOne) Update(set func(*PermissionUpsert)) *PermissionUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&PermissionUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (u *PermissionUpsertOne) SetCode(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCode sets the "code" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateCode() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateCode()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *PermissionUpsertOne) SetName(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateName() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (u *PermissionUpsertOne) SetType(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateType sets the "type" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateType() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateType()
|
|
})
|
|
}
|
|
|
|
// SetParentCode sets the "parent_code" field.
|
|
func (u *PermissionUpsertOne) SetParentCode(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetParentCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateParentCode sets the "parent_code" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateParentCode() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateParentCode()
|
|
})
|
|
}
|
|
|
|
// ClearParentCode clears the value of the "parent_code" field.
|
|
func (u *PermissionUpsertOne) ClearParentCode() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearParentCode()
|
|
})
|
|
}
|
|
|
|
// SetPath sets the "path" field.
|
|
func (u *PermissionUpsertOne) SetPath(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetPath(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePath sets the "path" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdatePath() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdatePath()
|
|
})
|
|
}
|
|
|
|
// ClearPath clears the value of the "path" field.
|
|
func (u *PermissionUpsertOne) ClearPath() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearPath()
|
|
})
|
|
}
|
|
|
|
// SetIcon sets the "icon" field.
|
|
func (u *PermissionUpsertOne) SetIcon(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetIcon(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIcon sets the "icon" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateIcon() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateIcon()
|
|
})
|
|
}
|
|
|
|
// ClearIcon clears the value of the "icon" field.
|
|
func (u *PermissionUpsertOne) ClearIcon() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearIcon()
|
|
})
|
|
}
|
|
|
|
// SetSort sets the "sort" field.
|
|
func (u *PermissionUpsertOne) SetSort(v int) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetSort(v)
|
|
})
|
|
}
|
|
|
|
// AddSort adds v to the "sort" field.
|
|
func (u *PermissionUpsertOne) AddSort(v int) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.AddSort(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSort sets the "sort" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateSort() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateSort()
|
|
})
|
|
}
|
|
|
|
// ClearSort clears the value of the "sort" field.
|
|
func (u *PermissionUpsertOne) ClearSort() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearSort()
|
|
})
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (u *PermissionUpsertOne) SetRemark(v string) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetRemark(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRemark sets the "remark" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateRemark() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateRemark()
|
|
})
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (u *PermissionUpsertOne) ClearRemark() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearRemark()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *PermissionUpsertOne) SetCreatedAt(v int64) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *PermissionUpsertOne) AddCreatedAt(v int64) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.AddCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateCreatedAt() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *PermissionUpsertOne) SetUpdatedAt(v int64) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *PermissionUpsertOne) AddUpdatedAt(v int64) *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.AddUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *PermissionUpsertOne) UpdateUpdatedAt() *PermissionUpsertOne {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *PermissionUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for PermissionCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *PermissionUpsertOne) 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 *PermissionUpsertOne) ID(ctx context.Context) (id int, 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 *PermissionUpsertOne) IDX(ctx context.Context) int {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// PermissionCreateBulk is the builder for creating many Permission entities in bulk.
|
|
type PermissionCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*PermissionCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the Permission entities in the database.
|
|
func (_c *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*Permission, 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.(*PermissionMutation)
|
|
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 = 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, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *PermissionCreateBulk) SaveX(ctx context.Context) []*Permission {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *PermissionCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *PermissionCreateBulk) 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.Permission.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.PermissionUpsert) {
|
|
// SetCode(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *PermissionCreateBulk) OnConflict(opts ...sql.ConflictOption) *PermissionUpsertBulk {
|
|
_c.conflict = opts
|
|
return &PermissionUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.Permission.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *PermissionCreateBulk) OnConflictColumns(columns ...string) *PermissionUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &PermissionUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// PermissionUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of Permission nodes.
|
|
type PermissionUpsertBulk struct {
|
|
create *PermissionCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.Permission.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *PermissionUpsertBulk) UpdateNewValues() *PermissionUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.Permission.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *PermissionUpsertBulk) Ignore() *PermissionUpsertBulk {
|
|
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 *PermissionUpsertBulk) DoNothing() *PermissionUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the PermissionCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *PermissionUpsertBulk) Update(set func(*PermissionUpsert)) *PermissionUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&PermissionUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetCode sets the "code" field.
|
|
func (u *PermissionUpsertBulk) SetCode(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCode sets the "code" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateCode() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateCode()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *PermissionUpsertBulk) SetName(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateName() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (u *PermissionUpsertBulk) SetType(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateType sets the "type" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateType() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateType()
|
|
})
|
|
}
|
|
|
|
// SetParentCode sets the "parent_code" field.
|
|
func (u *PermissionUpsertBulk) SetParentCode(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetParentCode(v)
|
|
})
|
|
}
|
|
|
|
// UpdateParentCode sets the "parent_code" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateParentCode() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateParentCode()
|
|
})
|
|
}
|
|
|
|
// ClearParentCode clears the value of the "parent_code" field.
|
|
func (u *PermissionUpsertBulk) ClearParentCode() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearParentCode()
|
|
})
|
|
}
|
|
|
|
// SetPath sets the "path" field.
|
|
func (u *PermissionUpsertBulk) SetPath(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetPath(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePath sets the "path" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdatePath() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdatePath()
|
|
})
|
|
}
|
|
|
|
// ClearPath clears the value of the "path" field.
|
|
func (u *PermissionUpsertBulk) ClearPath() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearPath()
|
|
})
|
|
}
|
|
|
|
// SetIcon sets the "icon" field.
|
|
func (u *PermissionUpsertBulk) SetIcon(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetIcon(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIcon sets the "icon" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateIcon() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateIcon()
|
|
})
|
|
}
|
|
|
|
// ClearIcon clears the value of the "icon" field.
|
|
func (u *PermissionUpsertBulk) ClearIcon() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearIcon()
|
|
})
|
|
}
|
|
|
|
// SetSort sets the "sort" field.
|
|
func (u *PermissionUpsertBulk) SetSort(v int) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetSort(v)
|
|
})
|
|
}
|
|
|
|
// AddSort adds v to the "sort" field.
|
|
func (u *PermissionUpsertBulk) AddSort(v int) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.AddSort(v)
|
|
})
|
|
}
|
|
|
|
// UpdateSort sets the "sort" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateSort() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateSort()
|
|
})
|
|
}
|
|
|
|
// ClearSort clears the value of the "sort" field.
|
|
func (u *PermissionUpsertBulk) ClearSort() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearSort()
|
|
})
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (u *PermissionUpsertBulk) SetRemark(v string) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetRemark(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRemark sets the "remark" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateRemark() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateRemark()
|
|
})
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (u *PermissionUpsertBulk) ClearRemark() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.ClearRemark()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *PermissionUpsertBulk) SetCreatedAt(v int64) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddCreatedAt adds v to the "created_at" field.
|
|
func (u *PermissionUpsertBulk) AddCreatedAt(v int64) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.AddCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateCreatedAt() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *PermissionUpsertBulk) SetUpdatedAt(v int64) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// AddUpdatedAt adds v to the "updated_at" field.
|
|
func (u *PermissionUpsertBulk) AddUpdatedAt(v int64) *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.AddUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *PermissionUpsertBulk) UpdateUpdatedAt() *PermissionUpsertBulk {
|
|
return u.Update(func(s *PermissionUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *PermissionUpsertBulk) 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 PermissionCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for PermissionCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *PermissionUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|