role_menu.go
775 字节
package models
import (
"github.com/astaxie/beego/orm"
)
type RoleMenu struct {
Id int64 `orm:"column(id);auto" description:"主键"`
RoleId int64 `orm:"column(role_id);null" description:"role.id"`
MenuId int `orm:"column(menu_id);null" description:"menu.id"`
Opption string `orm:"column(opption);size(500);null" description:"配置"`
Code string `orm:"column(code)"`
}
func (t *RoleMenu) TableName() string {
return "role_menu"
}
func init() {
orm.RegisterModel(new(RoleMenu))
}
func GetRoleMenuByRole(roleid int64) ([]RoleMenu, error) {
var (
list []RoleMenu
err error
)
o := orm.NewOrm()
_, err = o.QueryTable(&RoleMenu{}).
Filter("role_id", roleid).
All(&list)
if err == orm.ErrNoRows {
return list, nil
}
return list, err
}