package models_func

import (
	"errors"

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

type EtcSelectName struct {
	EtcType    string `xorm:"not null VARCHAR(21)"`
	SelectName string `xorm:"VARCHAR(49)"`
}
type EtcSelectNamePageRet struct {
	Page []EtcSelectName
}

func (t *EtcSelectNamePageRet) GetPage(YDB *xorm.Engine) error {

	qry := *YDB.Select("distinctrow etc_type, select_name").Table("dbr_etc").Asc("sort_no")

	if _, err := qry.FindAndCount(&t.Page); err == nil {
		e.FuncRun("oytrsderas", e.CurrFuncName())
		return nil
	} else {
		return errors.New(e.PageQryErr("mniosgfde", e.CurrFuncName()+err.Error()))
	}
}
