Пример #1
0
// 菜单列表
func (this *Menus) List() {
	data := make(map[string]interface{})
	items := []menu.AdminMenu{}

	page, rows := this.GetPageSize()

	adminMenus := menu.GetAdminMenuHelper().Menus
	pMenu := menu.AdminMenu{}

	this.subMenu(pMenu, adminMenus, &items)

	records := len(items)
	offset := (page - 1) * rows

	if offset < records {
		if offset+rows > records {
			data["menus"] = items[offset : records-offset]
		} else {
			data["menus"] = items[offset:rows]
		}
	} else {
		data["menus"] = nil
	}

	data["pagination"] = models.Pageinate{
		Records: records,
		Page:    page,
		Rows:    rows,
	}

	this.JsonOut(data, "0")
}
Пример #2
0
// 权限管理
func (this *Admins) Privilege() {
	AdminMenuHelper := menu.GetAdminMenuHelper()

	data := make(map[string]interface{})

	for _, menu := range AdminMenuHelper.Menus {
		data[menu.Label] = menu
	}

	this.JsonOut(data, "0")
}
Пример #3
0
/**
 *
 * 渲染视图
 *
 */
func (this *base) display(args ...string) {
	//
	ctrlName, actionName := this.GetControllerAndAction()

	if nil != this.CurrentAdmin {
		AdminMenuHelper := menu.GetAdminMenuHelper()
		this.Data["AdminMenus"] = AdminMenuHelper.Render(ctrlName, actionName, this.CurrentAdmin, this.Ctx.Request.RequestURI)
		this.Data["CurrentAdmin"] = this.CurrentAdmin
	}
	// 参数个数
	num := len(args)

	// 模板路径
	tplName := this.moudleName + "/"

	if num >= 1 && "" != args[0] {
		tplName += args[0]
	} else {
		tplName += strings.ToLower(ctrlName+"/"+actionName) + ".tpl"
	}

	// Layout路径
	layout := this.moudleName + "/"

	if num >= 2 && "" != args[1] {
		layout += args[1]
	} else {
		layout += "main.tpl"
	}

	this.Layout = layout
	this.TplNames = tplName
	// 应用信息
	this.Data["AppName"] = beego.AppConfig.String("AppName")
	this.Data["AppAuthor"] = beego.AppConfig.String("AppAuthor")
	// XSRF
	this.Data["XsrfToken"] = this.XsrfToken()
	this.Data["xsrfInput"] = template.HTML(this.XsrfFormHtml())

}
Пример #4
0
func (this *Menus) Info() {
	id, _ := this.GetInt(":id")

	items := []menu.AdminMenu{}

	data := make(map[string]interface{})
	data["menu"] = nil

	adminMenus := menu.GetAdminMenuHelper().Menus
	pMenu := menu.AdminMenu{}

	this.subMenu(pMenu, adminMenus, &items)

	for _, item := range items {
		if item.Id == id {
			data["menu"] = item
			break
		}
	}

	this.JsonOut(data, "0")
}