// Code generated by go-queryset. DO NOT EDIT.
package models

import (
	"errors"
	"fmt"
	"time"

	"github.com/jinzhu/gorm"
)

// ===== BEGIN of all query sets

// ===== BEGIN of query set RedeemCodeQuerySet

// RedeemCodeQuerySet is an queryset type for RedeemCode
type RedeemCodeQuerySet struct {
	db *gorm.DB
}

// NewRedeemCodeQuerySet constructs new RedeemCodeQuerySet
func NewRedeemCodeQuerySet(db *gorm.DB) RedeemCodeQuerySet {
	return RedeemCodeQuerySet{
		db: db.Model(&RedeemCode{}),
	}
}

func (qs RedeemCodeQuerySet) w(db *gorm.DB) RedeemCodeQuerySet {
	return NewRedeemCodeQuerySet(db)
}

// Create is an autogenerated method
// nolint: dupl
func (o *RedeemCode) Create(db *gorm.DB) error {
	return db.Create(o).Error
}

// Delete is an autogenerated method
// nolint: dupl
func (o *RedeemCode) Delete(db *gorm.DB) error {
	return db.Delete(o).Error
}

// All is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) All(ret *[]RedeemCode) error {
	return qs.db.Find(ret).Error
}

// CodeSecretEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeSecretEq(codeSecret string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("code_secret = ?", codeSecret))
}

// CodeSecretIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeSecretIn(codeSecret ...string) RedeemCodeQuerySet {
	if len(codeSecret) == 0 {
		qs.db.AddError(errors.New("must at least pass one codeSecret in CodeSecretIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("code_secret IN (?)", codeSecret))
}

// CodeSecretNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeSecretNe(codeSecret string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("code_secret != ?", codeSecret))
}

// CodeSecretNotIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeSecretNotIn(codeSecret ...string) RedeemCodeQuerySet {
	if len(codeSecret) == 0 {
		qs.db.AddError(errors.New("must at least pass one codeSecret in CodeSecretNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("code_secret NOT IN (?)", codeSecret))
}

// CodeTypeEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeTypeEq(codeType string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("code_type = ?", codeType))
}

// CodeTypeIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeTypeIn(codeType ...string) RedeemCodeQuerySet {
	if len(codeType) == 0 {
		qs.db.AddError(errors.New("must at least pass one codeType in CodeTypeIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("code_type IN (?)", codeType))
}

// CodeTypeNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeTypeNe(codeType string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("code_type != ?", codeType))
}

// CodeTypeNotIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CodeTypeNotIn(codeType ...string) RedeemCodeQuerySet {
	if len(codeType) == 0 {
		qs.db.AddError(errors.New("must at least pass one codeType in CodeTypeNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("code_type NOT IN (?)", codeType))
}

// Count is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) Count() (int, error) {
	var count int
	err := qs.db.Count(&count).Error
	return count, err
}

// CreatedAtEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CreatedAtEq(createdAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at = ?", createdAt))
}

// CreatedAtGt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CreatedAtGt(createdAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at > ?", createdAt))
}

// CreatedAtGte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CreatedAtGte(createdAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at >= ?", createdAt))
}

// CreatedAtLt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CreatedAtLt(createdAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at < ?", createdAt))
}

// CreatedAtLte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CreatedAtLte(createdAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at <= ?", createdAt))
}

// CreatedAtNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) CreatedAtNe(createdAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at != ?", createdAt))
}

// Delete is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) Delete() error {
	return qs.db.Delete(RedeemCode{}).Error
}

// DeleteNum is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeleteNum() (int64, error) {
	db := qs.db.Delete(RedeemCode{})
	return db.RowsAffected, db.Error
}

// DeleteNumUnscoped is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeleteNumUnscoped() (int64, error) {
	db := qs.db.Unscoped().Delete(RedeemCode{})
	return db.RowsAffected, db.Error
}

// DeletedAtEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtEq(deletedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at = ?", deletedAt))
}

// DeletedAtGt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtGt(deletedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at > ?", deletedAt))
}

// DeletedAtGte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtGte(deletedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at >= ?", deletedAt))
}

// DeletedAtIsNotNull is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtIsNotNull() RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at IS NOT NULL"))
}

// DeletedAtIsNull is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtIsNull() RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at IS NULL"))
}

// DeletedAtLt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtLt(deletedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at < ?", deletedAt))
}

// DeletedAtLte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtLte(deletedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at <= ?", deletedAt))
}

// DeletedAtNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) DeletedAtNe(deletedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at != ?", deletedAt))
}

// EffectiveTimeEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) EffectiveTimeEq(effectiveTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("effective_time = ?", effectiveTime))
}

// EffectiveTimeGt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) EffectiveTimeGt(effectiveTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("effective_time > ?", effectiveTime))
}

// EffectiveTimeGte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) EffectiveTimeGte(effectiveTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("effective_time >= ?", effectiveTime))
}

// EffectiveTimeLt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) EffectiveTimeLt(effectiveTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("effective_time < ?", effectiveTime))
}

// EffectiveTimeLte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) EffectiveTimeLte(effectiveTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("effective_time <= ?", effectiveTime))
}

// EffectiveTimeNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) EffectiveTimeNe(effectiveTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("effective_time != ?", effectiveTime))
}

// ExpirationTimeEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) ExpirationTimeEq(expirationTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("expiration_time = ?", expirationTime))
}

// ExpirationTimeGt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) ExpirationTimeGt(expirationTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("expiration_time > ?", expirationTime))
}

// ExpirationTimeGte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) ExpirationTimeGte(expirationTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("expiration_time >= ?", expirationTime))
}

// ExpirationTimeLt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) ExpirationTimeLt(expirationTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("expiration_time < ?", expirationTime))
}

// ExpirationTimeLte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) ExpirationTimeLte(expirationTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("expiration_time <= ?", expirationTime))
}

// ExpirationTimeNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) ExpirationTimeNe(expirationTime time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("expiration_time != ?", expirationTime))
}

// GetDB is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) GetDB() *gorm.DB {
	return qs.db
}

// GetUpdater is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) GetUpdater() RedeemCodeUpdater {
	return NewRedeemCodeUpdater(qs.db)
}

// IDEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDEq(ID uint32) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("id = ?", ID))
}

// IDGt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDGt(ID uint32) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("id > ?", ID))
}

// IDGte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDGte(ID uint32) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("id >= ?", ID))
}

// IDIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDIn(ID ...uint32) RedeemCodeQuerySet {
	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))
}

// IDLt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDLt(ID uint32) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("id < ?", ID))
}

// IDLte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDLte(ID uint32) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("id <= ?", ID))
}

// IDNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDNe(ID uint32) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("id != ?", ID))
}

// IDNotIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) IDNotIn(ID ...uint32) RedeemCodeQuerySet {
	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))
}

// Limit is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) Limit(limit int) RedeemCodeQuerySet {
	return qs.w(qs.db.Limit(limit))
}

// Offset is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) Offset(offset int) RedeemCodeQuerySet {
	return qs.w(qs.db.Offset(offset))
}

// One is used to retrieve one result. It returns gorm.ErrRecordNotFound
// if nothing was fetched
func (qs RedeemCodeQuerySet) One(ret *RedeemCode) error {
	return qs.db.First(ret).Error
}

// OrderAscByCreatedAt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderAscByCreatedAt() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("created_at ASC"))
}

// OrderAscByDeletedAt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderAscByDeletedAt() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("deleted_at ASC"))
}

// OrderAscByEffectiveTime is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderAscByEffectiveTime() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("effective_time ASC"))
}

// OrderAscByExpirationTime is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderAscByExpirationTime() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("expiration_time ASC"))
}

