Added password token entity.
This commit is contained in:
parent
1ac68b7d9f
commit
c9d50cb3d4
25 changed files with 3489 additions and 20 deletions
|
|
@ -5,6 +5,7 @@ package ent
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"goweb/ent/passwordtoken"
|
||||
"goweb/ent/predicate"
|
||||
"goweb/ent/user"
|
||||
|
||||
|
|
@ -44,11 +45,47 @@ func (uu *UserUpdate) SetPassword(s string) *UserUpdate {
|
|||
return uu
|
||||
}
|
||||
|
||||
// AddOwnerIDs adds the "owner" edge to the PasswordToken entity by IDs.
|
||||
func (uu *UserUpdate) AddOwnerIDs(ids ...int) *UserUpdate {
|
||||
uu.mutation.AddOwnerIDs(ids...)
|
||||
return uu
|
||||
}
|
||||
|
||||
// AddOwner adds the "owner" edges to the PasswordToken entity.
|
||||
func (uu *UserUpdate) AddOwner(p ...*PasswordToken) *UserUpdate {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return uu.AddOwnerIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uu *UserUpdate) Mutation() *UserMutation {
|
||||
return uu.mutation
|
||||
}
|
||||
|
||||
// ClearOwner clears all "owner" edges to the PasswordToken entity.
|
||||
func (uu *UserUpdate) ClearOwner() *UserUpdate {
|
||||
uu.mutation.ClearOwner()
|
||||
return uu
|
||||
}
|
||||
|
||||
// RemoveOwnerIDs removes the "owner" edge to PasswordToken entities by IDs.
|
||||
func (uu *UserUpdate) RemoveOwnerIDs(ids ...int) *UserUpdate {
|
||||
uu.mutation.RemoveOwnerIDs(ids...)
|
||||
return uu
|
||||
}
|
||||
|
||||
// RemoveOwner removes "owner" edges to PasswordToken entities.
|
||||
func (uu *UserUpdate) RemoveOwner(p ...*PasswordToken) *UserUpdate {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return uu.RemoveOwnerIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (uu *UserUpdate) Save(ctx context.Context) (int, error) {
|
||||
var (
|
||||
|
|
@ -168,6 +205,60 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
Column: user.FieldPassword,
|
||||
})
|
||||
}
|
||||
if uu.mutation.OwnerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: true,
|
||||
Table: user.OwnerTable,
|
||||
Columns: []string{user.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uu.mutation.RemovedOwnerIDs(); len(nodes) > 0 && !uu.mutation.OwnerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: true,
|
||||
Table: user.OwnerTable,
|
||||
Columns: []string{user.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uu.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: true,
|
||||
Table: user.OwnerTable,
|
||||
Columns: []string{user.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
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, uu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{user.Label}
|
||||
|
|
@ -205,11 +296,47 @@ func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne {
|
|||
return uuo
|
||||
}
|
||||
|
||||
// AddOwnerIDs adds the "owner" edge to the PasswordToken entity by IDs.
|
||||
func (uuo *UserUpdateOne) AddOwnerIDs(ids ...int) *UserUpdateOne {
|
||||
uuo.mutation.AddOwnerIDs(ids...)
|
||||
return uuo
|
||||
}
|
||||
|
||||
// AddOwner adds the "owner" edges to the PasswordToken entity.
|
||||
func (uuo *UserUpdateOne) AddOwner(p ...*PasswordToken) *UserUpdateOne {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return uuo.AddOwnerIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (uuo *UserUpdateOne) Mutation() *UserMutation {
|
||||
return uuo.mutation
|
||||
}
|
||||
|
||||
// ClearOwner clears all "owner" edges to the PasswordToken entity.
|
||||
func (uuo *UserUpdateOne) ClearOwner() *UserUpdateOne {
|
||||
uuo.mutation.ClearOwner()
|
||||
return uuo
|
||||
}
|
||||
|
||||
// RemoveOwnerIDs removes the "owner" edge to PasswordToken entities by IDs.
|
||||
func (uuo *UserUpdateOne) RemoveOwnerIDs(ids ...int) *UserUpdateOne {
|
||||
uuo.mutation.RemoveOwnerIDs(ids...)
|
||||
return uuo
|
||||
}
|
||||
|
||||
// RemoveOwner removes "owner" edges to PasswordToken entities.
|
||||
func (uuo *UserUpdateOne) RemoveOwner(p ...*PasswordToken) *UserUpdateOne {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return uuo.RemoveOwnerIDs(ids...)
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne {
|
||||
|
|
@ -353,6 +480,60 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
|||
Column: user.FieldPassword,
|
||||
})
|
||||
}
|
||||
if uuo.mutation.OwnerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: true,
|
||||
Table: user.OwnerTable,
|
||||
Columns: []string{user.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uuo.mutation.RemovedOwnerIDs(); len(nodes) > 0 && !uuo.mutation.OwnerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: true,
|
||||
Table: user.OwnerTable,
|
||||
Columns: []string{user.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := uuo.mutation.OwnerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: true,
|
||||
Table: user.OwnerTable,
|
||||
Columns: []string{user.OwnerColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Column: passwordtoken.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &User{config: uuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue