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.
 
 
 
 
 
 

233 lines
6.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.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-07-08 17:19
  16. /// 描 述:教师注册功能开关控制
  17. /// </summary>
  18. public class TeachSwitchService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<TeachSwitchEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var data = this.BaseRepository().FindList<TeachSwitchEntity>();
  31. if (!data.Any(a => a.type == "js"))
  32. {
  33. var jsEntity = new TeachSwitchEntity()
  34. {
  35. status = "0",
  36. type = "js"
  37. };
  38. jsEntity.Create();
  39. this.BaseRepository().Insert(jsEntity);
  40. }
  41. if (!data.Any(a => a.type == "fx"))
  42. {
  43. var fxEntity = new TeachSwitchEntity()
  44. {
  45. status = "0",
  46. type = "fx"
  47. };
  48. fxEntity.Create();
  49. this.BaseRepository().Insert(fxEntity);
  50. }
  51. //网上办事大厅
  52. if (!data.Any(a => a.type == "ssosystem"))
  53. {
  54. var jsEntity = new TeachSwitchEntity()
  55. {
  56. status = "0",
  57. type = "ssosystem"
  58. };
  59. jsEntity.Create();
  60. this.BaseRepository().Insert(jsEntity);
  61. }
  62. var strSql = new StringBuilder();
  63. strSql.Append("SELECT ");
  64. strSql.Append(@"
  65. t.ID,
  66. t.status,
  67. t.type
  68. ");
  69. strSql.Append(" FROM TeachSwitch t ");
  70. strSql.Append(" WHERE 1=1 ");
  71. var queryParam = queryJson.ToJObject();
  72. // 虚拟参数
  73. var dp = new DynamicParameters(new { });
  74. return this.BaseRepository().FindList<TeachSwitchEntity>(strSql.ToString(), dp, pagination);
  75. }
  76. catch (Exception ex)
  77. {
  78. if (ex is ExceptionEx)
  79. {
  80. throw;
  81. }
  82. else
  83. {
  84. throw ExceptionEx.ThrowServiceException(ex);
  85. }
  86. }
  87. }
  88. /// <summary>
  89. /// 获取TeachSwitch表实体数据
  90. /// <param name="keyValue">主键</param>
  91. /// <summary>
  92. /// <returns></returns>
  93. public TeachSwitchEntity GetTeachSwitchEntity(string keyValue)
  94. {
  95. try
  96. {
  97. return this.BaseRepository().FindEntity<TeachSwitchEntity>(keyValue);
  98. }
  99. catch (Exception ex)
  100. {
  101. if (ex is ExceptionEx)
  102. {
  103. throw;
  104. }
  105. else
  106. {
  107. throw ExceptionEx.ThrowServiceException(ex);
  108. }
  109. }
  110. }
  111. internal bool FindFirst(string type)
  112. {
  113. try
  114. {
  115. var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
  116. if (result != null)
  117. {
  118. return result.status == "1" ? true : false;
  119. }
  120. else
  121. {
  122. return false;
  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. internal TeachSwitchEntity GetFirst(string type)
  138. {
  139. try
  140. {
  141. var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
  142. if (result == null)
  143. {
  144. result = new TeachSwitchEntity { status = "0", type = type };
  145. result.Create();
  146. this.BaseRepository().Insert(result);
  147. }
  148. return result;
  149. }
  150. catch (Exception ex)
  151. {
  152. if (ex is ExceptionEx)
  153. {
  154. throw;
  155. }
  156. else
  157. {
  158. throw ExceptionEx.ThrowServiceException(ex);
  159. }
  160. }
  161. }
  162. #endregion
  163. #region 提交数据
  164. /// <summary>
  165. /// 删除实体数据
  166. /// <param name="keyValue">主键</param>
  167. /// <summary>
  168. /// <returns></returns>
  169. public void DeleteEntity(string keyValue)
  170. {
  171. try
  172. {
  173. this.BaseRepository().Delete<TeachSwitchEntity>(t => t.ID == keyValue);
  174. }
  175. catch (Exception ex)
  176. {
  177. if (ex is ExceptionEx)
  178. {
  179. throw;
  180. }
  181. else
  182. {
  183. throw ExceptionEx.ThrowServiceException(ex);
  184. }
  185. }
  186. }
  187. /// <summary>
  188. /// 保存实体数据(新增、修改)
  189. /// <param name="keyValue">主键</param>
  190. /// <summary>
  191. /// <returns></returns>
  192. public void SaveEntity(string keyValue, TeachSwitchEntity entity)
  193. {
  194. try
  195. {
  196. if (!string.IsNullOrEmpty(keyValue))
  197. {
  198. entity.Modify(keyValue);
  199. this.BaseRepository().Update(entity);
  200. }
  201. else
  202. {
  203. entity.Create();
  204. this.BaseRepository().Insert(entity);
  205. }
  206. }
  207. catch (Exception ex)
  208. {
  209. if (ex is ExceptionEx)
  210. {
  211. throw;
  212. }
  213. else
  214. {
  215. throw ExceptionEx.ThrowServiceException(ex);
  216. }
  217. }
  218. }
  219. #endregion
  220. }
  221. }