package content

import (
	"time"
	"zhenyihuibao/conf"
)

const(
	CourseStatusOn = 1
	CourseStatusOff = 2
)

//课程表
type FaCourses 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:"create_time created" json:"create_time" description:"创建时间"`
	UpdateTime      time.Time 	`xorm:"update_time updated"json:"update_time" description:"更新时间"`
	IsFree			int			`xorm:"not null comment('是否免费') INT(11)" json:"is_free"`
	Weight			int			`xorm:"not null comment('权重') INT(11)" json:"weight"`
	Status			int			`xorm:"not null comment('状态') INT(11)" json:"status"`
}


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