25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

184 lines
5.5 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. strSql.Append(" FROM TeacherTrain t ");
  35. strSql.Append(" WHERE 1=1 ");
  36. var queryParam = queryJson.ToJObject();
  37. // 虚拟参数
  38. var dp = new DynamicParameters(new { });
  39. if (!queryParam["EID"].IsEmpty())
  40. {
  41. dp.Add("EID", queryParam["EID"].ToString(), DbType.String);
  42. strSql.Append(" AND t.EID = @EID ");
  43. }
  44. return this.BaseRepository().FindList<TeacherTrainEntity>(strSql.ToString(), dp, pagination);
  45. }
  46. catch (Exception ex)
  47. {
  48. if (ex is ExceptionEx)
  49. {
  50. throw;
  51. }
  52. else
  53. {
  54. throw ExceptionEx.ThrowServiceException(ex);
  55. }
  56. }
  57. }
  58. /// <summary>
  59. /// 获取TeacherTrain表实体数据
  60. /// <param name="keyValue">主键</param>
  61. /// <summary>
  62. /// <returns></returns>
  63. public TeacherTrainEntity GetTeacherTrainEntity(string keyValue)
  64. {
  65. try
  66. {
  67. return this.BaseRepository().FindEntity<TeacherTrainEntity>(keyValue);
  68. }
  69. catch (Exception ex)
  70. {
  71. if (ex is ExceptionEx)
  72. {
  73. throw;
  74. }
  75. else
  76. {
  77. throw ExceptionEx.ThrowServiceException(ex);
  78. }
  79. }
  80. }
  81. /// <summary>
  82. /// 获取页面显示列表数据
  83. /// <summary>
  84. /// <param name="queryJson">查询参数</param>
  85. /// <returns></returns>
  86. public IEnumerable<TeacherTrainEntity> GetListByEmpId(string empId)
  87. {
  88. try
  89. {
  90. var data = new List<TeacherTrainEntity>();
  91. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(empId);
  92. if (empInfoEntity != null)
  93. {
  94. var userEntity = this.BaseRepository().FindEntity<UserEntity>(x => x.F_Account == empInfoEntity.EmpNo);
  95. if (userEntity != null)
  96. {
  97. return this.BaseRepository().FindList<TeacherTrainEntity>(x => x.EID == userEntity.F_UserId);
  98. }
  99. }
  100. return data;
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowServiceException(ex);
  111. }
  112. }
  113. }
  114. #endregion
  115. #region 提交数据
  116. /// <summary>
  117. /// 删除实体数据
  118. /// <param name="keyValue">主键</param>
  119. /// <summary>
  120. /// <returns></returns>
  121. public void DeleteEntity(string keyValue)
  122. {
  123. try
  124. {
  125. this.BaseRepository().Delete<TeacherTrainEntity>(t => t.TTID == keyValue);
  126. }
  127. catch (Exception ex)
  128. {
  129. if (ex is ExceptionEx)
  130. {
  131. throw;
  132. }
  133. else
  134. {
  135. throw ExceptionEx.ThrowServiceException(ex);
  136. }
  137. }
  138. }
  139. /// <summary>
  140. /// 保存实体数据(新增、修改)
  141. /// <param name="keyValue">主键</param>
  142. /// <summary>
  143. /// <returns></returns>
  144. public void SaveEntity(string keyValue, TeacherTrainEntity entity)
  145. {
  146. try
  147. {
  148. if (!string.IsNullOrEmpty(keyValue))
  149. {
  150. entity.Modify(keyValue);
  151. this.BaseRepository().Update(entity);
  152. }
  153. else
  154. {
  155. entity.Create();
  156. this.BaseRepository().Insert(entity);
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. if (ex is ExceptionEx)
  162. {
  163. throw;
  164. }
  165. else
  166. {
  167. throw ExceptionEx.ThrowServiceException(ex);
  168. }
  169. }
  170. }
  171. #endregion
  172. }
  173. }