SystemMenuPermissionRepository.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using OASystem.Domain;
  2. using OASystem.Domain.Entities.System;
  3. using OASystem.Domain.ViewModels.System;
  4. namespace OASystem.Infrastructure.Repositories.System
  5. {
  6. public class SystemMenuPermissionRepository : BaseRepository<Sys_SystemMenuPermission, SystemMenuPermissionView>
  7. {
  8. public SystemMenuPermissionRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
  9. {
  10. }
  11. /// <summary>
  12. /// 分页查询页面表
  13. /// </summary>
  14. /// <param name="_SystemMenuPermissionRepository"></param>
  15. /// <param name="mid">模块id</param>
  16. /// <param name="pageSize">行数</param>
  17. /// <param name="currentPage">页码</param>
  18. /// <returns></returns>
  19. public Result GetSystemMenuViweData(SystemMenuPermissionRepository _SystemMenuPermissionRepository,int mid,int pageSize,int currentPage)
  20. {
  21. Result result = new Result();
  22. if (currentPage == 0 || pageSize == 0)
  23. {
  24. return result;
  25. }
  26. string sql = $@"select top {pageSize} * from (select row_number()
  27. over(order by id asc) as rownumber,*
  28. from Sys_SystemMenuPermission where mid = {mid} and isdel = 0 and IsEnable = 1 ) temp_row
  29. where rownumber> {(currentPage - 1) * pageSize};";
  30. var DBdata = _SystemMenuPermissionRepository.GetListBySqlWithNolock(sql);
  31. if (DBdata == null || DBdata.Count == 0)
  32. {
  33. result.Code = -1;
  34. result.Msg = "暂无数据!";
  35. result.Data = new
  36. {
  37. DBdata,
  38. total = 0
  39. };
  40. return result;
  41. }
  42. var total = _SystemMenuPermissionRepository.Query<Sys_SystemMenuPermission>(x => x.Mid == mid).Count();
  43. result.Code = 0;
  44. result.Msg = "成功!";
  45. result.Data = new
  46. {
  47. DBdata = DBdata.Select(x => new SystemMenuPermissionView
  48. {
  49. Id = x.Id,
  50. Name = x.Name,
  51. Mid = mid,
  52. SystemMenuCode = x.SystemMenuCode
  53. }),
  54. total = total
  55. };
  56. return result;
  57. }
  58. }
  59. }