You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
219 lines
8.0 KiB
219 lines
8.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// SysRolePermHandler 的摘要说明
|
|
/// </summary>
|
|
public class SysRolePermHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TBL.SysRolepermBLL bll = new BLL.TBL.SysRolepermBLL();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "角色权限操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = GetModelList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddModel(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditModel(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelModel(context);
|
|
break;
|
|
case "RolePermList":
|
|
returnstr = RolePermList(context);
|
|
break;
|
|
case "RolePermAddEdit":
|
|
returnstr = RolePermAddEdit(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GetModelList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string keywords = context.Request.Params["keywords"];
|
|
string limit = context.Request.Params["limit"];
|
|
string page = context.Request.Params["page"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = null;
|
|
if (!string.IsNullOrEmpty(keywords))
|
|
{
|
|
where = "APP_ID like '" + keywords + "' or ROLE_ID like '" + keywords + "' ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.Count(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.TBL.TBL_SYS_ROLEPERM_Model> list = bll.QueryList(pageIndex, pageSize, where, null);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "角色权限操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "角色权限操作请求", "查询");
|
|
return returnstr;
|
|
|
|
}
|
|
//
|
|
private string DelModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string UIDList = context.Request.Params["UIDList"];
|
|
UIDList = UIDList.Replace(",", "','");
|
|
if (bll.Delete(UIDList))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "删除失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "角色权限操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "角色权限操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
private string AddModel(HttpContext context)
|
|
{
|
|
return null;
|
|
}
|
|
private string EditModel(HttpContext context)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
private string RolePermList(HttpContext context)
|
|
{
|
|
string appid = context.Request.Params["appId"];
|
|
string roleId = context.Request.Params["roleId"];
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
returnstr = "{\"code\":0,\"data\":";
|
|
|
|
DataTable dt = bll.RolePermDataset(appid, roleId);
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "角色权限操作请求", "查询异常:" + e);
|
|
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "角色权限操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
//保存角色权限
|
|
private string RolePermAddEdit(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
|
|
try
|
|
{
|
|
string appid = context.Request.Params["appId"];
|
|
string roleId = context.Request.Params["roleId"];
|
|
string permIDList = context.Request.Params["permIDList"];
|
|
// permIDList = permIDList.Substring(0, permIDList.Length - 1);
|
|
permIDList = permIDList.Trim(',');
|
|
//permIDList = permIDList.Replace(",", "','");
|
|
string[] permIDArry = permIDList.Split(',');
|
|
bool isDelete = bll.Delete(roleId);//清空原来的权限
|
|
if (isDelete)
|
|
{
|
|
for (int i = 0; i < permIDArry.Length; i++)
|
|
{
|
|
FangYar.Model.TBL.TBL_SYS_ROLEPERM_Model model = new Model.TBL.TBL_SYS_ROLEPERM_Model();
|
|
model.APP_ID = appid;
|
|
model.ROLE_ID = roleId;
|
|
model.PERM_ID = permIDArry[i];
|
|
bll.Add(model);
|
|
}
|
|
msg = "设置成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "设置失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "权限设置失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "角色权限操作请求", "保存角色权限异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "角色权限操作请求", "保存角色权限");
|
|
return returnstr;
|
|
|
|
|
|
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|