// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "mingyang-admin-app-rpc/ent/predicate" "mingyang-admin-app-rpc/ent/user" "mingyang-admin-app-rpc/ent/userloginlog" "mingyang-admin-app-rpc/ent/userthirdauth" "sync" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) const ( // Operation types. OpCreate = ent.OpCreate OpDelete = ent.OpDelete OpDeleteOne = ent.OpDeleteOne OpUpdate = ent.OpUpdate OpUpdateOne = ent.OpUpdateOne // Node types. TypeUser = "User" TypeUserLoginLog = "UserLoginLog" TypeUserThirdAuth = "UserThirdAuth" ) // UserMutation represents an operation that mutates the User nodes in the graph. type UserMutation struct { config op Op typ string id *uint64 created_at *time.Time updated_at *time.Time status *uint8 addstatus *int8 tenant_id *uint64 addtenant_id *int64 deleted_at *time.Time username *string email *string mobile *string password_hash *string salt *string nickname *string avatar *string gender *user.Gender birthday *time.Time account_status *user.AccountStatus is_verified *uint32 addis_verified *int32 registered_login_ip *string login_attempts *int64 addlogin_attempts *int64 metadata *map[string]interface{} registration_source *string clearedFields map[string]struct{} done bool oldValue func(context.Context) (*User, error) predicates []predicate.User } var _ ent.Mutation = (*UserMutation)(nil) // userOption allows management of the mutation configuration using functional options. type userOption func(*UserMutation) // newUserMutation creates new mutation for the User entity. func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { m := &UserMutation{ config: c, op: op, typ: TypeUser, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withUserID sets the ID field of the mutation. func withUserID(id uint64) userOption { return func(m *UserMutation) { var ( err error once sync.Once value *User ) m.oldValue = func(ctx context.Context) (*User, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().User.Get(ctx, id) } }) return value, err } m.id = &id } } // withUser sets the old User of the mutation. func withUser(node *User) userOption { return func(m *UserMutation) { m.oldValue = func(context.Context) (*User, error) { return node, nil } m.id = &node.ID } } // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. func (m UserMutation) Client() *Client { client := &Client{config: m.config} client.init() return client } // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. func (m UserMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } tx := &Tx{config: m.config} tx.init() return tx, nil } // SetID sets the value of the id field. Note that this // operation is only accepted on creation of User entities. func (m *UserMutation) SetID(id uint64) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. func (m *UserMutation) ID() (id uint64, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *UserMutation) IDs(ctx context.Context) ([]uint64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []uint64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().User.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetCreatedAt sets the "created_at" field. func (m *UserMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. func (m *UserMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return } return *v, true } // OldCreatedAt returns the old "created_at" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } return oldValue.CreatedAt, nil } // ResetCreatedAt resets all changes to the "created_at" field. func (m *UserMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. func (m *UserMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return } return *v, true } // OldUpdatedAt returns the old "updated_at" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } return oldValue.UpdatedAt, nil } // ResetUpdatedAt resets all changes to the "updated_at" field. func (m *UserMutation) ResetUpdatedAt() { m.updated_at = nil } // SetStatus sets the "status" field. func (m *UserMutation) SetStatus(u uint8) { m.status = &u m.addstatus = nil } // Status returns the value of the "status" field in the mutation. func (m *UserMutation) Status() (r uint8, exists bool) { v := m.status if v == nil { return } return *v, true } // OldStatus returns the old "status" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldStatus(ctx context.Context) (v uint8, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldStatus: %w", err) } return oldValue.Status, nil } // AddStatus adds u to the "status" field. func (m *UserMutation) AddStatus(u int8) { if m.addstatus != nil { *m.addstatus += u } else { m.addstatus = &u } } // AddedStatus returns the value that was added to the "status" field in this mutation. func (m *UserMutation) AddedStatus() (r int8, exists bool) { v := m.addstatus if v == nil { return } return *v, true } // ClearStatus clears the value of the "status" field. func (m *UserMutation) ClearStatus() { m.status = nil m.addstatus = nil m.clearedFields[user.FieldStatus] = struct{}{} } // StatusCleared returns if the "status" field was cleared in this mutation. func (m *UserMutation) StatusCleared() bool { _, ok := m.clearedFields[user.FieldStatus] return ok } // ResetStatus resets all changes to the "status" field. func (m *UserMutation) ResetStatus() { m.status = nil m.addstatus = nil delete(m.clearedFields, user.FieldStatus) } // SetTenantID sets the "tenant_id" field. func (m *UserMutation) SetTenantID(u uint64) { m.tenant_id = &u m.addtenant_id = nil } // TenantID returns the value of the "tenant_id" field in the mutation. func (m *UserMutation) TenantID() (r uint64, exists bool) { v := m.tenant_id if v == nil { return } return *v, true } // OldTenantID returns the old "tenant_id" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldTenantID(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTenantID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldTenantID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldTenantID: %w", err) } return oldValue.TenantID, nil } // AddTenantID adds u to the "tenant_id" field. func (m *UserMutation) AddTenantID(u int64) { if m.addtenant_id != nil { *m.addtenant_id += u } else { m.addtenant_id = &u } } // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. func (m *UserMutation) AddedTenantID() (r int64, exists bool) { v := m.addtenant_id if v == nil { return } return *v, true } // ResetTenantID resets all changes to the "tenant_id" field. func (m *UserMutation) ResetTenantID() { m.tenant_id = nil m.addtenant_id = nil } // SetDeletedAt sets the "deleted_at" field. func (m *UserMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. func (m *UserMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return } return *v, true } // OldDeletedAt returns the old "deleted_at" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } return oldValue.DeletedAt, nil } // ClearDeletedAt clears the value of the "deleted_at" field. func (m *UserMutation) ClearDeletedAt() { m.deleted_at = nil m.clearedFields[user.FieldDeletedAt] = struct{}{} } // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. func (m *UserMutation) DeletedAtCleared() bool { _, ok := m.clearedFields[user.FieldDeletedAt] return ok } // ResetDeletedAt resets all changes to the "deleted_at" field. func (m *UserMutation) ResetDeletedAt() { m.deleted_at = nil delete(m.clearedFields, user.FieldDeletedAt) } // SetUsername sets the "username" field. func (m *UserMutation) SetUsername(s string) { m.username = &s } // Username returns the value of the "username" field in the mutation. func (m *UserMutation) Username() (r string, exists bool) { v := m.username if v == nil { return } return *v, true } // OldUsername returns the old "username" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUsername is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUsername requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUsername: %w", err) } return oldValue.Username, nil } // ResetUsername resets all changes to the "username" field. func (m *UserMutation) ResetUsername() { m.username = nil } // SetEmail sets the "email" field. func (m *UserMutation) SetEmail(s string) { m.email = &s } // Email returns the value of the "email" field in the mutation. func (m *UserMutation) Email() (r string, exists bool) { v := m.email if v == nil { return } return *v, true } // OldEmail returns the old "email" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldEmail is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldEmail requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldEmail: %w", err) } return oldValue.Email, nil } // ResetEmail resets all changes to the "email" field. func (m *UserMutation) ResetEmail() { m.email = nil } // SetMobile sets the "mobile" field. func (m *UserMutation) SetMobile(s string) { m.mobile = &s } // Mobile returns the value of the "mobile" field in the mutation. func (m *UserMutation) Mobile() (r string, exists bool) { v := m.mobile if v == nil { return } return *v, true } // OldMobile returns the old "mobile" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldMobile(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMobile is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMobile requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMobile: %w", err) } return oldValue.Mobile, nil } // ClearMobile clears the value of the "mobile" field. func (m *UserMutation) ClearMobile() { m.mobile = nil m.clearedFields[user.FieldMobile] = struct{}{} } // MobileCleared returns if the "mobile" field was cleared in this mutation. func (m *UserMutation) MobileCleared() bool { _, ok := m.clearedFields[user.FieldMobile] return ok } // ResetMobile resets all changes to the "mobile" field. func (m *UserMutation) ResetMobile() { m.mobile = nil delete(m.clearedFields, user.FieldMobile) } // SetPasswordHash sets the "password_hash" field. func (m *UserMutation) SetPasswordHash(s string) { m.password_hash = &s } // PasswordHash returns the value of the "password_hash" field in the mutation. func (m *UserMutation) PasswordHash() (r string, exists bool) { v := m.password_hash if v == nil { return } return *v, true } // OldPasswordHash returns the old "password_hash" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldPasswordHash(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPasswordHash is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldPasswordHash requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldPasswordHash: %w", err) } return oldValue.PasswordHash, nil } // ResetPasswordHash resets all changes to the "password_hash" field. func (m *UserMutation) ResetPasswordHash() { m.password_hash = nil } // SetSalt sets the "salt" field. func (m *UserMutation) SetSalt(s string) { m.salt = &s } // Salt returns the value of the "salt" field in the mutation. func (m *UserMutation) Salt() (r string, exists bool) { v := m.salt if v == nil { return } return *v, true } // OldSalt returns the old "salt" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldSalt(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldSalt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldSalt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldSalt: %w", err) } return oldValue.Salt, nil } // ResetSalt resets all changes to the "salt" field. func (m *UserMutation) ResetSalt() { m.salt = nil } // SetNickname sets the "nickname" field. func (m *UserMutation) SetNickname(s string) { m.nickname = &s } // Nickname returns the value of the "nickname" field in the mutation. func (m *UserMutation) Nickname() (r string, exists bool) { v := m.nickname if v == nil { return } return *v, true } // OldNickname returns the old "nickname" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldNickname(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldNickname is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldNickname requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldNickname: %w", err) } return oldValue.Nickname, nil } // ResetNickname resets all changes to the "nickname" field. func (m *UserMutation) ResetNickname() { m.nickname = nil } // SetAvatar sets the "avatar" field. func (m *UserMutation) SetAvatar(s string) { m.avatar = &s } // Avatar returns the value of the "avatar" field in the mutation. func (m *UserMutation) Avatar() (r string, exists bool) { v := m.avatar if v == nil { return } return *v, true } // OldAvatar returns the old "avatar" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldAvatar(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAvatar is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAvatar requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAvatar: %w", err) } return oldValue.Avatar, nil } // ClearAvatar clears the value of the "avatar" field. func (m *UserMutation) ClearAvatar() { m.avatar = nil m.clearedFields[user.FieldAvatar] = struct{}{} } // AvatarCleared returns if the "avatar" field was cleared in this mutation. func (m *UserMutation) AvatarCleared() bool { _, ok := m.clearedFields[user.FieldAvatar] return ok } // ResetAvatar resets all changes to the "avatar" field. func (m *UserMutation) ResetAvatar() { m.avatar = nil delete(m.clearedFields, user.FieldAvatar) } // SetGender sets the "gender" field. func (m *UserMutation) SetGender(u user.Gender) { m.gender = &u } // Gender returns the value of the "gender" field in the mutation. func (m *UserMutation) Gender() (r user.Gender, exists bool) { v := m.gender if v == nil { return } return *v, true } // OldGender returns the old "gender" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldGender(ctx context.Context) (v user.Gender, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldGender is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldGender requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldGender: %w", err) } return oldValue.Gender, nil } // ResetGender resets all changes to the "gender" field. func (m *UserMutation) ResetGender() { m.gender = nil } // SetBirthday sets the "birthday" field. func (m *UserMutation) SetBirthday(t time.Time) { m.birthday = &t } // Birthday returns the value of the "birthday" field in the mutation. func (m *UserMutation) Birthday() (r time.Time, exists bool) { v := m.birthday if v == nil { return } return *v, true } // OldBirthday returns the old "birthday" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldBirthday(ctx context.Context) (v *time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldBirthday is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldBirthday requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldBirthday: %w", err) } return oldValue.Birthday, nil } // ClearBirthday clears the value of the "birthday" field. func (m *UserMutation) ClearBirthday() { m.birthday = nil m.clearedFields[user.FieldBirthday] = struct{}{} } // BirthdayCleared returns if the "birthday" field was cleared in this mutation. func (m *UserMutation) BirthdayCleared() bool { _, ok := m.clearedFields[user.FieldBirthday] return ok } // ResetBirthday resets all changes to the "birthday" field. func (m *UserMutation) ResetBirthday() { m.birthday = nil delete(m.clearedFields, user.FieldBirthday) } // SetAccountStatus sets the "account_status" field. func (m *UserMutation) SetAccountStatus(us user.AccountStatus) { m.account_status = &us } // AccountStatus returns the value of the "account_status" field in the mutation. func (m *UserMutation) AccountStatus() (r user.AccountStatus, exists bool) { v := m.account_status if v == nil { return } return *v, true } // OldAccountStatus returns the old "account_status" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldAccountStatus(ctx context.Context) (v user.AccountStatus, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAccountStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAccountStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAccountStatus: %w", err) } return oldValue.AccountStatus, nil } // ResetAccountStatus resets all changes to the "account_status" field. func (m *UserMutation) ResetAccountStatus() { m.account_status = nil } // SetIsVerified sets the "is_verified" field. func (m *UserMutation) SetIsVerified(u uint32) { m.is_verified = &u m.addis_verified = nil } // IsVerified returns the value of the "is_verified" field in the mutation. func (m *UserMutation) IsVerified() (r uint32, exists bool) { v := m.is_verified if v == nil { return } return *v, true } // OldIsVerified returns the old "is_verified" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldIsVerified(ctx context.Context) (v uint32, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldIsVerified is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldIsVerified requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldIsVerified: %w", err) } return oldValue.IsVerified, nil } // AddIsVerified adds u to the "is_verified" field. func (m *UserMutation) AddIsVerified(u int32) { if m.addis_verified != nil { *m.addis_verified += u } else { m.addis_verified = &u } } // AddedIsVerified returns the value that was added to the "is_verified" field in this mutation. func (m *UserMutation) AddedIsVerified() (r int32, exists bool) { v := m.addis_verified if v == nil { return } return *v, true } // ResetIsVerified resets all changes to the "is_verified" field. func (m *UserMutation) ResetIsVerified() { m.is_verified = nil m.addis_verified = nil } // SetRegisteredLoginIP sets the "registered_login_ip" field. func (m *UserMutation) SetRegisteredLoginIP(s string) { m.registered_login_ip = &s } // RegisteredLoginIP returns the value of the "registered_login_ip" field in the mutation. func (m *UserMutation) RegisteredLoginIP() (r string, exists bool) { v := m.registered_login_ip if v == nil { return } return *v, true } // OldRegisteredLoginIP returns the old "registered_login_ip" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldRegisteredLoginIP(ctx context.Context) (v *string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRegisteredLoginIP is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldRegisteredLoginIP requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldRegisteredLoginIP: %w", err) } return oldValue.RegisteredLoginIP, nil } // ClearRegisteredLoginIP clears the value of the "registered_login_ip" field. func (m *UserMutation) ClearRegisteredLoginIP() { m.registered_login_ip = nil m.clearedFields[user.FieldRegisteredLoginIP] = struct{}{} } // RegisteredLoginIPCleared returns if the "registered_login_ip" field was cleared in this mutation. func (m *UserMutation) RegisteredLoginIPCleared() bool { _, ok := m.clearedFields[user.FieldRegisteredLoginIP] return ok } // ResetRegisteredLoginIP resets all changes to the "registered_login_ip" field. func (m *UserMutation) ResetRegisteredLoginIP() { m.registered_login_ip = nil delete(m.clearedFields, user.FieldRegisteredLoginIP) } // SetLoginAttempts sets the "login_attempts" field. func (m *UserMutation) SetLoginAttempts(i int64) { m.login_attempts = &i m.addlogin_attempts = nil } // LoginAttempts returns the value of the "login_attempts" field in the mutation. func (m *UserMutation) LoginAttempts() (r int64, exists bool) { v := m.login_attempts if v == nil { return } return *v, true } // OldLoginAttempts returns the old "login_attempts" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldLoginAttempts(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginAttempts is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginAttempts requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginAttempts: %w", err) } return oldValue.LoginAttempts, nil } // AddLoginAttempts adds i to the "login_attempts" field. func (m *UserMutation) AddLoginAttempts(i int64) { if m.addlogin_attempts != nil { *m.addlogin_attempts += i } else { m.addlogin_attempts = &i } } // AddedLoginAttempts returns the value that was added to the "login_attempts" field in this mutation. func (m *UserMutation) AddedLoginAttempts() (r int64, exists bool) { v := m.addlogin_attempts if v == nil { return } return *v, true } // ResetLoginAttempts resets all changes to the "login_attempts" field. func (m *UserMutation) ResetLoginAttempts() { m.login_attempts = nil m.addlogin_attempts = nil } // SetMetadata sets the "metadata" field. func (m *UserMutation) SetMetadata(value map[string]interface{}) { m.metadata = &value } // Metadata returns the value of the "metadata" field in the mutation. func (m *UserMutation) Metadata() (r map[string]interface{}, exists bool) { v := m.metadata if v == nil { return } return *v, true } // OldMetadata returns the old "metadata" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldMetadata(ctx context.Context) (v map[string]interface{}, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldMetadata is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldMetadata requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldMetadata: %w", err) } return oldValue.Metadata, nil } // ClearMetadata clears the value of the "metadata" field. func (m *UserMutation) ClearMetadata() { m.metadata = nil m.clearedFields[user.FieldMetadata] = struct{}{} } // MetadataCleared returns if the "metadata" field was cleared in this mutation. func (m *UserMutation) MetadataCleared() bool { _, ok := m.clearedFields[user.FieldMetadata] return ok } // ResetMetadata resets all changes to the "metadata" field. func (m *UserMutation) ResetMetadata() { m.metadata = nil delete(m.clearedFields, user.FieldMetadata) } // SetRegistrationSource sets the "registration_source" field. func (m *UserMutation) SetRegistrationSource(s string) { m.registration_source = &s } // RegistrationSource returns the value of the "registration_source" field in the mutation. func (m *UserMutation) RegistrationSource() (r string, exists bool) { v := m.registration_source if v == nil { return } return *v, true } // OldRegistrationSource returns the old "registration_source" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserMutation) OldRegistrationSource(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRegistrationSource is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldRegistrationSource requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldRegistrationSource: %w", err) } return oldValue.RegistrationSource, nil } // ClearRegistrationSource clears the value of the "registration_source" field. func (m *UserMutation) ClearRegistrationSource() { m.registration_source = nil m.clearedFields[user.FieldRegistrationSource] = struct{}{} } // RegistrationSourceCleared returns if the "registration_source" field was cleared in this mutation. func (m *UserMutation) RegistrationSourceCleared() bool { _, ok := m.clearedFields[user.FieldRegistrationSource] return ok } // ResetRegistrationSource resets all changes to the "registration_source" field. func (m *UserMutation) ResetRegistrationSource() { m.registration_source = nil delete(m.clearedFields, user.FieldRegistrationSource) } // Where appends a list predicates to the UserMutation builder. func (m *UserMutation) Where(ps ...predicate.User) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the UserMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.User, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *UserMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *UserMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (User). func (m *UserMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { fields := make([]string, 0, 20) if m.created_at != nil { fields = append(fields, user.FieldCreatedAt) } if m.updated_at != nil { fields = append(fields, user.FieldUpdatedAt) } if m.status != nil { fields = append(fields, user.FieldStatus) } if m.tenant_id != nil { fields = append(fields, user.FieldTenantID) } if m.deleted_at != nil { fields = append(fields, user.FieldDeletedAt) } if m.username != nil { fields = append(fields, user.FieldUsername) } if m.email != nil { fields = append(fields, user.FieldEmail) } if m.mobile != nil { fields = append(fields, user.FieldMobile) } if m.password_hash != nil { fields = append(fields, user.FieldPasswordHash) } if m.salt != nil { fields = append(fields, user.FieldSalt) } if m.nickname != nil { fields = append(fields, user.FieldNickname) } if m.avatar != nil { fields = append(fields, user.FieldAvatar) } if m.gender != nil { fields = append(fields, user.FieldGender) } if m.birthday != nil { fields = append(fields, user.FieldBirthday) } if m.account_status != nil { fields = append(fields, user.FieldAccountStatus) } if m.is_verified != nil { fields = append(fields, user.FieldIsVerified) } if m.registered_login_ip != nil { fields = append(fields, user.FieldRegisteredLoginIP) } if m.login_attempts != nil { fields = append(fields, user.FieldLoginAttempts) } if m.metadata != nil { fields = append(fields, user.FieldMetadata) } if m.registration_source != nil { fields = append(fields, user.FieldRegistrationSource) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *UserMutation) Field(name string) (ent.Value, bool) { switch name { case user.FieldCreatedAt: return m.CreatedAt() case user.FieldUpdatedAt: return m.UpdatedAt() case user.FieldStatus: return m.Status() case user.FieldTenantID: return m.TenantID() case user.FieldDeletedAt: return m.DeletedAt() case user.FieldUsername: return m.Username() case user.FieldEmail: return m.Email() case user.FieldMobile: return m.Mobile() case user.FieldPasswordHash: return m.PasswordHash() case user.FieldSalt: return m.Salt() case user.FieldNickname: return m.Nickname() case user.FieldAvatar: return m.Avatar() case user.FieldGender: return m.Gender() case user.FieldBirthday: return m.Birthday() case user.FieldAccountStatus: return m.AccountStatus() case user.FieldIsVerified: return m.IsVerified() case user.FieldRegisteredLoginIP: return m.RegisteredLoginIP() case user.FieldLoginAttempts: return m.LoginAttempts() case user.FieldMetadata: return m.Metadata() case user.FieldRegistrationSource: return m.RegistrationSource() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case user.FieldCreatedAt: return m.OldCreatedAt(ctx) case user.FieldUpdatedAt: return m.OldUpdatedAt(ctx) case user.FieldStatus: return m.OldStatus(ctx) case user.FieldTenantID: return m.OldTenantID(ctx) case user.FieldDeletedAt: return m.OldDeletedAt(ctx) case user.FieldUsername: return m.OldUsername(ctx) case user.FieldEmail: return m.OldEmail(ctx) case user.FieldMobile: return m.OldMobile(ctx) case user.FieldPasswordHash: return m.OldPasswordHash(ctx) case user.FieldSalt: return m.OldSalt(ctx) case user.FieldNickname: return m.OldNickname(ctx) case user.FieldAvatar: return m.OldAvatar(ctx) case user.FieldGender: return m.OldGender(ctx) case user.FieldBirthday: return m.OldBirthday(ctx) case user.FieldAccountStatus: return m.OldAccountStatus(ctx) case user.FieldIsVerified: return m.OldIsVerified(ctx) case user.FieldRegisteredLoginIP: return m.OldRegisteredLoginIP(ctx) case user.FieldLoginAttempts: return m.OldLoginAttempts(ctx) case user.FieldMetadata: return m.OldMetadata(ctx) case user.FieldRegistrationSource: return m.OldRegistrationSource(ctx) } return nil, fmt.Errorf("unknown User field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *UserMutation) SetField(name string, value ent.Value) error { switch name { case user.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil case user.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUpdatedAt(v) return nil case user.FieldStatus: v, ok := value.(uint8) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetStatus(v) return nil case user.FieldTenantID: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTenantID(v) return nil case user.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil case user.FieldUsername: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUsername(v) return nil case user.FieldEmail: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEmail(v) return nil case user.FieldMobile: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMobile(v) return nil case user.FieldPasswordHash: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPasswordHash(v) return nil case user.FieldSalt: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSalt(v) return nil case user.FieldNickname: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetNickname(v) return nil case user.FieldAvatar: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAvatar(v) return nil case user.FieldGender: v, ok := value.(user.Gender) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetGender(v) return nil case user.FieldBirthday: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetBirthday(v) return nil case user.FieldAccountStatus: v, ok := value.(user.AccountStatus) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAccountStatus(v) return nil case user.FieldIsVerified: v, ok := value.(uint32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetIsVerified(v) return nil case user.FieldRegisteredLoginIP: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRegisteredLoginIP(v) return nil case user.FieldLoginAttempts: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginAttempts(v) return nil case user.FieldMetadata: v, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetMetadata(v) return nil case user.FieldRegistrationSource: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRegistrationSource(v) return nil } return fmt.Errorf("unknown User field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *UserMutation) AddedFields() []string { var fields []string if m.addstatus != nil { fields = append(fields, user.FieldStatus) } if m.addtenant_id != nil { fields = append(fields, user.FieldTenantID) } if m.addis_verified != nil { fields = append(fields, user.FieldIsVerified) } if m.addlogin_attempts != nil { fields = append(fields, user.FieldLoginAttempts) } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *UserMutation) AddedField(name string) (ent.Value, bool) { switch name { case user.FieldStatus: return m.AddedStatus() case user.FieldTenantID: return m.AddedTenantID() case user.FieldIsVerified: return m.AddedIsVerified() case user.FieldLoginAttempts: return m.AddedLoginAttempts() } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *UserMutation) AddField(name string, value ent.Value) error { switch name { case user.FieldStatus: v, ok := value.(int8) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddStatus(v) return nil case user.FieldTenantID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTenantID(v) return nil case user.FieldIsVerified: v, ok := value.(int32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddIsVerified(v) return nil case user.FieldLoginAttempts: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddLoginAttempts(v) return nil } return fmt.Errorf("unknown User numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *UserMutation) ClearedFields() []string { var fields []string if m.FieldCleared(user.FieldStatus) { fields = append(fields, user.FieldStatus) } if m.FieldCleared(user.FieldDeletedAt) { fields = append(fields, user.FieldDeletedAt) } if m.FieldCleared(user.FieldMobile) { fields = append(fields, user.FieldMobile) } if m.FieldCleared(user.FieldAvatar) { fields = append(fields, user.FieldAvatar) } if m.FieldCleared(user.FieldBirthday) { fields = append(fields, user.FieldBirthday) } if m.FieldCleared(user.FieldRegisteredLoginIP) { fields = append(fields, user.FieldRegisteredLoginIP) } if m.FieldCleared(user.FieldMetadata) { fields = append(fields, user.FieldMetadata) } if m.FieldCleared(user.FieldRegistrationSource) { fields = append(fields, user.FieldRegistrationSource) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *UserMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *UserMutation) ClearField(name string) error { switch name { case user.FieldStatus: m.ClearStatus() return nil case user.FieldDeletedAt: m.ClearDeletedAt() return nil case user.FieldMobile: m.ClearMobile() return nil case user.FieldAvatar: m.ClearAvatar() return nil case user.FieldBirthday: m.ClearBirthday() return nil case user.FieldRegisteredLoginIP: m.ClearRegisteredLoginIP() return nil case user.FieldMetadata: m.ClearMetadata() return nil case user.FieldRegistrationSource: m.ClearRegistrationSource() return nil } return fmt.Errorf("unknown User nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *UserMutation) ResetField(name string) error { switch name { case user.FieldCreatedAt: m.ResetCreatedAt() return nil case user.FieldUpdatedAt: m.ResetUpdatedAt() return nil case user.FieldStatus: m.ResetStatus() return nil case user.FieldTenantID: m.ResetTenantID() return nil case user.FieldDeletedAt: m.ResetDeletedAt() return nil case user.FieldUsername: m.ResetUsername() return nil case user.FieldEmail: m.ResetEmail() return nil case user.FieldMobile: m.ResetMobile() return nil case user.FieldPasswordHash: m.ResetPasswordHash() return nil case user.FieldSalt: m.ResetSalt() return nil case user.FieldNickname: m.ResetNickname() return nil case user.FieldAvatar: m.ResetAvatar() return nil case user.FieldGender: m.ResetGender() return nil case user.FieldBirthday: m.ResetBirthday() return nil case user.FieldAccountStatus: m.ResetAccountStatus() return nil case user.FieldIsVerified: m.ResetIsVerified() return nil case user.FieldRegisteredLoginIP: m.ResetRegisteredLoginIP() return nil case user.FieldLoginAttempts: m.ResetLoginAttempts() return nil case user.FieldMetadata: m.ResetMetadata() return nil case user.FieldRegistrationSource: m.ResetRegistrationSource() return nil } return fmt.Errorf("unknown User field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *UserMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *UserMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *UserMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *UserMutation) ClearEdge(name string) error { return fmt.Errorf("unknown User unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *UserMutation) ResetEdge(name string) error { return fmt.Errorf("unknown User edge %s", name) } // UserLoginLogMutation represents an operation that mutates the UserLoginLog nodes in the graph. type UserLoginLogMutation struct { config op Op typ string id *uint64 created_at *time.Time updated_at *time.Time status *uint8 addstatus *int8 tenant_id *uint64 addtenant_id *int64 deleted_at *time.Time user_id *uint64 adduser_id *int64 login_time *time.Time login_ip *string login_location *string login_type *userloginlog.LoginType login_platform *userloginlog.LoginPlatform login_result *bool failure_reason *string session_id *string latency_ms *int addlatency_ms *int auth_id *uint64 addauth_id *int64 additional_data *map[string]interface{} clearedFields map[string]struct{} done bool oldValue func(context.Context) (*UserLoginLog, error) predicates []predicate.UserLoginLog } var _ ent.Mutation = (*UserLoginLogMutation)(nil) // userloginlogOption allows management of the mutation configuration using functional options. type userloginlogOption func(*UserLoginLogMutation) // newUserLoginLogMutation creates new mutation for the UserLoginLog entity. func newUserLoginLogMutation(c config, op Op, opts ...userloginlogOption) *UserLoginLogMutation { m := &UserLoginLogMutation{ config: c, op: op, typ: TypeUserLoginLog, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withUserLoginLogID sets the ID field of the mutation. func withUserLoginLogID(id uint64) userloginlogOption { return func(m *UserLoginLogMutation) { var ( err error once sync.Once value *UserLoginLog ) m.oldValue = func(ctx context.Context) (*UserLoginLog, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().UserLoginLog.Get(ctx, id) } }) return value, err } m.id = &id } } // withUserLoginLog sets the old UserLoginLog of the mutation. func withUserLoginLog(node *UserLoginLog) userloginlogOption { return func(m *UserLoginLogMutation) { m.oldValue = func(context.Context) (*UserLoginLog, error) { return node, nil } m.id = &node.ID } } // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. func (m UserLoginLogMutation) Client() *Client { client := &Client{config: m.config} client.init() return client } // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. func (m UserLoginLogMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } tx := &Tx{config: m.config} tx.init() return tx, nil } // SetID sets the value of the id field. Note that this // operation is only accepted on creation of UserLoginLog entities. func (m *UserLoginLogMutation) SetID(id uint64) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. func (m *UserLoginLogMutation) ID() (id uint64, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *UserLoginLogMutation) IDs(ctx context.Context) ([]uint64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []uint64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().UserLoginLog.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetCreatedAt sets the "created_at" field. func (m *UserLoginLogMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. func (m *UserLoginLogMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return } return *v, true } // OldCreatedAt returns the old "created_at" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } return oldValue.CreatedAt, nil } // ResetCreatedAt resets all changes to the "created_at" field. func (m *UserLoginLogMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. func (m *UserLoginLogMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. func (m *UserLoginLogMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return } return *v, true } // OldUpdatedAt returns the old "updated_at" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } return oldValue.UpdatedAt, nil } // ResetUpdatedAt resets all changes to the "updated_at" field. func (m *UserLoginLogMutation) ResetUpdatedAt() { m.updated_at = nil } // SetStatus sets the "status" field. func (m *UserLoginLogMutation) SetStatus(u uint8) { m.status = &u m.addstatus = nil } // Status returns the value of the "status" field in the mutation. func (m *UserLoginLogMutation) Status() (r uint8, exists bool) { v := m.status if v == nil { return } return *v, true } // OldStatus returns the old "status" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldStatus(ctx context.Context) (v uint8, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldStatus: %w", err) } return oldValue.Status, nil } // AddStatus adds u to the "status" field. func (m *UserLoginLogMutation) AddStatus(u int8) { if m.addstatus != nil { *m.addstatus += u } else { m.addstatus = &u } } // AddedStatus returns the value that was added to the "status" field in this mutation. func (m *UserLoginLogMutation) AddedStatus() (r int8, exists bool) { v := m.addstatus if v == nil { return } return *v, true } // ClearStatus clears the value of the "status" field. func (m *UserLoginLogMutation) ClearStatus() { m.status = nil m.addstatus = nil m.clearedFields[userloginlog.FieldStatus] = struct{}{} } // StatusCleared returns if the "status" field was cleared in this mutation. func (m *UserLoginLogMutation) StatusCleared() bool { _, ok := m.clearedFields[userloginlog.FieldStatus] return ok } // ResetStatus resets all changes to the "status" field. func (m *UserLoginLogMutation) ResetStatus() { m.status = nil m.addstatus = nil delete(m.clearedFields, userloginlog.FieldStatus) } // SetTenantID sets the "tenant_id" field. func (m *UserLoginLogMutation) SetTenantID(u uint64) { m.tenant_id = &u m.addtenant_id = nil } // TenantID returns the value of the "tenant_id" field in the mutation. func (m *UserLoginLogMutation) TenantID() (r uint64, exists bool) { v := m.tenant_id if v == nil { return } return *v, true } // OldTenantID returns the old "tenant_id" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldTenantID(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTenantID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldTenantID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldTenantID: %w", err) } return oldValue.TenantID, nil } // AddTenantID adds u to the "tenant_id" field. func (m *UserLoginLogMutation) AddTenantID(u int64) { if m.addtenant_id != nil { *m.addtenant_id += u } else { m.addtenant_id = &u } } // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. func (m *UserLoginLogMutation) AddedTenantID() (r int64, exists bool) { v := m.addtenant_id if v == nil { return } return *v, true } // ResetTenantID resets all changes to the "tenant_id" field. func (m *UserLoginLogMutation) ResetTenantID() { m.tenant_id = nil m.addtenant_id = nil } // SetDeletedAt sets the "deleted_at" field. func (m *UserLoginLogMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. func (m *UserLoginLogMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return } return *v, true } // OldDeletedAt returns the old "deleted_at" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } return oldValue.DeletedAt, nil } // ClearDeletedAt clears the value of the "deleted_at" field. func (m *UserLoginLogMutation) ClearDeletedAt() { m.deleted_at = nil m.clearedFields[userloginlog.FieldDeletedAt] = struct{}{} } // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. func (m *UserLoginLogMutation) DeletedAtCleared() bool { _, ok := m.clearedFields[userloginlog.FieldDeletedAt] return ok } // ResetDeletedAt resets all changes to the "deleted_at" field. func (m *UserLoginLogMutation) ResetDeletedAt() { m.deleted_at = nil delete(m.clearedFields, userloginlog.FieldDeletedAt) } // SetUserID sets the "user_id" field. func (m *UserLoginLogMutation) SetUserID(u uint64) { m.user_id = &u m.adduser_id = nil } // UserID returns the value of the "user_id" field in the mutation. func (m *UserLoginLogMutation) UserID() (r uint64, exists bool) { v := m.user_id if v == nil { return } return *v, true } // OldUserID returns the old "user_id" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldUserID(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUserID: %w", err) } return oldValue.UserID, nil } // AddUserID adds u to the "user_id" field. func (m *UserLoginLogMutation) AddUserID(u int64) { if m.adduser_id != nil { *m.adduser_id += u } else { m.adduser_id = &u } } // AddedUserID returns the value that was added to the "user_id" field in this mutation. func (m *UserLoginLogMutation) AddedUserID() (r int64, exists bool) { v := m.adduser_id if v == nil { return } return *v, true } // ResetUserID resets all changes to the "user_id" field. func (m *UserLoginLogMutation) ResetUserID() { m.user_id = nil m.adduser_id = nil } // SetLoginTime sets the "login_time" field. func (m *UserLoginLogMutation) SetLoginTime(t time.Time) { m.login_time = &t } // LoginTime returns the value of the "login_time" field in the mutation. func (m *UserLoginLogMutation) LoginTime() (r time.Time, exists bool) { v := m.login_time if v == nil { return } return *v, true } // OldLoginTime returns the old "login_time" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLoginTime(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginTime is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginTime requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginTime: %w", err) } return oldValue.LoginTime, nil } // ResetLoginTime resets all changes to the "login_time" field. func (m *UserLoginLogMutation) ResetLoginTime() { m.login_time = nil } // SetLoginIP sets the "login_ip" field. func (m *UserLoginLogMutation) SetLoginIP(s string) { m.login_ip = &s } // LoginIP returns the value of the "login_ip" field in the mutation. func (m *UserLoginLogMutation) LoginIP() (r string, exists bool) { v := m.login_ip if v == nil { return } return *v, true } // OldLoginIP returns the old "login_ip" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLoginIP(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginIP is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginIP requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginIP: %w", err) } return oldValue.LoginIP, nil } // ResetLoginIP resets all changes to the "login_ip" field. func (m *UserLoginLogMutation) ResetLoginIP() { m.login_ip = nil } // SetLoginLocation sets the "login_location" field. func (m *UserLoginLogMutation) SetLoginLocation(s string) { m.login_location = &s } // LoginLocation returns the value of the "login_location" field in the mutation. func (m *UserLoginLogMutation) LoginLocation() (r string, exists bool) { v := m.login_location if v == nil { return } return *v, true } // OldLoginLocation returns the old "login_location" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLoginLocation(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginLocation is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginLocation requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginLocation: %w", err) } return oldValue.LoginLocation, nil } // ClearLoginLocation clears the value of the "login_location" field. func (m *UserLoginLogMutation) ClearLoginLocation() { m.login_location = nil m.clearedFields[userloginlog.FieldLoginLocation] = struct{}{} } // LoginLocationCleared returns if the "login_location" field was cleared in this mutation. func (m *UserLoginLogMutation) LoginLocationCleared() bool { _, ok := m.clearedFields[userloginlog.FieldLoginLocation] return ok } // ResetLoginLocation resets all changes to the "login_location" field. func (m *UserLoginLogMutation) ResetLoginLocation() { m.login_location = nil delete(m.clearedFields, userloginlog.FieldLoginLocation) } // SetLoginType sets the "login_type" field. func (m *UserLoginLogMutation) SetLoginType(ut userloginlog.LoginType) { m.login_type = &ut } // LoginType returns the value of the "login_type" field in the mutation. func (m *UserLoginLogMutation) LoginType() (r userloginlog.LoginType, exists bool) { v := m.login_type if v == nil { return } return *v, true } // OldLoginType returns the old "login_type" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLoginType(ctx context.Context) (v userloginlog.LoginType, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginType: %w", err) } return oldValue.LoginType, nil } // ResetLoginType resets all changes to the "login_type" field. func (m *UserLoginLogMutation) ResetLoginType() { m.login_type = nil } // SetLoginPlatform sets the "login_platform" field. func (m *UserLoginLogMutation) SetLoginPlatform(up userloginlog.LoginPlatform) { m.login_platform = &up } // LoginPlatform returns the value of the "login_platform" field in the mutation. func (m *UserLoginLogMutation) LoginPlatform() (r userloginlog.LoginPlatform, exists bool) { v := m.login_platform if v == nil { return } return *v, true } // OldLoginPlatform returns the old "login_platform" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLoginPlatform(ctx context.Context) (v userloginlog.LoginPlatform, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginPlatform is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginPlatform requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginPlatform: %w", err) } return oldValue.LoginPlatform, nil } // ResetLoginPlatform resets all changes to the "login_platform" field. func (m *UserLoginLogMutation) ResetLoginPlatform() { m.login_platform = nil } // SetLoginResult sets the "login_result" field. func (m *UserLoginLogMutation) SetLoginResult(b bool) { m.login_result = &b } // LoginResult returns the value of the "login_result" field in the mutation. func (m *UserLoginLogMutation) LoginResult() (r bool, exists bool) { v := m.login_result if v == nil { return } return *v, true } // OldLoginResult returns the old "login_result" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLoginResult(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLoginResult is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLoginResult requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLoginResult: %w", err) } return oldValue.LoginResult, nil } // ResetLoginResult resets all changes to the "login_result" field. func (m *UserLoginLogMutation) ResetLoginResult() { m.login_result = nil } // SetFailureReason sets the "failure_reason" field. func (m *UserLoginLogMutation) SetFailureReason(s string) { m.failure_reason = &s } // FailureReason returns the value of the "failure_reason" field in the mutation. func (m *UserLoginLogMutation) FailureReason() (r string, exists bool) { v := m.failure_reason if v == nil { return } return *v, true } // OldFailureReason returns the old "failure_reason" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldFailureReason(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldFailureReason is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldFailureReason requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldFailureReason: %w", err) } return oldValue.FailureReason, nil } // ClearFailureReason clears the value of the "failure_reason" field. func (m *UserLoginLogMutation) ClearFailureReason() { m.failure_reason = nil m.clearedFields[userloginlog.FieldFailureReason] = struct{}{} } // FailureReasonCleared returns if the "failure_reason" field was cleared in this mutation. func (m *UserLoginLogMutation) FailureReasonCleared() bool { _, ok := m.clearedFields[userloginlog.FieldFailureReason] return ok } // ResetFailureReason resets all changes to the "failure_reason" field. func (m *UserLoginLogMutation) ResetFailureReason() { m.failure_reason = nil delete(m.clearedFields, userloginlog.FieldFailureReason) } // SetSessionID sets the "session_id" field. func (m *UserLoginLogMutation) SetSessionID(s string) { m.session_id = &s } // SessionID returns the value of the "session_id" field in the mutation. func (m *UserLoginLogMutation) SessionID() (r string, exists bool) { v := m.session_id if v == nil { return } return *v, true } // OldSessionID returns the old "session_id" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldSessionID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldSessionID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldSessionID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldSessionID: %w", err) } return oldValue.SessionID, nil } // ClearSessionID clears the value of the "session_id" field. func (m *UserLoginLogMutation) ClearSessionID() { m.session_id = nil m.clearedFields[userloginlog.FieldSessionID] = struct{}{} } // SessionIDCleared returns if the "session_id" field was cleared in this mutation. func (m *UserLoginLogMutation) SessionIDCleared() bool { _, ok := m.clearedFields[userloginlog.FieldSessionID] return ok } // ResetSessionID resets all changes to the "session_id" field. func (m *UserLoginLogMutation) ResetSessionID() { m.session_id = nil delete(m.clearedFields, userloginlog.FieldSessionID) } // SetLatencyMs sets the "latency_ms" field. func (m *UserLoginLogMutation) SetLatencyMs(i int) { m.latency_ms = &i m.addlatency_ms = nil } // LatencyMs returns the value of the "latency_ms" field in the mutation. func (m *UserLoginLogMutation) LatencyMs() (r int, exists bool) { v := m.latency_ms if v == nil { return } return *v, true } // OldLatencyMs returns the old "latency_ms" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldLatencyMs(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldLatencyMs is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldLatencyMs requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldLatencyMs: %w", err) } return oldValue.LatencyMs, nil } // AddLatencyMs adds i to the "latency_ms" field. func (m *UserLoginLogMutation) AddLatencyMs(i int) { if m.addlatency_ms != nil { *m.addlatency_ms += i } else { m.addlatency_ms = &i } } // AddedLatencyMs returns the value that was added to the "latency_ms" field in this mutation. func (m *UserLoginLogMutation) AddedLatencyMs() (r int, exists bool) { v := m.addlatency_ms if v == nil { return } return *v, true } // ClearLatencyMs clears the value of the "latency_ms" field. func (m *UserLoginLogMutation) ClearLatencyMs() { m.latency_ms = nil m.addlatency_ms = nil m.clearedFields[userloginlog.FieldLatencyMs] = struct{}{} } // LatencyMsCleared returns if the "latency_ms" field was cleared in this mutation. func (m *UserLoginLogMutation) LatencyMsCleared() bool { _, ok := m.clearedFields[userloginlog.FieldLatencyMs] return ok } // ResetLatencyMs resets all changes to the "latency_ms" field. func (m *UserLoginLogMutation) ResetLatencyMs() { m.latency_ms = nil m.addlatency_ms = nil delete(m.clearedFields, userloginlog.FieldLatencyMs) } // SetAuthID sets the "auth_id" field. func (m *UserLoginLogMutation) SetAuthID(u uint64) { m.auth_id = &u m.addauth_id = nil } // AuthID returns the value of the "auth_id" field in the mutation. func (m *UserLoginLogMutation) AuthID() (r uint64, exists bool) { v := m.auth_id if v == nil { return } return *v, true } // OldAuthID returns the old "auth_id" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldAuthID(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAuthID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAuthID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAuthID: %w", err) } return oldValue.AuthID, nil } // AddAuthID adds u to the "auth_id" field. func (m *UserLoginLogMutation) AddAuthID(u int64) { if m.addauth_id != nil { *m.addauth_id += u } else { m.addauth_id = &u } } // AddedAuthID returns the value that was added to the "auth_id" field in this mutation. func (m *UserLoginLogMutation) AddedAuthID() (r int64, exists bool) { v := m.addauth_id if v == nil { return } return *v, true } // ClearAuthID clears the value of the "auth_id" field. func (m *UserLoginLogMutation) ClearAuthID() { m.auth_id = nil m.addauth_id = nil m.clearedFields[userloginlog.FieldAuthID] = struct{}{} } // AuthIDCleared returns if the "auth_id" field was cleared in this mutation. func (m *UserLoginLogMutation) AuthIDCleared() bool { _, ok := m.clearedFields[userloginlog.FieldAuthID] return ok } // ResetAuthID resets all changes to the "auth_id" field. func (m *UserLoginLogMutation) ResetAuthID() { m.auth_id = nil m.addauth_id = nil delete(m.clearedFields, userloginlog.FieldAuthID) } // SetAdditionalData sets the "additional_data" field. func (m *UserLoginLogMutation) SetAdditionalData(value map[string]interface{}) { m.additional_data = &value } // AdditionalData returns the value of the "additional_data" field in the mutation. func (m *UserLoginLogMutation) AdditionalData() (r map[string]interface{}, exists bool) { v := m.additional_data if v == nil { return } return *v, true } // OldAdditionalData returns the old "additional_data" field's value of the UserLoginLog entity. // If the UserLoginLog object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserLoginLogMutation) OldAdditionalData(ctx context.Context) (v map[string]interface{}, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAdditionalData is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAdditionalData requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAdditionalData: %w", err) } return oldValue.AdditionalData, nil } // ClearAdditionalData clears the value of the "additional_data" field. func (m *UserLoginLogMutation) ClearAdditionalData() { m.additional_data = nil m.clearedFields[userloginlog.FieldAdditionalData] = struct{}{} } // AdditionalDataCleared returns if the "additional_data" field was cleared in this mutation. func (m *UserLoginLogMutation) AdditionalDataCleared() bool { _, ok := m.clearedFields[userloginlog.FieldAdditionalData] return ok } // ResetAdditionalData resets all changes to the "additional_data" field. func (m *UserLoginLogMutation) ResetAdditionalData() { m.additional_data = nil delete(m.clearedFields, userloginlog.FieldAdditionalData) } // Where appends a list predicates to the UserLoginLogMutation builder. func (m *UserLoginLogMutation) Where(ps ...predicate.UserLoginLog) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the UserLoginLogMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *UserLoginLogMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.UserLoginLog, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *UserLoginLogMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *UserLoginLogMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (UserLoginLog). func (m *UserLoginLogMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserLoginLogMutation) Fields() []string { fields := make([]string, 0, 17) if m.created_at != nil { fields = append(fields, userloginlog.FieldCreatedAt) } if m.updated_at != nil { fields = append(fields, userloginlog.FieldUpdatedAt) } if m.status != nil { fields = append(fields, userloginlog.FieldStatus) } if m.tenant_id != nil { fields = append(fields, userloginlog.FieldTenantID) } if m.deleted_at != nil { fields = append(fields, userloginlog.FieldDeletedAt) } if m.user_id != nil { fields = append(fields, userloginlog.FieldUserID) } if m.login_time != nil { fields = append(fields, userloginlog.FieldLoginTime) } if m.login_ip != nil { fields = append(fields, userloginlog.FieldLoginIP) } if m.login_location != nil { fields = append(fields, userloginlog.FieldLoginLocation) } if m.login_type != nil { fields = append(fields, userloginlog.FieldLoginType) } if m.login_platform != nil { fields = append(fields, userloginlog.FieldLoginPlatform) } if m.login_result != nil { fields = append(fields, userloginlog.FieldLoginResult) } if m.failure_reason != nil { fields = append(fields, userloginlog.FieldFailureReason) } if m.session_id != nil { fields = append(fields, userloginlog.FieldSessionID) } if m.latency_ms != nil { fields = append(fields, userloginlog.FieldLatencyMs) } if m.auth_id != nil { fields = append(fields, userloginlog.FieldAuthID) } if m.additional_data != nil { fields = append(fields, userloginlog.FieldAdditionalData) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *UserLoginLogMutation) Field(name string) (ent.Value, bool) { switch name { case userloginlog.FieldCreatedAt: return m.CreatedAt() case userloginlog.FieldUpdatedAt: return m.UpdatedAt() case userloginlog.FieldStatus: return m.Status() case userloginlog.FieldTenantID: return m.TenantID() case userloginlog.FieldDeletedAt: return m.DeletedAt() case userloginlog.FieldUserID: return m.UserID() case userloginlog.FieldLoginTime: return m.LoginTime() case userloginlog.FieldLoginIP: return m.LoginIP() case userloginlog.FieldLoginLocation: return m.LoginLocation() case userloginlog.FieldLoginType: return m.LoginType() case userloginlog.FieldLoginPlatform: return m.LoginPlatform() case userloginlog.FieldLoginResult: return m.LoginResult() case userloginlog.FieldFailureReason: return m.FailureReason() case userloginlog.FieldSessionID: return m.SessionID() case userloginlog.FieldLatencyMs: return m.LatencyMs() case userloginlog.FieldAuthID: return m.AuthID() case userloginlog.FieldAdditionalData: return m.AdditionalData() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *UserLoginLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case userloginlog.FieldCreatedAt: return m.OldCreatedAt(ctx) case userloginlog.FieldUpdatedAt: return m.OldUpdatedAt(ctx) case userloginlog.FieldStatus: return m.OldStatus(ctx) case userloginlog.FieldTenantID: return m.OldTenantID(ctx) case userloginlog.FieldDeletedAt: return m.OldDeletedAt(ctx) case userloginlog.FieldUserID: return m.OldUserID(ctx) case userloginlog.FieldLoginTime: return m.OldLoginTime(ctx) case userloginlog.FieldLoginIP: return m.OldLoginIP(ctx) case userloginlog.FieldLoginLocation: return m.OldLoginLocation(ctx) case userloginlog.FieldLoginType: return m.OldLoginType(ctx) case userloginlog.FieldLoginPlatform: return m.OldLoginPlatform(ctx) case userloginlog.FieldLoginResult: return m.OldLoginResult(ctx) case userloginlog.FieldFailureReason: return m.OldFailureReason(ctx) case userloginlog.FieldSessionID: return m.OldSessionID(ctx) case userloginlog.FieldLatencyMs: return m.OldLatencyMs(ctx) case userloginlog.FieldAuthID: return m.OldAuthID(ctx) case userloginlog.FieldAdditionalData: return m.OldAdditionalData(ctx) } return nil, fmt.Errorf("unknown UserLoginLog field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *UserLoginLogMutation) SetField(name string, value ent.Value) error { switch name { case userloginlog.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil case userloginlog.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUpdatedAt(v) return nil case userloginlog.FieldStatus: v, ok := value.(uint8) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetStatus(v) return nil case userloginlog.FieldTenantID: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTenantID(v) return nil case userloginlog.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil case userloginlog.FieldUserID: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserID(v) return nil case userloginlog.FieldLoginTime: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginTime(v) return nil case userloginlog.FieldLoginIP: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginIP(v) return nil case userloginlog.FieldLoginLocation: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginLocation(v) return nil case userloginlog.FieldLoginType: v, ok := value.(userloginlog.LoginType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginType(v) return nil case userloginlog.FieldLoginPlatform: v, ok := value.(userloginlog.LoginPlatform) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginPlatform(v) return nil case userloginlog.FieldLoginResult: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLoginResult(v) return nil case userloginlog.FieldFailureReason: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetFailureReason(v) return nil case userloginlog.FieldSessionID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetSessionID(v) return nil case userloginlog.FieldLatencyMs: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetLatencyMs(v) return nil case userloginlog.FieldAuthID: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAuthID(v) return nil case userloginlog.FieldAdditionalData: v, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAdditionalData(v) return nil } return fmt.Errorf("unknown UserLoginLog field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *UserLoginLogMutation) AddedFields() []string { var fields []string if m.addstatus != nil { fields = append(fields, userloginlog.FieldStatus) } if m.addtenant_id != nil { fields = append(fields, userloginlog.FieldTenantID) } if m.adduser_id != nil { fields = append(fields, userloginlog.FieldUserID) } if m.addlatency_ms != nil { fields = append(fields, userloginlog.FieldLatencyMs) } if m.addauth_id != nil { fields = append(fields, userloginlog.FieldAuthID) } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *UserLoginLogMutation) AddedField(name string) (ent.Value, bool) { switch name { case userloginlog.FieldStatus: return m.AddedStatus() case userloginlog.FieldTenantID: return m.AddedTenantID() case userloginlog.FieldUserID: return m.AddedUserID() case userloginlog.FieldLatencyMs: return m.AddedLatencyMs() case userloginlog.FieldAuthID: return m.AddedAuthID() } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *UserLoginLogMutation) AddField(name string, value ent.Value) error { switch name { case userloginlog.FieldStatus: v, ok := value.(int8) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddStatus(v) return nil case userloginlog.FieldTenantID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTenantID(v) return nil case userloginlog.FieldUserID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUserID(v) return nil case userloginlog.FieldLatencyMs: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddLatencyMs(v) return nil case userloginlog.FieldAuthID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddAuthID(v) return nil } return fmt.Errorf("unknown UserLoginLog numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *UserLoginLogMutation) ClearedFields() []string { var fields []string if m.FieldCleared(userloginlog.FieldStatus) { fields = append(fields, userloginlog.FieldStatus) } if m.FieldCleared(userloginlog.FieldDeletedAt) { fields = append(fields, userloginlog.FieldDeletedAt) } if m.FieldCleared(userloginlog.FieldLoginLocation) { fields = append(fields, userloginlog.FieldLoginLocation) } if m.FieldCleared(userloginlog.FieldFailureReason) { fields = append(fields, userloginlog.FieldFailureReason) } if m.FieldCleared(userloginlog.FieldSessionID) { fields = append(fields, userloginlog.FieldSessionID) } if m.FieldCleared(userloginlog.FieldLatencyMs) { fields = append(fields, userloginlog.FieldLatencyMs) } if m.FieldCleared(userloginlog.FieldAuthID) { fields = append(fields, userloginlog.FieldAuthID) } if m.FieldCleared(userloginlog.FieldAdditionalData) { fields = append(fields, userloginlog.FieldAdditionalData) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *UserLoginLogMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *UserLoginLogMutation) ClearField(name string) error { switch name { case userloginlog.FieldStatus: m.ClearStatus() return nil case userloginlog.FieldDeletedAt: m.ClearDeletedAt() return nil case userloginlog.FieldLoginLocation: m.ClearLoginLocation() return nil case userloginlog.FieldFailureReason: m.ClearFailureReason() return nil case userloginlog.FieldSessionID: m.ClearSessionID() return nil case userloginlog.FieldLatencyMs: m.ClearLatencyMs() return nil case userloginlog.FieldAuthID: m.ClearAuthID() return nil case userloginlog.FieldAdditionalData: m.ClearAdditionalData() return nil } return fmt.Errorf("unknown UserLoginLog nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *UserLoginLogMutation) ResetField(name string) error { switch name { case userloginlog.FieldCreatedAt: m.ResetCreatedAt() return nil case userloginlog.FieldUpdatedAt: m.ResetUpdatedAt() return nil case userloginlog.FieldStatus: m.ResetStatus() return nil case userloginlog.FieldTenantID: m.ResetTenantID() return nil case userloginlog.FieldDeletedAt: m.ResetDeletedAt() return nil case userloginlog.FieldUserID: m.ResetUserID() return nil case userloginlog.FieldLoginTime: m.ResetLoginTime() return nil case userloginlog.FieldLoginIP: m.ResetLoginIP() return nil case userloginlog.FieldLoginLocation: m.ResetLoginLocation() return nil case userloginlog.FieldLoginType: m.ResetLoginType() return nil case userloginlog.FieldLoginPlatform: m.ResetLoginPlatform() return nil case userloginlog.FieldLoginResult: m.ResetLoginResult() return nil case userloginlog.FieldFailureReason: m.ResetFailureReason() return nil case userloginlog.FieldSessionID: m.ResetSessionID() return nil case userloginlog.FieldLatencyMs: m.ResetLatencyMs() return nil case userloginlog.FieldAuthID: m.ResetAuthID() return nil case userloginlog.FieldAdditionalData: m.ResetAdditionalData() return nil } return fmt.Errorf("unknown UserLoginLog field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserLoginLogMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *UserLoginLogMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserLoginLogMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *UserLoginLogMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserLoginLogMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *UserLoginLogMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *UserLoginLogMutation) ClearEdge(name string) error { return fmt.Errorf("unknown UserLoginLog unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *UserLoginLogMutation) ResetEdge(name string) error { return fmt.Errorf("unknown UserLoginLog edge %s", name) } // UserThirdAuthMutation represents an operation that mutates the UserThirdAuth nodes in the graph. type UserThirdAuthMutation struct { config op Op typ string id *uint64 created_at *time.Time updated_at *time.Time status *uint8 addstatus *int8 tenant_id *uint64 addtenant_id *int64 deleted_at *time.Time user_id *uint64 adduser_id *int64 openid *string unionid *string access_token *string refresh_token *string access_token_expiry *time.Time user_info *map[string]interface{} platform_user_id *string nickname *string avatar *string email *string phone *string is_bound *bool bound_at *time.Time extra_data *map[string]interface{} clearedFields map[string]struct{} done bool oldValue func(context.Context) (*UserThirdAuth, error) predicates []predicate.UserThirdAuth } var _ ent.Mutation = (*UserThirdAuthMutation)(nil) // userthirdauthOption allows management of the mutation configuration using functional options. type userthirdauthOption func(*UserThirdAuthMutation) // newUserThirdAuthMutation creates new mutation for the UserThirdAuth entity. func newUserThirdAuthMutation(c config, op Op, opts ...userthirdauthOption) *UserThirdAuthMutation { m := &UserThirdAuthMutation{ config: c, op: op, typ: TypeUserThirdAuth, clearedFields: make(map[string]struct{}), } for _, opt := range opts { opt(m) } return m } // withUserThirdAuthID sets the ID field of the mutation. func withUserThirdAuthID(id uint64) userthirdauthOption { return func(m *UserThirdAuthMutation) { var ( err error once sync.Once value *UserThirdAuth ) m.oldValue = func(ctx context.Context) (*UserThirdAuth, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { value, err = m.Client().UserThirdAuth.Get(ctx, id) } }) return value, err } m.id = &id } } // withUserThirdAuth sets the old UserThirdAuth of the mutation. func withUserThirdAuth(node *UserThirdAuth) userthirdauthOption { return func(m *UserThirdAuthMutation) { m.oldValue = func(context.Context) (*UserThirdAuth, error) { return node, nil } m.id = &node.ID } } // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. func (m UserThirdAuthMutation) Client() *Client { client := &Client{config: m.config} client.init() return client } // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. func (m UserThirdAuthMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } tx := &Tx{config: m.config} tx.init() return tx, nil } // SetID sets the value of the id field. Note that this // operation is only accepted on creation of UserThirdAuth entities. func (m *UserThirdAuthMutation) SetID(id uint64) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. func (m *UserThirdAuthMutation) ID() (id uint64, exists bool) { if m.id == nil { return } return *m.id, true } // IDs queries the database and returns the entity ids that match the mutation's predicate. // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. func (m *UserThirdAuthMutation) IDs(ctx context.Context) ([]uint64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { return []uint64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): return m.Client().UserThirdAuth.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetCreatedAt sets the "created_at" field. func (m *UserThirdAuthMutation) SetCreatedAt(t time.Time) { m.created_at = &t } // CreatedAt returns the value of the "created_at" field in the mutation. func (m *UserThirdAuthMutation) CreatedAt() (r time.Time, exists bool) { v := m.created_at if v == nil { return } return *v, true } // OldCreatedAt returns the old "created_at" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } return oldValue.CreatedAt, nil } // ResetCreatedAt resets all changes to the "created_at" field. func (m *UserThirdAuthMutation) ResetCreatedAt() { m.created_at = nil } // SetUpdatedAt sets the "updated_at" field. func (m *UserThirdAuthMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t } // UpdatedAt returns the value of the "updated_at" field in the mutation. func (m *UserThirdAuthMutation) UpdatedAt() (r time.Time, exists bool) { v := m.updated_at if v == nil { return } return *v, true } // OldUpdatedAt returns the old "updated_at" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } return oldValue.UpdatedAt, nil } // ResetUpdatedAt resets all changes to the "updated_at" field. func (m *UserThirdAuthMutation) ResetUpdatedAt() { m.updated_at = nil } // SetStatus sets the "status" field. func (m *UserThirdAuthMutation) SetStatus(u uint8) { m.status = &u m.addstatus = nil } // Status returns the value of the "status" field in the mutation. func (m *UserThirdAuthMutation) Status() (r uint8, exists bool) { v := m.status if v == nil { return } return *v, true } // OldStatus returns the old "status" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldStatus(ctx context.Context) (v uint8, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldStatus: %w", err) } return oldValue.Status, nil } // AddStatus adds u to the "status" field. func (m *UserThirdAuthMutation) AddStatus(u int8) { if m.addstatus != nil { *m.addstatus += u } else { m.addstatus = &u } } // AddedStatus returns the value that was added to the "status" field in this mutation. func (m *UserThirdAuthMutation) AddedStatus() (r int8, exists bool) { v := m.addstatus if v == nil { return } return *v, true } // ClearStatus clears the value of the "status" field. func (m *UserThirdAuthMutation) ClearStatus() { m.status = nil m.addstatus = nil m.clearedFields[userthirdauth.FieldStatus] = struct{}{} } // StatusCleared returns if the "status" field was cleared in this mutation. func (m *UserThirdAuthMutation) StatusCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldStatus] return ok } // ResetStatus resets all changes to the "status" field. func (m *UserThirdAuthMutation) ResetStatus() { m.status = nil m.addstatus = nil delete(m.clearedFields, userthirdauth.FieldStatus) } // SetTenantID sets the "tenant_id" field. func (m *UserThirdAuthMutation) SetTenantID(u uint64) { m.tenant_id = &u m.addtenant_id = nil } // TenantID returns the value of the "tenant_id" field in the mutation. func (m *UserThirdAuthMutation) TenantID() (r uint64, exists bool) { v := m.tenant_id if v == nil { return } return *v, true } // OldTenantID returns the old "tenant_id" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldTenantID(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldTenantID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldTenantID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldTenantID: %w", err) } return oldValue.TenantID, nil } // AddTenantID adds u to the "tenant_id" field. func (m *UserThirdAuthMutation) AddTenantID(u int64) { if m.addtenant_id != nil { *m.addtenant_id += u } else { m.addtenant_id = &u } } // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation. func (m *UserThirdAuthMutation) AddedTenantID() (r int64, exists bool) { v := m.addtenant_id if v == nil { return } return *v, true } // ResetTenantID resets all changes to the "tenant_id" field. func (m *UserThirdAuthMutation) ResetTenantID() { m.tenant_id = nil m.addtenant_id = nil } // SetDeletedAt sets the "deleted_at" field. func (m *UserThirdAuthMutation) SetDeletedAt(t time.Time) { m.deleted_at = &t } // DeletedAt returns the value of the "deleted_at" field in the mutation. func (m *UserThirdAuthMutation) DeletedAt() (r time.Time, exists bool) { v := m.deleted_at if v == nil { return } return *v, true } // OldDeletedAt returns the old "deleted_at" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldDeletedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err) } return oldValue.DeletedAt, nil } // ClearDeletedAt clears the value of the "deleted_at" field. func (m *UserThirdAuthMutation) ClearDeletedAt() { m.deleted_at = nil m.clearedFields[userthirdauth.FieldDeletedAt] = struct{}{} } // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation. func (m *UserThirdAuthMutation) DeletedAtCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldDeletedAt] return ok } // ResetDeletedAt resets all changes to the "deleted_at" field. func (m *UserThirdAuthMutation) ResetDeletedAt() { m.deleted_at = nil delete(m.clearedFields, userthirdauth.FieldDeletedAt) } // SetUserID sets the "user_id" field. func (m *UserThirdAuthMutation) SetUserID(u uint64) { m.user_id = &u m.adduser_id = nil } // UserID returns the value of the "user_id" field in the mutation. func (m *UserThirdAuthMutation) UserID() (r uint64, exists bool) { v := m.user_id if v == nil { return } return *v, true } // OldUserID returns the old "user_id" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldUserID(ctx context.Context) (v uint64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUserID: %w", err) } return oldValue.UserID, nil } // AddUserID adds u to the "user_id" field. func (m *UserThirdAuthMutation) AddUserID(u int64) { if m.adduser_id != nil { *m.adduser_id += u } else { m.adduser_id = &u } } // AddedUserID returns the value that was added to the "user_id" field in this mutation. func (m *UserThirdAuthMutation) AddedUserID() (r int64, exists bool) { v := m.adduser_id if v == nil { return } return *v, true } // ResetUserID resets all changes to the "user_id" field. func (m *UserThirdAuthMutation) ResetUserID() { m.user_id = nil m.adduser_id = nil } // SetOpenid sets the "openid" field. func (m *UserThirdAuthMutation) SetOpenid(s string) { m.openid = &s } // Openid returns the value of the "openid" field in the mutation. func (m *UserThirdAuthMutation) Openid() (r string, exists bool) { v := m.openid if v == nil { return } return *v, true } // OldOpenid returns the old "openid" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldOpenid(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldOpenid is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldOpenid requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldOpenid: %w", err) } return oldValue.Openid, nil } // ResetOpenid resets all changes to the "openid" field. func (m *UserThirdAuthMutation) ResetOpenid() { m.openid = nil } // SetUnionid sets the "unionid" field. func (m *UserThirdAuthMutation) SetUnionid(s string) { m.unionid = &s } // Unionid returns the value of the "unionid" field in the mutation. func (m *UserThirdAuthMutation) Unionid() (r string, exists bool) { v := m.unionid if v == nil { return } return *v, true } // OldUnionid returns the old "unionid" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldUnionid(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUnionid is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUnionid requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUnionid: %w", err) } return oldValue.Unionid, nil } // ClearUnionid clears the value of the "unionid" field. func (m *UserThirdAuthMutation) ClearUnionid() { m.unionid = nil m.clearedFields[userthirdauth.FieldUnionid] = struct{}{} } // UnionidCleared returns if the "unionid" field was cleared in this mutation. func (m *UserThirdAuthMutation) UnionidCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldUnionid] return ok } // ResetUnionid resets all changes to the "unionid" field. func (m *UserThirdAuthMutation) ResetUnionid() { m.unionid = nil delete(m.clearedFields, userthirdauth.FieldUnionid) } // SetAccessToken sets the "access_token" field. func (m *UserThirdAuthMutation) SetAccessToken(s string) { m.access_token = &s } // AccessToken returns the value of the "access_token" field in the mutation. func (m *UserThirdAuthMutation) AccessToken() (r string, exists bool) { v := m.access_token if v == nil { return } return *v, true } // OldAccessToken returns the old "access_token" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldAccessToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAccessToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAccessToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAccessToken: %w", err) } return oldValue.AccessToken, nil } // ClearAccessToken clears the value of the "access_token" field. func (m *UserThirdAuthMutation) ClearAccessToken() { m.access_token = nil m.clearedFields[userthirdauth.FieldAccessToken] = struct{}{} } // AccessTokenCleared returns if the "access_token" field was cleared in this mutation. func (m *UserThirdAuthMutation) AccessTokenCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldAccessToken] return ok } // ResetAccessToken resets all changes to the "access_token" field. func (m *UserThirdAuthMutation) ResetAccessToken() { m.access_token = nil delete(m.clearedFields, userthirdauth.FieldAccessToken) } // SetRefreshToken sets the "refresh_token" field. func (m *UserThirdAuthMutation) SetRefreshToken(s string) { m.refresh_token = &s } // RefreshToken returns the value of the "refresh_token" field in the mutation. func (m *UserThirdAuthMutation) RefreshToken() (r string, exists bool) { v := m.refresh_token if v == nil { return } return *v, true } // OldRefreshToken returns the old "refresh_token" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldRefreshToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRefreshToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldRefreshToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldRefreshToken: %w", err) } return oldValue.RefreshToken, nil } // ClearRefreshToken clears the value of the "refresh_token" field. func (m *UserThirdAuthMutation) ClearRefreshToken() { m.refresh_token = nil m.clearedFields[userthirdauth.FieldRefreshToken] = struct{}{} } // RefreshTokenCleared returns if the "refresh_token" field was cleared in this mutation. func (m *UserThirdAuthMutation) RefreshTokenCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldRefreshToken] return ok } // ResetRefreshToken resets all changes to the "refresh_token" field. func (m *UserThirdAuthMutation) ResetRefreshToken() { m.refresh_token = nil delete(m.clearedFields, userthirdauth.FieldRefreshToken) } // SetAccessTokenExpiry sets the "access_token_expiry" field. func (m *UserThirdAuthMutation) SetAccessTokenExpiry(t time.Time) { m.access_token_expiry = &t } // AccessTokenExpiry returns the value of the "access_token_expiry" field in the mutation. func (m *UserThirdAuthMutation) AccessTokenExpiry() (r time.Time, exists bool) { v := m.access_token_expiry if v == nil { return } return *v, true } // OldAccessTokenExpiry returns the old "access_token_expiry" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldAccessTokenExpiry(ctx context.Context) (v *time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAccessTokenExpiry is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAccessTokenExpiry requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAccessTokenExpiry: %w", err) } return oldValue.AccessTokenExpiry, nil } // ClearAccessTokenExpiry clears the value of the "access_token_expiry" field. func (m *UserThirdAuthMutation) ClearAccessTokenExpiry() { m.access_token_expiry = nil m.clearedFields[userthirdauth.FieldAccessTokenExpiry] = struct{}{} } // AccessTokenExpiryCleared returns if the "access_token_expiry" field was cleared in this mutation. func (m *UserThirdAuthMutation) AccessTokenExpiryCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldAccessTokenExpiry] return ok } // ResetAccessTokenExpiry resets all changes to the "access_token_expiry" field. func (m *UserThirdAuthMutation) ResetAccessTokenExpiry() { m.access_token_expiry = nil delete(m.clearedFields, userthirdauth.FieldAccessTokenExpiry) } // SetUserInfo sets the "user_info" field. func (m *UserThirdAuthMutation) SetUserInfo(value map[string]interface{}) { m.user_info = &value } // UserInfo returns the value of the "user_info" field in the mutation. func (m *UserThirdAuthMutation) UserInfo() (r map[string]interface{}, exists bool) { v := m.user_info if v == nil { return } return *v, true } // OldUserInfo returns the old "user_info" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldUserInfo(ctx context.Context) (v map[string]interface{}, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUserInfo is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldUserInfo requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldUserInfo: %w", err) } return oldValue.UserInfo, nil } // ClearUserInfo clears the value of the "user_info" field. func (m *UserThirdAuthMutation) ClearUserInfo() { m.user_info = nil m.clearedFields[userthirdauth.FieldUserInfo] = struct{}{} } // UserInfoCleared returns if the "user_info" field was cleared in this mutation. func (m *UserThirdAuthMutation) UserInfoCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldUserInfo] return ok } // ResetUserInfo resets all changes to the "user_info" field. func (m *UserThirdAuthMutation) ResetUserInfo() { m.user_info = nil delete(m.clearedFields, userthirdauth.FieldUserInfo) } // SetPlatformUserID sets the "platform_user_id" field. func (m *UserThirdAuthMutation) SetPlatformUserID(s string) { m.platform_user_id = &s } // PlatformUserID returns the value of the "platform_user_id" field in the mutation. func (m *UserThirdAuthMutation) PlatformUserID() (r string, exists bool) { v := m.platform_user_id if v == nil { return } return *v, true } // OldPlatformUserID returns the old "platform_user_id" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldPlatformUserID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPlatformUserID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldPlatformUserID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldPlatformUserID: %w", err) } return oldValue.PlatformUserID, nil } // ClearPlatformUserID clears the value of the "platform_user_id" field. func (m *UserThirdAuthMutation) ClearPlatformUserID() { m.platform_user_id = nil m.clearedFields[userthirdauth.FieldPlatformUserID] = struct{}{} } // PlatformUserIDCleared returns if the "platform_user_id" field was cleared in this mutation. func (m *UserThirdAuthMutation) PlatformUserIDCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldPlatformUserID] return ok } // ResetPlatformUserID resets all changes to the "platform_user_id" field. func (m *UserThirdAuthMutation) ResetPlatformUserID() { m.platform_user_id = nil delete(m.clearedFields, userthirdauth.FieldPlatformUserID) } // SetNickname sets the "nickname" field. func (m *UserThirdAuthMutation) SetNickname(s string) { m.nickname = &s } // Nickname returns the value of the "nickname" field in the mutation. func (m *UserThirdAuthMutation) Nickname() (r string, exists bool) { v := m.nickname if v == nil { return } return *v, true } // OldNickname returns the old "nickname" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldNickname(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldNickname is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldNickname requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldNickname: %w", err) } return oldValue.Nickname, nil } // ClearNickname clears the value of the "nickname" field. func (m *UserThirdAuthMutation) ClearNickname() { m.nickname = nil m.clearedFields[userthirdauth.FieldNickname] = struct{}{} } // NicknameCleared returns if the "nickname" field was cleared in this mutation. func (m *UserThirdAuthMutation) NicknameCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldNickname] return ok } // ResetNickname resets all changes to the "nickname" field. func (m *UserThirdAuthMutation) ResetNickname() { m.nickname = nil delete(m.clearedFields, userthirdauth.FieldNickname) } // SetAvatar sets the "avatar" field. func (m *UserThirdAuthMutation) SetAvatar(s string) { m.avatar = &s } // Avatar returns the value of the "avatar" field in the mutation. func (m *UserThirdAuthMutation) Avatar() (r string, exists bool) { v := m.avatar if v == nil { return } return *v, true } // OldAvatar returns the old "avatar" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldAvatar(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldAvatar is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldAvatar requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldAvatar: %w", err) } return oldValue.Avatar, nil } // ClearAvatar clears the value of the "avatar" field. func (m *UserThirdAuthMutation) ClearAvatar() { m.avatar = nil m.clearedFields[userthirdauth.FieldAvatar] = struct{}{} } // AvatarCleared returns if the "avatar" field was cleared in this mutation. func (m *UserThirdAuthMutation) AvatarCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldAvatar] return ok } // ResetAvatar resets all changes to the "avatar" field. func (m *UserThirdAuthMutation) ResetAvatar() { m.avatar = nil delete(m.clearedFields, userthirdauth.FieldAvatar) } // SetEmail sets the "email" field. func (m *UserThirdAuthMutation) SetEmail(s string) { m.email = &s } // Email returns the value of the "email" field in the mutation. func (m *UserThirdAuthMutation) Email() (r string, exists bool) { v := m.email if v == nil { return } return *v, true } // OldEmail returns the old "email" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldEmail(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldEmail is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldEmail requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldEmail: %w", err) } return oldValue.Email, nil } // ClearEmail clears the value of the "email" field. func (m *UserThirdAuthMutation) ClearEmail() { m.email = nil m.clearedFields[userthirdauth.FieldEmail] = struct{}{} } // EmailCleared returns if the "email" field was cleared in this mutation. func (m *UserThirdAuthMutation) EmailCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldEmail] return ok } // ResetEmail resets all changes to the "email" field. func (m *UserThirdAuthMutation) ResetEmail() { m.email = nil delete(m.clearedFields, userthirdauth.FieldEmail) } // SetPhone sets the "phone" field. func (m *UserThirdAuthMutation) SetPhone(s string) { m.phone = &s } // Phone returns the value of the "phone" field in the mutation. func (m *UserThirdAuthMutation) Phone() (r string, exists bool) { v := m.phone if v == nil { return } return *v, true } // OldPhone returns the old "phone" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldPhone(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldPhone is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldPhone requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldPhone: %w", err) } return oldValue.Phone, nil } // ClearPhone clears the value of the "phone" field. func (m *UserThirdAuthMutation) ClearPhone() { m.phone = nil m.clearedFields[userthirdauth.FieldPhone] = struct{}{} } // PhoneCleared returns if the "phone" field was cleared in this mutation. func (m *UserThirdAuthMutation) PhoneCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldPhone] return ok } // ResetPhone resets all changes to the "phone" field. func (m *UserThirdAuthMutation) ResetPhone() { m.phone = nil delete(m.clearedFields, userthirdauth.FieldPhone) } // SetIsBound sets the "is_bound" field. func (m *UserThirdAuthMutation) SetIsBound(b bool) { m.is_bound = &b } // IsBound returns the value of the "is_bound" field in the mutation. func (m *UserThirdAuthMutation) IsBound() (r bool, exists bool) { v := m.is_bound if v == nil { return } return *v, true } // OldIsBound returns the old "is_bound" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldIsBound(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldIsBound is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldIsBound requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldIsBound: %w", err) } return oldValue.IsBound, nil } // ResetIsBound resets all changes to the "is_bound" field. func (m *UserThirdAuthMutation) ResetIsBound() { m.is_bound = nil } // SetBoundAt sets the "bound_at" field. func (m *UserThirdAuthMutation) SetBoundAt(t time.Time) { m.bound_at = &t } // BoundAt returns the value of the "bound_at" field in the mutation. func (m *UserThirdAuthMutation) BoundAt() (r time.Time, exists bool) { v := m.bound_at if v == nil { return } return *v, true } // OldBoundAt returns the old "bound_at" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldBoundAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldBoundAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldBoundAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldBoundAt: %w", err) } return oldValue.BoundAt, nil } // ResetBoundAt resets all changes to the "bound_at" field. func (m *UserThirdAuthMutation) ResetBoundAt() { m.bound_at = nil } // SetExtraData sets the "extra_data" field. func (m *UserThirdAuthMutation) SetExtraData(value map[string]interface{}) { m.extra_data = &value } // ExtraData returns the value of the "extra_data" field in the mutation. func (m *UserThirdAuthMutation) ExtraData() (r map[string]interface{}, exists bool) { v := m.extra_data if v == nil { return } return *v, true } // OldExtraData returns the old "extra_data" field's value of the UserThirdAuth entity. // If the UserThirdAuth object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. func (m *UserThirdAuthMutation) OldExtraData(ctx context.Context) (v map[string]interface{}, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldExtraData is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { return v, errors.New("OldExtraData requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { return v, fmt.Errorf("querying old value for OldExtraData: %w", err) } return oldValue.ExtraData, nil } // ClearExtraData clears the value of the "extra_data" field. func (m *UserThirdAuthMutation) ClearExtraData() { m.extra_data = nil m.clearedFields[userthirdauth.FieldExtraData] = struct{}{} } // ExtraDataCleared returns if the "extra_data" field was cleared in this mutation. func (m *UserThirdAuthMutation) ExtraDataCleared() bool { _, ok := m.clearedFields[userthirdauth.FieldExtraData] return ok } // ResetExtraData resets all changes to the "extra_data" field. func (m *UserThirdAuthMutation) ResetExtraData() { m.extra_data = nil delete(m.clearedFields, userthirdauth.FieldExtraData) } // Where appends a list predicates to the UserThirdAuthMutation builder. func (m *UserThirdAuthMutation) Where(ps ...predicate.UserThirdAuth) { m.predicates = append(m.predicates, ps...) } // WhereP appends storage-level predicates to the UserThirdAuthMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. func (m *UserThirdAuthMutation) WhereP(ps ...func(*sql.Selector)) { p := make([]predicate.UserThirdAuth, len(ps)) for i := range ps { p[i] = ps[i] } m.Where(p...) } // Op returns the operation name. func (m *UserThirdAuthMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. func (m *UserThirdAuthMutation) SetOp(op Op) { m.op = op } // Type returns the node type of this mutation (UserThirdAuth). func (m *UserThirdAuthMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserThirdAuthMutation) Fields() []string { fields := make([]string, 0, 20) if m.created_at != nil { fields = append(fields, userthirdauth.FieldCreatedAt) } if m.updated_at != nil { fields = append(fields, userthirdauth.FieldUpdatedAt) } if m.status != nil { fields = append(fields, userthirdauth.FieldStatus) } if m.tenant_id != nil { fields = append(fields, userthirdauth.FieldTenantID) } if m.deleted_at != nil { fields = append(fields, userthirdauth.FieldDeletedAt) } if m.user_id != nil { fields = append(fields, userthirdauth.FieldUserID) } if m.openid != nil { fields = append(fields, userthirdauth.FieldOpenid) } if m.unionid != nil { fields = append(fields, userthirdauth.FieldUnionid) } if m.access_token != nil { fields = append(fields, userthirdauth.FieldAccessToken) } if m.refresh_token != nil { fields = append(fields, userthirdauth.FieldRefreshToken) } if m.access_token_expiry != nil { fields = append(fields, userthirdauth.FieldAccessTokenExpiry) } if m.user_info != nil { fields = append(fields, userthirdauth.FieldUserInfo) } if m.platform_user_id != nil { fields = append(fields, userthirdauth.FieldPlatformUserID) } if m.nickname != nil { fields = append(fields, userthirdauth.FieldNickname) } if m.avatar != nil { fields = append(fields, userthirdauth.FieldAvatar) } if m.email != nil { fields = append(fields, userthirdauth.FieldEmail) } if m.phone != nil { fields = append(fields, userthirdauth.FieldPhone) } if m.is_bound != nil { fields = append(fields, userthirdauth.FieldIsBound) } if m.bound_at != nil { fields = append(fields, userthirdauth.FieldBoundAt) } if m.extra_data != nil { fields = append(fields, userthirdauth.FieldExtraData) } return fields } // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. func (m *UserThirdAuthMutation) Field(name string) (ent.Value, bool) { switch name { case userthirdauth.FieldCreatedAt: return m.CreatedAt() case userthirdauth.FieldUpdatedAt: return m.UpdatedAt() case userthirdauth.FieldStatus: return m.Status() case userthirdauth.FieldTenantID: return m.TenantID() case userthirdauth.FieldDeletedAt: return m.DeletedAt() case userthirdauth.FieldUserID: return m.UserID() case userthirdauth.FieldOpenid: return m.Openid() case userthirdauth.FieldUnionid: return m.Unionid() case userthirdauth.FieldAccessToken: return m.AccessToken() case userthirdauth.FieldRefreshToken: return m.RefreshToken() case userthirdauth.FieldAccessTokenExpiry: return m.AccessTokenExpiry() case userthirdauth.FieldUserInfo: return m.UserInfo() case userthirdauth.FieldPlatformUserID: return m.PlatformUserID() case userthirdauth.FieldNickname: return m.Nickname() case userthirdauth.FieldAvatar: return m.Avatar() case userthirdauth.FieldEmail: return m.Email() case userthirdauth.FieldPhone: return m.Phone() case userthirdauth.FieldIsBound: return m.IsBound() case userthirdauth.FieldBoundAt: return m.BoundAt() case userthirdauth.FieldExtraData: return m.ExtraData() } return nil, false } // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. func (m *UserThirdAuthMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { case userthirdauth.FieldCreatedAt: return m.OldCreatedAt(ctx) case userthirdauth.FieldUpdatedAt: return m.OldUpdatedAt(ctx) case userthirdauth.FieldStatus: return m.OldStatus(ctx) case userthirdauth.FieldTenantID: return m.OldTenantID(ctx) case userthirdauth.FieldDeletedAt: return m.OldDeletedAt(ctx) case userthirdauth.FieldUserID: return m.OldUserID(ctx) case userthirdauth.FieldOpenid: return m.OldOpenid(ctx) case userthirdauth.FieldUnionid: return m.OldUnionid(ctx) case userthirdauth.FieldAccessToken: return m.OldAccessToken(ctx) case userthirdauth.FieldRefreshToken: return m.OldRefreshToken(ctx) case userthirdauth.FieldAccessTokenExpiry: return m.OldAccessTokenExpiry(ctx) case userthirdauth.FieldUserInfo: return m.OldUserInfo(ctx) case userthirdauth.FieldPlatformUserID: return m.OldPlatformUserID(ctx) case userthirdauth.FieldNickname: return m.OldNickname(ctx) case userthirdauth.FieldAvatar: return m.OldAvatar(ctx) case userthirdauth.FieldEmail: return m.OldEmail(ctx) case userthirdauth.FieldPhone: return m.OldPhone(ctx) case userthirdauth.FieldIsBound: return m.OldIsBound(ctx) case userthirdauth.FieldBoundAt: return m.OldBoundAt(ctx) case userthirdauth.FieldExtraData: return m.OldExtraData(ctx) } return nil, fmt.Errorf("unknown UserThirdAuth field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *UserThirdAuthMutation) SetField(name string, value ent.Value) error { switch name { case userthirdauth.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetCreatedAt(v) return nil case userthirdauth.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUpdatedAt(v) return nil case userthirdauth.FieldStatus: v, ok := value.(uint8) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetStatus(v) return nil case userthirdauth.FieldTenantID: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetTenantID(v) return nil case userthirdauth.FieldDeletedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetDeletedAt(v) return nil case userthirdauth.FieldUserID: v, ok := value.(uint64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserID(v) return nil case userthirdauth.FieldOpenid: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetOpenid(v) return nil case userthirdauth.FieldUnionid: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUnionid(v) return nil case userthirdauth.FieldAccessToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAccessToken(v) return nil case userthirdauth.FieldRefreshToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRefreshToken(v) return nil case userthirdauth.FieldAccessTokenExpiry: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAccessTokenExpiry(v) return nil case userthirdauth.FieldUserInfo: v, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserInfo(v) return nil case userthirdauth.FieldPlatformUserID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPlatformUserID(v) return nil case userthirdauth.FieldNickname: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetNickname(v) return nil case userthirdauth.FieldAvatar: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetAvatar(v) return nil case userthirdauth.FieldEmail: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetEmail(v) return nil case userthirdauth.FieldPhone: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetPhone(v) return nil case userthirdauth.FieldIsBound: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetIsBound(v) return nil case userthirdauth.FieldBoundAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetBoundAt(v) return nil case userthirdauth.FieldExtraData: v, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetExtraData(v) return nil } return fmt.Errorf("unknown UserThirdAuth field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *UserThirdAuthMutation) AddedFields() []string { var fields []string if m.addstatus != nil { fields = append(fields, userthirdauth.FieldStatus) } if m.addtenant_id != nil { fields = append(fields, userthirdauth.FieldTenantID) } if m.adduser_id != nil { fields = append(fields, userthirdauth.FieldUserID) } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *UserThirdAuthMutation) AddedField(name string) (ent.Value, bool) { switch name { case userthirdauth.FieldStatus: return m.AddedStatus() case userthirdauth.FieldTenantID: return m.AddedTenantID() case userthirdauth.FieldUserID: return m.AddedUserID() } return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. func (m *UserThirdAuthMutation) AddField(name string, value ent.Value) error { switch name { case userthirdauth.FieldStatus: v, ok := value.(int8) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddStatus(v) return nil case userthirdauth.FieldTenantID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddTenantID(v) return nil case userthirdauth.FieldUserID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.AddUserID(v) return nil } return fmt.Errorf("unknown UserThirdAuth numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. func (m *UserThirdAuthMutation) ClearedFields() []string { var fields []string if m.FieldCleared(userthirdauth.FieldStatus) { fields = append(fields, userthirdauth.FieldStatus) } if m.FieldCleared(userthirdauth.FieldDeletedAt) { fields = append(fields, userthirdauth.FieldDeletedAt) } if m.FieldCleared(userthirdauth.FieldUnionid) { fields = append(fields, userthirdauth.FieldUnionid) } if m.FieldCleared(userthirdauth.FieldAccessToken) { fields = append(fields, userthirdauth.FieldAccessToken) } if m.FieldCleared(userthirdauth.FieldRefreshToken) { fields = append(fields, userthirdauth.FieldRefreshToken) } if m.FieldCleared(userthirdauth.FieldAccessTokenExpiry) { fields = append(fields, userthirdauth.FieldAccessTokenExpiry) } if m.FieldCleared(userthirdauth.FieldUserInfo) { fields = append(fields, userthirdauth.FieldUserInfo) } if m.FieldCleared(userthirdauth.FieldPlatformUserID) { fields = append(fields, userthirdauth.FieldPlatformUserID) } if m.FieldCleared(userthirdauth.FieldNickname) { fields = append(fields, userthirdauth.FieldNickname) } if m.FieldCleared(userthirdauth.FieldAvatar) { fields = append(fields, userthirdauth.FieldAvatar) } if m.FieldCleared(userthirdauth.FieldEmail) { fields = append(fields, userthirdauth.FieldEmail) } if m.FieldCleared(userthirdauth.FieldPhone) { fields = append(fields, userthirdauth.FieldPhone) } if m.FieldCleared(userthirdauth.FieldExtraData) { fields = append(fields, userthirdauth.FieldExtraData) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. func (m *UserThirdAuthMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. func (m *UserThirdAuthMutation) ClearField(name string) error { switch name { case userthirdauth.FieldStatus: m.ClearStatus() return nil case userthirdauth.FieldDeletedAt: m.ClearDeletedAt() return nil case userthirdauth.FieldUnionid: m.ClearUnionid() return nil case userthirdauth.FieldAccessToken: m.ClearAccessToken() return nil case userthirdauth.FieldRefreshToken: m.ClearRefreshToken() return nil case userthirdauth.FieldAccessTokenExpiry: m.ClearAccessTokenExpiry() return nil case userthirdauth.FieldUserInfo: m.ClearUserInfo() return nil case userthirdauth.FieldPlatformUserID: m.ClearPlatformUserID() return nil case userthirdauth.FieldNickname: m.ClearNickname() return nil case userthirdauth.FieldAvatar: m.ClearAvatar() return nil case userthirdauth.FieldEmail: m.ClearEmail() return nil case userthirdauth.FieldPhone: m.ClearPhone() return nil case userthirdauth.FieldExtraData: m.ClearExtraData() return nil } return fmt.Errorf("unknown UserThirdAuth nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. func (m *UserThirdAuthMutation) ResetField(name string) error { switch name { case userthirdauth.FieldCreatedAt: m.ResetCreatedAt() return nil case userthirdauth.FieldUpdatedAt: m.ResetUpdatedAt() return nil case userthirdauth.FieldStatus: m.ResetStatus() return nil case userthirdauth.FieldTenantID: m.ResetTenantID() return nil case userthirdauth.FieldDeletedAt: m.ResetDeletedAt() return nil case userthirdauth.FieldUserID: m.ResetUserID() return nil case userthirdauth.FieldOpenid: m.ResetOpenid() return nil case userthirdauth.FieldUnionid: m.ResetUnionid() return nil case userthirdauth.FieldAccessToken: m.ResetAccessToken() return nil case userthirdauth.FieldRefreshToken: m.ResetRefreshToken() return nil case userthirdauth.FieldAccessTokenExpiry: m.ResetAccessTokenExpiry() return nil case userthirdauth.FieldUserInfo: m.ResetUserInfo() return nil case userthirdauth.FieldPlatformUserID: m.ResetPlatformUserID() return nil case userthirdauth.FieldNickname: m.ResetNickname() return nil case userthirdauth.FieldAvatar: m.ResetAvatar() return nil case userthirdauth.FieldEmail: m.ResetEmail() return nil case userthirdauth.FieldPhone: m.ResetPhone() return nil case userthirdauth.FieldIsBound: m.ResetIsBound() return nil case userthirdauth.FieldBoundAt: m.ResetBoundAt() return nil case userthirdauth.FieldExtraData: m.ResetExtraData() return nil } return fmt.Errorf("unknown UserThirdAuth field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. func (m *UserThirdAuthMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. func (m *UserThirdAuthMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *UserThirdAuthMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. func (m *UserThirdAuthMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *UserThirdAuthMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. func (m *UserThirdAuthMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. func (m *UserThirdAuthMutation) ClearEdge(name string) error { return fmt.Errorf("unknown UserThirdAuth unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. func (m *UserThirdAuthMutation) ResetEdge(name string) error { return fmt.Errorf("unknown UserThirdAuth edge %s", name) }