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.
 
 
 
 
 
 

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