// OrderAscByID is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderAscByID() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("id ASC"))
}

// OrderAscByUpdatedAt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderAscByUpdatedAt() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("updated_at ASC"))
}

// OrderDescByCreatedAt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderDescByCreatedAt() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("created_at DESC"))
}

// OrderDescByDeletedAt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderDescByDeletedAt() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("deleted_at DESC"))
}

// OrderDescByEffectiveTime is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderDescByEffectiveTime() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("effective_time DESC"))
}

// OrderDescByExpirationTime is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderDescByExpirationTime() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("expiration_time DESC"))
}

// OrderDescByID is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderDescByID() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("id DESC"))
}

// OrderDescByUpdatedAt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) OrderDescByUpdatedAt() RedeemCodeQuerySet {
	return qs.w(qs.db.Order("updated_at DESC"))
}

// SerialCodeEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) SerialCodeEq(serialCode string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("serial_code = ?", serialCode))
}

// SerialCodeIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) SerialCodeIn(serialCode ...string) RedeemCodeQuerySet {
	if len(serialCode) == 0 {
		qs.db.AddError(errors.New("must at least pass one serialCode in SerialCodeIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("serial_code IN (?)", serialCode))
}

// SerialCodeNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) SerialCodeNe(serialCode string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("serial_code != ?", serialCode))
}

// SerialCodeNotIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) SerialCodeNotIn(serialCode ...string) RedeemCodeQuerySet {
	if len(serialCode) == 0 {
		qs.db.AddError(errors.New("must at least pass one serialCode in SerialCodeNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("serial_code NOT IN (?)", serialCode))
}

// StatusEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) StatusEq(status string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("status = ?", status))
}

// StatusIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) StatusIn(status ...string) RedeemCodeQuerySet {
	if len(status) == 0 {
		qs.db.AddError(errors.New("must at least pass one status in StatusIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("status IN (?)", status))
}

// StatusNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) StatusNe(status string) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("status != ?", status))
}

// StatusNotIn is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) StatusNotIn(status ...string) RedeemCodeQuerySet {
	if len(status) == 0 {
		qs.db.AddError(errors.New("must at least pass one status in StatusNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("status NOT IN (?)", status))
}

// UpdatedAtEq is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) UpdatedAtEq(updatedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at = ?", updatedAt))
}

// UpdatedAtGt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) UpdatedAtGt(updatedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at > ?", updatedAt))
}

// UpdatedAtGte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) UpdatedAtGte(updatedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at >= ?", updatedAt))
}

// UpdatedAtLt is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) UpdatedAtLt(updatedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at < ?", updatedAt))
}

// UpdatedAtLte is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) UpdatedAtLte(updatedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at <= ?", updatedAt))
}

// UpdatedAtNe is an autogenerated method
// nolint: dupl
func (qs RedeemCodeQuerySet) UpdatedAtNe(updatedAt time.Time) RedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at != ?", updatedAt))
}

// SetCodeSecret is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetCodeSecret(codeSecret string) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.CodeSecret)] = codeSecret
	return u
}

// SetCodeType is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetCodeType(codeType string) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.CodeType)] = codeType
	return u
}

// SetCreatedAt is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetCreatedAt(createdAt time.Time) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.CreatedAt)] = createdAt
	return u
}

// SetDeletedAt is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetDeletedAt(deletedAt *time.Time) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.DeletedAt)] = deletedAt
	return u
}

// SetEffectiveTime is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetEffectiveTime(effectiveTime time.Time) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.EffectiveTime)] = effectiveTime
	return u
}

// SetExpirationTime is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetExpirationTime(expirationTime time.Time) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.ExpirationTime)] = expirationTime
	return u
}

// SetID is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetID(ID uint32) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.ID)] = ID
	return u
}

// SetSerialCode is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetSerialCode(serialCode string) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.SerialCode)] = serialCode
	return u
}

// SetStatus is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetStatus(status string) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.Status)] = status
	return u
}

