using LeaRun.Application.Busines.BaseManage; using LeaRun.Application.Cache; using LeaRun.Application.Code; using LeaRun.Application.Entity.BaseManage; using LeaRun.Util; using LeaRun.Util.WebControl; using System.Collections.Generic; using System.Threading; using System.Web.Mvc; namespace LeaRun.Application.Web.Areas.BaseManage.Controllers { /// /// 版 本 /// Copyright (c) 2013-2016 上海力软信息技术有限公司 /// 创建人:佘赐雄 /// 日 期:2015.11.4 14:31 /// 描 述:角色管理 /// public class RoleController : MvcControllerBase { private RoleBLL roleBLL = new RoleBLL(); private RoleCache roleCache = new RoleCache(); #region 视图功能 /// /// 角色管理 /// /// [HttpGet] [HandlerAuthorize(PermissionMode.Enforce)] public ActionResult Index() { return View(); } /// /// 角色表单 /// /// [HttpGet] [HandlerAuthorize(PermissionMode.Enforce)] public ActionResult Form() { return View(); } #endregion #region 获取数据 /// /// 角色列表 /// /// 公司Id /// 返回列表Json [HttpGet] public ActionResult GetListJson(string organizeId) { var data = roleCache.GetList(organizeId); return Content(data.ToJson()); } /// /// 角色列表 /// /// 分页参数 /// 查询参数 /// 返回分页列表Json [HttpGet] public ActionResult GetPageListJson(Pagination pagination, string queryJson) { var watch = CommonHelper.TimerStart(); var data = roleBLL.GetPageList(pagination, queryJson); var JsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return Content(JsonData.ToJson()); } /// /// 角色实体 /// /// 主键值 /// 返回对象Json [HttpGet] public ActionResult GetFormJson(string keyValue) { var data = roleBLL.GetEntity(keyValue); return Content(data.ToJson("yyyy-MM-dd HH:mm")); } #endregion #region 验证数据 /// /// 角色编号不能重复 /// /// 编号 /// 主键 /// [HttpGet] public ActionResult ExistEnCode(string EnCode, string keyValue) { bool IsOk = roleBLL.ExistEnCode(EnCode, keyValue); return Content(IsOk.ToString()); } /// /// 角色名称不能重复 /// /// 名称 /// 主键 /// [HttpGet] public ActionResult ExistFullName(string FullName, string keyValue) { bool IsOk = roleBLL.ExistFullName(FullName, keyValue); return Content(IsOk.ToString()); } #endregion #region 提交数据 /// /// 删除角色 /// /// 主键值 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] [HandlerAuthorize(PermissionMode.Enforce)] public ActionResult RemoveForm(string keyValue) { roleBLL.RemoveForm(keyValue); return Success("删除成功。"); } /// /// 保存角色表单(新增、修改) /// /// 主键值 /// 角色实体 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, RoleEntity roleEntity) { roleBLL.SaveForm(keyValue, roleEntity); return Success("操作成功。"); } #endregion } }