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.

76 lines
3.0 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using Entity.ViewModels;
  4. using SqlSugar;
  5. using SqlSugar.Base;
  6. using System;
  7. namespace EasyBL.WEBAPP.SYS
  8. {
  9. public class RoleMaintain_QryService : ServiceBase
  10. {
  11. #region 角色管理(分頁資料)
  12. /// <summary>
  13. /// 角色管理(分頁資料)
  14. /// </summary>
  15. /// <param name="i_crm">todo: describe i_crm parameter on QueryPage</param>
  16. /// <returns></returns>
  17. public ResponseMessage QueryPage(RequestMessage i_crm)
  18. {
  19. ResponseMessage rm = null;
  20. string sMsg = null;
  21. var db = SugarBase.GetIntance();
  22. try
  23. {
  24. do
  25. {
  26. var pml = new PageModel
  27. {
  28. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  29. PageSize = _fetchInt(i_crm, @"pageSize")
  30. };
  31. var iPageCount = 0;
  32. var sSortField = _fetchString(i_crm, @"sortField");
  33. var sSortOrder = _fetchString(i_crm, @"sortOrder");
  34. var sRuleID = _fetchString(i_crm, @"RuleID");
  35. var sRuleName = _fetchString(i_crm, @"RuleName");
  36. var sMemberID = _fetchString(i_crm, @"MemberID");
  37. var bExcel = _fetchBool(i_crm, @"Excel");
  38. pml.DataList = db.Queryable<OTB_SYS_Rules>("x")
  39. .Select(x => new OTB_SYS_Rules
  40. {
  41. OrgID = x.OrgID,
  42. RuleID = x.RuleID,
  43. RuleName = x.RuleName,
  44. DelStatus = x.DelStatus,
  45. ExFeild1 = SqlFunc.MappingColumn(x.RuleID, "dbo.[OFN_SYS_GetUserNameByRuleID](x.OrgID,x.RuleID)")
  46. })
  47. .MergeTable()
  48. .Where(x => x.OrgID == i_crm.ORIGID && x.DelStatus == "N" && x.RuleID.Contains(sRuleID) && x.RuleName.Contains(sRuleName) && x.ExFeild1.Contains(sMemberID))
  49. .OrderBy(sSortField, sSortOrder)
  50. .ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
  51. pml.Total = iPageCount;
  52. rm = new SuccessResponseMessage(null, i_crm);
  53. rm.DATA.Add(BLWording.REL, pml);
  54. } while (false);
  55. }
  56. catch (Exception ex)
  57. {
  58. sMsg = Util.GetLastExceptionMsg(ex);
  59. LogAndSendEmail(sMsg + @"Param:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(Task_QryService), @"角色管理", @"GetTasksPage(角色管理(分頁資料))", @"", @"", @"");
  60. }
  61. finally
  62. {
  63. if (null != sMsg)
  64. {
  65. rm = new ErrorResponseMessage(sMsg, i_crm);
  66. }
  67. }
  68. return rm;
  69. }
  70. #endregion 角色管理(分頁資料)
  71. }
  72. }