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.
 
 
 
 
 
 

195 lines
5.8 KiB

  1. using Dapper;
  2. using Learun.Application.Organization;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using Learun.DataBase.Repository;
  5. using Learun.Util;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Text;
  10. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  14. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2019-03-19 11:34
  17. /// 描 述:教师培训信息
  18. /// </summary>
  19. public class TeacherTrainService : RepositoryFactory
  20. {
  21. #region 获取数据
  22. /// <summary>
  23. /// 获取页面显示列表数据
  24. /// <summary>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<TeacherTrainEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT ");
  33. strSql.Append(@"
  34. t.TTID,
  35. t.EID,
  36. t.TTStartTime,
  37. t.TTEndTime,
  38. t.TTContent,
  39. t.TTOrganization,
  40. t.TTWay,
  41. t.TTCertificates,
  42. t.TTComment,
  43. t.TTLevel
  44. ");
  45. strSql.Append(" FROM TeacherTrain t ");
  46. strSql.Append(" WHERE 1=1 ");
  47. var queryParam = queryJson.ToJObject();
  48. // 虚拟参数
  49. var dp = new DynamicParameters(new { });
  50. if (!queryParam["EID"].IsEmpty())
  51. {
  52. dp.Add("EID", queryParam["EID"].ToString(), DbType.String);
  53. strSql.Append(" AND t.EID = @EID ");
  54. }
  55. return this.BaseRepository().FindList<TeacherTrainEntity>(strSql.ToString(), dp, pagination);
  56. }
  57. catch (Exception ex)
  58. {
  59. if (ex is ExceptionEx)
  60. {
  61. throw;
  62. }
  63. else
  64. {
  65. throw ExceptionEx.ThrowServiceException(ex);
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 获取TeacherTrain表实体数据
  71. /// <param name="keyValue">主键</param>
  72. /// <summary>
  73. /// <returns></returns>
  74. public TeacherTrainEntity GetTeacherTrainEntity(string keyValue)
  75. {
  76. try
  77. {
  78. return this.BaseRepository().FindEntity<TeacherTrainEntity>(keyValue);
  79. }
  80. catch (Exception ex)
  81. {
  82. if (ex is ExceptionEx)
  83. {
  84. throw;
  85. }
  86. else
  87. {
  88. throw ExceptionEx.ThrowServiceException(ex);
  89. }
  90. }
  91. }
  92. /// <summary>
  93. /// 获取页面显示列表数据
  94. /// <summary>
  95. /// <param name="queryJson">查询参数</param>
  96. /// <returns></returns>
  97. public IEnumerable<TeacherTrainEntity> GetListByEmpId(string empId)
  98. {
  99. try
  100. {
  101. var data = new List<TeacherTrainEntity>();
  102. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(empId);
  103. if (empInfoEntity != null)
  104. {
  105. var userEntity = this.BaseRepository().FindEntity<UserEntity>(x => x.F_Account == empInfoEntity.EmpNo);
  106. if (userEntity != null)
  107. {
  108. return this.BaseRepository().FindList<TeacherTrainEntity>(x => x.EID == userEntity.F_UserId);
  109. }
  110. }
  111. return data;
  112. }
  113. catch (Exception ex)
  114. {
  115. if (ex is ExceptionEx)
  116. {
  117. throw;
  118. }
  119. else
  120. {
  121. throw ExceptionEx.ThrowServiceException(ex);
  122. }
  123. }
  124. }
  125. #endregion
  126. #region 提交数据
  127. /// <summary>
  128. /// 删除实体数据
  129. /// <param name="keyValue">主键</param>
  130. /// <summary>
  131. /// <returns></returns>
  132. public void DeleteEntity(string keyValue)
  133. {
  134. try
  135. {
  136. this.BaseRepository().Delete<TeacherTrainEntity>(t => t.TTID == 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. /// <summary>
  154. /// <returns></returns>
  155. public void SaveEntity(string keyValue, TeacherTrainEntity entity)
  156. {
  157. try
  158. {
  159. if (!string.IsNullOrEmpty(keyValue))
  160. {
  161. entity.Modify(keyValue);
  162. this.BaseRepository().Update(entity);
  163. }
  164. else
  165. {
  166. entity.Create();
  167. this.BaseRepository().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. }