// SetUpdatedAt is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) SetUpdatedAt(updatedAt time.Time) RedeemCodeUpdater {
	u.fields[string(RedeemCodeDBSchema.UpdatedAt)] = updatedAt
	return u
}

// Update is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) Update() error {
	return u.db.Updates(u.fields).Error
}

// UpdateNum is an autogenerated method
// nolint: dupl
func (u RedeemCodeUpdater) UpdateNum() (int64, error) {
	db := u.db.Updates(u.fields)
	return db.RowsAffected, db.Error
}

// ===== END of query set RedeemCodeQuerySet

// ===== BEGIN of RedeemCode modifiers

// RedeemCodeDBSchemaField describes database schema field. It requires for method 'Update'
type RedeemCodeDBSchemaField string

// String method returns string representation of field.
// nolint: dupl
func (f RedeemCodeDBSchemaField) String() string {
	return string(f)
}

// RedeemCodeDBSchema stores db field names of RedeemCode
var RedeemCodeDBSchema = struct {
	ID             RedeemCodeDBSchemaField
	CreatedAt      RedeemCodeDBSchemaField
	UpdatedAt      RedeemCodeDBSchemaField
	DeletedAt      RedeemCodeDBSchemaField
	SerialCode     RedeemCodeDBSchemaField
	CodeType       RedeemCodeDBSchemaField
	Status         RedeemCodeDBSchemaField
	CodeSecret     RedeemCodeDBSchemaField
	EffectiveTime  RedeemCodeDBSchemaField
	ExpirationTime RedeemCodeDBSchemaField
}{

	ID:             RedeemCodeDBSchemaField("id"),
	CreatedAt:      RedeemCodeDBSchemaField("created_at"),
	UpdatedAt:      RedeemCodeDBSchemaField("updated_at"),
	DeletedAt:      RedeemCodeDBSchemaField("deleted_at"),
	SerialCode:     RedeemCodeDBSchemaField("serial_code"),
	CodeType:       RedeemCodeDBSchemaField("code_type"),
	Status:         RedeemCodeDBSchemaField("status"),
	CodeSecret:     RedeemCodeDBSchemaField("code_secret"),
	EffectiveTime:  RedeemCodeDBSchemaField("effective_time"),
	ExpirationTime: RedeemCodeDBSchemaField("expiration_time"),
}

// Update updates RedeemCode fields by primary key
// nolint: dupl
func (o *RedeemCode) Update(db *gorm.DB, fields ...RedeemCodeDBSchemaField) error {
	dbNameToFieldName := map[string]interface{}{
		"id":              o.ID,
		"created_at":      o.CreatedAt,
		"updated_at":      o.UpdatedAt,
		"deleted_at":      o.DeletedAt,
		"serial_code":     o.SerialCode,
		"code_type":       o.CodeType,
		"status":          o.Status,
		"code_secret":     o.CodeSecret,
		"effective_time":  o.EffectiveTime,
		"expiration_time": o.ExpirationTime,
	}
	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 RedeemCode %v fields %v: %s",
			o, fields, err)
	}

	return nil
}

// RedeemCodeUpdater is an RedeemCode updates manager
type RedeemCodeUpdater struct {
	fields map[string]interface{}
	db     *gorm.DB
}

// NewRedeemCodeUpdater creates new RedeemCode updater
// nolint: dupl
func NewRedeemCodeUpdater(db *gorm.DB) RedeemCodeUpdater {
	return RedeemCodeUpdater{
		fields: map[string]interface{}{},
		db:     db.Model(&RedeemCode{}),
	}
}

// ===== END of RedeemCode modifiers

// ===== BEGIN of query set UserRedeemCodeQuerySet

// UserRedeemCodeQuerySet is an queryset type for UserRedeemCode
type UserRedeemCodeQuerySet struct {
	db *gorm.DB
}

