<%@ WebHandler Language="C#" Class="SysRoleMenuHandler" %>
|
using Common;
|
using Dao;
|
using Model;
|
// using Newtonsoft.Json;
|
//using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using Newtonsoft.Json;
|
|
public class SysRoleMenuHandler : PageHandler<SysUser>
|
{
|
private SysRoleMenuDao _Dao = new SysRoleMenuDao();
|
|
private List<SysUser> _SysUserList;
|
|
public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context)
|
{
|
string @string = context.GetString("action");
|
switch (@string)
|
{
|
//case "update":
|
// return this.Update(context); //修改
|
case "loadRoleMenuList":
|
return this.LoadRoleMenuList(context); //获取角色权限列表
|
case "updatePermission":
|
return this.UpdatePermission(context); //保存角色权限
|
|
default:
|
throw new Exception("Invalid Action=" + @string);
|
}
|
}
|
|
private JsonPageResult LoadRoleMenuList(PageContext<SysUser> context)
|
{
|
//context.CheckRight("104", FailedOperation.PromptOnly);
|
string roleId = context.GetString("roleId");
|
if(string.IsNullOrEmpty(roleId))
|
throw new ArgumentException("用户角色不能为空,请输入!");
|
|
return new JsonPageResult(true, (object) this._Dao.LoadRoleMenuList(roleId).Keys);
|
}
|
|
private JsonPageResult UpdatePermission(PageContext<SysUser> context)
|
{
|
//context.CheckRight("1042", FailedOperation.PromptOnly);
|
string @string = context.GetString("menuIDArray");
|
string roleId = context.GetString("roleId");
|
string[] menuIDArray = JsonConvert.DeserializeObject<string[]>(@string);
|
if (menuIDArray == null)
|
throw new ArgumentException("菜单数据异常!");
|
if (string.IsNullOrEmpty(roleId) )
|
throw new ArgumentException("用户角色参数异常!");
|
|
this._Dao.UpdatePermission(roleId, menuIDArray);
|
return new JsonPageResult(true, (object) "保存权限成功!");
|
}
|
|
}
|