SystemMenuPermissionRepository.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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,int PortType)
  59. {
  60. Result result = new Result();
  61. if (uid != 0)
  62. {
  63. List<MenuLoadView> DBData = new List<MenuLoadView>();
  64. string sql = $@"
  65. select a.UId,a.SmId,b.Id as Funid,b.FunctionName,b.FunctionCode,c.Id as modulid,
  66. c.Name as modulName,c.STid,d.Id as pageid ,d.Name as PageName,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
  67. d.IosUrl
  68. from Sys_UserAuthority a inner join Sys_PageFunctionPermission b on a.FId = b.Id
  69. inner join Sys_SystemMenuPermission d on a.SmId = d.Id inner join Sys_SetData c on c.Id = d.Mid
  70. where uid = {uid} and b.Id = 1 and a.IsDel= 0 and b.IsDel = 0
  71. and b.IsEnable = 1 and c.IsDel = 0 and d.IsDel = 0 ";
  72. if (PortType == 1)
  73. {
  74. sql += $@" and d.IsEnable = 1 group by
  75. a.UId,a.SmId,b.Id,b.FunctionName,b.FunctionCode,c.Id,
  76. c.Name,c.STid,d.Id,d.Name,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
  77. d.IosUrl";
  78. DBData = _sqlSugar.SqlQueryable<MenuLoadView>(sql).ToList();
  79. }
  80. else if (PortType == 2)
  81. {
  82. sql += $@" and d.phoneIsEnable = 1 group by
  83. a.UId,a.SmId,b.Id,b.FunctionName,b.FunctionCode,c.Id,
  84. c.Name,c.STid,d.Id,d.Name,d.SystemMenuCode,d.webUrl,d.AndroidUrl,d.icon,
  85. d.IosUrl ";
  86. DBData = _sqlSugar.SqlQueryable<MenuLoadView>(sql).ToList();
  87. }
  88. result.Code = -1;
  89. result.Msg = "暂无数据!";
  90. if (DBData.Count > 0)
  91. {
  92. result.Code = 0;
  93. result.Msg = "成功!";
  94. result.Data = DBData;
  95. }
  96. }
  97. return result;
  98. }
  99. }
  100. }