SystemMenuPermissionRepository.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. public Result QueryMenuLoad(int uid)
  59. {
  60. Result result = new Result();
  61. if (uid != 0)
  62. {
  63. var DBData = _sqlSugar.SqlQueryable<MenuLoadView>($@"
  64. select a.id as userpageid ,a.UId,a.SmId,b.Id as Funid,b.FunctionName,b.FunctionCode,c.Id as modulid,
  65. c.Name as modulName,c.STid,d.Id as pageid ,d.Name as PageName,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
  66. d.IosUrl
  67. from Sys_UserAuthority a inner join Sys_PageFunctionPermission b on a.FId = b.Id
  68. inner join Sys_SystemMenuPermission d on a.SmId = d.Id inner join Sys_SetData c on c.Id = d.Mid
  69. where uid = {uid} and b.Id = 1 and a.IsDel= 0 and b.IsDel = 0
  70. and b.IsEnable = 1 and c.IsDel = 0 and d.IsDel = 0 and d.IsEnable = 1
  71. ").ToList();
  72. result.Code = -1;
  73. result.Msg = "暂无数据!";
  74. if (DBData.Count > 0)
  75. {
  76. result.Code = 0;
  77. result.Msg = "成功!";
  78. result.Data = DBData;
  79. }
  80. }
  81. return result;
  82. }
  83. }
  84. }