func (o *User) Update(db *gorm.DB, fields ...UserDBSchemaField) error {
	dbNameToFieldName := map[string]interface{}{
		"id":           o.ID,
		"user_name":    o.UserName,
		"password":     o.Password,
		"email":        o.Email,
		"roles":        o.Roles,
		"introduction": o.Introduction,
		"avatar":       o.Avatar,
		"created_at":   o.CreatedAt,
		"updated_at":   o.UpdatedAt,
	}
	u := map[string]interface{}{}
	for _, f := range fields {
		fs := f.String()
		u[fs] = dbNameToFieldName[fs]
	}
	if err := db.Model(o).Updates(u).Error; err != nil {
		if err == gorm.ErrRecordNotFound {
			return err
		}
		return fmt.Errorf("can't update User %v fields %v: %s",
			o, fields, err)
	}
	return nil
}
Update updates User fields by primary key
nolint: dupl
package model
import (
	"errors"
	"fmt"
	"time"
	"github.com/jinzhu/gorm"
)
type UserQuerySet struct {
	db *gorm.DB
}
func NewUserQuerySet(db *gorm.DB) UserQuerySet {
	return UserQuerySet{
		db: db.Model(&User{}),
	}
}
func (qs UserQuerySet) w(db *gorm.DB) UserQuerySet {
	return NewUserQuerySet(db)
}
func (qs UserQuerySet) All(ret *[]User) error {
	return qs.db.Find(ret).Error
}
func (qs UserQuerySet) AvatarEq(avatar string) UserQuerySet {
	return qs.w(qs.db.Where("avatar = ?", avatar))
}
func (qs UserQuerySet) AvatarIn(avatar ...string) UserQuerySet {
	if len(avatar) == 0 {
		qs.db.AddError(errors.New("must at least pass one avatar in AvatarIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("avatar IN (?)", avatar))
}
func (qs UserQuerySet) AvatarNe(avatar string) UserQuerySet {
	return qs.w(qs.db.Where("avatar != ?", avatar))
}
func (qs UserQuerySet) AvatarNotIn(avatar ...string) UserQuerySet {
	if len(avatar) == 0 {
		qs.db.AddError(errors.New("must at least pass one avatar in AvatarNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("avatar NOT IN (?)", avatar))
}
func (qs UserQuerySet) Count() (int, error) {
	var count int
	err := qs.db.Count(&count).Error
	return count, err
}
func (o *User) Create(db *gorm.DB) error {
	return db.Create(o).Error
}
func (qs UserQuerySet) CreatedAtEq(createdAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("created_at = ?", createdAt))
}
func (qs UserQuerySet) CreatedAtGt(createdAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("created_at > ?", createdAt))
}
func (qs UserQuerySet) CreatedAtGte(createdAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("created_at >= ?", createdAt))
}
func (qs UserQuerySet) CreatedAtLt(createdAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("created_at < ?", createdAt))
}
func (qs UserQuerySet) CreatedAtLte(createdAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("created_at <= ?", createdAt))
}
func (qs UserQuerySet) CreatedAtNe(createdAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("created_at != ?", createdAt))
}
func (o *User) Delete(db *gorm.DB) error {
	return db.Delete(o).Error
}
func (qs UserQuerySet) Delete() error {
	return qs.db.Delete(User{}).Error
}
func (qs UserQuerySet) DeleteNum() (int64, error) {
	db := qs.db.Delete(User{})
	return db.RowsAffected, db.Error
}
func (qs UserQuerySet) DeleteNumUnscoped() (int64, error) {
	db := qs.db.Unscoped().Delete(User{})
	return db.RowsAffected, db.Error
}
func (qs UserQuerySet) EmailEq(email string) UserQuerySet {
	return qs.w(qs.db.Where("email = ?", email))
}
func (qs UserQuerySet) EmailIn(email ...string) UserQuerySet {
	if len(email) == 0 {
		qs.db.AddError(errors.New("must at least pass one email in EmailIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("email IN (?)", email))
}
func (qs UserQuerySet) EmailNe(email string) UserQuerySet {
	return qs.w(qs.db.Where("email != ?", email))
}
func (qs UserQuerySet) EmailNotIn(email ...string) UserQuerySet {
	if len(email) == 0 {
		qs.db.AddError(errors.New("must at least pass one email in EmailNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("email NOT IN (?)", email))
}
func (qs UserQuerySet) GetUpdater() UserUpdater {
	return NewUserUpdater(qs.db)
}
func (qs UserQuerySet) IDEq(ID uint64) UserQuerySet {
	return qs.w(qs.db.Where("id = ?", ID))
}
func (qs UserQuerySet) IDGt(ID uint64) UserQuerySet {
	return qs.w(qs.db.Where("id > ?", ID))
}
func (qs UserQuerySet) IDGte(ID uint64) UserQuerySet {
	return qs.w(qs.db.Where("id >= ?", ID))
}
func (qs UserQuerySet) IDIn(ID ...uint64) UserQuerySet {
	if len(ID) == 0 {
		qs.db.AddError(errors.New("must at least pass one ID in IDIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("id IN (?)", ID))
}
func (qs UserQuerySet) IDLt(ID uint64) UserQuerySet {
	return qs.w(qs.db.Where("id < ?", ID))
}
func (qs UserQuerySet) IDLte(ID uint64) UserQuerySet {
	return qs.w(qs.db.Where("id <= ?", ID))
}
func (qs UserQuerySet) IDNe(ID uint64) UserQuerySet {
	return qs.w(qs.db.Where("id != ?", ID))
}
func (qs UserQuerySet) IDNotIn(ID ...uint64) UserQuerySet {
	if len(ID) == 0 {
		qs.db.AddError(errors.New("must at least pass one ID in IDNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("id NOT IN (?)", ID))
}
func (qs UserQuerySet) IntroductionEq(introduction string) UserQuerySet {
	return qs.w(qs.db.Where("introduction = ?", introduction))
}
func (qs UserQuerySet) IntroductionIn(introduction ...string) UserQuerySet {
	if len(introduction) == 0 {
		qs.db.AddError(errors.New("must at least pass one introduction in IntroductionIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("introduction IN (?)", introduction))
}
func (qs UserQuerySet) IntroductionNe(introduction string) UserQuerySet {
	return qs.w(qs.db.Where("introduction != ?", introduction))
}
func (qs UserQuerySet) IntroductionNotIn(introduction ...string) UserQuerySet {
	if len(introduction) == 0 {
		qs.db.AddError(errors.New("must at least pass one introduction in IntroductionNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("introduction NOT IN (?)", introduction))
}
func (qs UserQuerySet) Limit(limit int) UserQuerySet {
	return qs.w(qs.db.Limit(limit))
}
func (qs UserQuerySet) Offset(offset int) UserQuerySet {
	return qs.w(qs.db.Offset(offset))
}
func (qs UserQuerySet) One(ret *User) error {
	return qs.db.First(ret).Error
}
func (qs UserQuerySet) OrderAscByCreatedAt() UserQuerySet {
	return qs.w(qs.db.Order("created_at ASC"))
}
func (qs UserQuerySet) OrderAscByID() UserQuerySet {
	return qs.w(qs.db.Order("id ASC"))
}
func (qs UserQuerySet) OrderAscByUpdatedAt() UserQuerySet {
	return qs.w(qs.db.Order("updated_at ASC"))
}
func (qs UserQuerySet) OrderDescByCreatedAt() UserQuerySet {
	return qs.w(qs.db.Order("created_at DESC"))
}
func (qs UserQuerySet) OrderDescByID() UserQuerySet {
	return qs.w(qs.db.Order("id DESC"))
}
func (qs UserQuerySet) OrderDescByUpdatedAt() UserQuerySet {
	return qs.w(qs.db.Order("updated_at DESC"))
}
func (qs UserQuerySet) PasswordEq(password string) UserQuerySet {
	return qs.w(qs.db.Where("password = ?", password))
}
func (qs UserQuerySet) PasswordIn(password ...string) UserQuerySet {
	if len(password) == 0 {
		qs.db.AddError(errors.New("must at least pass one password in PasswordIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("password IN (?)", password))
}
func (qs UserQuerySet) PasswordNe(password string) UserQuerySet {
	return qs.w(qs.db.Where("password != ?", password))
}
func (qs UserQuerySet) PasswordNotIn(password ...string) UserQuerySet {
	if len(password) == 0 {
		qs.db.AddError(errors.New("must at least pass one password in PasswordNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("password NOT IN (?)", password))
}
func (qs UserQuerySet) RolesEq(roles string) UserQuerySet {
	return qs.w(qs.db.Where("roles = ?", roles))
}
func (qs UserQuerySet) RolesIn(roles ...string) UserQuerySet {
	if len(roles) == 0 {
		qs.db.AddError(errors.New("must at least pass one roles in RolesIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("roles IN (?)", roles))
}
func (qs UserQuerySet) RolesNe(roles string) UserQuerySet {
	return qs.w(qs.db.Where("roles != ?", roles))
}
func (qs UserQuerySet) RolesNotIn(roles ...string) UserQuerySet {
	if len(roles) == 0 {
		qs.db.AddError(errors.New("must at least pass one roles in RolesNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("roles NOT IN (?)", roles))
}
func (u UserUpdater) SetAvatar(avatar string) UserUpdater {
	u.fields[string(UserDBSchema.Avatar)] = avatar
	return u
}
func (u UserUpdater) SetCreatedAt(createdAt time.Time) UserUpdater {
	u.fields[string(UserDBSchema.CreatedAt)] = createdAt
	return u
}
func (u UserUpdater) SetEmail(email string) UserUpdater {
	u.fields[string(UserDBSchema.Email)] = email
	return u
}
func (u UserUpdater) SetID(ID uint64) UserUpdater {
	u.fields[string(UserDBSchema.ID)] = ID
	return u
}
func (u UserUpdater) SetIntroduction(introduction string) UserUpdater {
	u.fields[string(UserDBSchema.Introduction)] = introduction
	return u
}
func (u UserUpdater) SetPassword(password string) UserUpdater {
	u.fields[string(UserDBSchema.Password)] = password
	return u
}
func (u UserUpdater) SetRoles(roles string) UserUpdater {
	u.fields[string(UserDBSchema.Roles)] = roles
	return u
}
func (u UserUpdater) SetUpdatedAt(updatedAt time.Time) UserUpdater {
	u.fields[string(UserDBSchema.UpdatedAt)] = updatedAt
	return u
}
func (u UserUpdater) SetUserName(userName string) UserUpdater {
	u.fields[string(UserDBSchema.UserName)] = userName
	return u
}
func (u UserUpdater) Update() error {
	return u.db.Updates(u.fields).Error
}
func (u UserUpdater) UpdateNum() (int64, error) {
	db := u.db.Updates(u.fields)
	return db.RowsAffected, db.Error
}
func (qs UserQuerySet) UpdatedAtEq(updatedAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("updated_at = ?", updatedAt))
}
func (qs UserQuerySet) UpdatedAtGt(updatedAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("updated_at > ?", updatedAt))
}
func (qs UserQuerySet) UpdatedAtGte(updatedAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("updated_at >= ?", updatedAt))
}
func (qs UserQuerySet) UpdatedAtLt(updatedAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("updated_at < ?", updatedAt))
}
func (qs UserQuerySet) UpdatedAtLte(updatedAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("updated_at <= ?", updatedAt))
}
func (qs UserQuerySet) UpdatedAtNe(updatedAt time.Time) UserQuerySet {
	return qs.w(qs.db.Where("updated_at != ?", updatedAt))
}
func (qs UserQuerySet) UserNameEq(userName string) UserQuerySet {
	return qs.w(qs.db.Where("user_name = ?", userName))
}
func (qs UserQuerySet) UserNameIn(userName ...string) UserQuerySet {
	if len(userName) == 0 {
		qs.db.AddError(errors.New("must at least pass one userName in UserNameIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("user_name IN (?)", userName))
}
func (qs UserQuerySet) UserNameNe(userName string) UserQuerySet {
	return qs.w(qs.db.Where("user_name != ?", userName))
}
func (qs UserQuerySet) UserNameNotIn(userName ...string) UserQuerySet {
	if len(userName) == 0 {
		qs.db.AddError(errors.New("must at least pass one userName in UserNameNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("user_name NOT IN (?)", userName))
}
type UserDBSchemaField string
func (f UserDBSchemaField) String() string {
	return string(f)
}
var UserDBSchema = struct {
	ID           UserDBSchemaField
	UserName     UserDBSchemaField
	Password     UserDBSchemaField
	Email        UserDBSchemaField
	Roles        UserDBSchemaField
	Introduction UserDBSchemaField
	Avatar       UserDBSchemaField
	CreatedAt    UserDBSchemaField
	UpdatedAt    UserDBSchemaField
}{
	ID:           UserDBSchemaField("id"),
	UserName:     UserDBSchemaField("user_name"),
	Password:     UserDBSchemaField("password"),
	Email:        UserDBSchemaField("email"),
	Roles:        UserDBSchemaField("roles"),
	Introduction: UserDBSchemaField("introduction"),
	Avatar:       UserDBSchemaField("avatar"),
	CreatedAt:    UserDBSchemaField("created_at"),
	UpdatedAt:    UserDBSchemaField("updated_at"),
}