package content

import "zhenyihuibao/conf"

//分类表
type FaCategory struct {
	Id        		int   		`xorm:"not null pk autoincr INT(10)" json:"id"`
	Type			string		`xorm:"not null comment('分类') default '' VARCHAR(255)" json:"type"`
	Name			string		`xorm:"not null comment('name') default '' VARCHAR(255)" json:"name"`
	Image			string		`xorm:"not null comment('image') default '' VARCHAR(255)" json:"image"`
	LinkUrl			string		`xorm:"not null comment('link_url') default '' VARCHAR(255) link_url" json:"link_url"`
	Weigh			int			`xorm:"not null comment('权重') INT(11)" json:"weigh"`
	Status			string		`xorm:"not null comment('status') default '' VARCHAR(255)" json:"status"`
}

const(
	MobileCateType		= "mswiper"
	CategoryStatusOn 	= "normal"
	CategoryStatusOff 	= "off"
)

func (this *FaCategory) GetMhomeList() (itemList []*FaCategory, err error){
	session := conf.SqlServer.Where("1=1")
	err = session.Cols("id,name,image,link_url").Where("type = ?", MobileCateType).Where("status = ?", CategoryStatusOn).OrderBy("weigh desc").Limit(10, 0).Find(&itemList)
	if err != nil {
		return
	}
	return
}