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.
 
 
 
 
 
 

149 lines
4.5 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-05 11:38
  15. /// 描 述:社团签到
  16. /// </summary>
  17. public class CommunityAttendanceService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<CommunityAttendanceEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* ");
  31. strSql.Append(" FROM CommunityAttendance t ");
  32. strSql.Append(" WHERE 1=1 ");
  33. var queryParam = queryJson.ToJObject();
  34. // 虚拟参数
  35. var dp = new DynamicParameters(new { });
  36. return this.BaseRepository("CollegeMIS").FindList<CommunityAttendanceEntity>(strSql.ToString(), dp, pagination);
  37. }
  38. catch (Exception ex)
  39. {
  40. if (ex is ExceptionEx)
  41. {
  42. throw;
  43. }
  44. else
  45. {
  46. throw ExceptionEx.ThrowServiceException(ex);
  47. }
  48. }
  49. }
  50. /// <summary>
  51. /// 获取CommunityAttendance表实体数据
  52. /// <param name="keyValue">主键</param>
  53. /// <summary>
  54. /// <returns></returns>
  55. public CommunityAttendanceEntity GetCommunityAttendanceEntity(string keyValue)
  56. {
  57. try
  58. {
  59. return this.BaseRepository("CollegeMIS").FindEntity<CommunityAttendanceEntity>(keyValue);
  60. }
  61. catch (Exception ex)
  62. {
  63. if (ex is ExceptionEx)
  64. {
  65. throw;
  66. }
  67. else
  68. {
  69. throw ExceptionEx.ThrowServiceException(ex);
  70. }
  71. }
  72. }
  73. #endregion
  74. #region 提交数据
  75. /// <summary>
  76. /// 删除实体数据
  77. /// <param name="keyValue">主键</param>
  78. /// <summary>
  79. /// <returns></returns>
  80. public void DeleteEntity(string keyValue)
  81. {
  82. try
  83. {
  84. this.BaseRepository("CollegeMIS").Delete<CommunityAttendanceEntity>(t => t.Id == keyValue);
  85. }
  86. catch (Exception ex)
  87. {
  88. if (ex is ExceptionEx)
  89. {
  90. throw;
  91. }
  92. else
  93. {
  94. throw ExceptionEx.ThrowServiceException(ex);
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// 保存实体数据(新增、修改)
  100. /// <param name="keyValue">主键</param>
  101. /// <summary>
  102. /// <returns></returns>
  103. public void SaveEntity(string keyValue, CommunityAttendanceEntity entity)
  104. {
  105. try
  106. {
  107. var model = this.BaseRepository("CollegeMIS").FindEntity<CommunityAttendanceEntity>(x => x.CommunityId == entity.CommunityId && x.StuNo == entity.StuNo && x.Type == entity.Type && x.Date == entity.Date);
  108. if (!string.IsNullOrEmpty(keyValue))
  109. {
  110. if (model == null || (model != null && model.Id == keyValue))
  111. {
  112. entity.Modify(keyValue);
  113. this.BaseRepository("CollegeMIS").Update(entity);
  114. }
  115. }
  116. else
  117. {
  118. if (model == null)
  119. {
  120. entity.Create();
  121. this.BaseRepository("CollegeMIS").Insert(entity);
  122. }
  123. }
  124. }
  125. catch (Exception ex)
  126. {
  127. if (ex is ExceptionEx)
  128. {
  129. throw;
  130. }
  131. else
  132. {
  133. throw ExceptionEx.ThrowServiceException(ex);
  134. }
  135. }
  136. }
  137. #endregion
  138. }
  139. }