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.
 
 
 
 
 
 

207 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-06-17 09:17
  15. /// 描 述:健康打卡时段
  16. /// </summary>
  17. public class HealthPunchTimeService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<HealthPunchTimeEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.StarTime,
  35. t.EndTime,
  36. t.Description,
  37. t.CheckMark,
  38. t.CreateUser,
  39. t.CreateTime,
  40. t.Remark
  41. ");
  42. strSql.Append(" FROM HealthPunchTime t ");
  43. strSql.Append(" WHERE 1=1 ");
  44. var queryParam = queryJson.ToJObject();
  45. // 虚拟参数
  46. var dp = new DynamicParameters(new { });
  47. if (!queryParam["Description"].IsEmpty())
  48. {
  49. dp.Add("Description", queryParam["Description"].ToString(), DbType.String);
  50. strSql.Append(" AND t.Description = @Description ");
  51. }
  52. if (!queryParam["CheckMark"].IsEmpty())
  53. {
  54. dp.Add("CheckMark", queryParam["CheckMark"].ToString(), DbType.String);
  55. strSql.Append(" AND t.CheckMark = @CheckMark ");
  56. }
  57. return this.BaseRepository("CollegeMIS").FindList<HealthPunchTimeEntity>(strSql.ToString(), dp, pagination);
  58. }
  59. catch (Exception ex)
  60. {
  61. if (ex is ExceptionEx)
  62. {
  63. throw;
  64. }
  65. else
  66. {
  67. throw ExceptionEx.ThrowServiceException(ex);
  68. }
  69. }
  70. }
  71. /// <summary>
  72. /// 获取HealthPunchTime表实体数据
  73. /// </summary>
  74. /// <param name="keyValue">主键</param>
  75. /// <returns></returns>
  76. public HealthPunchTimeEntity GetHealthPunchTimeEntity(string keyValue)
  77. {
  78. try
  79. {
  80. return this.BaseRepository("CollegeMIS").FindEntity<HealthPunchTimeEntity>(keyValue);
  81. }
  82. catch (Exception ex)
  83. {
  84. if (ex is ExceptionEx)
  85. {
  86. throw;
  87. }
  88. else
  89. {
  90. throw ExceptionEx.ThrowServiceException(ex);
  91. }
  92. }
  93. }
  94. public HealthPunchTimeEntity GetTypeEntity(string keyValue)
  95. {
  96. try
  97. {
  98. return this.BaseRepository("CollegeMIS").FindEntity<HealthPunchTimeEntity>(x => x.Description == keyValue);
  99. }
  100. catch (Exception ex)
  101. {
  102. if (ex is ExceptionEx)
  103. {
  104. throw;
  105. }
  106. else
  107. {
  108. throw ExceptionEx.ThrowServiceException(ex);
  109. }
  110. }
  111. }
  112. #endregion
  113. #region 提交数据
  114. /// <summary>
  115. /// 删除实体数据
  116. /// </summary>
  117. /// <param name="keyValue">主键</param>
  118. public void DeleteEntity(string keyValue)
  119. {
  120. try
  121. {
  122. this.BaseRepository("CollegeMIS").Delete<HealthPunchTimeEntity>(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. /// </summary>
  139. /// <param name="keyValue">主键</param>
  140. /// <param name="entity">实体</param>
  141. public void SaveEntity(string keyValue, HealthPunchTimeEntity 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. public void EnableEntity(string keyValue)
  169. {
  170. try
  171. {
  172. var entity = this.BaseRepository("CollegeMIS").FindEntity<HealthPunchTimeEntity>(keyValue);
  173. if (entity.CheckMark == 0)
  174. {
  175. entity.CheckMark = 1;
  176. }
  177. else if (entity.CheckMark == 1)
  178. {
  179. entity.CheckMark = 0;
  180. }
  181. this.BaseRepository("CollegeMIS").Update(entity);
  182. }
  183. catch (Exception ex)
  184. {
  185. if (ex is ExceptionEx)
  186. {
  187. throw;
  188. }
  189. else
  190. {
  191. throw ExceptionEx.ThrowServiceException(ex);
  192. }
  193. }
  194. }
  195. #endregion
  196. }
  197. }