纽威
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.

94 lines
3.4 KiB

1 year ago
  1. using NFine.Code;
  2. using NFine.Domain.Entity.SystemManage;
  3. using NFine.Domain.IRepository.SystemManage;
  4. using NFine.Repository.SystemManage;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace NFine.Application.SystemManage
  8. {
  9. public class RoleApp
  10. {
  11. private IRoleRepository service = new RoleRepository();
  12. private ModuleApp moduleApp = new ModuleApp();
  13. private ModuleButtonApp moduleButtonApp = new ModuleButtonApp();
  14. public List<RoleEntity> GetList(Pagination pagination, string keyword = "")
  15. {
  16. var expression = ExtLinq.True<RoleEntity>();
  17. if (!string.IsNullOrEmpty(keyword))
  18. {
  19. expression = expression.And(t => t.F_FullName.Contains(keyword));
  20. expression = expression.Or(t => t.F_EnCode.Contains(keyword));
  21. }
  22. expression = expression.And(t => t.F_Category == 1);
  23. //return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
  24. if (pagination == null)
  25. {
  26. return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
  27. }
  28. else
  29. {
  30. return service.FindList(expression, pagination);
  31. }
  32. }
  33. public List<RoleEntity> GetList( string keyword = "")
  34. {
  35. var expression = ExtLinq.True<RoleEntity>();
  36. if (!string.IsNullOrEmpty(keyword))
  37. {
  38. expression = expression.And(t => t.F_FullName.Contains(keyword));
  39. expression = expression.Or(t => t.F_EnCode.Contains(keyword));
  40. }
  41. expression = expression.And(t => t.F_Category == 1);
  42. return service.IQueryable(expression).OrderBy(t => t.F_SortCode).ToList();
  43. }
  44. public RoleEntity GetForm(string keyValue)
  45. {
  46. return service.FindEntity(keyValue);
  47. }
  48. public void DeleteForm(string keyValue)
  49. {
  50. service.DeleteForm(keyValue);
  51. }
  52. public void SubmitForm(RoleEntity roleEntity, string[] permissionIds, string keyValue)
  53. {
  54. if (!string.IsNullOrEmpty(keyValue))
  55. {
  56. roleEntity.F_Id = keyValue;
  57. }
  58. else
  59. {
  60. roleEntity.F_Id = Common.GuId();
  61. }
  62. var moduledata = moduleApp.GetList();
  63. var buttondata = moduleButtonApp.GetList();
  64. List<RoleAuthorizeEntity> roleAuthorizeEntitys = new List<RoleAuthorizeEntity>();
  65. foreach (var itemId in permissionIds)
  66. {
  67. RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
  68. roleAuthorizeEntity.F_Id = Common.GuId();
  69. roleAuthorizeEntity.F_ObjectType = 1;
  70. roleAuthorizeEntity.F_ObjectId = roleEntity.F_Id;
  71. roleAuthorizeEntity.F_ItemId = itemId;
  72. if (moduledata.Find(t => t.F_Id == itemId) != null)
  73. {
  74. roleAuthorizeEntity.F_ItemType = 1;
  75. }
  76. if (buttondata.Find(t => t.F_Id == itemId) != null)
  77. {
  78. roleAuthorizeEntity.F_ItemType = 2;
  79. }
  80. roleAuthorizeEntitys.Add(roleAuthorizeEntity);
  81. }
  82. service.SubmitForm(roleEntity, roleAuthorizeEntitys, keyValue);
  83. }
  84. }
  85. }