wzp
2023-03-02 374ce4ffd0c459bb4067e8d5765f972668aff9b1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<%@ 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) "保存权限成功!");
    }
 
}