Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PBPostService.cs 4.3 KiB

4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Text;
  8. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2020-08-07 14:42
  15. /// 描 述:基地岗位管理
  16. /// </summary>
  17. public class PBPostService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<PBPostEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.ID,
  33. t.Name,
  34. t.Remark,
  35. t.PBID
  36. ");
  37. strSql.Append(" FROM PBPost t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. if (!queryParam["PBID"].IsEmpty())
  43. {
  44. dp.Add("PBID", queryParam["PBID"].ToString(), DbType.String);
  45. strSql.Append(" AND t.PBID = @PBID ");
  46. }
  47. return this.BaseRepository("CollegeMIS").FindList<PBPostEntity>(strSql.ToString(),dp, pagination);
  48. }
  49. catch (Exception ex)
  50. {
  51. if (ex is ExceptionEx)
  52. {
  53. throw;
  54. }
  55. else
  56. {
  57. throw ExceptionEx.ThrowServiceException(ex);
  58. }
  59. }
  60. }
  61. /// <summary>
  62. /// 获取PBPost表实体数据
  63. /// <param name="keyValue">主键</param>
  64. /// <summary>
  65. /// <returns></returns>
  66. public PBPostEntity GetPBPostEntity(string keyValue)
  67. {
  68. try
  69. {
  70. return this.BaseRepository("CollegeMIS").FindEntity<PBPostEntity>(keyValue);
  71. }
  72. catch (Exception ex)
  73. {
  74. if (ex is ExceptionEx)
  75. {
  76. throw;
  77. }
  78. else
  79. {
  80. throw ExceptionEx.ThrowServiceException(ex);
  81. }
  82. }
  83. }
  84. #endregion
  85. #region 提交数据
  86. /// <summary>
  87. /// 删除实体数据
  88. /// <param name="keyValue">主键</param>
  89. /// <summary>
  90. /// <returns></returns>
  91. public void DeleteEntity(string keyValue)
  92. {
  93. try
  94. {
  95. this.BaseRepository("CollegeMIS").Delete<PBPostEntity>(t=>t.ID == keyValue);
  96. }
  97. catch (Exception ex)
  98. {
  99. if (ex is ExceptionEx)
  100. {
  101. throw;
  102. }
  103. else
  104. {
  105. throw ExceptionEx.ThrowServiceException(ex);
  106. }
  107. }
  108. }
  109. /// <summary>
  110. /// 保存实体数据(新增、修改)
  111. /// <param name="keyValue">主键</param>
  112. /// <summary>
  113. /// <returns></returns>
  114. public void SaveEntity(string keyValue, PBPostEntity entity)
  115. {
  116. try
  117. {
  118. if (!string.IsNullOrEmpty(keyValue))
  119. {
  120. entity.Modify(keyValue);
  121. this.BaseRepository("CollegeMIS").Update(entity);
  122. }
  123. else
  124. {
  125. entity.Create();
  126. this.BaseRepository("CollegeMIS").Insert(entity);
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. if (ex is ExceptionEx)
  132. {
  133. throw;
  134. }
  135. else
  136. {
  137. throw ExceptionEx.ThrowServiceException(ex);
  138. }
  139. }
  140. }
  141. #endregion
  142. }
  143. }