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.

LostArticleInfoService.cs 6.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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.OA
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-05-20 15:14
  15. /// 描 述:失物招领
  16. /// </summary>
  17. public class LostArticleInfoService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">查询参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<LostArticleInfoEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"t.*
  33. ");
  34. strSql.Append(" FROM LostArticleInfo t ");
  35. strSql.Append(" WHERE 1=1 ");
  36. var queryParam = queryJson.ToJObject();
  37. // 虚拟参数
  38. var dp = new DynamicParameters(new { });
  39. if (queryParam.HasValues)
  40. {
  41. if (!queryParam["F_FullHead"].IsEmpty())
  42. {
  43. dp.Add("F_FullHead", "%" + queryParam["F_FullHead"].ToString() + "%", DbType.String);
  44. strSql.Append(" AND t.F_FullHead like @F_FullHead ");
  45. }
  46. }
  47. return this.BaseRepository().FindList<LostArticleInfoEntity>(strSql.ToString(), dp, pagination);
  48. }
  49. catch (Exception ex)
  50. {
  51. if (ex is ExceptionEx)
  52. {
  53. throw;
  54. }
  55. else
  56. {
  57. throw ExceptionEx.ThrowServiceException(ex);
  58. }
  59. }
  60. }
  61. /// <summary>
  62. /// 获取LostArticleInfo表实体数据
  63. /// </summary>
  64. /// <param name="keyValue">主键</param>
  65. /// <returns></returns>
  66. public LostArticleInfoEntity GetLostArticleInfoEntity(string keyValue)
  67. {
  68. try
  69. {
  70. return this.BaseRepository().FindEntity<LostArticleInfoEntity>(keyValue);
  71. }
  72. catch (Exception ex)
  73. {
  74. if (ex is ExceptionEx)
  75. {
  76. throw;
  77. }
  78. else
  79. {
  80. throw ExceptionEx.ThrowServiceException(ex);
  81. }
  82. }
  83. }
  84. #endregion
  85. #region 提交数据
  86. /// <summary>
  87. /// 删除实体数据
  88. /// </summary>
  89. /// <param name="keyValue">主键</param>
  90. public void DeleteEntity(string keyValue)
  91. {
  92. try
  93. {
  94. this.BaseRepository().Delete<LostArticleInfoEntity>(t => t.F_LId == keyValue);
  95. }
  96. catch (Exception ex)
  97. {
  98. if (ex is ExceptionEx)
  99. {
  100. throw;
  101. }
  102. else
  103. {
  104. throw ExceptionEx.ThrowServiceException(ex);
  105. }
  106. }
  107. }
  108. /// <summary>
  109. /// 保存实体数据(新增、修改)
  110. /// </summary>
  111. /// <param name="keyValue">主键</param>
  112. /// <param name="entity">实体</param>
  113. public void SaveEntity(string keyValue, LostArticleInfoEntity entity)
  114. {
  115. try
  116. {
  117. if (!string.IsNullOrEmpty(keyValue))
  118. {
  119. entity.Modify(keyValue);
  120. this.BaseRepository().Update(entity);
  121. }
  122. else
  123. {
  124. entity.Create();
  125. this.BaseRepository().Insert(entity);
  126. }
  127. }
  128. catch (Exception ex)
  129. {
  130. if (ex is ExceptionEx)
  131. {
  132. throw;
  133. }
  134. else
  135. {
  136. throw ExceptionEx.ThrowServiceException(ex);
  137. }
  138. }
  139. }
  140. /// <summary>
  141. /// 发布
  142. /// </summary>
  143. /// <param name="keyValue">主键</param>
  144. public void PublishForm(string keyValue)
  145. {
  146. try
  147. {
  148. //草稿0、待认领1、已认领2
  149. string sql = $"update LostArticleInfo set F_State=1 where F_LId='{keyValue}'";
  150. this.BaseRepository().ExecuteBySql(sql);
  151. }
  152. catch (Exception ex)
  153. {
  154. if (ex is ExceptionEx)
  155. {
  156. throw;
  157. }
  158. else
  159. {
  160. throw ExceptionEx.ThrowServiceException(ex);
  161. }
  162. }
  163. }
  164. /// <summary>
  165. /// 认领
  166. /// </summary>
  167. /// <param name="keyValue">主键</param>
  168. public void ClaimForm(string keyValue, LostArticleInfoEntity entity)
  169. {
  170. try
  171. {
  172. //草稿0、待认领1、已认领2
  173. UserInfo userInfo = LoginUserInfo.Get();
  174. string sql = $@"update LostArticleInfo set F_State=2,F_User='{entity.F_User}',F_UserTime='{entity.F_UserTime}',F_ClaimImage='{entity.F_ClaimImage}',
  175. F_ManageUserId='{userInfo.userId}',F_ManageUserName='{userInfo.realName}' where F_LId='{keyValue}'";
  176. this.BaseRepository().ExecuteBySql(sql);
  177. }
  178. catch (Exception ex)
  179. {
  180. if (ex is ExceptionEx)
  181. {
  182. throw;
  183. }
  184. else
  185. {
  186. throw ExceptionEx.ThrowServiceException(ex);
  187. }
  188. }
  189. }
  190. /// <summary>
  191. /// 撤下
  192. /// </summary>
  193. /// <param name="keyValue">主键</param>
  194. public void CancleForm(string keyValue)
  195. {
  196. try
  197. {
  198. //草稿0、待认领1、已认领2
  199. string sql = $"update LostArticleInfo set F_State=0 where F_LId='{keyValue}'";
  200. this.BaseRepository().ExecuteBySql(sql);
  201. }
  202. catch (Exception ex)
  203. {
  204. if (ex is ExceptionEx)
  205. {
  206. throw;
  207. }
  208. else
  209. {
  210. throw ExceptionEx.ThrowServiceException(ex);
  211. }
  212. }
  213. }
  214. #endregion
  215. }
  216. }