feat: rebuild auth identity foundation flow
This commit is contained in:
@@ -13,8 +13,10 @@ import (
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/Wei-Shaw/sub2api/ent/announcementread"
|
||||
"github.com/Wei-Shaw/sub2api/ent/apikey"
|
||||
"github.com/Wei-Shaw/sub2api/ent/authidentity"
|
||||
"github.com/Wei-Shaw/sub2api/ent/group"
|
||||
"github.com/Wei-Shaw/sub2api/ent/paymentorder"
|
||||
"github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
|
||||
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
||||
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
|
||||
"github.com/Wei-Shaw/sub2api/ent/redeemcode"
|
||||
@@ -243,6 +245,60 @@ func (_u *UserUpdate) ClearTotpEnabledAt() *UserUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSignupSource sets the "signup_source" field.
|
||||
func (_u *UserUpdate) SetSignupSource(v string) *UserUpdate {
|
||||
_u.mutation.SetSignupSource(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSignupSource sets the "signup_source" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableSignupSource(v *string) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetSignupSource(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastLoginAt sets the "last_login_at" field.
|
||||
func (_u *UserUpdate) SetLastLoginAt(v time.Time) *UserUpdate {
|
||||
_u.mutation.SetLastLoginAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastLoginAt sets the "last_login_at" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableLastLoginAt(v *time.Time) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetLastLoginAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastLoginAt clears the value of the "last_login_at" field.
|
||||
func (_u *UserUpdate) ClearLastLoginAt() *UserUpdate {
|
||||
_u.mutation.ClearLastLoginAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastActiveAt sets the "last_active_at" field.
|
||||
func (_u *UserUpdate) SetLastActiveAt(v time.Time) *UserUpdate {
|
||||
_u.mutation.SetLastActiveAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastActiveAt sets the "last_active_at" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableLastActiveAt(v *time.Time) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetLastActiveAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastActiveAt clears the value of the "last_active_at" field.
|
||||
func (_u *UserUpdate) ClearLastActiveAt() *UserUpdate {
|
||||
_u.mutation.ClearLastActiveAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetBalanceNotifyEnabled sets the "balance_notify_enabled" field.
|
||||
func (_u *UserUpdate) SetBalanceNotifyEnabled(v bool) *UserUpdate {
|
||||
_u.mutation.SetBalanceNotifyEnabled(v)
|
||||
@@ -483,6 +539,36 @@ func (_u *UserUpdate) AddPaymentOrders(v ...*PaymentOrder) *UserUpdate {
|
||||
return _u.AddPaymentOrderIDs(ids...)
|
||||
}
|
||||
|
||||
// AddAuthIdentityIDs adds the "auth_identities" edge to the AuthIdentity entity by IDs.
|
||||
func (_u *UserUpdate) AddAuthIdentityIDs(ids ...int64) *UserUpdate {
|
||||
_u.mutation.AddAuthIdentityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddAuthIdentities adds the "auth_identities" edges to the AuthIdentity entity.
|
||||
func (_u *UserUpdate) AddAuthIdentities(v ...*AuthIdentity) *UserUpdate {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddAuthIdentityIDs(ids...)
|
||||
}
|
||||
|
||||
// AddPendingAuthSessionIDs adds the "pending_auth_sessions" edge to the PendingAuthSession entity by IDs.
|
||||
func (_u *UserUpdate) AddPendingAuthSessionIDs(ids ...int64) *UserUpdate {
|
||||
_u.mutation.AddPendingAuthSessionIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddPendingAuthSessions adds the "pending_auth_sessions" edges to the PendingAuthSession entity.
|
||||
func (_u *UserUpdate) AddPendingAuthSessions(v ...*PendingAuthSession) *UserUpdate {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddPendingAuthSessionIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (_u *UserUpdate) Mutation() *UserMutation {
|
||||
return _u.mutation
|
||||
@@ -698,6 +784,48 @@ func (_u *UserUpdate) RemovePaymentOrders(v ...*PaymentOrder) *UserUpdate {
|
||||
return _u.RemovePaymentOrderIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearAuthIdentities clears all "auth_identities" edges to the AuthIdentity entity.
|
||||
func (_u *UserUpdate) ClearAuthIdentities() *UserUpdate {
|
||||
_u.mutation.ClearAuthIdentities()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveAuthIdentityIDs removes the "auth_identities" edge to AuthIdentity entities by IDs.
|
||||
func (_u *UserUpdate) RemoveAuthIdentityIDs(ids ...int64) *UserUpdate {
|
||||
_u.mutation.RemoveAuthIdentityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveAuthIdentities removes "auth_identities" edges to AuthIdentity entities.
|
||||
func (_u *UserUpdate) RemoveAuthIdentities(v ...*AuthIdentity) *UserUpdate {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveAuthIdentityIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearPendingAuthSessions clears all "pending_auth_sessions" edges to the PendingAuthSession entity.
|
||||
func (_u *UserUpdate) ClearPendingAuthSessions() *UserUpdate {
|
||||
_u.mutation.ClearPendingAuthSessions()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemovePendingAuthSessionIDs removes the "pending_auth_sessions" edge to PendingAuthSession entities by IDs.
|
||||
func (_u *UserUpdate) RemovePendingAuthSessionIDs(ids ...int64) *UserUpdate {
|
||||
_u.mutation.RemovePendingAuthSessionIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemovePendingAuthSessions removes "pending_auth_sessions" edges to PendingAuthSession entities.
|
||||
func (_u *UserUpdate) RemovePendingAuthSessions(v ...*PendingAuthSession) *UserUpdate {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemovePendingAuthSessionIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *UserUpdate) Save(ctx context.Context) (int, error) {
|
||||
if err := _u.defaults(); err != nil {
|
||||
@@ -767,6 +895,11 @@ func (_u *UserUpdate) check() error {
|
||||
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.SignupSource(); ok {
|
||||
if err := user.SignupSourceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "signup_source", err: fmt.Errorf(`ent: validator failed for field "User.signup_source": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -836,6 +969,21 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if _u.mutation.TotpEnabledAtCleared() {
|
||||
_spec.ClearField(user.FieldTotpEnabledAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.SignupSource(); ok {
|
||||
_spec.SetField(user.FieldSignupSource, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.LastLoginAt(); ok {
|
||||
_spec.SetField(user.FieldLastLoginAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.LastLoginAtCleared() {
|
||||
_spec.ClearField(user.FieldLastLoginAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.LastActiveAt(); ok {
|
||||
_spec.SetField(user.FieldLastActiveAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.LastActiveAtCleared() {
|
||||
_spec.ClearField(user.FieldLastActiveAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.BalanceNotifyEnabled(); ok {
|
||||
_spec.SetField(user.FieldBalanceNotifyEnabled, field.TypeBool, value)
|
||||
}
|
||||
@@ -1322,6 +1470,96 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.AuthIdentitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.AuthIdentitiesTable,
|
||||
Columns: []string{user.AuthIdentitiesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedAuthIdentitiesIDs(); len(nodes) > 0 && !_u.mutation.AuthIdentitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.AuthIdentitiesTable,
|
||||
Columns: []string{user.AuthIdentitiesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(authidentity.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 := _u.mutation.AuthIdentitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.AuthIdentitiesTable,
|
||||
Columns: []string{user.AuthIdentitiesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.PendingAuthSessionsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.PendingAuthSessionsTable,
|
||||
Columns: []string{user.PendingAuthSessionsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedPendingAuthSessionsIDs(); len(nodes) > 0 && !_u.mutation.PendingAuthSessionsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.PendingAuthSessionsTable,
|
||||
Columns: []string{user.PendingAuthSessionsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.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 := _u.mutation.PendingAuthSessionsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.PendingAuthSessionsTable,
|
||||
Columns: []string{user.PendingAuthSessionsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{user.Label}
|
||||
@@ -1548,6 +1786,60 @@ func (_u *UserUpdateOne) ClearTotpEnabledAt() *UserUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSignupSource sets the "signup_source" field.
|
||||
func (_u *UserUpdateOne) SetSignupSource(v string) *UserUpdateOne {
|
||||
_u.mutation.SetSignupSource(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableSignupSource sets the "signup_source" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableSignupSource(v *string) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSignupSource(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastLoginAt sets the "last_login_at" field.
|
||||
func (_u *UserUpdateOne) SetLastLoginAt(v time.Time) *UserUpdateOne {
|
||||
_u.mutation.SetLastLoginAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastLoginAt sets the "last_login_at" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableLastLoginAt(v *time.Time) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetLastLoginAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastLoginAt clears the value of the "last_login_at" field.
|
||||
func (_u *UserUpdateOne) ClearLastLoginAt() *UserUpdateOne {
|
||||
_u.mutation.ClearLastLoginAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastActiveAt sets the "last_active_at" field.
|
||||
func (_u *UserUpdateOne) SetLastActiveAt(v time.Time) *UserUpdateOne {
|
||||
_u.mutation.SetLastActiveAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastActiveAt sets the "last_active_at" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableLastActiveAt(v *time.Time) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetLastActiveAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastActiveAt clears the value of the "last_active_at" field.
|
||||
func (_u *UserUpdateOne) ClearLastActiveAt() *UserUpdateOne {
|
||||
_u.mutation.ClearLastActiveAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetBalanceNotifyEnabled sets the "balance_notify_enabled" field.
|
||||
func (_u *UserUpdateOne) SetBalanceNotifyEnabled(v bool) *UserUpdateOne {
|
||||
_u.mutation.SetBalanceNotifyEnabled(v)
|
||||
@@ -1788,6 +2080,36 @@ func (_u *UserUpdateOne) AddPaymentOrders(v ...*PaymentOrder) *UserUpdateOne {
|
||||
return _u.AddPaymentOrderIDs(ids...)
|
||||
}
|
||||
|
||||
// AddAuthIdentityIDs adds the "auth_identities" edge to the AuthIdentity entity by IDs.
|
||||
func (_u *UserUpdateOne) AddAuthIdentityIDs(ids ...int64) *UserUpdateOne {
|
||||
_u.mutation.AddAuthIdentityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddAuthIdentities adds the "auth_identities" edges to the AuthIdentity entity.
|
||||
func (_u *UserUpdateOne) AddAuthIdentities(v ...*AuthIdentity) *UserUpdateOne {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddAuthIdentityIDs(ids...)
|
||||
}
|
||||
|
||||
// AddPendingAuthSessionIDs adds the "pending_auth_sessions" edge to the PendingAuthSession entity by IDs.
|
||||
func (_u *UserUpdateOne) AddPendingAuthSessionIDs(ids ...int64) *UserUpdateOne {
|
||||
_u.mutation.AddPendingAuthSessionIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddPendingAuthSessions adds the "pending_auth_sessions" edges to the PendingAuthSession entity.
|
||||
func (_u *UserUpdateOne) AddPendingAuthSessions(v ...*PendingAuthSession) *UserUpdateOne {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddPendingAuthSessionIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the UserMutation object of the builder.
|
||||
func (_u *UserUpdateOne) Mutation() *UserMutation {
|
||||
return _u.mutation
|
||||
@@ -2003,6 +2325,48 @@ func (_u *UserUpdateOne) RemovePaymentOrders(v ...*PaymentOrder) *UserUpdateOne
|
||||
return _u.RemovePaymentOrderIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearAuthIdentities clears all "auth_identities" edges to the AuthIdentity entity.
|
||||
func (_u *UserUpdateOne) ClearAuthIdentities() *UserUpdateOne {
|
||||
_u.mutation.ClearAuthIdentities()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveAuthIdentityIDs removes the "auth_identities" edge to AuthIdentity entities by IDs.
|
||||
func (_u *UserUpdateOne) RemoveAuthIdentityIDs(ids ...int64) *UserUpdateOne {
|
||||
_u.mutation.RemoveAuthIdentityIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveAuthIdentities removes "auth_identities" edges to AuthIdentity entities.
|
||||
func (_u *UserUpdateOne) RemoveAuthIdentities(v ...*AuthIdentity) *UserUpdateOne {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveAuthIdentityIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearPendingAuthSessions clears all "pending_auth_sessions" edges to the PendingAuthSession entity.
|
||||
func (_u *UserUpdateOne) ClearPendingAuthSessions() *UserUpdateOne {
|
||||
_u.mutation.ClearPendingAuthSessions()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemovePendingAuthSessionIDs removes the "pending_auth_sessions" edge to PendingAuthSession entities by IDs.
|
||||
func (_u *UserUpdateOne) RemovePendingAuthSessionIDs(ids ...int64) *UserUpdateOne {
|
||||
_u.mutation.RemovePendingAuthSessionIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemovePendingAuthSessions removes "pending_auth_sessions" edges to PendingAuthSession entities.
|
||||
func (_u *UserUpdateOne) RemovePendingAuthSessions(v ...*PendingAuthSession) *UserUpdateOne {
|
||||
ids := make([]int64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemovePendingAuthSessionIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the UserUpdate builder.
|
||||
func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
@@ -2085,6 +2449,11 @@ func (_u *UserUpdateOne) check() error {
|
||||
return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.SignupSource(); ok {
|
||||
if err := user.SignupSourceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "signup_source", err: fmt.Errorf(`ent: validator failed for field "User.signup_source": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2171,6 +2540,21 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
|
||||
if _u.mutation.TotpEnabledAtCleared() {
|
||||
_spec.ClearField(user.FieldTotpEnabledAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.SignupSource(); ok {
|
||||
_spec.SetField(user.FieldSignupSource, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.LastLoginAt(); ok {
|
||||
_spec.SetField(user.FieldLastLoginAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.LastLoginAtCleared() {
|
||||
_spec.ClearField(user.FieldLastLoginAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.LastActiveAt(); ok {
|
||||
_spec.SetField(user.FieldLastActiveAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.LastActiveAtCleared() {
|
||||
_spec.ClearField(user.FieldLastActiveAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.BalanceNotifyEnabled(); ok {
|
||||
_spec.SetField(user.FieldBalanceNotifyEnabled, field.TypeBool, value)
|
||||
}
|
||||
@@ -2657,6 +3041,96 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.AuthIdentitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.AuthIdentitiesTable,
|
||||
Columns: []string{user.AuthIdentitiesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedAuthIdentitiesIDs(); len(nodes) > 0 && !_u.mutation.AuthIdentitiesCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.AuthIdentitiesTable,
|
||||
Columns: []string{user.AuthIdentitiesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(authidentity.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 := _u.mutation.AuthIdentitiesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.AuthIdentitiesTable,
|
||||
Columns: []string{user.AuthIdentitiesColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.PendingAuthSessionsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.PendingAuthSessionsTable,
|
||||
Columns: []string{user.PendingAuthSessionsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedPendingAuthSessionsIDs(); len(nodes) > 0 && !_u.mutation.PendingAuthSessionsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.PendingAuthSessionsTable,
|
||||
Columns: []string{user.PendingAuthSessionsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.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 := _u.mutation.PendingAuthSessionsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: user.PendingAuthSessionsTable,
|
||||
Columns: []string{user.PendingAuthSessionsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &User{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
|
||||
Reference in New Issue
Block a user