zhoufan 7 vuotta sitten
vanhempi
commit
03d641652e

+ 91 - 44
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/RoleFController.cs

@@ -18,60 +18,107 @@ namespace CallCenterApi.Interface.Controllers
18 18
         private BLL.T_Sys_ModuleInfo moduleInfoBLL = new BLL.T_Sys_ModuleInfo();
19 19
         private BLL.T_Sys_ModuleFunctions moduleFunctionsBLL = new BLL.T_Sys_ModuleFunctions();
20 20
         private BLL.T_Sys_RoleFunction roleFunctionBLL = new BLL.T_Sys_RoleFunction();
21
+        ////保存角色权限
22
+        //public ActionResult SaveRoleFunction(string[] functionIds, int roleId = 0)
23
+        //{
24
+
25
+        //    DataTable dt = new DataTable();
26
+        //    if (Request.IsAuthenticated)
27
+        //    {
28
+
29
+        //            if (functionIds == null)
30
+        //                return Error("参数错误");
31
+        //            Model.T_Sys_RoleFunction RoleModel = new Model.T_Sys_RoleFunction();
32
+        //            //查询选中页面中的权限
33
+        //            var idStr = string.Join(",", functionIds);
34
+        //            if (roleId == 0)
35
+        //            {
36
+        //                //管理员
37
+        //                var model = roleInfoBll.GetModel(17);
38
+        //                if (model == null)
39
+        //                    return Error("管理员用户不存在");
40
+        //                roleId = model.F_RoleId;
41
+        //                new BLL.T_Sys_RoleFunction().Delete1(roleId);
42
+        //                var childFuncIdList = moduleFunctionsBLL.DataTableToList(moduleFunctionsBLL.GetList(" F_ParentId in (" + idStr + ") ").Tables[0]).Select(x => x.F_FunctionId).ToList();
43
+        //                childFuncIdList.AddRange(functionIds.ToList().Select(x => Convert.ToInt32(x)).ToList());
44
+        //                var query = childFuncIdList.Distinct();
45
+        //                foreach (var funcId in query)
46
+        //                {
47
+        //                    RoleModel.F_RoleId = roleId;
48
+        //                    RoleModel.F_FunctionId = funcId;
49
+        //                    if (!roleFunctionBll.Add(RoleModel))
50
+        //                        return Error("权限设置失败");
51
+        //                    else
52
+        //                        return Success("权限设置成功");
53
+        //                }
54
+        //            }
55
+        //            else
56
+        //            {
57
+        //                new BLL.T_Sys_RoleFunction().Delete1(roleId);
58
+        //                var childFuncIdList = moduleFunctionsBLL.DataTableToList(moduleFunctionsBLL.GetList(" F_ParentId in (" + idStr + ") ").Tables[0]).Select(x => x.F_FunctionId).ToList();
59
+        //                childFuncIdList.AddRange(functionIds.ToList().Select(x => Convert.ToInt32(x)).ToList());
60
+        //                var query = childFuncIdList.Distinct();
61
+        //                foreach (var funcId in query)
62
+        //                {
63
+        //                    RoleModel.F_RoleId = roleId;
64
+        //                    RoleModel.F_FunctionId = funcId;
65
+        //                    if (!roleFunctionBll.Add(RoleModel))
66
+        //                        return Error("权限设置失败");
67
+        //                    else
68
+        //                        return Success("权限设置成功");
69
+        //                }
70
+        //            }
71
+
72
+        //            dt.Clear();
73
+        //            dt.Dispose();
74
+
75
+        //    }
76
+        //    return NoToken("未知错误,请重新登录");
77
+        //}
78
+
21 79
         //保存角色权限
22 80
         public ActionResult SaveRoleFunction(string[] functionIds, int roleId = 0)
