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.
133 lines
3.9 KiB
133 lines
3.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// RoleMenuHandler 的摘要说明
|
|
/// </summary>
|
|
public class RoleMenuHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TBL.SysRoleMenuBLL bll = new BLL.TBL.SysRoleMenuBLL();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
switch (action)
|
|
{
|
|
case "showRoleMenu":
|
|
returnstr = showRoleMenu(context);
|
|
break;
|
|
case "SaveRoleChooseMenu":
|
|
returnstr = SaveRoleChooseMenu(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
private string showRoleMenu(HttpContext context)
|
|
{
|
|
string appId = context.Request.Params["appId"];
|
|
string roleId = context.Request.Params["roleId"];
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
returnstr = "{\"code\":0,\"data\":";
|
|
DataTable dt = bll.queryDataTable(appId, roleId);
|
|
if (dt == null)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else if (dt.Rows.Count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch
|
|
{
|
|
returnstr = "{\"code\":-1,\"data\":[]";
|
|
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
//保存角色选择的菜单
|
|
private string SaveRoleChooseMenu(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
int deleteCount = 0;
|
|
try
|
|
{
|
|
string appId = context.Request.Params["appId"];
|
|
string roleId = context.Request.Params["roleId"];
|
|
string menuIdList = context.Request.Params["menuIdList"];
|
|
menuIdList = menuIdList.Trim(','); ;
|
|
|
|
// menuIdList = menuIdList.Replace(",", "','");
|
|
string[] menuIdArry = menuIdList.Split(',');
|
|
string where = "ROLE_ID='" + roleId + "'";
|
|
int count = bll.Count(where);
|
|
if (count > 0)
|
|
{
|
|
bool isDelete = bll.Delete(roleId);//清空原来的权限
|
|
if (isDelete)
|
|
{
|
|
deleteCount = count;
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < menuIdArry.Length; i++)
|
|
{
|
|
|
|
|
|
FangYar.Model.TBL.TBL_SysRoleMenuModel model = new Model.TBL.TBL_SysRoleMenuModel();
|
|
model.APP_ID = appId;
|
|
model.MENU_ID = menuIdArry[i];
|
|
model.ROLE_ID = roleId;
|
|
bool isadd = bll.Add(model);
|
|
if (!isadd)
|
|
{
|
|
msg = "设置失败";
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
msg = "设置成功!";
|
|
code = 1;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
msg = "设置失败!";
|
|
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"deleteCount\":" + deleteCount + ",\"msg\":\"" + msg + "\"}";
|
|
|
|
return returnstr;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|