示例#1
0
func (this *BaseController) Menus() {
	url := this.GetThisUrl()
	if url == "" {
		url = "index/index"
	}
	RoleId := 0 //初始
	Id := this.GetSession("role_id")
	if Id != nil {
		RoleId = Id.(int)
	}
	AdminMenu := models.NewAdmin_menu()
	ParentMenu, err := AdminMenu.GetParentMenu(RoleId) //顶级菜单
	if err != nil {
		fmt.Println(err)
	}
	MenuId, SecondId := AdminMenu.GetThisMenuId(url) //当前菜单的id,二级菜单id
	FristId := AdminMenu.GetFristMenuId(MenuId)      //当前菜单所属于的一级菜单id

	LeftMenu := AdminMenu.GetLeftMen(FristId, SecondId, url, RoleId) //左侧菜单
	Nikename := this.GetSession("name")
	if Nikename != nil {
		this.Data["Nikename"] = Nikename
	}
	this.Data["FristId"] = FristId
	this.Data["ParentMenu"] = ParentMenu
	this.Data["LeftMenu"] = LeftMenu
	this.Data["SiteName"] = "我的后台"
	this.Layout = "common/head.html"
	this.NeedLogin()
}
示例#2
0
//获取目标路径是否有权限
func (this *BaseController) GetAccessRoleAction(url string) bool {
	RoleId := 0 //初始
	Id := this.GetSession("role_id")
	if Id != nil {
		RoleId = Id.(int)
	}
	AdminMenu := models.NewAdmin_menu()
	return AdminMenu.GetAccessRoleAction(url, RoleId)
}