package content

import (
	"time"
	"zhenyihuibao/conf"
)

const(
	TeachersStatusOn  = 1
	TeachersStatusOff = 2
)

//课程表
type FaTeachers struct {
	Id        		int   		`xorm:"not null pk autoincr INT(10)" json:"id"`
	Name			string		`xorm:"not null comment('标题') default '' VARCHAR(255)" json:"name"`
	Icon			string		`xorm:"not null comment('icon') default '' VARCHAR(255)" json:"icon"`
	TeacherInfo		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:"更新时间"`
	Weight			int			`xorm:"not null comment('权重') INT(11)" json:"weight"`
	Status			int			`xorm:"not null comment('状态') INT(11)" json:"status"`
}


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