109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
using Core.Web.App_Start;
|
|
using Core.Web.WebHelper;
|
|
using CRM.Core.BLL.Base;
|
|
using CRM.Core.BLL.Util;
|
|
using CRM.Core.Common.Layui;
|
|
using CRM.Core.DTO;
|
|
using CRM.Core.Model.Entity;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
|
|
namespace Core.Web.Controllers
|
|
{
|
|
public class RoleController : BaseController
|
|
{
|
|
private BAS_ROLE_BL _role = new BAS_ROLE_BL();
|
|
ValidationErrors errors = new ValidationErrors();
|
|
|
|
[HttpGet]
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_NotButton, true)]
|
|
public ActionResult Index()
|
|
{
|
|
ViewBag.rightCode = RightsConfig.CONST_角色管理;
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_NotButton, false)]
|
|
public JsonResult GetList(Laypage pager, string where)
|
|
{
|
|
var list = _role.GetList();
|
|
var data = new LayuiData<BAS_ROLE>()
|
|
{
|
|
msg = "数据加载成功!",
|
|
count = pager.count,
|
|
code = 0,
|
|
data = list
|
|
};
|
|
return Json(data, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_Add, true)]
|
|
public ActionResult Edit(decimal? id)
|
|
{
|
|
BAS_ROLE model = new BAS_ROLE();
|
|
if (id.HasValue)
|
|
{
|
|
model = _role.GetModel(id.Value);
|
|
}
|
|
return View(model);
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_Add, false)]
|
|
public JsonResult Save(BAS_ROLE model)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return Json(new retMsg { result = false, retmsg = "验证不通过!" }, JsonRequestBehavior.AllowGet);
|
|
if (model.ROLEID != 0)
|
|
{
|
|
model.UPDATEUSER = Eid;
|
|
bool ret = _role.Update(ref errors, model);
|
|
}
|
|
else
|
|
{
|
|
model.CREATEUSER = Eid;
|
|
_role.Create(ref errors, model);
|
|
}
|
|
return JsonResult(errors);
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_Delete, false)]
|
|
public JsonResult Delete(int id)
|
|
{
|
|
bool ret = _role.Delete(ref errors, id);
|
|
return JsonResult(errors);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_Other1, false)]
|
|
public JsonResult Sort(int id1, int id2)
|
|
{
|
|
bool ret = _role.Sort(ref errors, id1, id2);
|
|
return JsonResult(errors);
|
|
}
|
|
|
|
|
|
|
|
CACHE_BL _cache = new CACHE_BL();
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_Other3, true)]
|
|
public ActionResult ConfigCom(decimal id)
|
|
{
|
|
BAS_ROLE model = _role.GetModel(id);
|
|
ViewBag.companyList = _cache.GetCompanyVirtual();
|
|
ViewBag.comlist = _role.GetRoleComList(id);
|
|
return View(model);
|
|
}
|
|
[HttpPost]
|
|
[AuthorizeRedirect(RightsConfig.CONST_角色管理, ToolBarConfig.CONST_Other3, false)]
|
|
public JsonResult ConfigComSave(int id, string comcode)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return Json(new retMsg { result = false, retmsg = "验证不通过!" }, JsonRequestBehavior.AllowGet);
|
|
_role.RoleComSave(ref errors, id, comcode);
|
|
return JsonResult(errors);
|
|
}
|
|
|
|
}
|
|
} |