예제 #1
0
파일: ajax.go 프로젝트: blackmady/GoCMS
//添加快捷方式
func (c *Ajax) AddPanel(admin_panel *models.Admin_Panel) revel.Result {

	if UserID, ok := c.Session["UserID"]; ok {

		var mid string = c.Params.Get("mid")

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		Mid, err := strconv.ParseInt(mid, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		//获取登陆用户信息
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		//是否已添加快捷方式
		isAdd := admin_panel.IsAdd(Mid, admin_info)

		if isAdd {
			panel_info := admin_panel.GetByMid(Mid, admin_info)

			Html := "<span><a target='right' href='/" + panel_info.Url + "/'>" + panel_info.Name + "</a><a class='panel-delete' href='javascript:delete_panel();'></a></span>"
			return c.RenderText(Html)
		} else {
			isFinish := admin_panel.AddPanel(Mid, admin_info)

			if isFinish {
				panel_info := admin_panel.GetByMid(Mid, admin_info)

				Html := "<span><a target='right' href='/" + panel_info.Url + "/'>" + panel_info.Name + "</a><a class='panel-delete' href='javascript:delete_panel();'></a></span>"
				return c.RenderText(Html)
			} else {
				Html := "<span><a href='javascript:;'>请重新添加</a></span>"
				return c.RenderText(Html)
			}
		}

	} else {
		Html := "<span><a href='javascript:;'>未登陆</a></span>"
		return c.RenderText(Html)
	}
}
예제 #2
0
파일: test.go 프로젝트: blackmady/GoCMS
func (c Test) Index(admin *models.Admin) revel.Result {
	title := "测试--GoCMS管理系统"

	if UserID, ok := c.Session["UserID"]; ok {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_info := admin.GetById(UserID)

		admin_panel := new(models.Admin_Panel)
		admin_panel.IsAdd(18, admin_info)
	}

	c.Render(title)
	return c.RenderTemplate("Public/Test.html")
}