PrivilegeLogic.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using CZFW.Framework.Interface;
  2. using CZFW.Framework.Model;
  3. using CZFW.Framework.Model.Entity;
  4. using CZFW.Framework.Model.ViewModel;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace CZFW.Framework.Logic
  8. {
  9. public class PrivilegeLogic : LogicBase<PrivilegeEntity>, IPrivilege
  10. {
  11. public IList<PrivilegeModel> GetListByGroupMark(string mark)
  12. {
  13. var res = GetSortedQueryable().Where(x => x.GroupMark == mark).Select(x => new PrivilegeModel()
  14. {
  15. Id = x.Id,
  16. ActionName = x.ActionName,
  17. AreaName = x.AreaName,
  18. ControllerName = x.ControllerName,
  19. Description = x.Description,
  20. GroupMark = x.GroupMark,
  21. Name = x.Name,
  22. SortOrder = x.SortOrder ?? 0,
  23. Url = x.Url
  24. }).ToList();
  25. return res;
  26. }
  27. public TableModel<PrivilegeModel> GetTableModelByGroupMark(string mark, int pageIndex = 1, int pageSize = 20)
  28. {
  29. var res = new TableModel<PrivilegeModel>();
  30. var queryable = GetSortedQueryable().Where(x => x.GroupMark == mark);
  31. var data = queryable.Select(x => new PrivilegeModel()
  32. {
  33. Id = x.Id,
  34. ActionName = x.ActionName,
  35. AreaName = x.AreaName,
  36. ControllerName = x.ControllerName,
  37. Description = x.Description,
  38. GroupMark = x.GroupMark,
  39. Name = x.Name,
  40. SortOrder = x.SortOrder ?? 0,
  41. Url = x.Url
  42. }).OrderByDescending(x=>x.SortOrder).Skip((pageIndex-1)*pageSize).Take(pageSize).ToList();
  43. res.SetData(data);
  44. var total = queryable.Count();
  45. res.Pager = new PagerModel(total, pageIndex, pageSize);
  46. res.TableHeads = PropertyHelper.Get(typeof(PrivilegeModel));
  47. return res;
  48. }
  49. }
  50. }