// NewUserRedeemCodeQuerySet constructs new UserRedeemCodeQuerySet
func NewUserRedeemCodeQuerySet(db *gorm.DB) UserRedeemCodeQuerySet {
	return UserRedeemCodeQuerySet{
		db: db.Model(&UserRedeemCode{}),
	}
}

func (qs UserRedeemCodeQuerySet) w(db *gorm.DB) UserRedeemCodeQuerySet {
	return NewUserRedeemCodeQuerySet(db)
}

// Create is an autogenerated method
// nolint: dupl
func (o *UserRedeemCode) Create(db *gorm.DB) error {
	return db.Create(o).Error
}

// Delete is an autogenerated method
// nolint: dupl
func (o *UserRedeemCode) Delete(db *gorm.DB) error {
	return db.Delete(o).Error
}

// ActivityTypeEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeEq(activityType uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("activity_type = ?", activityType))
}

// ActivityTypeGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeGt(activityType uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("activity_type > ?", activityType))
}

// ActivityTypeGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeGte(activityType uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("activity_type >= ?", activityType))
}

// ActivityTypeIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeIn(activityType ...uint32) UserRedeemCodeQuerySet {
	if len(activityType) == 0 {
		qs.db.AddError(errors.New("must at least pass one activityType in ActivityTypeIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("activity_type IN (?)", activityType))
}

// ActivityTypeLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeLt(activityType uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("activity_type < ?", activityType))
}

// ActivityTypeLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeLte(activityType uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("activity_type <= ?", activityType))
}

// ActivityTypeNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeNe(activityType uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("activity_type != ?", activityType))
}

// ActivityTypeNotIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ActivityTypeNotIn(activityType ...uint32) UserRedeemCodeQuerySet {
	if len(activityType) == 0 {
		qs.db.AddError(errors.New("must at least pass one activityType in ActivityTypeNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("activity_type NOT IN (?)", activityType))
}

// All is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) All(ret *[]UserRedeemCode) error {
	return qs.db.Find(ret).Error
}

// CodeTypeEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CodeTypeEq(codeType string) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("code_type = ?", codeType))
}

// CodeTypeIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CodeTypeIn(codeType ...string) UserRedeemCodeQuerySet {
	if len(codeType) == 0 {
		qs.db.AddError(errors.New("must at least pass one codeType in CodeTypeIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("code_type IN (?)", codeType))
}

// CodeTypeNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CodeTypeNe(codeType string) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("code_type != ?", codeType))
}

// CodeTypeNotIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CodeTypeNotIn(codeType ...string) UserRedeemCodeQuerySet {
	if len(codeType) == 0 {
		qs.db.AddError(errors.New("must at least pass one codeType in CodeTypeNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("code_type NOT IN (?)", codeType))
}

// ConvertTimeEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ConvertTimeEq(convertTime time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("convert_time = ?", convertTime))
}

// ConvertTimeGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ConvertTimeGt(convertTime time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("convert_time > ?", convertTime))
}

// ConvertTimeGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ConvertTimeGte(convertTime time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("convert_time >= ?", convertTime))
}

// ConvertTimeLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ConvertTimeLt(convertTime time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("convert_time < ?", convertTime))
}

// ConvertTimeLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ConvertTimeLte(convertTime time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("convert_time <= ?", convertTime))
}

// ConvertTimeNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) ConvertTimeNe(convertTime time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("convert_time != ?", convertTime))
}

// Count is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) Count() (int, error) {
	var count int
	err := qs.db.Count(&count).Error
	return count, err
}

// CreatedAtEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CreatedAtEq(createdAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at = ?", createdAt))
}

// CreatedAtGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CreatedAtGt(createdAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at > ?", createdAt))
}

// CreatedAtGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CreatedAtGte(createdAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at >= ?", createdAt))
}

// CreatedAtLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CreatedAtLt(createdAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at < ?", createdAt))
}

// CreatedAtLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CreatedAtLte(createdAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at <= ?", createdAt))
}

// CreatedAtNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) CreatedAtNe(createdAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("created_at != ?", createdAt))
}

// Delete is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) Delete() error {
	return qs.db.Delete(UserRedeemCode{}).Error
}

// DeleteNum is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeleteNum() (int64, error) {
	db := qs.db.Delete(UserRedeemCode{})
	return db.RowsAffected, db.Error
}

// DeleteNumUnscoped is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeleteNumUnscoped() (int64, error) {
	db := qs.db.Unscoped().Delete(UserRedeemCode{})
	return db.RowsAffected, db.Error
}

// DeletedAtEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtEq(deletedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at = ?", deletedAt))
}

// DeletedAtGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtGt(deletedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at > ?", deletedAt))
}

// DeletedAtGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtGte(deletedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at >= ?", deletedAt))
}

// DeletedAtIsNotNull is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtIsNotNull() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at IS NOT NULL"))
}

// DeletedAtIsNull is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtIsNull() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at IS NULL"))
}

// DeletedAtLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtLt(deletedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at < ?", deletedAt))
}

// DeletedAtLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtLte(deletedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at <= ?", deletedAt))
}

// DeletedAtNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) DeletedAtNe(deletedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("deleted_at != ?", deletedAt))
}

// GetDB is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) GetDB() *gorm.DB {
	return qs.db
}

// GetUpdater is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) GetUpdater() UserRedeemCodeUpdater {
	return NewUserRedeemCodeUpdater(qs.db)
}

// IDEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDEq(ID uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("id = ?", ID))
}

// IDGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDGt(ID uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("id > ?", ID))
}

// IDGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDGte(ID uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("id >= ?", ID))
}

// IDIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDIn(ID ...uint32) UserRedeemCodeQuerySet {
	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))
}

// IDLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDLt(ID uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("id < ?", ID))
}

// IDLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDLte(ID uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("id <= ?", ID))
}

// IDNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDNe(ID uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("id != ?", ID))
}

// IDNotIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) IDNotIn(ID ...uint32) UserRedeemCodeQuerySet {
	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))
}

// Limit is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) Limit(limit int) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Limit(limit))
}

// Offset is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) Offset(offset int) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Offset(offset))
}

// One is used to retrieve one result. It returns gorm.ErrRecordNotFound
// if nothing was fetched
func (qs UserRedeemCodeQuerySet) One(ret *UserRedeemCode) error {
	return qs.db.First(ret).Error
}

// OrderAscByActivityType is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByActivityType() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("activity_type ASC"))
}

// OrderAscByConvertTime is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByConvertTime() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("convert_time ASC"))
}

// OrderAscByCreatedAt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByCreatedAt() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("created_at ASC"))
}

// OrderAscByDeletedAt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByDeletedAt() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("deleted_at ASC"))
}

// OrderAscByID is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByID() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("id ASC"))
}

// OrderAscByUid is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByUid() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("uid ASC"))
}

// OrderAscByUpdatedAt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderAscByUpdatedAt() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("updated_at ASC"))
}

// OrderDescByActivityType is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByActivityType() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("activity_type DESC"))
}

// OrderDescByConvertTime is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByConvertTime() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("convert_time DESC"))
}

// OrderDescByCreatedAt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByCreatedAt() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("created_at DESC"))
}

// OrderDescByDeletedAt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByDeletedAt() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("deleted_at DESC"))
}

// OrderDescByID is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByID() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("id DESC"))
}

// OrderDescByUid is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByUid() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("uid DESC"))
}

// OrderDescByUpdatedAt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) OrderDescByUpdatedAt() UserRedeemCodeQuerySet {
	return qs.w(qs.db.Order("updated_at DESC"))
}

// SerialCodeEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) SerialCodeEq(serialCode string) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("serial_code = ?", serialCode))
}

// SerialCodeIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) SerialCodeIn(serialCode ...string) UserRedeemCodeQuerySet {
	if len(serialCode) == 0 {
		qs.db.AddError(errors.New("must at least pass one serialCode in SerialCodeIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("serial_code IN (?)", serialCode))
}

// SerialCodeNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) SerialCodeNe(serialCode string) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("serial_code != ?", serialCode))
}

// SerialCodeNotIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) SerialCodeNotIn(serialCode ...string) UserRedeemCodeQuerySet {
	if len(serialCode) == 0 {
		qs.db.AddError(errors.New("must at least pass one serialCode in SerialCodeNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("serial_code NOT IN (?)", serialCode))
}

// StatusEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) StatusEq(status string) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("status = ?", status))
}

// StatusIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) StatusIn(status ...string) UserRedeemCodeQuerySet {
	if len(status) == 0 {
		qs.db.AddError(errors.New("must at least pass one status in StatusIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("status IN (?)", status))
}

// StatusNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) StatusNe(status string) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("status != ?", status))
}

// StatusNotIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) StatusNotIn(status ...string) UserRedeemCodeQuerySet {
	if len(status) == 0 {
		qs.db.AddError(errors.New("must at least pass one status in StatusNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("status NOT IN (?)", status))
}

// UidEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidEq(uid uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("uid = ?", uid))
}

// UidGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidGt(uid uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("uid > ?", uid))
}

// UidGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidGte(uid uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("uid >= ?", uid))
}

// UidIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidIn(uid ...uint32) UserRedeemCodeQuerySet {
	if len(uid) == 0 {
		qs.db.AddError(errors.New("must at least pass one uid in UidIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("uid IN (?)", uid))
}

// UidLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidLt(uid uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("uid < ?", uid))
}

// UidLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidLte(uid uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("uid <= ?", uid))
}

// UidNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidNe(uid uint32) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("uid != ?", uid))
}

// UidNotIn is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UidNotIn(uid ...uint32) UserRedeemCodeQuerySet {
	if len(uid) == 0 {
		qs.db.AddError(errors.New("must at least pass one uid in UidNotIn"))
		return qs.w(qs.db)
	}
	return qs.w(qs.db.Where("uid NOT IN (?)", uid))
}

// UpdatedAtEq is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UpdatedAtEq(updatedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at = ?", updatedAt))
}

// UpdatedAtGt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UpdatedAtGt(updatedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at > ?", updatedAt))
}

// UpdatedAtGte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UpdatedAtGte(updatedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at >= ?", updatedAt))
}

// UpdatedAtLt is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UpdatedAtLt(updatedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at < ?", updatedAt))
}

// UpdatedAtLte is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UpdatedAtLte(updatedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at <= ?", updatedAt))
}

// UpdatedAtNe is an autogenerated method
// nolint: dupl
func (qs UserRedeemCodeQuerySet) UpdatedAtNe(updatedAt time.Time) UserRedeemCodeQuerySet {
	return qs.w(qs.db.Where("updated_at != ?", updatedAt))
}

// SetActivityType is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetActivityType(activityType uint32) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.ActivityType)] = activityType
	return u
}

// SetCodeType is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetCodeType(codeType string) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.CodeType)] = codeType
	return u
}

// SetConvertTime is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetConvertTime(convertTime time.Time) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.ConvertTime)] = convertTime
	return u
}

// SetCreatedAt is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetCreatedAt(createdAt time.Time) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.CreatedAt)] = createdAt
	return u
}

// SetDeletedAt is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetDeletedAt(deletedAt *time.Time) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.DeletedAt)] = deletedAt
	return u
}

// SetID is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetID(ID uint32) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.ID)] = ID
	return u
}

// SetSerialCode is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetSerialCode(serialCode string) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.SerialCode)] = serialCode
	return u
}

// SetStatus is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetStatus(status string) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.Status)] = status
	return u
}

