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.
 
 
 
 
 
 

199 lines
6.3 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. /// 日 期:2020-01-04 15:23
  15. /// 描 述:社团会员
  16. /// </summary>
  17. public class CommunityMemberService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<CommunityMemberEntity> GetPageList(Pagination pagination, string queryJson, string stuNo)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* ");
  31. strSql.Append(" FROM CommunityMember t ");
  32. strSql.Append(" WHERE 1=1 ");
  33. var queryParam = queryJson.ToJObject();
  34. // 虚拟参数
  35. var dp = new DynamicParameters(new { });
  36. if (!queryParam["CommunityId"].IsEmpty())
  37. {
  38. dp.Add("CommunityId", queryParam["CommunityId"].ToString(), DbType.String);
  39. strSql.Append(" AND t.CommunityId = @CommunityId ");
  40. }
  41. if (!queryParam["StuName"].IsEmpty())
  42. {
  43. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  44. strSql.Append(" AND t.StuName like @StuName ");
  45. }
  46. if (!stuNo.IsEmpty())
  47. {
  48. dp.Add("StuNo", stuNo.ToString(), DbType.String);
  49. strSql.Append(" AND t.StuNo = @StuNo ");
  50. }
  51. return this.BaseRepository("CollegeMIS").FindList<CommunityMemberEntity>(strSql.ToString(), dp, pagination);
  52. }
  53. catch (Exception ex)
  54. {
  55. if (ex is ExceptionEx)
  56. {
  57. throw;
  58. }
  59. else
  60. {
  61. throw ExceptionEx.ThrowServiceException(ex);
  62. }
  63. }
  64. }
  65. /// <summary>
  66. /// 获取页面显示列表数据
  67. /// <summary>
  68. /// <param name="queryJson">查询参数</param>
  69. /// <returns></returns>
  70. public IEnumerable<CommunityMemberEntity> GetList(string communityId)
  71. {
  72. try
  73. {
  74. var strSql = new StringBuilder();
  75. var dp = new DynamicParameters(new { });
  76. strSql.Append("SELECT t.* FROM CommunityMember t WHERE 1=1 ");
  77. // 虚拟参数
  78. if (!communityId.IsEmpty())
  79. {
  80. dp.Add("communityId", communityId.ToString(), DbType.String);
  81. strSql.Append(" AND t.CommunityId = @communityId ");
  82. }
  83. return this.BaseRepository("CollegeMIS").FindList<CommunityMemberEntity>(strSql.ToString(), dp);
  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. /// <summary>
  98. /// 获取CommunityMember表实体数据
  99. /// <param name="keyValue">主键</param>
  100. /// <summary>
  101. /// <returns></returns>
  102. public CommunityMemberEntity GetCommunityMemberEntity(string keyValue)
  103. {
  104. try
  105. {
  106. return this.BaseRepository("CollegeMIS").FindEntity<CommunityMemberEntity>(keyValue);
  107. }
  108. catch (Exception ex)
  109. {
  110. if (ex is ExceptionEx)
  111. {
  112. throw;
  113. }
  114. else
  115. {
  116. throw ExceptionEx.ThrowServiceException(ex);
  117. }
  118. }
  119. }
  120. #endregion
  121. #region 提交数据
  122. /// <summary>
  123. /// 删除实体数据
  124. /// <param name="keyValue">主键</param>
  125. /// <summary>
  126. /// <returns></returns>
  127. public void DeleteEntity(string keyValue)
  128. {
  129. try
  130. {
  131. this.BaseRepository("CollegeMIS").Delete<CommunityMemberEntity>(t => t.Id == keyValue);
  132. }
  133. catch (Exception ex)
  134. {
  135. if (ex is ExceptionEx)
  136. {
  137. throw;
  138. }
  139. else
  140. {
  141. throw ExceptionEx.ThrowServiceException(ex);
  142. }
  143. }
  144. }
  145. /// <summary>
  146. /// 保存实体数据(新增、修改)
  147. /// <param name="keyValue">主键</param>
  148. /// <summary>
  149. /// <returns></returns>
  150. public void SaveEntity(string keyValue, CommunityMemberEntity entity)
  151. {
  152. try
  153. {
  154. var model = this.BaseRepository("CollegeMIS").FindEntity<CommunityMemberEntity>(x => x.CommunityId == entity.CommunityId && x.StuNo == entity.StuNo);
  155. if (!string.IsNullOrEmpty(keyValue))
  156. {
  157. if (model == null || (model != null && model.Id == keyValue))
  158. {
  159. entity.Modify(keyValue);
  160. this.BaseRepository("CollegeMIS").Update(entity);
  161. }
  162. }
  163. else
  164. {
  165. if (model == null)
  166. {
  167. entity.Create();
  168. this.BaseRepository("CollegeMIS").Insert(entity);
  169. }
  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. }