Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

180 righe
5.7 KiB

  1. using System;
  2. using Nancy;
  3. using Learun.Util;
  4. using System.Collections.Generic;
  5. using Learun.Application.TwoDevelopment.EducationalAdministration;
  6. namespace Learun.Application.WebApi
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创 建:超级管理员
  12. /// 日 期:2021-07-23 10:15
  13. /// 描 述:学生请销假
  14. /// </summary>
  15. public class DtStuLeaveApi : BaseApi
  16. {
  17. private DtStuLeaveIBLL dtStuLeaveIBLL = new DtStuLeaveBLL();
  18. /// <summary>
  19. /// 注册接口
  20. /// <summary>
  21. public DtStuLeaveApi()
  22. : base("/Learun/EducationalAdministration/DtStuLeave")
  23. {
  24. Get["/pagelist"] = GetPageList;
  25. Get["/list"] = GetList;
  26. Get["/form"] = GetForm;
  27. Post["/delete"] = DeleteForm;
  28. Post["/save"] = SaveForm;
  29. Post["/submit"] = CancelFrom;
  30. //Post["/cancel"] = CancelFrom;
  31. }
  32. #region 获取数据
  33. /// <summary>
  34. /// 获取页面显示列表分页数据
  35. /// <summary>
  36. /// <param name="_"></param>
  37. /// <returns></returns>
  38. public Response GetPageList(dynamic _)
  39. {
  40. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  41. var data = dtStuLeaveIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  42. var jsonData = new
  43. {
  44. rows = data,
  45. total = parameter.pagination.total,
  46. page = parameter.pagination.page,
  47. records = parameter.pagination.records
  48. };
  49. return Success(jsonData);
  50. }
  51. /// <summary>
  52. /// 获取页面显示列表数据
  53. /// <summary>
  54. /// <param name="_"></param>
  55. /// <returns></returns>
  56. public Response GetList(dynamic _)
  57. {
  58. string queryJson = this.GetReqData();
  59. var data = dtStuLeaveIBLL.GetList(queryJson);
  60. return Success(data);
  61. }
  62. /// <summary>
  63. /// 获取表单数据
  64. /// <summary>
  65. /// <param name="_"></param>
  66. /// <returns></returns>
  67. public Response GetForm(dynamic _)
  68. {
  69. string keyValue = this.GetReqData();
  70. var DtStuLeaveData = dtStuLeaveIBLL.GetDtStuLeaveEntity(keyValue);
  71. var jsonData = new
  72. {
  73. DtStuLeave = DtStuLeaveData,
  74. };
  75. return Success(jsonData);
  76. }
  77. #endregion
  78. #region 提交数据
  79. /// <summary>
  80. /// 删除实体数据
  81. /// <param name="_"></param>
  82. /// <summary>
  83. /// <returns></returns>
  84. public Response DeleteForm(dynamic _)
  85. {
  86. string keyValue = this.GetReqData();
  87. dtStuLeaveIBLL.DeleteEntity(keyValue);
  88. return Success("删除成功!");
  89. }
  90. /// <summary>
  91. /// 保存实体数据(新增、修改)
  92. /// <param name="_"></param>
  93. /// <summary>
  94. /// <returns></returns>
  95. public Response SaveForm(dynamic _)
  96. {
  97. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  98. DtStuLeaveEntity entity = parameter.strEntity.ToObject<DtStuLeaveEntity>();
  99. if (entity.BeginDate < entity.EndDate)
  100. {
  101. TimeSpan ts = Convert.ToDateTime(entity.EndDate) - Convert.ToDateTime(entity.BeginDate);
  102. if (ts.Hours < 12)
  103. {
  104. entity.LeaveDay = ("0.5").ToDecimal();
  105. }
  106. else if (ts.Hours >= 12 && ts.Hours <= 24)
  107. {
  108. entity.LeaveDay = 1;
  109. }
  110. else
  111. {
  112. entity.LeaveDay = ts.Days;
  113. }
  114. entity.SchemeCode = "DtStuLeave";
  115. var userinfo = LoginUserInfo.Get();
  116. entity.CreateUserId = userinfo.userId;
  117. if (string.IsNullOrEmpty(parameter.keyValue))
  118. {
  119. entity.FlowNo = "0";
  120. entity.LeaveAddTime = DateTime.Now;
  121. }
  122. dtStuLeaveIBLL.SaveEntity(parameter.keyValue, entity);
  123. return Success("保存成功!");
  124. }
  125. else
  126. {
  127. return Fail("请假时间不得早于结束时间");
  128. }
  129. }
  130. #endregion
  131. #region 扩展代码
  132. /// <summary>
  133. ///
  134. /// <param name="_"></param>
  135. /// <summary>
  136. /// <returns></returns>
  137. public Response SubmitForm(dynamic _)
  138. {
  139. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  140. DtStuLeaveEntity entity = parameter.strEntity.ToObject<DtStuLeaveEntity>();
  141. entity.processId = Guid.NewGuid().ToString();
  142. dtStuLeaveIBLL.SaveEntity(parameter.keyValue, entity);
  143. dtStuLeaveIBLL.ModifyStatus(parameter.keyValue, 1, parameter.strEntity);
  144. return Success("提交成功!");
  145. }
  146. /// <summary>
  147. /// 休假
  148. /// <param name="_"></param>
  149. /// <summary>
  150. /// <returns></returns>
  151. public Response CancelFrom(dynamic _)
  152. {
  153. string keyValue = this.GetReqData();
  154. dtStuLeaveIBLL.IsFinish(keyValue);
  155. return Success("销假成功!");
  156. }
  157. #endregion
  158. #region 私有类
  159. /// <summary>
  160. /// 表单实体类
  161. /// <summary>
  162. private class ReqFormEntity
  163. {
  164. public string keyValue { get; set; }
  165. public string strEntity { get; set; }
  166. }
  167. #endregion
  168. }
  169. }