package models_func

import (
	"errors"

	"github.com/dabory/abango-rest"
	e "github.com/dabory/abango-rest/etc"
)

type UserSelect struct {
	Id   int    `xorm:"not null pk autoincr INT(10)"`
	Name string `xorm:"not null VARCHAR(49)"`
}
type UserSelectPage struct {
	Page []UserSelect
}

func GetUserSelect(y *abango.Controller, sel *UserSelectPage, filter string) error { //여기서는 filter 안쓰고 슴슴

	qry := *y.Db.
		Table("users").
		Select("users.id, nick_name").
		Join("INNER", "dbr_user_ext", "dbr_user_ext.id=users.id").
		Where("branch_id=" + e.NumToStr(y.Gtb.BranchId)).
		Where("is_expired = '0'").
		Asc("nick_name")

	if err := qry.Find(&sel.Page); err == nil {
		e.FuncRun("3f34fga43far", e.CurrFuncName())
		return nil
	} else {
		return errors.New(e.PageQryErr("ltrysgaera", e.CurrFuncName()+err.Error()))
	}
}
