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.
 
 
 
 
 
 

293 lines
8.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.Text;
  8. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-03-06 17:17
  15. /// 描 述:查看日志
  16. /// </summary>
  17. public class JournalReceiveService : RepositoryFactory
  18. {
  19. #region 构造函数和属性
  20. private string fieldSql;
  21. public JournalReceiveService()
  22. {
  23. fieldSql=@"
  24. t.JournalReceiveId,
  25. t.JTitle,
  26. t.JTypeId,
  27. t.JSenderId,
  28. t.JSender,
  29. t.JReceiveId,
  30. t.JReceive,
  31. t.JIsRead,
  32. t.JSendTime
  33. ";
  34. }
  35. #endregion
  36. #region 获取数据
  37. /// <summary>
  38. /// 获取列表数据
  39. /// <summary>
  40. /// <returns></returns>
  41. public IEnumerable<JournalReceiveEntity> GetPageList(Pagination pagination, string queryJson)
  42. {
  43. try
  44. {
  45. var strSql = new StringBuilder();
  46. strSql.Append("SELECT ");
  47. strSql.Append(fieldSql);
  48. strSql.Append(" FROM JournalReceive t ");
  49. strSql.Append(" WHERE 1=1 ");
  50. var queryParam = queryJson.ToJObject();
  51. // 虚拟参数
  52. var dp = new DynamicParameters(new { });
  53. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  54. {
  55. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  56. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  57. strSql.Append(" AND ( JSendTime >= @startTime AND JSendTime <= @endTime ) ");
  58. }
  59. if (!queryParam["keyword"].IsEmpty())
  60. {
  61. dp.Add("keyword", "%" + queryParam["keyword"].ToString() + "%", DbType.String);
  62. strSql.Append(" AND JTitle Like @keyword ");
  63. }
  64. if (!queryParam["userId"].IsEmpty())
  65. {
  66. dp.Add("userId", "" + queryParam["userId"].ToString() + "", DbType.String);
  67. strSql.Append(" AND JReceiveId=@userId ");
  68. }
  69. return this.BaseRepository().FindList<JournalReceiveEntity>(strSql.ToString(),dp,pagination);
  70. }
  71. catch (Exception ex)
  72. {
  73. if (ex is ExceptionEx)
  74. {
  75. throw;
  76. }
  77. else
  78. {
  79. throw ExceptionEx.ThrowServiceException(ex);
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// 获取实体数据
  85. /// <param name="keyValue">主键</param>
  86. /// <summary>
  87. /// <returns></returns>
  88. public JournalReceiveEntity GetEntity(string keyValue)
  89. {
  90. try
  91. {
  92. return this.BaseRepository().FindEntity<JournalReceiveEntity>(keyValue);
  93. }
  94. catch (Exception ex)
  95. {
  96. if (ex is ExceptionEx)
  97. {
  98. throw;
  99. }
  100. else
  101. {
  102. throw ExceptionEx.ThrowServiceException(ex);
  103. }
  104. }
  105. }
  106. /// <summary>
  107. /// 获取页面显示列表数据
  108. /// <summary>
  109. /// <param name="queryJson">查询参数</param>
  110. /// <returns></returns>
  111. public IEnumerable<JournalReceiveEntity> GetList(string queryJson)
  112. {
  113. try
  114. {
  115. var strSql = new StringBuilder();
  116. strSql.Append("SELECT ");
  117. strSql.Append(@"
  118. t.JournalReceiveId,
  119. t.JSender,
  120. t.JTitle,
  121. t.JTypeId,
  122. t.JContent,
  123. t.JSendTime
  124. ");
  125. strSql.Append(" FROM JournalReceive t ");
  126. strSql.Append(" WHERE 1=1 ");
  127. var queryParam = queryJson.ToJObject();
  128. // 虚拟参数
  129. var dp = new DynamicParameters(new { });
  130. return this.BaseRepository().FindList<JournalReceiveEntity>(strSql.ToString(), dp);
  131. }
  132. catch (Exception ex)
  133. {
  134. if (ex is ExceptionEx)
  135. {
  136. throw;
  137. }
  138. else
  139. {
  140. throw ExceptionEx.ThrowServiceException(ex);
  141. }
  142. }
  143. }
  144. /// <summary>
  145. /// 获取JournalReceive表实体数据
  146. /// <param name="keyValue">主键</param>
  147. /// <summary>
  148. /// <returns></returns>
  149. public JournalReceiveEntity GetJournalReceiveEntity(string keyValue)
  150. {
  151. try
  152. {
  153. return this.BaseRepository().FindEntity<JournalReceiveEntity>(keyValue);
  154. }
  155. catch (Exception ex)
  156. {
  157. if (ex is ExceptionEx)
  158. {
  159. throw;
  160. }
  161. else
  162. {
  163. throw ExceptionEx.ThrowServiceException(ex);
  164. }
  165. }
  166. }
  167. #endregion
  168. #region 提交数据
  169. /// <summary>
  170. /// 删除实体数据
  171. /// <param name="keyValue">主键</param>
  172. /// <summary>
  173. /// <returns></returns>
  174. public void DeleteEntity(string keyValue)
  175. {
  176. try
  177. {
  178. this.BaseRepository().Delete<JournalReceiveEntity>(t=>t.JournalReceiveId == keyValue);
  179. }
  180. catch (Exception ex)
  181. {
  182. if (ex is ExceptionEx)
  183. {
  184. throw;
  185. }
  186. else
  187. {
  188. throw ExceptionEx.ThrowServiceException(ex);
  189. }
  190. }
  191. }
  192. /// <summary>
  193. /// 保存实体数据(新增、修改)
  194. /// <param name="keyValue">主键</param>
  195. /// <summary>
  196. /// <returns></returns>
  197. public void SaveEntity(string keyValue, JournalReceiveEntity entity)
  198. {
  199. try
  200. {
  201. if (!string.IsNullOrEmpty(keyValue))
  202. {
  203. entity.Modify(keyValue);
  204. this.BaseRepository().Update(entity);
  205. }
  206. else
  207. {
  208. entity.Create();
  209. this.BaseRepository().Insert(entity);
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. if (ex is ExceptionEx)
  215. {
  216. throw;
  217. }
  218. else
  219. {
  220. throw ExceptionEx.ThrowServiceException(ex);
  221. }
  222. }
  223. }
  224. /// <summary>
  225. /// 保存实体数据(新增、修改)
  226. /// <param name="keyValue">主键</param>
  227. /// <summary>
  228. /// <returns></returns>
  229. public void SaveEntity(UserInfo userInfo, string keyValue, JournalReceiveEntity entity)
  230. {
  231. try
  232. {
  233. if (!string.IsNullOrEmpty(keyValue))
  234. {
  235. entity.Modify(keyValue, userInfo);
  236. this.BaseRepository().Update(entity);
  237. }
  238. else
  239. {
  240. entity.Create(userInfo);
  241. this.BaseRepository().Insert(entity);
  242. }
  243. }
  244. catch (Exception ex)
  245. {
  246. if (ex is ExceptionEx)
  247. {
  248. throw;
  249. }
  250. else
  251. {
  252. throw ExceptionEx.ThrowServiceException(ex);
  253. }
  254. }
  255. }
  256. public void Read(string keyValue)
  257. {
  258. try
  259. {
  260. this.BaseRepository().ExecuteBySql("update JournalReceive set JIsRead=1 where JournalReceiveId='" + keyValue + "'", null);
  261. }
  262. catch (Exception ex)
  263. {
  264. if (ex is ExceptionEx)
  265. {
  266. throw;
  267. }
  268. else
  269. {
  270. throw ExceptionEx.ThrowServiceException(ex);
  271. }
  272. }
  273. }
  274. #endregion
  275. }
  276. }