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.
 
 
 
 
 
 

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