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.

ScheduleService.cs 4.5 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.OA.Schedule
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创建人:陈彬彬
  15. /// 日 期:2017.07.11
  16. /// 描 述:日程管理
  17. /// </summary>
  18. public class ScheduleService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表分页数据
  23. /// <summary>
  24. /// <param name="pagination">分页参数</param>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<ScheduleEntity> GetPageListByUserId(Pagination pagination, string queryJson, string userId)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT t.* ");
  33. strSql.Append(" FROM LR_OA_Schedule t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!userId.IsEmpty())
  39. {
  40. dp.Add("F_CreateUserId", userId, DbType.String);
  41. strSql.Append(" AND t.F_CreateUserId = @F_CreateUserId ");
  42. }
  43. return this.BaseRepository().FindList<ScheduleEntity>(strSql.ToString(), dp, pagination);
  44. }
  45. catch (Exception ex)
  46. {
  47. if (ex is ExceptionEx)
  48. {
  49. throw;
  50. }
  51. else
  52. {
  53. throw ExceptionEx.ThrowServiceException(ex);
  54. }
  55. }
  56. }
  57. /// <summary>
  58. /// 获取列表
  59. /// </summary>
  60. /// <returns>返回列表</returns>
  61. public IEnumerable<ScheduleEntity> GetList()
  62. {
  63. try
  64. {
  65. return this.BaseRepository().FindList<ScheduleEntity>();
  66. }
  67. catch (Exception ex)
  68. {
  69. if (ex is ExceptionEx)
  70. throw;
  71. else
  72. throw ExceptionEx.ThrowServiceException(ex);
  73. }
  74. }
  75. /// <summary>
  76. /// 获取实体
  77. /// </summary>
  78. /// <param name="keyValue">主键值</param>
  79. /// <returns></returns>
  80. public ScheduleEntity GetEntity(string keyValue)
  81. {
  82. try
  83. {
  84. return this.BaseRepository().FindEntity<ScheduleEntity>(keyValue);
  85. }
  86. catch (Exception ex)
  87. {
  88. if (ex is ExceptionEx)
  89. throw;
  90. else
  91. throw ExceptionEx.ThrowServiceException(ex);
  92. }
  93. }
  94. #endregion
  95. #region 提交数据
  96. /// <summary>
  97. /// 删除数据
  98. /// </summary>
  99. /// <param name="keyValue">主键</param>
  100. public void RemoveForm(string keyValue)
  101. {
  102. try
  103. {
  104. //this.BaseRepository().Delete(keyValue);
  105. this.BaseRepository().Delete<ScheduleEntity>(x => x.F_ScheduleId == keyValue);
  106. }
  107. catch (Exception ex)
  108. {
  109. if (ex is ExceptionEx)
  110. throw;
  111. else
  112. throw ExceptionEx.ThrowServiceException(ex);
  113. }
  114. }
  115. /// <summary>
  116. /// 保存表单(新增、修改)
  117. /// </summary>
  118. /// <param name="keyValue">主键值</param>
  119. /// <param name="entity">实体对象</param>
  120. /// <returns></returns>
  121. public void SaveForm(string keyValue, ScheduleEntity entity)
  122. {
  123. try
  124. {
  125. if (!string.IsNullOrEmpty(keyValue))
  126. {
  127. entity.Modify(keyValue);
  128. this.BaseRepository().Update(entity);
  129. }
  130. else
  131. {
  132. entity.Create();
  133. this.BaseRepository().Insert(entity);
  134. }
  135. }
  136. catch (Exception ex)
  137. {
  138. if (ex is ExceptionEx)
  139. throw;
  140. else
  141. throw ExceptionEx.ThrowServiceException(ex);
  142. }
  143. }
  144. #endregion
  145. }
  146. }