package exam

import (
	"zhenyihuibao/conf"
	"zhenyihuibao/pkg/logging"
)

type BankTitle struct{
	QuesTitle 	`xorm:"extends"`
}

func (this *BankTitle) TableName() string {
	return "ques_bank_title"
}

func (this *BankTitle) GetTitleListByBankId(bankId int)(banTitleList []*BankTitle, err error){
	session := conf.SqlServer.Where("1=1")
	err = session.Table("ques_bank_title").
		Alias("qbt").
		Cols("t.*").
		Join("LEFT", []string{"ques_title", "t"}, "qbt.ques_title_id = t.id").
		Where("qbt.ques_bank_id = ?", bankId).
		OrderBy("qbt.weight desc").
		Find(&banTitleList)
	if err != nil {
		logging.MyLogger.Errorf("Model.GetTitleListByBankId ---- sql查询失败",err.Error())
		return
	}
	return
}