534 lines
17 KiB
Go
534 lines
17 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"schisandra-album-cloud-microservices/common/ent/predicate"
|
|
"schisandra-album-cloud-microservices/common/ent/scaauthpermissionrule"
|
|
"schisandra-album-cloud-microservices/common/ent/scaauthrole"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// ScaAuthRoleUpdate is the builder for updating ScaAuthRole entities.
|
|
type ScaAuthRoleUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ScaAuthRoleMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
|
|
func (saru *ScaAuthRoleUpdate) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdate {
|
|
saru.mutation.Where(ps...)
|
|
return saru
|
|
}
|
|
|
|
// SetRoleName sets the "role_name" field.
|
|
func (saru *ScaAuthRoleUpdate) SetRoleName(s string) *ScaAuthRoleUpdate {
|
|
saru.mutation.SetRoleName(s)
|
|
return saru
|
|
}
|
|
|
|
// SetNillableRoleName sets the "role_name" field if the given value is not nil.
|
|
func (saru *ScaAuthRoleUpdate) SetNillableRoleName(s *string) *ScaAuthRoleUpdate {
|
|
if s != nil {
|
|
saru.SetRoleName(*s)
|
|
}
|
|
return saru
|
|
}
|
|
|
|
// SetRoleKey sets the "role_key" field.
|
|
func (saru *ScaAuthRoleUpdate) SetRoleKey(s string) *ScaAuthRoleUpdate {
|
|
saru.mutation.SetRoleKey(s)
|
|
return saru
|
|
}
|
|
|
|
// SetNillableRoleKey sets the "role_key" field if the given value is not nil.
|
|
func (saru *ScaAuthRoleUpdate) SetNillableRoleKey(s *string) *ScaAuthRoleUpdate {
|
|
if s != nil {
|
|
saru.SetRoleKey(*s)
|
|
}
|
|
return saru
|
|
}
|
|
|
|
// SetUpdateAt sets the "update_at" field.
|
|
func (saru *ScaAuthRoleUpdate) SetUpdateAt(t time.Time) *ScaAuthRoleUpdate {
|
|
saru.mutation.SetUpdateAt(t)
|
|
return saru
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (saru *ScaAuthRoleUpdate) SetDeleted(i int) *ScaAuthRoleUpdate {
|
|
saru.mutation.ResetDeleted()
|
|
saru.mutation.SetDeleted(i)
|
|
return saru
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (saru *ScaAuthRoleUpdate) SetNillableDeleted(i *int) *ScaAuthRoleUpdate {
|
|
if i != nil {
|
|
saru.SetDeleted(*i)
|
|
}
|
|
return saru
|
|
}
|
|
|
|
// AddDeleted adds i to the "deleted" field.
|
|
func (saru *ScaAuthRoleUpdate) AddDeleted(i int) *ScaAuthRoleUpdate {
|
|
saru.mutation.AddDeleted(i)
|
|
return saru
|
|
}
|
|
|
|
// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
|
|
func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate {
|
|
saru.mutation.AddScaAuthPermissionRuleIDs(ids...)
|
|
return saru
|
|
}
|
|
|
|
// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
|
func (saru *ScaAuthRoleUpdate) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate {
|
|
ids := make([]int64, len(s))
|
|
for i := range s {
|
|
ids[i] = s[i].ID
|
|
}
|
|
return saru.AddScaAuthPermissionRuleIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ScaAuthRoleMutation object of the builder.
|
|
func (saru *ScaAuthRoleUpdate) Mutation() *ScaAuthRoleMutation {
|
|
return saru.mutation
|
|
}
|
|
|
|
// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
|
func (saru *ScaAuthRoleUpdate) ClearScaAuthPermissionRule() *ScaAuthRoleUpdate {
|
|
saru.mutation.ClearScaAuthPermissionRule()
|
|
return saru
|
|
}
|
|
|
|
// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs.
|
|
func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdate {
|
|
saru.mutation.RemoveScaAuthPermissionRuleIDs(ids...)
|
|
return saru
|
|
}
|
|
|
|
// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities.
|
|
func (saru *ScaAuthRoleUpdate) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdate {
|
|
ids := make([]int64, len(s))
|
|
for i := range s {
|
|
ids[i] = s[i].ID
|
|
}
|
|
return saru.RemoveScaAuthPermissionRuleIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (saru *ScaAuthRoleUpdate) Save(ctx context.Context) (int, error) {
|
|
saru.defaults()
|
|
return withHooks(ctx, saru.sqlSave, saru.mutation, saru.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (saru *ScaAuthRoleUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := saru.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (saru *ScaAuthRoleUpdate) Exec(ctx context.Context) error {
|
|
_, err := saru.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (saru *ScaAuthRoleUpdate) ExecX(ctx context.Context) {
|
|
if err := saru.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (saru *ScaAuthRoleUpdate) defaults() {
|
|
if _, ok := saru.mutation.UpdateAt(); !ok {
|
|
v := scaauthrole.UpdateDefaultUpdateAt()
|
|
saru.mutation.SetUpdateAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (saru *ScaAuthRoleUpdate) check() error {
|
|
if v, ok := saru.mutation.RoleName(); ok {
|
|
if err := scaauthrole.RoleNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := saru.mutation.RoleKey(); ok {
|
|
if err := scaauthrole.RoleKeyValidator(v); err != nil {
|
|
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (saru *ScaAuthRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
if err := saru.check(); err != nil {
|
|
return n, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
|
|
if ps := saru.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := saru.mutation.RoleName(); ok {
|
|
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
|
|
}
|
|
if value, ok := saru.mutation.RoleKey(); ok {
|
|
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
|
|
}
|
|
if value, ok := saru.mutation.UpdateAt(); ok {
|
|
_spec.SetField(scaauthrole.FieldUpdateAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := saru.mutation.Deleted(); ok {
|
|
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if value, ok := saru.mutation.AddedDeleted(); ok {
|
|
_spec.AddField(scaauthrole.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if saru.mutation.ScaAuthPermissionRuleCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
|
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := saru.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saru.mutation.ScaAuthPermissionRuleCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
|
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := saru.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
|
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, saru.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{scaauthrole.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
saru.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// ScaAuthRoleUpdateOne is the builder for updating a single ScaAuthRole entity.
|
|
type ScaAuthRoleUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *ScaAuthRoleMutation
|
|
}
|
|
|
|
// SetRoleName sets the "role_name" field.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetRoleName(s string) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.SetRoleName(s)
|
|
return saruo
|
|
}
|
|
|
|
// SetNillableRoleName sets the "role_name" field if the given value is not nil.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleName(s *string) *ScaAuthRoleUpdateOne {
|
|
if s != nil {
|
|
saruo.SetRoleName(*s)
|
|
}
|
|
return saruo
|
|
}
|
|
|
|
// SetRoleKey sets the "role_key" field.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetRoleKey(s string) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.SetRoleKey(s)
|
|
return saruo
|
|
}
|
|
|
|
// SetNillableRoleKey sets the "role_key" field if the given value is not nil.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetNillableRoleKey(s *string) *ScaAuthRoleUpdateOne {
|
|
if s != nil {
|
|
saruo.SetRoleKey(*s)
|
|
}
|
|
return saruo
|
|
}
|
|
|
|
// SetUpdateAt sets the "update_at" field.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetUpdateAt(t time.Time) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.SetUpdateAt(t)
|
|
return saruo
|
|
}
|
|
|
|
// SetDeleted sets the "deleted" field.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetDeleted(i int) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.ResetDeleted()
|
|
saruo.mutation.SetDeleted(i)
|
|
return saruo
|
|
}
|
|
|
|
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
|
func (saruo *ScaAuthRoleUpdateOne) SetNillableDeleted(i *int) *ScaAuthRoleUpdateOne {
|
|
if i != nil {
|
|
saruo.SetDeleted(*i)
|
|
}
|
|
return saruo
|
|
}
|
|
|
|
// AddDeleted adds i to the "deleted" field.
|
|
func (saruo *ScaAuthRoleUpdateOne) AddDeleted(i int) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.AddDeleted(i)
|
|
return saruo
|
|
}
|
|
|
|
// AddScaAuthPermissionRuleIDs adds the "sca_auth_permission_rule" edge to the ScaAuthPermissionRule entity by IDs.
|
|
func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.AddScaAuthPermissionRuleIDs(ids...)
|
|
return saruo
|
|
}
|
|
|
|
// AddScaAuthPermissionRule adds the "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
|
func (saruo *ScaAuthRoleUpdateOne) AddScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne {
|
|
ids := make([]int64, len(s))
|
|
for i := range s {
|
|
ids[i] = s[i].ID
|
|
}
|
|
return saruo.AddScaAuthPermissionRuleIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the ScaAuthRoleMutation object of the builder.
|
|
func (saruo *ScaAuthRoleUpdateOne) Mutation() *ScaAuthRoleMutation {
|
|
return saruo.mutation
|
|
}
|
|
|
|
// ClearScaAuthPermissionRule clears all "sca_auth_permission_rule" edges to the ScaAuthPermissionRule entity.
|
|
func (saruo *ScaAuthRoleUpdateOne) ClearScaAuthPermissionRule() *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.ClearScaAuthPermissionRule()
|
|
return saruo
|
|
}
|
|
|
|
// RemoveScaAuthPermissionRuleIDs removes the "sca_auth_permission_rule" edge to ScaAuthPermissionRule entities by IDs.
|
|
func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRuleIDs(ids ...int64) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.RemoveScaAuthPermissionRuleIDs(ids...)
|
|
return saruo
|
|
}
|
|
|
|
// RemoveScaAuthPermissionRule removes "sca_auth_permission_rule" edges to ScaAuthPermissionRule entities.
|
|
func (saruo *ScaAuthRoleUpdateOne) RemoveScaAuthPermissionRule(s ...*ScaAuthPermissionRule) *ScaAuthRoleUpdateOne {
|
|
ids := make([]int64, len(s))
|
|
for i := range s {
|
|
ids[i] = s[i].ID
|
|
}
|
|
return saruo.RemoveScaAuthPermissionRuleIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the ScaAuthRoleUpdate builder.
|
|
func (saruo *ScaAuthRoleUpdateOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleUpdateOne {
|
|
saruo.mutation.Where(ps...)
|
|
return saruo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (saruo *ScaAuthRoleUpdateOne) Select(field string, fields ...string) *ScaAuthRoleUpdateOne {
|
|
saruo.fields = append([]string{field}, fields...)
|
|
return saruo
|
|
}
|
|
|
|
// Save executes the query and returns the updated ScaAuthRole entity.
|
|
func (saruo *ScaAuthRoleUpdateOne) Save(ctx context.Context) (*ScaAuthRole, error) {
|
|
saruo.defaults()
|
|
return withHooks(ctx, saruo.sqlSave, saruo.mutation, saruo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (saruo *ScaAuthRoleUpdateOne) SaveX(ctx context.Context) *ScaAuthRole {
|
|
node, err := saruo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (saruo *ScaAuthRoleUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := saruo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (saruo *ScaAuthRoleUpdateOne) ExecX(ctx context.Context) {
|
|
if err := saruo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (saruo *ScaAuthRoleUpdateOne) defaults() {
|
|
if _, ok := saruo.mutation.UpdateAt(); !ok {
|
|
v := scaauthrole.UpdateDefaultUpdateAt()
|
|
saruo.mutation.SetUpdateAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (saruo *ScaAuthRoleUpdateOne) check() error {
|
|
if v, ok := saruo.mutation.RoleName(); ok {
|
|
if err := scaauthrole.RoleNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "role_name", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := saruo.mutation.RoleKey(); ok {
|
|
if err := scaauthrole.RoleKeyValidator(v); err != nil {
|
|
return &ValidationError{Name: "role_key", err: fmt.Errorf(`ent: validator failed for field "ScaAuthRole.role_key": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (saruo *ScaAuthRoleUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthRole, err error) {
|
|
if err := saruo.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(scaauthrole.Table, scaauthrole.Columns, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64))
|
|
id, ok := saruo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthRole.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := saruo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, scaauthrole.FieldID)
|
|
for _, f := range fields {
|
|
if !scaauthrole.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != scaauthrole.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := saruo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := saruo.mutation.RoleName(); ok {
|
|
_spec.SetField(scaauthrole.FieldRoleName, field.TypeString, value)
|
|
}
|
|
if value, ok := saruo.mutation.RoleKey(); ok {
|
|
_spec.SetField(scaauthrole.FieldRoleKey, field.TypeString, value)
|
|
}
|
|
if value, ok := saruo.mutation.UpdateAt(); ok {
|
|
_spec.SetField(scaauthrole.FieldUpdateAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := saruo.mutation.Deleted(); ok {
|
|
_spec.SetField(scaauthrole.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if value, ok := saruo.mutation.AddedDeleted(); ok {
|
|
_spec.AddField(scaauthrole.FieldDeleted, field.TypeInt, value)
|
|
}
|
|
if saruo.mutation.ScaAuthPermissionRuleCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
|
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := saruo.mutation.RemovedScaAuthPermissionRuleIDs(); len(nodes) > 0 && !saruo.mutation.ScaAuthPermissionRuleCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
|
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := saruo.mutation.ScaAuthPermissionRuleIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: scaauthrole.ScaAuthPermissionRuleTable,
|
|
Columns: []string{scaauthrole.ScaAuthPermissionRuleColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(scaauthpermissionrule.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &ScaAuthRole{config: saruo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, saruo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{scaauthrole.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
saruo.mutation.done = true
|
|
return _node, nil
|
|
}
|