🎉 init
This commit is contained in:
595
common/ent/scaauthusersocial_update.go
Normal file
595
common/ent/scaauthusersocial_update.go
Normal file
@@ -0,0 +1,595 @@
|
||||
// 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/scaauthuser"
|
||||
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ScaAuthUserSocialUpdate is the builder for updating ScaAuthUserSocial entities.
|
||||
type ScaAuthUserSocialUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ScaAuthUserSocialMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
|
||||
func (sausu *ScaAuthUserSocialUpdate) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.Where(ps...)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetUserID(s string) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.SetUserID(s)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableUserID(s *string) *ScaAuthUserSocialUpdate {
|
||||
if s != nil {
|
||||
sausu.SetUserID(*s)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetOpenID sets the "open_id" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetOpenID(s string) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.SetOpenID(s)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableOpenID sets the "open_id" field if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdate {
|
||||
if s != nil {
|
||||
sausu.SetOpenID(*s)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetSource sets the "source" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetSource(s string) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.SetSource(s)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableSource sets the "source" field if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableSource(s *string) *ScaAuthUserSocialUpdate {
|
||||
if s != nil {
|
||||
sausu.SetSource(*s)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetStatus(i int) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.ResetStatus()
|
||||
sausu.mutation.SetStatus(i)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableStatus(i *int) *ScaAuthUserSocialUpdate {
|
||||
if i != nil {
|
||||
sausu.SetStatus(*i)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// AddStatus adds i to the "status" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) AddStatus(i int) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.AddStatus(i)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetUpdateAt sets the "update_at" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetUpdateAt(t time.Time) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.SetUpdateAt(t)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// ClearUpdateAt clears the value of the "update_at" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) ClearUpdateAt() *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.ClearUpdateAt()
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetDeleted sets the "deleted" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetDeleted(i int) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.ResetDeleted()
|
||||
sausu.mutation.SetDeleted(i)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableDeleted(i *int) *ScaAuthUserSocialUpdate {
|
||||
if i != nil {
|
||||
sausu.SetDeleted(*i)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// AddDeleted adds i to the "deleted" field.
|
||||
func (sausu *ScaAuthUserSocialUpdate) AddDeleted(i int) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.AddDeleted(i)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.SetScaAuthUserID(id)
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdate {
|
||||
if id != nil {
|
||||
sausu = sausu.SetScaAuthUserID(*id)
|
||||
}
|
||||
return sausu
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdate {
|
||||
return sausu.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
|
||||
func (sausu *ScaAuthUserSocialUpdate) Mutation() *ScaAuthUserSocialMutation {
|
||||
return sausu.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausu *ScaAuthUserSocialUpdate) ClearScaAuthUser() *ScaAuthUserSocialUpdate {
|
||||
sausu.mutation.ClearScaAuthUser()
|
||||
return sausu
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (sausu *ScaAuthUserSocialUpdate) Save(ctx context.Context) (int, error) {
|
||||
sausu.defaults()
|
||||
return withHooks(ctx, sausu.sqlSave, sausu.mutation, sausu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (sausu *ScaAuthUserSocialUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := sausu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (sausu *ScaAuthUserSocialUpdate) Exec(ctx context.Context) error {
|
||||
_, err := sausu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sausu *ScaAuthUserSocialUpdate) ExecX(ctx context.Context) {
|
||||
if err := sausu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (sausu *ScaAuthUserSocialUpdate) defaults() {
|
||||
if _, ok := sausu.mutation.UpdateAt(); !ok && !sausu.mutation.UpdateAtCleared() {
|
||||
v := scaauthusersocial.UpdateDefaultUpdateAt()
|
||||
sausu.mutation.SetUpdateAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (sausu *ScaAuthUserSocialUpdate) check() error {
|
||||
if v, ok := sausu.mutation.UserID(); ok {
|
||||
if err := scaauthusersocial.UserIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sausu.mutation.OpenID(); ok {
|
||||
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sausu.mutation.Source(); ok {
|
||||
if err := scaauthusersocial.SourceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sausu *ScaAuthUserSocialUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := sausu.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
|
||||
if ps := sausu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := sausu.mutation.UserID(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := sausu.mutation.OpenID(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := sausu.mutation.Source(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
|
||||
}
|
||||
if value, ok := sausu.mutation.Status(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := sausu.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := sausu.mutation.UpdateAt(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldUpdateAt, field.TypeTime, value)
|
||||
}
|
||||
if sausu.mutation.UpdateAtCleared() {
|
||||
_spec.ClearField(scaauthusersocial.FieldUpdateAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := sausu.mutation.Deleted(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := sausu.mutation.AddedDeleted(); ok {
|
||||
_spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt, value)
|
||||
}
|
||||
if sausu.mutation.ScaAuthUserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sausu.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.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, sausu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthusersocial.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
sausu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// ScaAuthUserSocialUpdateOne is the builder for updating a single ScaAuthUserSocial entity.
|
||||
type ScaAuthUserSocialUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *ScaAuthUserSocialMutation
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetUserID(s string) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.SetUserID(s)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableUserID(s *string) *ScaAuthUserSocialUpdateOne {
|
||||
if s != nil {
|
||||
sausuo.SetUserID(*s)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetOpenID sets the "open_id" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetOpenID(s string) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.SetOpenID(s)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableOpenID sets the "open_id" field if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableOpenID(s *string) *ScaAuthUserSocialUpdateOne {
|
||||
if s != nil {
|
||||
sausuo.SetOpenID(*s)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetSource sets the "source" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetSource(s string) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.SetSource(s)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableSource sets the "source" field if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableSource(s *string) *ScaAuthUserSocialUpdateOne {
|
||||
if s != nil {
|
||||
sausuo.SetSource(*s)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetStatus(i int) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.ResetStatus()
|
||||
sausuo.mutation.SetStatus(i)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableStatus(i *int) *ScaAuthUserSocialUpdateOne {
|
||||
if i != nil {
|
||||
sausuo.SetStatus(*i)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// AddStatus adds i to the "status" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) AddStatus(i int) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.AddStatus(i)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetUpdateAt sets the "update_at" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetUpdateAt(t time.Time) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.SetUpdateAt(t)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// ClearUpdateAt clears the value of the "update_at" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) ClearUpdateAt() *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.ClearUpdateAt()
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetDeleted sets the "deleted" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetDeleted(i int) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.ResetDeleted()
|
||||
sausuo.mutation.SetDeleted(i)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableDeleted sets the "deleted" field if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableDeleted(i *int) *ScaAuthUserSocialUpdateOne {
|
||||
if i != nil {
|
||||
sausuo.SetDeleted(*i)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// AddDeleted adds i to the "deleted" field.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) AddDeleted(i int) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.AddDeleted(i)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUserID(id int64) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.SetScaAuthUserID(id)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetNillableScaAuthUserID sets the "sca_auth_user" edge to the ScaAuthUser entity by ID if the given value is not nil.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetNillableScaAuthUserID(id *int64) *ScaAuthUserSocialUpdateOne {
|
||||
if id != nil {
|
||||
sausuo = sausuo.SetScaAuthUserID(*id)
|
||||
}
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// SetScaAuthUser sets the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SetScaAuthUser(s *ScaAuthUser) *ScaAuthUserSocialUpdateOne {
|
||||
return sausuo.SetScaAuthUserID(s.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the ScaAuthUserSocialMutation object of the builder.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Mutation() *ScaAuthUserSocialMutation {
|
||||
return sausuo.mutation
|
||||
}
|
||||
|
||||
// ClearScaAuthUser clears the "sca_auth_user" edge to the ScaAuthUser entity.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) ClearScaAuthUser() *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.ClearScaAuthUser()
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ScaAuthUserSocialUpdate builder.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Where(ps ...predicate.ScaAuthUserSocial) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.mutation.Where(ps...)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Select(field string, fields ...string) *ScaAuthUserSocialUpdateOne {
|
||||
sausuo.fields = append([]string{field}, fields...)
|
||||
return sausuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated ScaAuthUserSocial entity.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Save(ctx context.Context) (*ScaAuthUserSocial, error) {
|
||||
sausuo.defaults()
|
||||
return withHooks(ctx, sausuo.sqlSave, sausuo.mutation, sausuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) SaveX(ctx context.Context) *ScaAuthUserSocial {
|
||||
node, err := sausuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := sausuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := sausuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) defaults() {
|
||||
if _, ok := sausuo.mutation.UpdateAt(); !ok && !sausuo.mutation.UpdateAtCleared() {
|
||||
v := scaauthusersocial.UpdateDefaultUpdateAt()
|
||||
sausuo.mutation.SetUpdateAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) check() error {
|
||||
if v, ok := sausuo.mutation.UserID(); ok {
|
||||
if err := scaauthusersocial.UserIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.user_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sausuo.mutation.OpenID(); ok {
|
||||
if err := scaauthusersocial.OpenIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "open_id", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.open_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := sausuo.mutation.Source(); ok {
|
||||
if err := scaauthusersocial.SourceValidator(v); err != nil {
|
||||
return &ValidationError{Name: "source", err: fmt.Errorf(`ent: validator failed for field "ScaAuthUserSocial.source": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sausuo *ScaAuthUserSocialUpdateOne) sqlSave(ctx context.Context) (_node *ScaAuthUserSocial, err error) {
|
||||
if err := sausuo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(scaauthusersocial.Table, scaauthusersocial.Columns, sqlgraph.NewFieldSpec(scaauthusersocial.FieldID, field.TypeInt64))
|
||||
id, ok := sausuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ScaAuthUserSocial.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := sausuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, scaauthusersocial.FieldID)
|
||||
for _, f := range fields {
|
||||
if !scaauthusersocial.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != scaauthusersocial.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := sausuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := sausuo.mutation.UserID(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldUserID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := sausuo.mutation.OpenID(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldOpenID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := sausuo.mutation.Source(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldSource, field.TypeString, value)
|
||||
}
|
||||
if value, ok := sausuo.mutation.Status(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := sausuo.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(scaauthusersocial.FieldStatus, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := sausuo.mutation.UpdateAt(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldUpdateAt, field.TypeTime, value)
|
||||
}
|
||||
if sausuo.mutation.UpdateAtCleared() {
|
||||
_spec.ClearField(scaauthusersocial.FieldUpdateAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := sausuo.mutation.Deleted(); ok {
|
||||
_spec.SetField(scaauthusersocial.FieldDeleted, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := sausuo.mutation.AddedDeleted(); ok {
|
||||
_spec.AddField(scaauthusersocial.FieldDeleted, field.TypeInt, value)
|
||||
}
|
||||
if sausuo.mutation.ScaAuthUserCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := sausuo.mutation.ScaAuthUserIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: scaauthusersocial.ScaAuthUserTable,
|
||||
Columns: []string{scaauthusersocial.ScaAuthUserColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(scaauthuser.FieldID, field.TypeInt64),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ScaAuthUserSocial{config: sausuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, sausuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{scaauthusersocial.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
sausuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
Reference in New Issue
Block a user