當前位置: 首頁>>代碼示例>>Golang>>正文


Golang models.Admin類代碼示例

本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.Admin的典型用法代碼示例。如果您正苦於以下問題:Golang Admin類的具體用法?Golang Admin怎麽用?Golang Admin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Admin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetPanel

//獲取快捷方式
func (c *Ajax) GetPanel(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)

		panel_info := admin_panel.GetByMid(Mid, admin_info)

		if panel_info.Id > 0 {
			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 := ""
			return c.RenderText(Html)
		}

	} else {
		Html := "<span><a href='javascript:;'>未登陸</a></span>"
		return c.RenderText(Html)
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:35,代碼來源:ajax.go

示例2: Pos

//當前位置
func (c *Ajax) Pos(menu *models.Menu) revel.Result {
	var id string = c.Params.Get("id")

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

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

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

		//獲取登陸用戶信息
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		menu_str := menu.GetPos(Id, admin_info)
		return c.RenderText(menu_str)
	} else {
		return c.RenderText("")
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:26,代碼來源:ajax.go

示例3: ScreenUnlock

//解鎖
func (c *Ajax) ScreenUnlock(admin *models.Admin) revel.Result {
	var lock_password string = c.Params.Get("lock_password")

	if lock_password == "" || len(lock_password) <= 0 {
		return c.RenderText("2")
	}

	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)

		if admin_info.Password != utils.Md5(lock_password) {
			return c.RenderText("3")
		} else {
			c.Session["lock_screen"] = "0"
			return c.RenderText("1")
		}
	} else {
		return c.RenderText("4")
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:27,代碼來源:ajax.go

示例4: Logout

//退出登陸
func (c *User) Logout(admin *models.Admin) revel.Result {

	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)

		//******************************************
		//管理員日誌
		logs := new(models.Logs)
		desc := "登陸用戶名:" + admin_info.Username + "|^|退出係統!|^|登陸ID:" + fmt.Sprintf("%d", admin_info.Id)
		logs.Save(admin_info, c.Controller, desc)
		//*****************************************

		for k := range c.Session {
			if k != "Lang" {
				delete(c.Session, k)
			}
		}
	}

	c.Flash.Success("安全退出")
	c.Flash.Out["url"] = "/User/Login/"
	return c.Redirect("/Message/")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:30,代碼來源:user.go

示例5: CheckLogin

//檢測登陸
func CheckLogin(c *revel.Controller) revel.Result {

	//登陸頁麵,CSS, JS, Ajax, 驗證碼頁麵 都不進行登陸驗證
	if c.Name == "User" && c.MethodName == "Login" || c.Name == "Ajax" || c.Name == "Static" || c.Name == "Captcha" || c.Name == "Kindeditor" {

		if LANG, ok := c.Session["Lang"]; ok {
			//設置語言
			c.RenderArgs["currentLocale"] = LANG
		} else {
			//設置默認語言
			c.RenderArgs["currentLocale"] = "zh"
		}

		return nil
	} else {

		UserID := utils.GetSession("UserID", c.Session)

		if len(UserID) > 0 {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
				return c.Redirect("/Login/")
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)
			if admin_info.Id <= 0 {
				return c.Redirect("/Login/")
			}

			//控製器
			c.RenderArgs["Controller"] = c.Name
			//動作
			c.RenderArgs["action"] = c.Action
			//模型
			c.RenderArgs["Model"] = c.MethodName

			//登陸信息
			c.RenderArgs["admin_info"] = admin_info

			//設置語言
			c.RenderArgs["currentLocale"] = admin_info.Lang
		} else {

			//控製器
			c.RenderArgs["Controller"] = c.Name
			//動作
			c.RenderArgs["action"] = c.Action
			//模型
			c.RenderArgs["Model"] = c.MethodName

			return c.Redirect("/Login/")
		}
	}

	return nil
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:59,代碼來源:init.go

示例6: SetStatus

//設置狀態
func (c Role) SetStatus(role *models.Role) revel.Result {
	var id string = c.Params.Get("id")
	var status string = c.Params.Get("status")

	data := make(map[string]string)

	if len(id) > 0 && len(status) > 0 {
		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

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

		role.Status = Status

		if role.SetStatus(Id) {

			//******************************************
			//管理員日誌
			if UserID, ok := c.Session["UserID"]; ok {
				UserID, err := strconv.ParseInt(UserID, 10, 64)
				if err != nil {
					revel.WARN.Println(err)
				}

				admin := new(models.Admin)
				admin_info := admin.GetById(UserID)

				logs := new(models.Logs)
				if Status == 1 {
					desc := "角色管理|^|設置狀態|^|狀態:啟用"
					logs.Save(admin_info, c.Controller, desc)
				} else {
					desc := "角色管理|^|設置狀態|^|狀態:鎖定"
					logs.Save(admin_info, c.Controller, desc)
				}
			}
			//*****************************************

			data["status"] = "1"
			data["message"] = "設置成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "0"
			data["message"] = "設置失敗!"
			return c.RenderJson(data)
		}
	} else {
		data["status"] = "0"
		data["message"] = "設置失敗!"
		return c.RenderJson(data)
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:58,代碼來源:role.go

示例7: Delete

//刪除公告
func (c Announce) Delete(announce *models.Announce) revel.Result {

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

	data := make(map[string]string)

	if len(id) > 0 {
		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		if announce.DelByID(Id) {

			//******************************************
			//管理員日誌
			UserID := utils.GetSession("UserID", c.Session)
			if len(UserID) > 0 {
				UserID, err := strconv.ParseInt(UserID, 10, 64)
				if err != nil {
					revel.WARN.Println(err)
				}

				admin := new(models.Admin)
				admin_info := admin.GetById(UserID)

				logs := new(models.Logs)
				desc := "刪除公告|^|ID:" + id
				logs.Save(admin_info, c.Controller, desc)
			}
			//*****************************************

			data["status"] = "1"
			data["message"] = "刪除成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "0"
			data["message"] = "刪除失敗!"
			return c.RenderJson(data)
		}
	} else {
		data["status"] = "0"
		data["message"] = "刪除失敗!"
		return c.RenderJson(data)
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:47,代碼來源:announce.go

示例8: Index

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")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:19,代碼來源:test.go

示例9: Delete

//刪除欄目
func (c Category) Delete(category *models.Category) revel.Result {
	var id string = c.Params.Get("id")

	data := make(map[string]string)

	if len(id) <= 0 {
		data["status"] = "0"
		data["message"] = "參數錯誤!"
	}

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

	if category.DelByID(Id) {

		//******************************************
		//管理員日誌
		if UserID, ok := c.Session["UserID"]; ok {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			logs := new(models.Logs)
			desc := "刪除欄目|^|ID:" + id
			logs.Save(admin_info, c.Controller, desc)
		}
		//*****************************************

		data["status"] = "1"
		data["message"] = "刪除成功!"
	} else {
		data["status"] = "0"
		data["message"] = "刪除失敗!"
	}

	return c.RenderJson(data)
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:44,代碼來源:category.go

示例10: Index

//首頁
func (c Menu) Index(menu *models.Menu) 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 := new(models.Admin)
		admin_info := admin.GetById(UserID)

		menus := menu.GetMenuHtml(admin_info)

		c.Render(title, menus)
	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Setting/Menu/Index.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:22,代碼來源:menu.go

示例11: DelPanel

//刪除快捷方式
func (c *Ajax) DelPanel(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)

		is_True := admin_panel.DelPanel(Mid, admin_info)

		data := make(map[string]string)

		if is_True {
			data["status"] = "0"
			data["message"] = "取消成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "2"
			data["message"] = "取消失敗!"
			return c.RenderJson(data)
		}
	} else {
		data := make(map[string]string)
		data["status"] = "1"
		data["message"] = "未登陸!"
		return c.RenderJson(data)
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:39,代碼來源:ajax.go

示例12: Index

func (c Category) Index(category *models.Category) revel.Result {
	title := "欄目管理--GoCMS管理係統"

	UserID := utils.GetSession("UserID", c.Session)

	if len(UserID) > 0 {

		UserID, err := strconv.ParseInt(UserID, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		admin := new(models.Admin)
		admin_info := admin.GetById(UserID)

		categorys := category.GetCateGoryHtml(admin_info)

		c.Render(title, categorys)
	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Content/Category/Index.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:23,代碼來源:category.go

示例13: Member

//成員管理
func (c Role) Member(role *models.Role) revel.Result {
	title := "成員管理--GoCMS管理係統"

	var id string = c.Params.Get("id")
	var page string = c.Params.Get("page")

	if len(id) > 0 {
		Id, err := strconv.ParseInt(id, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		where := make(map[string]string)

		admin := new(models.Admin)

		if len(page) > 0 {
			Page, err := strconv.ParseInt(page, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin_list, pages := admin.GetByAll(Id, where, Page, 10)

			c.Render(title, admin_list, pages)
		} else {
			admin_list, pages := admin.GetByAll(Id, where, 1, 10)

			c.Render(title, admin_list, pages)
		}

	} else {
		c.Render(title)
	}

	return c.RenderTemplate("Setting/Role/Member.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:38,代碼來源:role.go

示例14: DelAll

//清空日誌
func (c Logs) DelAll(logs *models.Logs) revel.Result {

	data := make(map[string]string)

	IsDel := logs.DelAll()

	if IsDel {

		//******************************************
		//管理員日誌
		if UserID, ok := c.Session["UserID"]; ok {
			UserID, err := strconv.ParseInt(UserID, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}

			admin := new(models.Admin)
			admin_info := admin.GetById(UserID)

			logs := new(models.Logs)
			desc := "清空日誌|^|日誌管理"
			logs.Save(admin_info, c.Controller, desc)
		}

		//*****************************************

		data["status"] = "1"
		data["url"] = "/Message/"
		data["message"] = "清空日誌完成!"
		return c.RenderJson(data)
	} else {
		data["status"] = "0"
		data["url"] = "/Message/"
		data["message"] = "清空日誌失敗!"
		return c.RenderJson(data)
	}
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:38,代碼來源:logs.go

示例15: Index

//首頁
func (c Admin) Index(admin *models.Admin) revel.Result {
	title := "管理員管理--GoCMS管理係統"

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

	where := make(map[string]string)

	if len(page) > 0 {
		Page, err := strconv.ParseInt(page, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		admin_list, pages := admin.GetByAll(0, where, Page, 10)

		c.Render(title, admin_list, pages)
	} else {
		admin_list, pages := admin.GetByAll(0, where, 1, 10)

		c.Render(title, admin_list, pages)
	}

	return c.RenderTemplate("Setting/Admin/Index.html")
}
開發者ID:blackmady,項目名稱:GoCMS,代碼行數:25,代碼來源:admin.go


注:本文中的github.com/blackmady/NoneCMS/app/models.Admin類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。