You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
4.5 KiB

3 weeks ago
  1. using NFine.Application.SystemManage;
  2. using NFine.Code;
  3. using NFine.Domain.Entity.SystemManage;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web.Mvc;
  7. namespace NFine.Web.Areas.SystemManage.Controllers
  8. {
  9. public class RoleAuthorizeController : ControllerBase
  10. {
  11. private RoleAuthorizeApp roleAuthorizeApp = new RoleAuthorizeApp();
  12. private ModuleApp moduleApp = new ModuleApp();
  13. private ModuleButtonApp moduleButtonApp = new ModuleButtonApp();
  14. private FormDataActionApp formDataActionApp = new FormDataActionApp();
  15. public ActionResult GetPermissionTree(string roleId)
  16. {
  17. var moduledata = moduleApp.GetListALL();
  18. var buttondata = moduleButtonApp.GetList();
  19. var authorizedata = new List<RoleAuthorizeEntity>();
  20. if (!string.IsNullOrEmpty(roleId))
  21. {
  22. authorizedata = roleAuthorizeApp.GetList(roleId);
  23. }
  24. var treeList = new List<TreeViewModel>();
  25. foreach (ModuleEntity item in moduledata)
  26. {
  27. TreeViewModel tree = new TreeViewModel();
  28. bool hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  29. tree.id = item.F_Id;
  30. tree.text = item.F_FullName;
  31. tree.value = item.F_EnCode;
  32. tree.parentId = item.F_ParentId;
  33. tree.isexpand = true;
  34. tree.complete = true;
  35. tree.showcheck = true;
  36. tree.checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id);
  37. tree.hasChildren = true;
  38. tree.img = item.F_Icon == "" ? "" : item.F_Icon;
  39. treeList.Add(tree);
  40. }
  41. foreach (ModuleButtonEntity item in buttondata)
  42. {
  43. TreeViewModel tree = new TreeViewModel();
  44. bool hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  45. tree.id = item.F_Id;
  46. tree.text = item.F_FullName;
  47. tree.value = item.F_EnCode;
  48. tree.parentId = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId;
  49. tree.isexpand = true;
  50. tree.complete = true;
  51. tree.showcheck = true;
  52. tree.checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id);
  53. tree.hasChildren = hasChildren;
  54. tree.img = item.F_Icon == "" ? "" : item.F_Icon;
  55. treeList.Add(tree);
  56. }
  57. return Content(treeList.TreeViewJson());
  58. }
  59. public ActionResult GetDataActionTree(string roleId)
  60. {
  61. var moduledata = moduleApp.GetListALL();
  62. var dataaction = formDataActionApp.GetList();
  63. var dataActiondata = new List<RoleDataPowerEntity>();
  64. if (!string.IsNullOrEmpty(roleId))
  65. {
  66. dataActiondata = formDataActionApp.GetRoleDataList(roleId);
  67. }
  68. var treeList = new List<TreeViewModel>();
  69. foreach (ModuleEntity item in moduledata)
  70. {
  71. TreeViewModel tree = new TreeViewModel();
  72. bool hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  73. tree.id = item.F_Id;
  74. tree.text = item.F_FullName;
  75. tree.value = item.F_EnCode;
  76. tree.parentId = item.F_ParentId;
  77. tree.isexpand = true;
  78. tree.complete = true;
  79. tree.showcheck = true;
  80. tree.checkstate = dataActiondata.Count(t => t.DataActionId == item.F_Id);
  81. tree.hasChildren = true;
  82. tree.img = item.F_Icon == "" ? "" : item.F_Icon;
  83. treeList.Add(tree);
  84. }
  85. foreach (FormDataActionEntity item in dataaction)
  86. {
  87. TreeViewModel tree = new TreeViewModel();
  88. tree.id = item.ID;
  89. tree.text = item.CFiledName;
  90. tree.value = item.CCaption;
  91. tree.parentId = item.SourceId;
  92. tree.isexpand = true;
  93. tree.complete = true;
  94. tree.showcheck = true;
  95. tree.checkstate = dataActiondata.Count(t => t.DataActionId == item.ID);
  96. tree.hasChildren = false;
  97. tree.img = "";
  98. treeList.Add(tree);
  99. }
  100. return Content(treeList.DataActionTreeViewJson());
  101. }
  102. }
  103. }