示例#1
0
文件: c_role.go 项目: yubo/falcon
// @Title Get
// @Description get role by id
// @Param	id		path 	int	true		"The key for staticblock"
// @Success {code:200, data:object} models.Role
// @Failure {code:int, msg:string}
// @router /:id [get]
func (c *RoleController) GetRole() {
	id, err := c.GetInt(":id")
	if err != nil {
		c.SendMsg(403, err.Error())
	} else {
		role, err := models.GetRole(id)
		if err != nil {
			c.SendMsg(403, err.Error())
		} else {
			c.SendObj(200, role)
		}
	}
}
示例#2
0
文件: c_role.go 项目: yubo/falcon
func (c *MainController) EditRole() {
	var role *models.Role

	id, err := c.GetInt(":id")
	if err != nil {
		goto out
	}

	role, err = models.GetRole(id)
	if err != nil {
		goto out
	}

	c.PrepareEnv()
	c.Data["Role"] = role
	c.Data["H1"] = "edit role"
	c.Data["Method"] = "put"
	c.TplName = "role/edit.tpl"
	return
out:
	c.SendMsg(400, err.Error())
}