QSMP.Web/Areas/System/Controllers/RoleAuthorizeController.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QSMP.Web.Controllers;
using QSMP.Web.Filters;
using QSMP.Logic.Sys;
using QSMP.Utility.ResponseModels;
using QSMP.Utility.Format;
using QSMP.Utility.Extension;
namespace QSMP.Web.Areas.System.Controllers
{
[LoginChecked]
public class RoleAuthorizeController : BaseController
{
private SysRoleAuthorizeLogic roleAuthorizeLogic;
private SysPermissionLogic permissionLogic;
public RoleAuthorizeController()
{
roleAuthorizeLogic = new SysRoleAuthorizeLogic();
permissionLogic =new SysPermissionLogic();
}
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string roleId)
{
var listPerIds = roleAuthorizeLogic.GetList(roleId).Select(c => c.ModuleId).ToList();
var listAllPers = permissionLogic.GetList();
List<ZTreeNode> result = new List<ZTreeNode>();
foreach (var item in listAllPers)
{
ZTreeNode model = new ZTreeNode();
model.@checked = listPerIds.Contains(item.Id) ? model.@checked = true : model.@checked = false;
model.id = item.Id;
model.pId = item.ParentId;
model.name = item.Name;
model.open = true;
result.Add(model);
}
return Content(result.ToJson());
}
[HttpPost]
public ActionResult Form(string roleId, string perIds)
{
roleAuthorizeLogic.Authorize(roleId, perIds.ToStrArray());
return Success("授权成功");
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
