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.
 
 
 
 
 
 

181 lines
5.2 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-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-12-31 10:25
  15. /// 描 述:党组织管理架构表
  16. /// </summary>
  17. public class PMOrganizationService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<PMOrganizationEntity> 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.Code,
  35. t.Remark
  36. ");
  37. strSql.Append(" FROM PMOrganization t ");
  38. strSql.Append(" WHERE 1=1 ");
  39. var queryParam = queryJson.ToJObject();
  40. // 虚拟参数
  41. var dp = new DynamicParameters(new { });
  42. if (!queryParam["Name"].IsEmpty())
  43. {
  44. dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String);
  45. strSql.Append(" AND t.Name Like @Name ");
  46. }
  47. if (!queryParam["Code"].IsEmpty())
  48. {
  49. dp.Add("Code", "%" + queryParam["Code"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.Code Like @Code ");
  51. }
  52. return this.BaseRepository("CollegeMIS").FindList<PMOrganizationEntity>(strSql.ToString(),dp, pagination);
  53. }
  54. catch (Exception ex)
  55. {
  56. if (ex is ExceptionEx)
  57. {
  58. throw;
  59. }
  60. else
  61. {
  62. throw ExceptionEx.ThrowServiceException(ex);
  63. }
  64. }
  65. }
  66. /// <summary>
  67. /// 获取PMOrganization表实体数据
  68. /// <param name="keyValue">主键</param>
  69. /// <summary>
  70. /// <returns></returns>
  71. public PMOrganizationEntity GetPMOrganizationEntity(string keyValue)
  72. {
  73. try
  74. {
  75. return this.BaseRepository("CollegeMIS").FindEntity<PMOrganizationEntity>(keyValue);
  76. }
  77. catch (Exception ex)
  78. {
  79. if (ex is ExceptionEx)
  80. {
  81. throw;
  82. }
  83. else
  84. {
  85. throw ExceptionEx.ThrowServiceException(ex);
  86. }
  87. }
  88. }
  89. /// <summary>
  90. /// 获取树形数据
  91. /// </summary>
  92. /// <returns></returns>
  93. public DataTable GetSqlTree()
  94. {
  95. try
  96. {
  97. return this.BaseRepository().FindTable(" select * from PMOrganization ");
  98. }
  99. catch (Exception ex)
  100. {
  101. if (ex is ExceptionEx)
  102. {
  103. throw;
  104. }
  105. else
  106. {
  107. throw ExceptionEx.ThrowServiceException(ex);
  108. }
  109. }
  110. }
  111. #endregion
  112. #region 提交数据
  113. /// <summary>
  114. /// 删除实体数据
  115. /// <param name="keyValue">主键</param>
  116. /// <summary>
  117. /// <returns></returns>
  118. public void DeleteEntity(string keyValue)
  119. {
  120. try
  121. {
  122. this.BaseRepository("CollegeMIS").Delete<PMOrganizationEntity>(t=>t.ID == keyValue);
  123. }
  124. catch (Exception ex)
  125. {
  126. if (ex is ExceptionEx)
  127. {
  128. throw;
  129. }
  130. else
  131. {
  132. throw ExceptionEx.ThrowServiceException(ex);
  133. }
  134. }
  135. }
  136. /// <summary>
  137. /// 保存实体数据(新增、修改)
  138. /// <param name="keyValue">主键</param>
  139. /// <summary>
  140. /// <returns></returns>
  141. public void SaveEntity(string keyValue, PMOrganizationEntity entity)
  142. {
  143. try
  144. {
  145. if (!string.IsNullOrEmpty(keyValue))
  146. {
  147. entity.Modify(keyValue);
  148. this.BaseRepository("CollegeMIS").Update(entity);
  149. }
  150. else
  151. {
  152. entity.Create();
  153. this.BaseRepository("CollegeMIS").Insert(entity);
  154. }
  155. }
  156. catch (Exception ex)
  157. {
  158. if (ex is ExceptionEx)
  159. {
  160. throw;
  161. }
  162. else
  163. {
  164. throw ExceptionEx.ThrowServiceException(ex);
  165. }
  166. }
  167. }
  168. #endregion
  169. }
  170. }