23 81
         {
24
-            
82
+
25 83
             DataTable dt = new DataTable();
26 84
             if (Request.IsAuthenticated)
27 85
             {
28
-              
29
-                    if (functionIds == null)
30
-                        return Error("参数错误");
31
-                    Model.T_Sys_RoleFunction RoleModel = new Model.T_Sys_RoleFunction();
32
-                    //查询选中页面中的权限
33
-                    var idStr = string.Join(",", functionIds);
34
-                    if (roleId == 0)
86
+
87
+                if (functionIds == null)
88
+                    return Error("参数错误");
89
+                Model.T_Sys_RoleFunction RoleModel = new Model.T_Sys_RoleFunction();
90
+
91
+                var query = functionIds.Distinct();
92
+                if (roleId == 0)
93
+                {
94
+                    //管理员
95
+                    var model = roleInfoBll.GetModel(17);
96
+                    if (model == null)
97
+                        return Error("管理员用户不存在");
98
+                    roleId = model.F_RoleId;
99
+
100
+                    foreach (var funcId in query)
35 101
                     {
36
-                        //管理员
37
-                        var model = roleInfoBll.GetModel(17);
38
-                        if (model == null)
39
-                            return Error("管理员用户不存在");
40
-                        roleId = model.F_RoleId;
41
-                        new BLL.T_Sys_RoleFunction().Delete1(roleId);
42
-                        var childFuncIdList = moduleFunctionsBLL.DataTableToList(moduleFunctionsBLL.GetList(" F_ParentId in (" + idStr + ") ").Tables[0]).Select(x => x.F_FunctionId).ToList();
43
-                        childFuncIdList.AddRange(functionIds.ToList().Select(x => Convert.ToInt32(x)).ToList());
44
-                        var query = childFuncIdList.Distinct();
45
-                        foreach (var funcId in query)
46
-                        {
47
-                            RoleModel.F_RoleId = roleId;
48
-                            RoleModel.F_FunctionId = funcId;
49
-                            if (!roleFunctionBll.Add(RoleModel))
50
-                                return Error("权限设置失败");
51
-                            else
52
-                                return Success("权限设置成功");
53
-                        }
102
+                        RoleModel.F_RoleId = roleId;
103
+                        RoleModel.F_FunctionId = Int32.Parse( funcId);
104
+                        roleFunctionBll.Add(RoleModel);
54 105
                     }
55
-                    else
106
+                }
107
+                else
108
+                {
109
+                    new BLL.T_Sys_RoleFunction().Delete1(roleId);
110
+
111
+                    foreach (var funcId in query)
56 112
                     {
57
-                        new BLL.T_Sys_RoleFunction().Delete1(roleId);
58
-                        var childFuncIdList = moduleFunctionsBLL.DataTableToList(moduleFunctionsBLL.GetList(" F_ParentId in (" + idStr + ") ").Tables[0]).Select(x => x.F_FunctionId).ToList();
59
-                        childFuncIdList.AddRange(functionIds.ToList().Select(x => Convert.ToInt32(x)).ToList());
60
-                        var query = childFuncIdList.Distinct();
61
-                        foreach (var funcId in query)
62
-                        {
63
-                            RoleModel.F_RoleId = roleId;
64
-                            RoleModel.F_FunctionId = funcId;
65
-                            if (!roleFunctionBll.Add(RoleModel))
66
-                                return Error("权限设置失败");
67
-                            else
68
-                                return Success("权限设置成功");
69
-                        }
113
+                        RoleModel.F_RoleId = roleId;
114
+                        RoleModel.F_FunctionId = Int32.Parse(funcId);
115
+                        roleFunctionBll.Add(RoleModel);
70 116
                     }
71
-           
72
-                    dt.Clear();
73
-                    dt.Dispose();
74
-                
117
+                }
118
+
119
+                dt.Clear();
120
+                dt.Dispose();
121
+                return Success("权限设置成功");
75 122
             }
76 123
             return NoToken("未知错误,请重新登录");
77 124
         }