当前位置: 首页>>代码示例>>Golang>>正文


Golang Role.Desc方法代码示例

本文整理汇总了Golang中admin/app/models.Role.Desc方法的典型用法代码示例。如果您正苦于以下问题:Golang Role.Desc方法的具体用法?Golang Role.Desc怎么用?Golang Role.Desc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在admin/app/models.Role的用法示例。


在下文中一共展示了Role.Desc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Add

//添加角色
func (c Role) Add(role *models.Role) revel.Result {

	if c.Request.Method == "GET" {
		title := "添加角色--GoCMS管理系统"

		menu := new(models.Menu)
		tree := menu.GetMenuTree("")

		c.Render(title, tree)
		return c.RenderTemplate("Setting/Role/Add.html")
	} else {

		var rolename string = c.Params.Get("rolename")
		if len(rolename) > 0 {
			role.Rolename = rolename
		} else {
			c.Flash.Error("请输入角色名称!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var desc string = c.Params.Get("desc")
		if len(desc) > 0 {
			role.Desc = desc
		} else {
			c.Flash.Error("请输入角色描述!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var data string = c.Params.Get("data")
		if len(data) > 0 {
			role.Data = data
		} else {
			c.Flash.Error("请选择所属权限!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var status string = c.Params.Get("status")
		if len(status) > 0 {
			Status, err := strconv.ParseInt(status, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			role.Status = Status
		} else {
			c.Flash.Error("请选择是否启用!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		if role.Save() {
			c.Flash.Success("添加角色成功")
			c.Flash.Out["url"] = "/Role/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加角色失败")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}
	}
}
开发者ID:qmdx,项目名称:GoCMS,代码行数:64,代码来源:role.go

示例2: Add

//添加角色
func (c Role) Add(role *models.Role) revel.Result {

	if c.Request.Method == "GET" {
		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)

			menu := new(models.Menu)
			tree := menu.GetMenuTree("", admin_info)

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

		return c.RenderTemplate("Setting/Role/Add.html")
	} else {

		var rolename string = c.Params.Get("rolename")
		if len(rolename) > 0 {
			role.Rolename = rolename
		} else {
			c.Flash.Error("请输入角色名称!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var desc string = c.Params.Get("desc")
		if len(desc) > 0 {
			role.Desc = desc
		} else {
			c.Flash.Error("请输入角色描述!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var data string = c.Params.Get("data")
		if len(data) > 0 {
			role.Data = data
		} else {
			c.Flash.Error("请选择所属权限!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		var status string = c.Params.Get("status")
		if len(status) > 0 {
			Status, err := strconv.ParseInt(status, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			role.Status = Status
		} else {
			c.Flash.Error("请选择是否启用!")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}

		if role.Save() {

			//******************************************
			//管理员日志
			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 := "添加角色:" + rolename + "|^|角色管理"
				logs.Save(admin_info, c.Controller, desc)
			}
			//*****************************************

			c.Flash.Success("添加角色成功")
			c.Flash.Out["url"] = "/Role/"
			return c.Redirect("/Message/")
		} else {
			c.Flash.Error("添加角色失败")
			c.Flash.Out["url"] = "/Role/Add/"
			return c.Redirect("/Message/")
		}
	}
}
开发者ID:JREAMLU,项目名称:GoCMS,代码行数:96,代码来源:role.go

示例3: Edit

//编辑角色
func (c Role) Edit(role *models.Role) revel.Result {
	if c.Request.Method == "GET" {
		title := "编辑角色--GoCMS管理系统"

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

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

			role_info := role.GetById(Id)

			menu := new(models.Menu)
			tree := menu.GetMenuTree(role_info.Data)

			c.Render(title, role_info, tree, Id)
		} else {

			menu := new(models.Menu)
			tree := menu.GetMenuTree("")

			c.Render(title, tree)
		}

		return c.RenderTemplate("Setting/Role/Edit.html")
	} else {
		var id string = c.Params.Get("id")

		if len(id) > 0 {

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

			var rolename string = c.Params.Get("rolename")
			if len(rolename) > 0 {
				role.Rolename = rolename
			} else {
				c.Flash.Error("请输入角色名称!")
				c.Flash.Out["url"] = "/Role/Edit/" + id + "/"
				return c.Redirect("/Message/")
			}

			var desc string = c.Params.Get("desc")
			if len(desc) > 0 {
				role.Desc = desc
			} else {
				c.Flash.Error("请输入角色描述!")
				c.Flash.Out["url"] = "/Role/Edit/" + id + "/"
				return c.Redirect("/Message/")
			}

			var data string = c.Params.Get("data")
			if len(data) > 0 {
				role.Data = data
			} else {
				c.Flash.Error("请选择所属权限!")
				c.Flash.Out["url"] = "/Role/Edit/" + id + "/"
				return c.Redirect("/Message/")
			}

			var status string = c.Params.Get("status")
			if len(status) > 0 {
				Status, err := strconv.ParseInt(status, 10, 64)
				if err != nil {
					revel.WARN.Println(err)
				}
				role.Status = Status
			} else {
				c.Flash.Error("请选择是否启用!")
				c.Flash.Out["url"] = "/Role/Edit/" + id + "/"
				return c.Redirect("/Message/")
			}

			if role.Edit(Id) {
				c.Flash.Success("编辑角色成功")
				c.Flash.Out["url"] = "/Role/"
				return c.Redirect("/Message/")
			} else {
				c.Flash.Error("编辑角色失败")
				c.Flash.Out["url"] = "/Role/Edit/" + id + "/"
				return c.Redirect("/Message/")
			}
		} else {
			c.Flash.Error("编辑角色失败")
			c.Flash.Out["url"] = "/Role/Edit/" + id + "/"
			return c.Redirect("/Message/")
		}
	}
}
开发者ID:qmdx,项目名称:GoCMS,代码行数:94,代码来源:role.go


注:本文中的admin/app/models.Role.Desc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。