// 给用户分配角色
func (this *UserController) AllocationRole() {
	Id, _ := this.GetInt64("Id")
	fmt.Printf("给用户分配角色 Id is %d\n", Id)
	err, user := m.IsExitUser(Id)
	roleByUser := m.GetRoleByUserId(Id)

	roles, _ := m.GetAllRole()
	if err != nil {
		this.Rsp(false, "不存在这个用户")
	} else {
		this.Data["User"] = &user
		roleList := make([]m.Role, len(roles))
		for k, role := range roles {
			roleList[k].Id = role["Id"].(int64)
			roleList[k].Name = role["Name"].(string)
			roleList[k].Key = role["Key"].(string)
			roleList[k].Description = role["Description"].(string)
			roleList[k].Status = role["Status"].(int64)
			if roleList[k].Status == 2 {
				roleList[k].Isnormal = true
			} else {
				roleList[k].Isnormal = false
			}

		}
		this.Data["RoleList"] = &roleList
		this.Data["UserRole"] = roleByUser.Name
		this.TplNames = "user/userRole.html"
	}
}
// 角色列表
func (this *RoleController) List() {
	if this.IsAjax() {
		sEcho := this.GetString("sEcho")
		// 表格显示在全部数据的开始位置
		iDiaplayStart := this.GetString("iDisplayStart")
		// 显示的条数
		iDisplayLength := this.GetString("iDisplayLength")
		iStart, _ := strconv.Atoi(iDiaplayStart)
		iLength, _ := strconv.Atoi(iDisplayLength)
		page := iStart / iLength

		_, count := m.GetAllRole()
		roles, _ := m.GetRoleList(int64(page+1), int64(iLength), "Id")

		for _, role := range roles {
			switch role["Status"] {
			case int64(2):
				role["Statusname"] = "正常"
			case int64(1):
				role["Statusname"] = "禁止"
			default:
				role["Statusname"] = "不正常"
			}

		}

		data := make(map[string]interface{})
		data["aaData"] = &roles
		data["iTotalDisplayRecords"] = count
		data["iTotalRecords"] = iLength
		data["sEcho"] = sEcho
		this.Data["json"] = &data
		this.ServeJson()
	} else {
		this.Data["ActionUrl"] = "localhost:8080"
		this.TplNames = "role/index.html"
	}

}