package models
import "github.com/astaxie/beego/orm"
type Region struct {
Id int
Name string
}
type Type struct {
Id int
Name string
}
func init() {
orm.RegisterModel(new(Type))
orm.RegisterModel(new(Region))
}
func ChannelRegion(channelId int) (int64, []Region, error) {
o := orm.NewOrm()
var regions []Region
num, err := o.Raw("select id, name from channel_region where channel_id = ? AND status = 1 ORDER BY sort DESC", channelId).QueryRows(®ions)
return num, regions, err
}
func ChannelType(channelId int) (int64, []Type, error) {
o := orm.NewOrm()
var types []Type
num, err := o.Raw("select id, name from channel_type where channel_id = ? AND status = 1 ORDER BY sort DESC", channelId).QueryRows(&types)
return num, types, err
}