83 lines
3.5 KiB
C#
83 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Base
|
|
{
|
|
public class RoleRightResourceController : BaseController
|
|
{
|
|
ValidationErrors errors = new ValidationErrors();
|
|
private IBAS_ROLERIGHTRESOURCE roleRightResourceBiz;
|
|
private IBAS_ROLERIGHTRESOURCE_Q roleRightResourceBiz_Q;
|
|
public RoleRightResourceController(IBAS_ROLERIGHTRESOURCE _roleRightResourceBiz, IBAS_ROLERIGHTRESOURCE_Q _roleRightResourceBiz_Q)
|
|
{
|
|
this.roleRightResourceBiz = _roleRightResourceBiz;
|
|
this.roleRightResourceBiz_Q = _roleRightResourceBiz_Q;
|
|
}
|
|
#region 首页
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_角色权限管理)]
|
|
public ActionResult Index()
|
|
{
|
|
//ToolBar
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.角色权限管理, userRightId);
|
|
List<string> listBtn = new List<string>(toolbtn);
|
|
List<string> Buttons = new List<string>();
|
|
Buttons.Add("Other6");
|
|
Buttons.Add("Other5");
|
|
Buttons.Add("Other4");
|
|
Buttons.AddRange(listBtn);
|
|
tool.AllowButton(Buttons.ToArray());
|
|
// tool.AllowButton("Other1", "Other2", "Other3", "Other4", "Other5", "Other6");
|
|
tool.AddOtherButton("Other6", "展开权限", "icon-flag", "ExpandAll_Click", true);
|
|
tool.AddOtherButton("Other5", "折叠权限", "icon-show", "CollapseAll_Click", true);
|
|
tool.AddOtherButton("Other4", "刷新", "icon-reload", "Reload_Click", true);
|
|
tool.AddOtherButton("Other1", "保存", "icon-save", "Save_Click", true);
|
|
tool.AddOtherButton("Other2", "新增角色", "icon-add", "AddRole_Click", true);
|
|
tool.AddOtherButton("Other3", "更新权限", "icon-reload", "RightLoad_Click", true);
|
|
|
|
ViewBag.ToolBar = tool;
|
|
return View();
|
|
}
|
|
#endregion
|
|
#region 获取角色权限
|
|
/// <summary>
|
|
/// 获取角色权限
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_角色权限管理)]
|
|
public JsonResult GetBas_RoleRight(string id)
|
|
{
|
|
decimal roleId = -1;
|
|
if (id != null)
|
|
roleId = Convert.ToDecimal(id);
|
|
return Json(roleRightResourceBiz_Q.GetObjectByRoleId(roleId), JsonRequestBehavior.AllowGet);
|
|
}
|
|
#endregion
|
|
#region 保存角色权限
|
|
[AuthorizeToolBar(InitRights.CONST_角色权限管理, InitToolBar.CONST_Other1)]
|
|
public JsonResult Save(string roleId, string rightIds)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(roleId))
|
|
return JsonHandler.ManageMessage("参数不对!", false);
|
|
|
|
bool result = roleRightResourceBiz.Save(ref errors, Convert.ToDecimal(roleId), rightIds, UserId);
|
|
return JsonHandler.UpdateMessage(errors, result);
|
|
}
|
|
#endregion
|
|
|
|
#region 同步权限和ToolButton
|
|
[AuthorizeToolBar(InitRights.CONST_角色权限管理, InitToolBar.CONST_Other1)]
|
|
public ActionResult SyncRightAndToolBar()
|
|
{
|
|
bool result = new InitRightsToData().Insert(ref errors);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|