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.
 
 
 
 
 
 

198 lines
5.6 KiB

  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.PersonnelManagement
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-10-21 09:52
  15. /// 描 述:学校邮箱管理
  16. /// </summary>
  17. public class EmailManagementService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<EmailManagementEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.*");
  32. strSql.Append(" FROM EmailManagement t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. return this.BaseRepository().FindList<EmailManagementEntity>(strSql.ToString(),dp, pagination);
  38. }
  39. catch (Exception ex)
  40. {
  41. if (ex is ExceptionEx)
  42. {
  43. throw;
  44. }
  45. else
  46. {
  47. throw ExceptionEx.ThrowServiceException(ex);
  48. }
  49. }
  50. }
  51. /// <summary>
  52. /// 获取EmailManagement表实体数据
  53. /// </summary>
  54. /// <param name="keyValue">主键</param>
  55. /// <returns></returns>
  56. public EmailManagementEntity GetEmailManagementEntity(string keyValue)
  57. {
  58. try
  59. {
  60. return this.BaseRepository().FindEntity<EmailManagementEntity>(keyValue);
  61. }
  62. catch (Exception ex)
  63. {
  64. if (ex is ExceptionEx)
  65. {
  66. throw;
  67. }
  68. else
  69. {
  70. throw ExceptionEx.ThrowServiceException(ex);
  71. }
  72. }
  73. }
  74. /// <summary>
  75. /// 获取EmailManagement表实体数据
  76. /// </summary>
  77. /// <param name="keyValue">主键</param>
  78. /// <returns></returns>
  79. public EmailManagementEntity GetEmailManagementEntityEnabled()
  80. {
  81. try
  82. {
  83. return this.BaseRepository().FindEntity<EmailManagementEntity>(x=>x.F_EnabledMark == 1);
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowServiceException(ex);
  94. }
  95. }
  96. }
  97. #endregion
  98. #region 提交数据
  99. /// <summary>
  100. /// 删除实体数据
  101. /// </summary>
  102. /// <param name="keyValue">主键</param>
  103. public void DeleteEntity(string keyValue)
  104. {
  105. try
  106. {
  107. this.BaseRepository().Delete<EmailManagementEntity>(t=>t.F_Id == keyValue);
  108. }
  109. catch (Exception ex)
  110. {
  111. if (ex is ExceptionEx)
  112. {
  113. throw;
  114. }
  115. else
  116. {
  117. throw ExceptionEx.ThrowServiceException(ex);
  118. }
  119. }
  120. }
  121. /// <summary>
  122. /// 保存实体数据(新增、修改)
  123. /// </summary>
  124. /// <param name="keyValue">主键</param>
  125. /// <param name="entity">实体</param>
  126. public void SaveEntity(string keyValue, EmailManagementEntity entity)
  127. {
  128. try
  129. {
  130. if (!string.IsNullOrEmpty(keyValue))
  131. {
  132. entity.Modify(keyValue);
  133. this.BaseRepository().Update(entity);
  134. }
  135. else
  136. {
  137. entity.Create();
  138. this.BaseRepository().Insert(entity);
  139. }
  140. }
  141. catch (Exception ex)
  142. {
  143. if (ex is ExceptionEx)
  144. {
  145. throw;
  146. }
  147. else
  148. {
  149. throw ExceptionEx.ThrowServiceException(ex);
  150. }
  151. }
  152. }
  153. /// <summary>
  154. /// 启用
  155. /// </summary>
  156. /// <param name="keyValue">主键</param>
  157. public void DoEnabled(string keyValue, string status)
  158. {
  159. try
  160. {
  161. if (status == "1")
  162. {
  163. //启用
  164. this.BaseRepository().ExecuteBySql($"update EmailManagement set F_EnabledMark=1 where F_Id='{keyValue}' ");
  165. }
  166. else
  167. {
  168. //禁用
  169. this.BaseRepository().ExecuteBySql($"update EmailManagement set F_EnabledMark=0 where F_Id='{keyValue}' ");
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. if (ex is ExceptionEx)
  175. {
  176. throw;
  177. }
  178. else
  179. {
  180. throw ExceptionEx.ThrowServiceException(ex);
  181. }
  182. }
  183. }
  184. #endregion
  185. }
  186. }