package content

import (
	"time"
	"zhenyihuibao/conf"
)

const(
	JewelsStatusOn = 1
	JewelsStatusOff = 2
)

//课程表
type FaJewels struct {
	Id        		int   		`xorm:"not null pk autoincr INT(10)" json:"id"`
	Title			string		`xorm:"not null comment('标题') default '' VARCHAR(255)" json:"title"`
	Icon			string		`xorm:"not null comment('icon') default '' VARCHAR(255)" json:"icon"`
	ExtrInfo		string		`xorm:"not null comment('extr_info') default '' VARCHAR(255)" json:"extr_info"`
	Description		string		`xorm:"not null comment('描述') default '' VARCHAR(255)" json:"description"`
	Content			string		`xorm:"comment('content') text" json:"content"`
	CreateTime      time.Time 	`xorm:"created not null default 'CURRENT_TIMESTAMP' TIMESTAMP" json:"create_time,omitempty" description:"创建时间"`
	UpdateTime      time.Time 	`xorm:"created not null default 'CURRENT_TIMESTAMP' TIMESTAMP" json:"update_time,omitempty" description:"更新时间"`
	Weight			int			`xorm:"not null comment('权重') INT(11)" json:"weight"`
	Status			int			`xorm:"not null comment('状态') INT(11)" json:"status"`
}


func (this *FaJewels) GetMhomeList() (itemList []*FaJewels, err error){
	session := conf.SqlServer.Where("1=1")
	err = session.Cols("id,title,icon,description,extr_info,update_time").
		Where("status = ?", JewelsStatusOn).
		OrderBy("weight desc").
		Limit(20, 0).
		Find(&itemList)
	if err != nil {
		return
	}
	return
}