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.
 
 
 
 
 
 

157 lines
4.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-11-11 14:37
  15. /// 描 述:职业技能证书管理
  16. /// </summary>
  17. public class CertificateManageService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<CertificateManageEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.ID,
  33. t.Code,
  34. t.Name
  35. ");
  36. strSql.Append(" FROM CertificateManage t ");
  37. strSql.Append(" WHERE 1=1 ");
  38. var queryParam = queryJson.ToJObject();
  39. // 虚拟参数
  40. var dp = new DynamicParameters(new { });
  41. if (!queryParam["Code"].IsEmpty())
  42. {
  43. dp.Add("Code", "%" + queryParam["Code"].ToString() + "%", DbType.String);
  44. strSql.Append(" AND t.Code Like @Code ");
  45. }
  46. if (!queryParam["Name"].IsEmpty())
  47. {
  48. dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String);
  49. strSql.Append(" AND t.Name Like @Name ");
  50. }
  51. return this.BaseRepository("CollegeMIS").FindList<CertificateManageEntity>(strSql.ToString(),dp, pagination);
  52. }
  53. catch (Exception ex)
  54. {
  55. if (ex is ExceptionEx)
  56. {
  57. throw;
  58. }
  59. else
  60. {
  61. throw ExceptionEx.ThrowServiceException(ex);
  62. }
  63. }
  64. }
  65. /// <summary>
  66. /// 获取CertificateManage表实体数据
  67. /// <param name="keyValue">主键</param>
  68. /// <summary>
  69. /// <returns></returns>
  70. public CertificateManageEntity GetCertificateManageEntity(string keyValue)
  71. {
  72. try
  73. {
  74. return this.BaseRepository("CollegeMIS").FindEntity<CertificateManageEntity>(keyValue);
  75. }
  76. catch (Exception ex)
  77. {
  78. if (ex is ExceptionEx)
  79. {
  80. throw;
  81. }
  82. else
  83. {
  84. throw ExceptionEx.ThrowServiceException(ex);
  85. }
  86. }
  87. }
  88. #endregion
  89. #region 提交数据
  90. /// <summary>
  91. /// 删除实体数据
  92. /// <param name="keyValue">主键</param>
  93. /// <summary>
  94. /// <returns></returns>
  95. public void DeleteEntity(string keyValue)
  96. {
  97. try
  98. {
  99. this.BaseRepository("CollegeMIS").Delete<CertificateManageEntity>(t=>t.ID == keyValue);
  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. /// <summary>
  114. /// 保存实体数据(新增、修改)
  115. /// <param name="keyValue">主键</param>
  116. /// <summary>
  117. /// <returns></returns>
  118. public void SaveEntity(string keyValue, CertificateManageEntity entity)
  119. {
  120. try
  121. {
  122. if (!string.IsNullOrEmpty(keyValue))
  123. {
  124. entity.Modify(keyValue);
  125. this.BaseRepository("CollegeMIS").Update(entity);
  126. }
  127. else
  128. {
  129. entity.Create();
  130. this.BaseRepository("CollegeMIS").Insert(entity);
  131. }
  132. }
  133. catch (Exception ex)
  134. {
  135. if (ex is ExceptionEx)
  136. {
  137. throw;
  138. }
  139. else
  140. {
  141. throw ExceptionEx.ThrowServiceException(ex);
  142. }
  143. }
  144. }
  145. #endregion
  146. }
  147. }