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.
 
 
 
 
 
 

161 lines
4.8 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-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2020-02-07 18:32
  15. /// 描 述:排课对接管理
  16. /// </summary>
  17. public class ArrangeLessonButtService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<ArrangeLessonButtEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* ");
  31. strSql.Append(" FROM ArrangeLessonButt t ");
  32. strSql.Append(" WHERE 1=1 ");
  33. var queryParam = queryJson.ToJObject();
  34. // 虚拟参数
  35. var dp = new DynamicParameters(new { });
  36. if (!queryParam["ResetTable"].IsEmpty())
  37. {
  38. dp.Add("ResetTable", queryParam["ResetTable"].ToString(), DbType.String);
  39. strSql.Append(" AND t.ResetTable = @ResetTable ");
  40. }
  41. return this.BaseRepository("CollegeMIS").FindList<ArrangeLessonButtEntity>(strSql.ToString(), dp, pagination);
  42. }
  43. catch (Exception ex)
  44. {
  45. if (ex is ExceptionEx)
  46. {
  47. throw;
  48. }
  49. else
  50. {
  51. throw ExceptionEx.ThrowServiceException(ex);
  52. }
  53. }
  54. }
  55. /// <summary>
  56. /// 获取ArrangeLessonButt表实体数据
  57. /// <param name="keyValue">主键</param>
  58. /// <summary>
  59. /// <returns></returns>
  60. public ArrangeLessonButtEntity GetArrangeLessonButtEntity(string keyValue)
  61. {
  62. try
  63. {
  64. return this.BaseRepository("CollegeMIS").FindEntity<ArrangeLessonButtEntity>(keyValue);
  65. }
  66. catch (Exception ex)
  67. {
  68. if (ex is ExceptionEx)
  69. {
  70. throw;
  71. }
  72. else
  73. {
  74. throw ExceptionEx.ThrowServiceException(ex);
  75. }
  76. }
  77. }
  78. #endregion
  79. #region 提交数据
  80. /// <summary>
  81. /// 删除实体数据
  82. /// <param name="keyValue">主键</param>
  83. /// <summary>
  84. /// <returns></returns>
  85. public void DeleteEntity(string keyValue)
  86. {
  87. try
  88. {
  89. this.BaseRepository("CollegeMIS").Delete<ArrangeLessonButtEntity>(t => t.Id == keyValue);
  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. /// <param name="keyValue">主键</param>
  106. /// <summary>
  107. /// <returns></returns>
  108. public void SaveEntity(string keyValue, ArrangeLessonButtEntity entity)
  109. {
  110. var db = this.BaseRepository("CollegeMIS");
  111. var db2 = this.BaseRepository();
  112. db.BeginTrans();
  113. try
  114. {
  115. if (!string.IsNullOrEmpty(keyValue))
  116. {
  117. entity.Modify(keyValue);
  118. db.Update(entity);
  119. }
  120. else
  121. {
  122. entity.Create();
  123. db.Insert(entity);
  124. }
  125. //修改基础数据表的同步状态
  126. if (entity.ResetTable == "LR_Base_Company")
  127. {
  128. db2.ExecuteBySql("update LR_Base_Company set SyncFlag='false' ");
  129. }
  130. else
  131. {
  132. db.ExecuteBySql("update " + entity.ResetTable + " set SyncFlag='false' ");
  133. }
  134. db.Commit();
  135. }
  136. catch (Exception ex)
  137. {
  138. if (ex is ExceptionEx)
  139. {
  140. throw;
  141. }
  142. else
  143. {
  144. throw ExceptionEx.ThrowServiceException(ex);
  145. }
  146. }
  147. }
  148. #endregion
  149. }
  150. }