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.

CodeSchemaService.cs 5.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.Base.CodeSchemaModule
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架
  12. /// Copyright (c) 2013-2018 上海力软信息技术有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-03-01 11:09
  15. /// 描 述:代码模板
  16. /// </summary>
  17. public class CodeSchemaService : 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<LR_Base_CodeSchemaEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.F_Id,
  34. t.F_Name,
  35. t.F_Catalog,
  36. t.F_Type,
  37. t.F_Description
  38. ");
  39. strSql.Append(" FROM LR_Base_CodeSchema t ");
  40. strSql.Append(" WHERE 1=1 ");
  41. var queryParam = queryJson.ToJObject();
  42. // 虚拟参数
  43. var dp = new DynamicParameters(new { });
  44. if (!queryParam["F_Name"].IsEmpty())
  45. {
  46. dp.Add("F_Name", "%" + queryParam["F_Name"].ToString() + "%", DbType.String);
  47. strSql.Append(" AND t.F_Name Like @F_Name ");
  48. }
  49. if (!queryParam["F_Catalog"].IsEmpty())
  50. {
  51. dp.Add("F_Catalog",queryParam["F_Catalog"].ToString(), DbType.String);
  52. strSql.Append(" AND t.F_Catalog = @F_Catalog ");
  53. }
  54. return this.BaseRepository().FindList<LR_Base_CodeSchemaEntity>(strSql.ToString(),dp, pagination);
  55. }
  56. catch (Exception ex)
  57. {
  58. if (ex is ExceptionEx)
  59. {
  60. throw;
  61. }
  62. else
  63. {
  64. throw ExceptionEx.ThrowServiceException(ex);
  65. }
  66. }
  67. }
  68. /// <summary>
  69. /// 获取LR_Base_CodeSchema表实体数据
  70. /// </summary>
  71. /// <param name="keyValue">主键</param>
  72. /// <returns></returns>
  73. public LR_Base_CodeSchemaEntity GetLR_Base_CodeSchemaEntity(string keyValue)
  74. {
  75. try
  76. {
  77. return this.BaseRepository().FindEntity<LR_Base_CodeSchemaEntity>(keyValue);
  78. }
  79. catch (Exception ex)
  80. {
  81. if (ex is ExceptionEx)
  82. {
  83. throw;
  84. }
  85. else
  86. {
  87. throw ExceptionEx.ThrowServiceException(ex);
  88. }
  89. }
  90. }
  91. /// <summary>
  92. /// 获取树形数据
  93. /// </summary>
  94. /// <returns></returns>
  95. public DataTable GetSqlTree()
  96. {
  97. try
  98. {
  99. return this.BaseRepository().FindTable(" select * from lr_base_dataitemdetail ");
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowServiceException(ex);
  110. }
  111. }
  112. }
  113. #endregion
  114. #region 提交数据
  115. /// <summary>
  116. /// 删除实体数据
  117. /// </summary>
  118. /// <param name="keyValue">主键</param>
  119. /// <returns></returns>
  120. public void DeleteEntity(string keyValue)
  121. {
  122. try
  123. {
  124. this.BaseRepository().Delete<LR_Base_CodeSchemaEntity>(t=>t.F_Id == keyValue);
  125. }
  126. catch (Exception ex)
  127. {
  128. if (ex is ExceptionEx)
  129. {
  130. throw;
  131. }
  132. else
  133. {
  134. throw ExceptionEx.ThrowServiceException(ex);
  135. }
  136. }
  137. }
  138. /// <summary>
  139. /// 保存实体数据(新增、修改)
  140. /// </summary>
  141. /// <param name="keyValue">主键</param>
  142. /// <param name="entity">实体</param>
  143. /// <returns></returns>
  144. public void SaveEntity(string keyValue, LR_Base_CodeSchemaEntity entity)
  145. {
  146. try
  147. {
  148. if (!string.IsNullOrEmpty(keyValue))
  149. {
  150. entity.Modify(keyValue);
  151. this.BaseRepository().Update(entity);
  152. }
  153. else
  154. {
  155. entity.Create();
  156. this.BaseRepository().Insert(entity);
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. if (ex is ExceptionEx)
  162. {
  163. throw;
  164. }
  165. else
  166. {
  167. throw ExceptionEx.ThrowServiceException(ex);
  168. }
  169. }
  170. }
  171. #endregion
  172. }
  173. }