ModuleController.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using Lottomat.Application.Busines.AuthorizeManage;
  2. using Lottomat.Application.Code;
  3. using Lottomat.Application.Entity.AuthorizeManage;
  4. using Lottomat.Util;
  5. using Lottomat.Util.WebControl;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Web.Mvc;
  9. using Lottomat.Util.Extension;
  10. namespace Lottomat.Application.Admin.Areas.AuthorizeManage.Controllers
  11. {
  12. /// <summary>
  13. /// 版 本 1.0
  14. /// Copyright (c) 2016-2017
  15. /// 创建人:赵轶
  16. /// 日 期:2015.10.27 09:16
  17. /// 描 述:系统功能
  18. /// </summary>
  19. public class ModuleController : MvcControllerBase
  20. {
  21. private ModuleBLL moduleBLL = new ModuleBLL();
  22. #region 视图功能
  23. /// <summary>
  24. /// 功能管理
  25. /// </summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. [HandlerAuthorize(PermissionMode.Enforce)]
  29. public ActionResult Index()
  30. {
  31. return View();
  32. }
  33. /// <summary>
  34. /// 功能表单
  35. /// </summary>
  36. /// <returns></returns>
  37. [HttpGet]
  38. [HandlerAuthorize(PermissionMode.Enforce)]
  39. public ActionResult Form()
  40. {
  41. ViewBag.ModuleId = Request["keyValue"];
  42. return View();
  43. }
  44. /// <summary>
  45. /// 功能图标
  46. /// </summary>
  47. /// <returns></returns>
  48. [HttpGet]
  49. public ActionResult Icon()
  50. {
  51. return View();
  52. }
  53. #endregion
  54. #region 获取数据
  55. /// <summary>
  56. /// 功能列表
  57. /// </summary>
  58. /// <param name="keyword">关键字</param>
  59. /// <returns>返回树形Json</returns>
  60. [HttpGet]
  61. public ActionResult GetTreeJson(string keyword)
  62. {
  63. var data = moduleBLL.GetList();
  64. if (!string.IsNullOrEmpty(keyword))
  65. {
  66. data = data.TreeWhere(t => t.FullName.Contains(keyword), "");
  67. }
  68. var treeList = new List<TreeEntity>();
  69. foreach (ModuleEntity item in data)
  70. {
  71. bool hasChildren = data.Count(t => t.ParentId == item.ModuleId) != 0;
  72. TreeEntity tree = new TreeEntity
  73. {
  74. id = item.ModuleId,
  75. text = item.FullName,
  76. value = item.ModuleId,
  77. isexpand = true,
  78. complete = true,
  79. hasChildren = hasChildren,
  80. parentId = item.ParentId,
  81. img = item.Icon
  82. };
  83. treeList.Add(tree);
  84. }
  85. return Content(treeList.TreeToJson());
  86. }
  87. /// <summary>
  88. /// 获取目录级功能列表
  89. /// </summary>
  90. /// <param name="keyword">关键字</param>
  91. /// <returns>返回树形Json</returns>
  92. [HttpGet]
  93. public ActionResult GetCatalogTreeJson(string keyword)
  94. {
  95. var data = moduleBLL.GetList();
  96. data = data.FindAll(t => t.IsMenu != 1);
  97. if (!string.IsNullOrEmpty(keyword))
  98. {
  99. data = data.TreeWhere(t => t.FullName.Contains(keyword), "");
  100. }
  101. var treeList = new List<TreeEntity>();
  102. foreach (ModuleEntity item in data)
  103. {
  104. bool hasChildren = data.Count(t => t.ParentId == item.ModuleId) != 0;
  105. TreeEntity tree = new TreeEntity
  106. {
  107. id = item.ModuleId,
  108. text = item.FullName,
  109. value = item.ModuleId,
  110. isexpand = true,
  111. complete = true,
  112. hasChildren = hasChildren,
  113. parentId = item.ParentId,
  114. img = item.Icon
  115. };
  116. treeList.Add(tree);
  117. }
  118. return Content(treeList.TreeToJson());
  119. }
  120. /// <summary>
  121. /// 功能列表
  122. /// </summary>
  123. /// <param name="parentid">节点Id</param>
  124. /// <param name="condition">查询条件</param>
  125. /// <param name="keyword">关键字</param>
  126. /// <returns>返回列表Json</returns>
  127. [HttpGet]
  128. public ActionResult GetListJson(string parentid, string condition, string keyword)
  129. {
  130. var data = moduleBLL.GetList(parentid);
  131. if (!string.IsNullOrEmpty(condition) && !string.IsNullOrEmpty(keyword))
  132. {
  133. #region 多条件查询
  134. switch (condition)
  135. {
  136. case "EnCode": //编号
  137. data = data.FindAll(t => t.EnCode.Contains(keyword));
  138. break;
  139. case "FullName": //名称
  140. data = data.FindAll(t => t.FullName.Contains(keyword));
  141. break;
  142. case "UrlAddress": //地址
  143. data = data.FindAll(t => t.UrlAddress.Contains(keyword));
  144. break;
  145. default:
  146. break;
  147. }
  148. #endregion
  149. }
  150. return Content(data.ToJson());
  151. }
  152. /// <summary>
  153. /// 功能实体 返回对象Json
  154. /// </summary>
  155. /// <param name="keyValue">主键值</param>
  156. /// <returns></returns>
  157. [HttpGet]
  158. public ActionResult GetFormJson(string keyValue)
  159. {
  160. var data = moduleBLL.GetEntity(keyValue);
  161. return Content(data.ToJson());
  162. }
  163. #endregion
  164. #region 验证数据
  165. /// <summary>
  166. /// 功能编号不能重复
  167. /// </summary>
  168. /// <param name="EnCode">编号</param>
  169. /// <param name="keyValue">主键</param>
  170. /// <returns></returns>
  171. [HttpGet]
  172. public ActionResult ExistEnCode(string EnCode, string keyValue)
  173. {
  174. bool IsOk = moduleBLL.ExistEnCode(EnCode, keyValue);
  175. return Content(IsOk.ToString());
  176. }
  177. /// <summary>
  178. /// 功能名称不能重复
  179. /// </summary>
  180. /// <param name="FullName">名称</param>
  181. /// <param name="keyValue">主键</param>
  182. /// <returns></returns>
  183. [HttpGet]
  184. public ActionResult ExistFullName(string FullName, string keyValue)
  185. {
  186. bool IsOk = moduleBLL.ExistFullName(FullName, keyValue);
  187. return Content(IsOk.ToString());
  188. }
  189. #endregion
  190. #region 提交数据
  191. /// <summary>
  192. /// 删除功能
  193. /// </summary>
  194. /// <param name="keyValue">主键值</param>
  195. /// <returns></returns>
  196. [HttpPost]
  197. [ValidateAntiForgeryToken]
  198. [AjaxOnly]
  199. [HandlerAuthorize(PermissionMode.Enforce)]
  200. public ActionResult RemoveForm(string keyValue)
  201. {
  202. moduleBLL.RemoveForm(keyValue);
  203. return Success("删除成功。");
  204. }
  205. /// <summary>
  206. /// 保存功能表单
  207. /// </summary>
  208. /// <param name="keyValue">主键值</param>
  209. /// <param name="moduleEntity">功能实体</param>
  210. /// <param name="moduleButtonListJson">按钮实体列表</param>
  211. /// <param name="moduleColumnListJson">视图实体列表</param>
  212. /// <returns></returns>
  213. [HttpPost]
  214. [ValidateAntiForgeryToken]
  215. [AjaxOnly]
  216. public ActionResult SaveForm(string keyValue, ModuleEntity moduleEntity, string moduleButtonListJson, string moduleColumnListJson)
  217. {
  218. moduleBLL.SaveForm(keyValue, moduleEntity, moduleButtonListJson, moduleColumnListJson);
  219. return Success("保存成功。");
  220. }
  221. #endregion
  222. }
  223. }