func (m *_UserDBMgr) FindOneFetch(unique Unique) (*User, error) {
	obj := UserMgr.NewUser()
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), unique.SQLFormat(true))
	objs, err := m.FetchBySQL(query, unique.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("none record")
}
Deprecated: Use FetchByXXXUnique instead.
package model
import (
	"context"
	"database/sql"
	"errors"
	"fmt"
	"strings"
	"time"
	"github.com/ezbuy/redis-orm/orm"
	"github.com/go-redis/redis/v8"
	"gopkg.in/go-playground/validator.v9"
)
var (
	_ sql.DB
	_ time.Time
	_ fmt.Formatter
	_ strings.Reader
	_ orm.VSet
	_ validator.Validate
	_ context.Context
)
type User struct {
	Id          int32      `db:"id" json:"id"`
	SubID       int32      `db:"sub_id" json:"sub_id"`
	Name        string     `db:"name" json:"name" validate:"required"`
	Mailbox     string     `db:"mailbox" json:"mailbox" validate:"required"`
	Sex         bool       `db:"sex" json:"sex"`
	Age         int32      `db:"age" json:"age"`
	Longitude   float64    `db:"longitude" json:"longitude"`
	Latitude    float64    `db:"latitude" json:"latitude"`
	Description string     `db:"description" json:"description"`
	Password    string     `db:"password" json:"password"`
	HeadUrl     string     `db:"head_url" json:"head_url"`
	Status      int32      `db:"user_status" json:"status"`
	CreatedAt   time.Time  `db:"created_at" json:"created_at"`
	UpdatedAt   time.Time  `db:"updated_at" json:"updated_at"`
	DeletedAt   *time.Time `db:"deleted_at" json:"deleted_at"`
}
var UserColumns = struct {
	Id          string
	SubID       string
	Name        string
	Mailbox     string
	Sex         string
	Age         string
	Longitude   string
	Latitude    string
	Description string
	Password    string
	HeadUrl     string
	Status      string
	CreatedAt   string
	UpdatedAt   string
	DeletedAt   string
}{
	"id",
	"sub_id",
	"name",
	"mailbox",
	"sex",
	"age",
	"longitude",
	"latitude",
	"description",
	"password",
	"head_url",
	"user_status",
	"created_at",
	"updated_at",
	"deleted_at",
}
type _UserMgr struct {
}
var UserMgr *_UserMgr
func (m *_UserMgr) NewUser() *User {
	return &User{}
}
func (obj *User) GetNameSpace() string {
	return "model"
}
func (obj *User) GetClassName() string {
	return "User"
}
func (obj *User) GetTableName() string {
	return "users"
}
func (obj *User) GetColumns() []string {
	columns := []string{
		"users.`id`",
		"users.`sub_id`",
		"users.`name`",
		"users.`mailbox`",
		"users.`sex`",
		"users.`age`",
		"users.`longitude`",
		"users.`latitude`",
		"users.`description`",
		"users.`password`",
		"users.`head_url`",
		"users.`user_status`",
		"users.`created_at`",
		"users.`updated_at`",
		"users.`deleted_at`",
	}
	return columns
}
func (obj *User) GetNoneIncrementColumns() []string {
	columns := []string{
		"`sub_id`",
		"`name`",
		"`mailbox`",
		"`sex`",
		"`age`",
		"`longitude`",
		"`latitude`",
		"`description`",
		"`password`",
		"`head_url`",
		"`user_status`",
		"`created_at`",
		"`updated_at`",
		"`deleted_at`",
	}
	return columns
}
func (obj *User) GetPrimaryKey() PrimaryKey {
	pk := UserMgr.NewPrimaryKey()
	pk.Id = obj.Id
	return pk
}
func (obj *User) Validate() error {
	validate := validator.New()
	return validate.Struct(obj)
}
func (obj *User) GetIndexes() []string {
	idx := []string{
		"Sex",
		"Age",
	}
	return idx
}
func (obj *User) GetStoreType() string {
	return "hash"
}
func (obj *User) GetPrimaryName() string {
	pk := obj.GetPrimaryKey()
	return pk.Key()
}
type IdOfUserPK struct {
	Id int32
}
func (m *_UserMgr) NewPrimaryKey() *IdOfUserPK {
	return &IdOfUserPK{}
}
func (u *IdOfUserPK) Key() string {
	strs := []string{
		"Id",
		fmt.Sprint(u.Id),
	}
	return fmt.Sprintf("%s", strings.Join(strs, ":"))
}
func (u *IdOfUserPK) Parse(key string) error {
	arr := strings.Split(key, ":")
	if len(arr)%2 != 0 {
		return fmt.Errorf("key (%s) format error", key)
	}
	kv := map[string]string{}
	for i := 0; i < len(arr)/2; i++ {
		kv[arr[2*i]] = arr[2*i+1]
	}
	vId, ok := kv["Id"]
	if !ok {
		return fmt.Errorf("key (%s) without (Id) field", key)
	}
	if err := orm.StringScan(vId, &(u.Id)); err != nil {
		return err
	}
	return nil
}
func (u *IdOfUserPK) SQLFormat() string {
	conditions := []string{
		"`id` = ?",
	}
	return orm.SQLWhere(conditions)
}
func (u *IdOfUserPK) SQLParams() []interface{} {
	return []interface{}{
		u.Id,
	}
}
func (u *IdOfUserPK) Columns() []string {
	return []string{
		"`id`",
	}
}
type MailboxPasswordOfUserUK struct {
	Mailbox  string
	Password string
}
func (u *MailboxPasswordOfUserUK) Key() string {
	strs := []string{
		"Mailbox",
		fmt.Sprint(u.Mailbox),
		"Password",
		fmt.Sprint(u.Password),
	}
	return fmt.Sprintf("%s", strings.Join(strs, ":"))
}
func (u *MailboxPasswordOfUserUK) SQLFormat(limit bool) string {
	conditions := []string{
		"`mailbox` = ?",
		"`password` = ?",
	}
	return orm.SQLWhere(conditions)
}
func (u *MailboxPasswordOfUserUK) SQLParams() []interface{} {
	return []interface{}{
		u.Mailbox,
		u.Password,
	}
}
func (u *MailboxPasswordOfUserUK) SQLLimit() int {
	return 1
}
func (u *MailboxPasswordOfUserUK) Limit(n int) {
}
func (u *MailboxPasswordOfUserUK) Offset(n int) {
}
func (u *MailboxPasswordOfUserUK) UKRelation(store *orm.RedisStore) UniqueRelation {
	return MailboxPasswordOfUserUKRelationRedisMgr(store)
}
type SexOfUserIDX struct {
	Sex    bool
	offset int
	limit  int
}
func (u *SexOfUserIDX) Key() string {
	strs := []string{
		"Sex",
		fmt.Sprint(u.Sex),
	}
	return fmt.Sprintf("%s", strings.Join(strs, ":"))
}
func (u *SexOfUserIDX) SQLFormat(limit bool) string {
	conditions := []string{
		"`sex` = ?",
	}
	if limit {
		return fmt.Sprintf("%s %s", orm.SQLWhere(conditions), orm.SQLOffsetLimit(u.offset, u.limit))
	}
	return orm.SQLWhere(conditions)
}
func (u *SexOfUserIDX) SQLParams() []interface{} {
	return []interface{}{
		u.Sex,
	}
}
func (u *SexOfUserIDX) SQLLimit() int {
	if u.limit > 0 {
		return u.limit
	}
	return -1
}
func (u *SexOfUserIDX) Limit(n int) {
	u.limit = n
}
func (u *SexOfUserIDX) Offset(n int) {
	u.offset = n
}
func (u *SexOfUserIDX) PositionOffsetLimit(len int) (int, int) {
	if u.limit <= 0 {
		return 0, len
	}
	if u.offset+u.limit > len {
		return u.offset, len
	}
	return u.offset, u.limit
}
func (u *SexOfUserIDX) IDXRelation(store *orm.RedisStore) IndexRelation {
	return SexOfUserIDXRelationRedisMgr(store)
}
type IdOfUserRNG struct {
	IdBegin      int64
	IdEnd        int64
	offset       int
	limit        int
	includeBegin bool
	includeEnd   bool
	revert       bool
}
func (u *IdOfUserRNG) Key() string {
	strs := []string{
		"Id",
	}
	return fmt.Sprintf("%s", strings.Join(strs, ":"))
}
func (u *IdOfUserRNG) beginOp() string {
	if u.includeBegin {
		return ">="
	}
	return ">"
}
func (u *IdOfUserRNG) endOp() string {
	if u.includeBegin {
		return "<="
	}
	return "<"
}
func (u *IdOfUserRNG) SQLFormat(limit bool) string {
	conditions := []string{}
	if u.IdBegin != u.IdEnd {
		if u.IdBegin != -1 {
			conditions = append(conditions, fmt.Sprintf("`id` %s ?", u.beginOp()))
		}
		if u.IdEnd != -1 {
			conditions = append(conditions, fmt.Sprintf("`id` %s ?", u.endOp()))
		}
	}
	if limit {
		return fmt.Sprintf("%s %s %s", orm.SQLWhere(conditions), orm.SQLOrderBy("`id`", u.revert), orm.SQLOffsetLimit(u.offset, u.limit))
	}
	return fmt.Sprintf("%s %s", orm.SQLWhere(conditions), orm.SQLOrderBy("`id`", u.revert))
}
func (u *IdOfUserRNG) SQLParams() []interface{} {
	params := []interface{}{}
	if u.IdBegin != u.IdEnd {
		if u.IdBegin != -1 {
			params = append(params, u.IdBegin)
		}
		if u.IdEnd != -1 {
			params = append(params, u.IdEnd)
		}
	}
	return params
}
func (u *IdOfUserRNG) SQLLimit() int {
	if u.limit > 0 {
		return u.limit
	}
	return -1
}
func (u *IdOfUserRNG) Limit(n int) {
	u.limit = n
}
func (u *IdOfUserRNG) Offset(n int) {
	u.offset = n
}
func (u *IdOfUserRNG) PositionOffsetLimit(len int) (int, int) {
	if u.limit <= 0 {
		return 0, len
	}
	if u.offset+u.limit > len {
		return u.offset, len
	}
	return u.offset, u.limit
}
func (u *IdOfUserRNG) Begin() int64 {
	start := u.IdBegin
	if start == -1 || start == 0 {
		start = 0
	}
	if start > 0 {
		if !u.includeBegin {
			start = start + 1
		}
	}
	return start
}
func (u *IdOfUserRNG) End() int64 {
	stop := u.IdEnd
	if stop == 0 || stop == -1 {
		stop = -1
	}
	if stop > 0 {
		if !u.includeBegin {
			stop = stop - 1
		}
	}
	return stop
}
func (u *IdOfUserRNG) Revert(b bool) {
	u.revert = b
}
func (u *IdOfUserRNG) IncludeBegin(f bool) {
	u.includeBegin = f
}
func (u *IdOfUserRNG) IncludeEnd(f bool) {
	u.includeEnd = f
}
func (u *IdOfUserRNG) RNGRelation(store *orm.RedisStore) RangeRelation {
	return IdOfUserRNGRelationRedisMgr(store)
}
type AgeOfUserRNG struct {
	AgeBegin     int64
	AgeEnd       int64
	offset       int
	limit        int
	includeBegin bool
	includeEnd   bool
	revert       bool
}
func (u *AgeOfUserRNG) Key() string {
	strs := []string{
		"Age",
	}
	return fmt.Sprintf("%s", strings.Join(strs, ":"))
}
func (u *AgeOfUserRNG) beginOp() string {
	if u.includeBegin {
		return ">="
	}
	return ">"
}
func (u *AgeOfUserRNG) endOp() string {
	if u.includeBegin {
		return "<="
	}
	return "<"
}
func (u *AgeOfUserRNG) SQLFormat(limit bool) string {
	conditions := []string{}
	if u.AgeBegin != u.AgeEnd {
		if u.AgeBegin != -1 {
			conditions = append(conditions, fmt.Sprintf("`age` %s ?", u.beginOp()))
		}
		if u.AgeEnd != -1 {
			conditions = append(conditions, fmt.Sprintf("`age` %s ?", u.endOp()))
		}
	}
	if limit {
		return fmt.Sprintf("%s %s %s", orm.SQLWhere(conditions), orm.SQLOrderBy("`age`", u.revert), orm.SQLOffsetLimit(u.offset, u.limit))
	}
	return fmt.Sprintf("%s %s", orm.SQLWhere(conditions), orm.SQLOrderBy("`age`", u.revert))
}
func (u *AgeOfUserRNG) SQLParams() []interface{} {
	params := []interface{}{}
	if u.AgeBegin != u.AgeEnd {
		if u.AgeBegin != -1 {
			params = append(params, u.AgeBegin)
		}
		if u.AgeEnd != -1 {
			params = append(params, u.AgeEnd)
		}
	}
	return params
}
func (u *AgeOfUserRNG) SQLLimit() int {
	if u.limit > 0 {
		return u.limit
	}
	return -1
}
func (u *AgeOfUserRNG) Limit(n int) {
	u.limit = n
}
func (u *AgeOfUserRNG) Offset(n int) {
	u.offset = n
}
func (u *AgeOfUserRNG) PositionOffsetLimit(len int) (int, int) {
	if u.limit <= 0 {
		return 0, len
	}
	if u.offset+u.limit > len {
		return u.offset, len
	}
	return u.offset, u.limit
}
func (u *AgeOfUserRNG) Begin() int64 {
	start := u.AgeBegin
	if start == -1 || start == 0 {
		start = 0
	}
	if start > 0 {
		if !u.includeBegin {
			start = start + 1
		}
	}
	return start
}
func (u *AgeOfUserRNG) End() int64 {
	stop := u.AgeEnd
	if stop == 0 || stop == -1 {
		stop = -1
	}
	if stop > 0 {
		if !u.includeBegin {
			stop = stop - 1
		}
	}
	return stop
}
func (u *AgeOfUserRNG) Revert(b bool) {
	u.revert = b
}
func (u *AgeOfUserRNG) IncludeBegin(f bool) {
	u.includeBegin = f
}
func (u *AgeOfUserRNG) IncludeEnd(f bool) {
	u.includeEnd = f
}
func (u *AgeOfUserRNG) RNGRelation(store *orm.RedisStore) RangeRelation {
	return AgeOfUserRNGRelationRedisMgr(store)
}
type _UserDBMgr struct {
	db orm.DB
}
func (m *_UserMgr) DB(db orm.DB) *_UserDBMgr {
	return UserDBMgr(db)
}
func UserDBMgr(db orm.DB) *_UserDBMgr {
	if db == nil {
		panic(fmt.Errorf("UserDBMgr init need db"))
	}
	return &_UserDBMgr{db: db}
}
func (m *_UserDBMgr) Search(where string, orderby string, limit string, args ...interface{}) ([]*User, error) {
	obj := UserMgr.NewUser()
	if limit = strings.ToUpper(strings.TrimSpace(limit)); limit != "" && !strings.HasPrefix(limit, "LIMIT") {
		limit = "LIMIT " + limit
	}
	conditions := []string{where, orderby, limit}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), strings.Join(conditions, " "))
	return m.FetchBySQL(query, args...)
}
func (m *_UserDBMgr) SearchContext(ctx context.Context, where string, orderby string, limit string, args ...interface{}) ([]*User, error) {
	obj := UserMgr.NewUser()
	if limit = strings.ToUpper(strings.TrimSpace(limit)); limit != "" && !strings.HasPrefix(limit, "LIMIT") {
		limit = "LIMIT " + limit
	}
	conditions := []string{where, orderby, limit}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), strings.Join(conditions, " "))
	return m.FetchBySQLContext(ctx, query, args...)
}
func (m *_UserDBMgr) SearchConditions(conditions []string, orderby string, offset int, limit int, args ...interface{}) ([]*User, error) {
	obj := UserMgr.NewUser()
	q := fmt.Sprintf("SELECT %s FROM users %s %s %s",
		strings.Join(obj.GetColumns(), ","),
		orm.SQLWhere(conditions),
		orderby,
		orm.SQLOffsetLimit(offset, limit))
	return m.FetchBySQL(q, args...)
}
func (m *_UserDBMgr) SearchConditionsContext(ctx context.Context, conditions []string, orderby string, offset int, limit int, args ...interface{}) ([]*User, error) {
	obj := UserMgr.NewUser()
	q := fmt.Sprintf("SELECT %s FROM users %s %s %s",
		strings.Join(obj.GetColumns(), ","),
		orm.SQLWhere(conditions),
		orderby,
		orm.SQLOffsetLimit(offset, limit))
	return m.FetchBySQLContext(ctx, q, args...)
}
func (m *_UserDBMgr) SearchCount(where string, args ...interface{}) (int64, error) {
	return m.queryCount(where, args...)
}
func (m *_UserDBMgr) SearchCountContext(ctx context.Context, where string, args ...interface{}) (int64, error) {
	return m.queryCountContext(ctx, where, args...)
}
func (m *_UserDBMgr) SearchConditionsCount(conditions []string, args ...interface{}) (int64, error) {
	return m.queryCount(orm.SQLWhere(conditions), args...)
}
func (m *_UserDBMgr) SearchConditionsCountContext(ctx context.Context, conditions []string, args ...interface{}) (int64, error) {
	return m.queryCountContext(ctx, orm.SQLWhere(conditions), args...)
}
func (m *_UserDBMgr) FetchBySQL(q string, args ...interface{}) (results []*User, err error) {
	rows, err := m.db.Query(q, args...)
	if err != nil {
		return nil, fmt.Errorf("User fetch error: %v", err)
	}
	defer rows.Close()
	var Description sql.NullString
	var HeadUrl sql.NullString
	var CreatedAt int64
	var UpdatedAt int64
	var DeletedAt sql.NullInt64
	for rows.Next() {
		var result User
		err = rows.Scan(&(result.Id), &(result.SubID), &(result.Name), &(result.Mailbox), &(result.Sex), &(result.Age), &(result.Longitude), &(result.Latitude), &Description, &(result.Password), &HeadUrl, &(result.Status), &CreatedAt, &UpdatedAt, &DeletedAt)
		if err != nil {
			m.db.SetError(err)
			return nil, err
		}
		result.Description = Description.String
		result.HeadUrl = HeadUrl.String
		result.CreatedAt = time.Unix(CreatedAt, 0)
		result.UpdatedAt = time.Unix(UpdatedAt, 0)
		if DeletedAt.Valid {
			DeletedAtValue := DeletedAt.Int64
			DeletedAtPoint := time.Unix(DeletedAtValue, 0)
			result.DeletedAt = &DeletedAtPoint
		} else {
			result.DeletedAt = nil
		}
		results = append(results, &result)
	}
	if err = rows.Err(); err != nil {
		m.db.SetError(err)
		return nil, fmt.Errorf("User fetch result error: %v", err)
	}
	return
}
func (m *_UserDBMgr) FetchBySQLContext(ctx context.Context, q string, args ...interface{}) (results []*User, err error) {
	rows, err := m.db.QueryContext(ctx, q, args...)
	if err != nil {
		return nil, fmt.Errorf("User fetch error: %v", err)
	}
	defer rows.Close()
	var Description sql.NullString
	var HeadUrl sql.NullString
	var CreatedAt int64
	var UpdatedAt int64
	var DeletedAt sql.NullInt64
	for rows.Next() {
		var result User
		err = rows.Scan(&(result.Id), &(result.SubID), &(result.Name), &(result.Mailbox), &(result.Sex), &(result.Age), &(result.Longitude), &(result.Latitude), &Description, &(result.Password), &HeadUrl, &(result.Status), &CreatedAt, &UpdatedAt, &DeletedAt)
		if err != nil {
			m.db.SetError(err)
			return nil, err
		}
		result.Description = Description.String
		result.HeadUrl = HeadUrl.String
		result.CreatedAt = time.Unix(CreatedAt, 0)
		result.UpdatedAt = time.Unix(UpdatedAt, 0)
		if DeletedAt.Valid {
			DeletedAtValue := DeletedAt.Int64
			DeletedAtPoint := time.Unix(DeletedAtValue, 0)
			result.DeletedAt = &DeletedAtPoint
		} else {
			result.DeletedAt = nil
		}
		results = append(results, &result)
	}
	if err = rows.Err(); err != nil {
		m.db.SetError(err)
		return nil, fmt.Errorf("User fetch result error: %v", err)
	}
	return
}
func (m *_UserDBMgr) Exist(pk PrimaryKey) (bool, error) {
	c, err := m.queryCount(pk.SQLFormat(), pk.SQLParams()...)
	if err != nil {
		return false, err
	}
	return (c != 0), nil
}
func (m *_UserDBMgr) Fetch(pk PrimaryKey) (*User, error) {
	obj := UserMgr.NewUser()
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), pk.SQLFormat())
	objs, err := m.FetchBySQL(query, pk.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User fetch record not found")
}
func (m *_UserDBMgr) IsErrNotFound(err error) bool {
	return strings.Contains(err.Error(), "not found") || err == sql.ErrNoRows
}
func (m *_UserDBMgr) FetchByPrimaryKey(id int32) (*User, error) {
	obj := UserMgr.NewUser()
	pk := &IdOfUserPK{
		Id: id,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), pk.SQLFormat())
	objs, err := m.FetchBySQL(query, pk.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User fetch record not found")
}
func (m *_UserDBMgr) FetchByPrimaryKeyContext(ctx context.Context, id int32) (*User, error) {
	obj := UserMgr.NewUser()
	pk := &IdOfUserPK{
		Id: id,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), pk.SQLFormat())
	objs, err := m.FetchBySQLContext(ctx, query, pk.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User fetch record not found")
}
func (m *_UserDBMgr) FetchByPrimaryKeys(ids []int32) ([]*User, error) {
	size := len(ids)
	if size == 0 {
		return nil, nil
	}
	params := make([]interface{}, 0, size)
	for _, pk := range ids {
		params = append(params, pk)
	}
	obj := UserMgr.NewUser()
	query := fmt.Sprintf("SELECT %s FROM users WHERE `id` IN (?%s)", strings.Join(obj.GetColumns(), ","),
		strings.Repeat(",?", size-1))
	return m.FetchBySQL(query, params...)
}
func (m *_UserDBMgr) FetchByPrimaryKeysContext(ctx context.Context, ids []int32) ([]*User, error) {
	size := len(ids)
	if size == 0 {
		return nil, nil
	}
	params := make([]interface{}, 0, size)
	for _, pk := range ids {
		params = append(params, pk)
	}
	obj := UserMgr.NewUser()
	query := fmt.Sprintf("SELECT %s FROM users WHERE `id` IN (?%s)", strings.Join(obj.GetColumns(), ","),
		strings.Repeat(",?", size-1))
	return m.FetchBySQLContext(ctx, query, params...)
}
func (m *_UserDBMgr) FindBySex(sex bool, limit int, offset int) ([]*User, error) {
	obj := UserMgr.NewUser()
	idx_ := &SexOfUserIDX{
		Sex:    sex,
		limit:  limit,
		offset: offset,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), idx_.SQLFormat(true))
	return m.FetchBySQL(query, idx_.SQLParams()...)
}
func (m *_UserDBMgr) FindBySexContext(ctx context.Context, sex bool, limit int, offset int) ([]*User, error) {
	obj := UserMgr.NewUser()
	idx_ := &SexOfUserIDX{
		Sex:    sex,
		limit:  limit,
		offset: offset,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), idx_.SQLFormat(true))
	return m.FetchBySQLContext(ctx, query, idx_.SQLParams()...)
}
func (m *_UserDBMgr) FindAllBySex(sex bool) ([]*User, error) {
	obj := UserMgr.NewUser()
	idx_ := &SexOfUserIDX{
		Sex: sex,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), idx_.SQLFormat(true))
	return m.FetchBySQL(query, idx_.SQLParams()...)
}
func (m *_UserDBMgr) FindAllBySexContext(ctx context.Context, sex bool) ([]*User, error) {
	obj := UserMgr.NewUser()
	idx_ := &SexOfUserIDX{
		Sex: sex,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), idx_.SQLFormat(true))
	return m.FetchBySQLContext(ctx, query, idx_.SQLParams()...)
}
func (m *_UserDBMgr) FindBySexGroup(items []bool) ([]*User, error) {
	obj := UserMgr.NewUser()
	if len(items) == 0 {
		return nil, nil
	}
	params := make([]interface{}, 0, len(items))
	for _, item := range items {
		params = append(params, item)
	}
	query := fmt.Sprintf("SELECT %s FROM users where `sex` in (?", strings.Join(obj.GetColumns(), ",")) +
		strings.Repeat(",?", len(items)-1) + ")"
	return m.FetchBySQL(query, params...)
}
func (m *_UserDBMgr) FindBySexGroupContext(ctx context.Context, items []bool) ([]*User, error) {
	obj := UserMgr.NewUser()
	if len(items) == 0 {
		return nil, nil
	}
	params := make([]interface{}, 0, len(items))
	for _, item := range items {
		params = append(params, item)
	}
	query := fmt.Sprintf("SELECT %s FROM users where `sex` in (?", strings.Join(obj.GetColumns(), ",")) +
		strings.Repeat(",?", len(items)-1) + ")"
	return m.FetchBySQLContext(ctx, query, params...)
}
func (m *_UserDBMgr) FetchByMailboxPassword(mailbox string, password string) (*User, error) {
	obj := UserMgr.NewUser()
	uniq := &MailboxPasswordOfUserUK{
		Mailbox:  mailbox,
		Password: password,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), uniq.SQLFormat(true))
	objs, err := m.FetchBySQL(query, uniq.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User fetch record not found")
}
func (m *_UserDBMgr) FetchByMailboxPasswordContext(ctx context.Context, mailbox string, password string) (*User, error) {
	obj := UserMgr.NewUser()
	uniq := &MailboxPasswordOfUserUK{
		Mailbox:  mailbox,
		Password: password,
	}
	query := fmt.Sprintf("SELECT %s FROM users %s", strings.Join(obj.GetColumns(), ","), uniq.SQLFormat(true))
	objs, err := m.FetchBySQLContext(ctx, query, uniq.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User fetch record not found")
}
func (m *_UserDBMgr) FindOne(unique Unique) (PrimaryKey, error) {
	objs, err := m.queryLimit(unique.SQLFormat(true), unique.SQLLimit(), unique.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User find record not found")
}
func (m *_UserDBMgr) FindOneContext(ctx context.Context, unique Unique) (PrimaryKey, error) {
	objs, err := m.queryLimitContext(ctx, unique.SQLFormat(true), unique.SQLLimit(), unique.SQLParams()...)
	if err != nil {
		return nil, err
	}
	if len(objs) > 0 {
		return objs[0], nil
	}
	return nil, fmt.Errorf("User find record not found")
}