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.
 
 
 
 
 
 

264 lines
8.0 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. if (!data.Any(a => a.type == "modifypwdfirstday"))
  74. {
  75. var jsEntity = new TeachSwitchEntity()
  76. {
  77. status = "0",
  78. type = "modifypwdfirstday"
  79. };
  80. jsEntity.Create();
  81. this.BaseRepository().Insert(jsEntity);
  82. }
  83. if (!data.Any(a => a.type == "modifypwdtip"))
  84. {
  85. var jsEntity = new TeachSwitchEntity()
  86. {
  87. status = "0",
  88. type = "modifypwdtip"
  89. };
  90. jsEntity.Create();
  91. this.BaseRepository().Insert(jsEntity);
  92. }
  93. var strSql = new StringBuilder();
  94. strSql.Append("SELECT ");
  95. strSql.Append(@"
  96. t.ID,
  97. t.status,
  98. t.type
  99. ");
  100. strSql.Append(" FROM TeachSwitch t ");
  101. strSql.Append(" WHERE 1=1 ");
  102. var queryParam = queryJson.ToJObject();
  103. // 虚拟参数
  104. var dp = new DynamicParameters(new { });
  105. return this.BaseRepository().FindList<TeachSwitchEntity>(strSql.ToString(), dp, pagination);
  106. }
  107. catch (Exception ex)
  108. {
  109. if (ex is ExceptionEx)
  110. {
  111. throw;
  112. }
  113. else
  114. {
  115. throw ExceptionEx.ThrowServiceException(ex);
  116. }
  117. }
  118. }
  119. /// <summary>
  120. /// 获取TeachSwitch表实体数据
  121. /// <param name="keyValue">主键</param>
  122. /// <summary>
  123. /// <returns></returns>
  124. public TeachSwitchEntity GetTeachSwitchEntity(string keyValue)
  125. {
  126. try
  127. {
  128. return this.BaseRepository().FindEntity<TeachSwitchEntity>(keyValue);
  129. }
  130. catch (Exception ex)
  131. {
  132. if (ex is ExceptionEx)
  133. {
  134. throw;
  135. }
  136. else
  137. {
  138. throw ExceptionEx.ThrowServiceException(ex);
  139. }
  140. }
  141. }
  142. internal bool FindFirst(string type)
  143. {
  144. try
  145. {
  146. var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
  147. if (result != null)
  148. {
  149. return result.status == "1" ? true : false;
  150. }
  151. else
  152. {
  153. return false;
  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. internal TeachSwitchEntity GetFirst(string type)
  169. {
  170. try
  171. {
  172. var result = this.BaseRepository().FindList<TeachSwitchEntity>(a => a.type == type).FirstOrDefault();
  173. if (result == null)
  174. {
  175. result = new TeachSwitchEntity { status = "0", type = type };
  176. result.Create();
  177. this.BaseRepository().Insert(result);
  178. }
  179. return result;
  180. }
  181. catch (Exception ex)
  182. {
  183. if (ex is ExceptionEx)
  184. {
  185. throw;
  186. }
  187. else
  188. {
  189. throw ExceptionEx.ThrowServiceException(ex);
  190. }
  191. }
  192. }
  193. #endregion
  194. #region 提交数据
  195. /// <summary>
  196. /// 删除实体数据
  197. /// <param name="keyValue">主键</param>
  198. /// <summary>
  199. /// <returns></returns>
  200. public void DeleteEntity(string keyValue)
  201. {
  202. try
  203. {
  204. this.BaseRepository().Delete<TeachSwitchEntity>(t => t.ID == keyValue);
  205. }
  206. catch (Exception ex)
  207. {
  208. if (ex is ExceptionEx)
  209. {
  210. throw;
  211. }
  212. else
  213. {
  214. throw ExceptionEx.ThrowServiceException(ex);
  215. }
  216. }
  217. }
  218. /// <summary>
  219. /// 保存实体数据(新增、修改)
  220. /// <param name="keyValue">主键</param>
  221. /// <summary>
  222. /// <returns></returns>
  223. public void SaveEntity(string keyValue, TeachSwitchEntity entity)
  224. {
  225. try
  226. {
  227. if (!string.IsNullOrEmpty(keyValue))
  228. {
  229. entity.Modify(keyValue);
  230. this.BaseRepository().Update(entity);
  231. }
  232. else
  233. {
  234. entity.Create();
  235. this.BaseRepository().Insert(entity);
  236. }
  237. }
  238. catch (Exception ex)
  239. {
  240. if (ex is ExceptionEx)
  241. {
  242. throw;
  243. }
  244. else
  245. {
  246. throw ExceptionEx.ThrowServiceException(ex);
  247. }
  248. }
  249. }
  250. #endregion
  251. }
  252. }