// SetUid is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetUid(uid uint32) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.Uid)] = uid
	return u
}

// SetUpdatedAt is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) SetUpdatedAt(updatedAt time.Time) UserRedeemCodeUpdater {
	u.fields[string(UserRedeemCodeDBSchema.UpdatedAt)] = updatedAt
	return u
}

// Update is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) Update() error {
	return u.db.Updates(u.fields).Error
}

// UpdateNum is an autogenerated method
// nolint: dupl
func (u UserRedeemCodeUpdater) UpdateNum() (int64, error) {
	db := u.db.Updates(u.fields)
	return db.RowsAffected, db.Error
}

// ===== END of query set UserRedeemCodeQuerySet

// ===== BEGIN of UserRedeemCode modifiers

// UserRedeemCodeDBSchemaField describes database schema field. It requires for method 'Update'
type UserRedeemCodeDBSchemaField string

// String method returns string representation of field.
// nolint: dupl
func (f UserRedeemCodeDBSchemaField) String() string {
	return string(f)
}

// UserRedeemCodeDBSchema stores db field names of UserRedeemCode
var UserRedeemCodeDBSchema = struct {
	ID           UserRedeemCodeDBSchemaField
	CreatedAt    UserRedeemCodeDBSchemaField
	UpdatedAt    UserRedeemCodeDBSchemaField
	DeletedAt    UserRedeemCodeDBSchemaField
	Uid          UserRedeemCodeDBSchemaField
	Status       UserRedeemCodeDBSchemaField
	SerialCode   UserRedeemCodeDBSchemaField
	CodeType     UserRedeemCodeDBSchemaField
	ConvertTime  UserRedeemCodeDBSchemaField
	ActivityType UserRedeemCodeDBSchemaField
}{

	ID:           UserRedeemCodeDBSchemaField("id"),
	CreatedAt:    UserRedeemCodeDBSchemaField("created_at"),
	UpdatedAt:    UserRedeemCodeDBSchemaField("updated_at"),
	DeletedAt:    UserRedeemCodeDBSchemaField("deleted_at"),
	Uid:          UserRedeemCodeDBSchemaField("uid"),
	Status:       UserRedeemCodeDBSchemaField("status"),
	SerialCode:   UserRedeemCodeDBSchemaField("serial_code"),
	CodeType:     UserRedeemCodeDBSchemaField("code_type"),
	ConvertTime:  UserRedeemCodeDBSchemaField("convert_time"),
	ActivityType: UserRedeemCodeDBSchemaField("activity_type"),
}

// Update updates UserRedeemCode fields by primary key
// nolint: dupl
func (o *UserRedeemCode) Update(db *gorm.DB, fields ...UserRedeemCodeDBSchemaField) error {
	dbNameToFieldName := map[string]interface{}{
		"id":            o.ID,
		"created_at":    o.CreatedAt,
		"updated_at":    o.UpdatedAt,
		"deleted_at":    o.DeletedAt,
		"uid":           o.Uid,
		"status":        o.Status,
		"serial_code":   o.SerialCode,
		"code_type":     o.CodeType,
		"convert_time":  o.ConvertTime,
		"activity_type": o.ActivityType,
	}
	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 UserRedeemCode %v fields %v: %s",
			o, fields, err)
	}

	return nil
}

// UserRedeemCodeUpdater is an UserRedeemCode updates manager
type UserRedeemCodeUpdater struct {
	fields map[string]interface{}
	db     *gorm.DB
}

// NewUserRedeemCodeUpdater creates new UserRedeemCode updater
// nolint: dupl
func NewUserRedeemCodeUpdater(db *gorm.DB) UserRedeemCodeUpdater {
	return UserRedeemCodeUpdater{
		fields: map[string]interface{}{},
		db:     db.Model(&UserRedeemCode{}),
	}
}

// ===== END of UserRedeemCode modifiers

// ===== END of all query sets
