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.
 
 
 
 
 
 

244 lines
7.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.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. //微信快捷登录
  63. if (!data.Any(a => a.type == "wxloginforpc"))
  64. {
  65. var jsEntity = new TeachSwitchEntity()
  66. {
  67. status = "0",
  68. type = "wxloginforpc"
  69. };
  70. jsEntity.Create();
  71. this.BaseRepository().Insert(jsEntity);
  72. }
  73. var strSql = new StringBuilder();
  74. strSql.Append("SELECT ");
  75. strSql.Append(@"
  76. t.ID,
  77. t.status,
  78. t.type
  79. ");
  80. strSql.Append(" FROM TeachSwitch t ");
  81. strSql.Append(" WHERE 1=1 ");
  82. var queryParam = queryJson.ToJObject();
  83. // 虚拟参数
  84. var dp = new DynamicParameters(new { });
  85. return this.BaseRepository().FindList<TeachSwitchEntity>(strSql.ToString(), dp, pagination);
  86. }
  87. catch (Exception ex)
  88. {
  89. if (ex is ExceptionEx)
  90. {
  91. throw;
  92. }
  93. else
  94. {
  95. throw ExceptionEx.ThrowServiceException(ex);
  96. }
  97. }
  98. }
  99. /// <summary>
  100. /// 获取TeachSwitch表实体数据
  101. /// <param name="keyValue">主键</param>
  102. /// <summary>
  103. /// <returns></returns>
  104. public TeachSwitchEntity GetTeachSwitchEntity(string keyValue)
  105. {
  106. try
  107. {
  108. return this.BaseRepository().FindEntity<TeachSwitchEntity>(keyValue);
  109. }
  110. catch (Exception ex)
  111. {
  112. if (ex is ExceptionEx)
  113. {
  114. throw;
  115. }
  116. else
  117. {
  118. throw ExceptionEx.ThrowServiceException(ex);
  119. }
  120. }
  121. }
  122. internal bool FindFirst(string type)
  123. {
  124. try
  125. {
  126. var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
  127. if (result != null)
  128. {
  129. return result.status == "1" ? true : false;
  130. }
  131. else
  132. {
  133. return false;
  134. }
  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. internal TeachSwitchEntity GetFirst(string type)
  149. {
  150. try
  151. {
  152. var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
  153. if (result == null)
  154. {
  155. result = new TeachSwitchEntity { status = "0", type = type };
  156. result.Create();
  157. this.BaseRepository().Insert(result);
  158. }
  159. return result;
  160. }
  161. catch (Exception ex)
  162. {
  163. if (ex is ExceptionEx)
  164. {
  165. throw;
  166. }
  167. else
  168. {
  169. throw ExceptionEx.ThrowServiceException(ex);
  170. }
  171. }
  172. }
  173. #endregion
  174. #region 提交数据
  175. /// <summary>
  176. /// 删除实体数据
  177. /// <param name="keyValue">主键</param>
  178. /// <summary>
  179. /// <returns></returns>
  180. public void DeleteEntity(string keyValue)
  181. {
  182. try
  183. {
  184. this.BaseRepository().Delete<TeachSwitchEntity>(t => t.ID == keyValue);
  185. }
  186. catch (Exception ex)
  187. {
  188. if (ex is ExceptionEx)
  189. {
  190. throw;
  191. }
  192. else
  193. {
  194. throw ExceptionEx.ThrowServiceException(ex);
  195. }
  196. }
  197. }
  198. /// <summary>
  199. /// 保存实体数据(新增、修改)
  200. /// <param name="keyValue">主键</param>
  201. /// <summary>
  202. /// <returns></returns>
  203. public void SaveEntity(string keyValue, TeachSwitchEntity entity)
  204. {
  205. try
  206. {
  207. if (!string.IsNullOrEmpty(keyValue))
  208. {
  209. entity.Modify(keyValue);
  210. this.BaseRepository().Update(entity);
  211. }
  212. else
  213. {
  214. entity.Create();
  215. this.BaseRepository().Insert(entity);
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. if (ex is ExceptionEx)
  221. {
  222. throw;
  223. }
  224. else
  225. {
  226. throw ExceptionEx.ThrowServiceException(ex);
  227. }
  228. }
  229. }
  230. #endregion
  231. }
  232. }