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.
 
 
 
 
 
 

204 line
6.7 KiB

  1. using Nancy;
  2. using Learun.Util;
  3. using System.Collections.Generic;
  4. using Learun.Application.TwoDevelopment.EducationalAdministration;
  5. using static Learun.Application.WebApi.Modules.StuInfoFreshApi;
  6. using System;
  7. using System.IO;
  8. using System.Linq;
  9. using Learun.Application.Base.SystemModule;
  10. using Learun.Application.OA;
  11. using Learun.Application.OA.File.FileInfo;
  12. using Learun.Application.TwoDevelopment.LogisticsManagement;
  13. using Learun.Application.TwoDevelopment.LR_Desktop;
  14. using Learun.Application.WorkFlow;
  15. using Microsoft.Ajax.Utilities;
  16. namespace Learun.Application.WebApi
  17. {
  18. ///2022.11.14
  19. /// <summary>
  20. /// 学生请假
  21. /// </summary>
  22. public class StuLeaveManagementApi : BaseApi
  23. {
  24. private StuLeaveManagementIBLL stuLeaveManagementIBLL = new StuLeaveManagementBLL();
  25. /// <summary>
  26. /// 注册接口
  27. /// <summary>
  28. public StuLeaveManagementApi()
  29. : base("/Learun/adms/EducationalAdministration/StuLeaveManagement")
  30. {
  31. Get["/pagelist"] = GetPageList;
  32. Get["/form"] = GetForm;
  33. Post["/delete"] = DeleteForm;
  34. Post["/save"] = SaveForm;
  35. //判断是否可以审核
  36. Get["/ischeck"] = IsCheck;
  37. //学生请假--教师审核列表
  38. Get["/checkpagelist"] = GetCheckPageList;
  39. //审核学生请假
  40. Post["/savecheck"] = SaveCheckForm;
  41. }
  42. #region 获取数据
  43. /// <summary>
  44. /// 获取页面显示列表分页数据
  45. /// <summary>
  46. /// <param name="_"></param>
  47. /// <returns></returns>
  48. public Response GetPageList(dynamic _)
  49. {
  50. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  51. var data = stuLeaveManagementIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  52. var jsonData = new
  53. {
  54. rows = data,
  55. total = parameter.pagination.total,
  56. page = parameter.pagination.page,
  57. records = parameter.pagination.records
  58. };
  59. return Success(jsonData);
  60. }
  61. /// <summary>
  62. /// 学生请假--教师审核列表
  63. /// <summary>
  64. /// <param name="_"></param>
  65. /// <returns></returns>
  66. public Response GetCheckPageList(dynamic _)
  67. {
  68. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  69. var data = stuLeaveManagementIBLL.GetCheckPageList(parameter.pagination, parameter.queryJson);
  70. var jsonData = new
  71. {
  72. rows = data,
  73. total = parameter.pagination.total,
  74. page = parameter.pagination.page,
  75. records = parameter.pagination.records
  76. };
  77. return Success(jsonData);
  78. }
  79. /// <summary>
  80. /// 获取表单数据
  81. /// <summary>
  82. /// <param name="_"></param>
  83. /// <returns></returns>
  84. public Response GetForm(dynamic _)
  85. {
  86. string keyValue = this.GetReqData();
  87. var StuLeaveManagementData = stuLeaveManagementIBLL.GetStuLeaveManagementEntity(keyValue);
  88. var jsonData = new
  89. {
  90. StuLeaveManagement = StuLeaveManagementData,
  91. };
  92. return Success(jsonData);
  93. }
  94. #endregion
  95. #region 提交数据
  96. /// <summary>
  97. /// 删除实体数据
  98. /// <param name="_"></param>
  99. /// <summary>
  100. /// <returns></returns>
  101. public Response DeleteForm(dynamic _)
  102. {
  103. string keyValue = this.GetReqData();
  104. stuLeaveManagementIBLL.DeleteEntity(keyValue);
  105. return Success("删除成功!");
  106. }
  107. /// <summary>
  108. /// 保存实体数据(新增、修改)
  109. /// <param name="_"></param>
  110. /// <summary>
  111. /// <returns></returns>
  112. public Response SaveForm(dynamic _)
  113. {
  114. var loginInfo = LoginUserInfo.Get();
  115. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  116. StuLeaveManagementEntity entity = parameter.strEntity.ToObject<StuLeaveManagementEntity>();
  117. if (string.IsNullOrEmpty(parameter.keyValue))
  118. {
  119. entity.CreateUserId = loginInfo.userId;
  120. entity.CreateUserNo = loginInfo.account;
  121. entity.CreateTime = DateTime.Now;
  122. }
  123. stuLeaveManagementIBLL.SaveEntity(parameter.keyValue, entity);
  124. return Success("保存成功!");
  125. }
  126. /// <summary>
  127. /// 判断是否可以审核
  128. /// <summary>
  129. /// <param name="_"></param>
  130. /// <returns></returns>
  131. public Response IsCheck(dynamic _)
  132. {
  133. string keyValue = this.GetReqData();
  134. var stuLeaveManagementData = stuLeaveManagementIBLL.GetStuLeaveManagementEntity(keyValue);
  135. bool isDeptDirector = false; //登录用户是否是系主任标识
  136. var deptDirectorRoleId = Config.GetValue("DeptDirectorRoleId");
  137. var loginInfoRoleIds = LoginUserInfo.Get().roleIds;
  138. if (loginInfoRoleIds.IndexOf(',') == -1)
  139. {
  140. if (loginInfoRoleIds == deptDirectorRoleId)
  141. {
  142. isDeptDirector = true;
  143. }
  144. }
  145. else
  146. {
  147. if (loginInfoRoleIds.Split(',').Contains(deptDirectorRoleId))
  148. {
  149. isDeptDirector = true;
  150. }
  151. }
  152. if (stuLeaveManagementData.LeaveDay > 2 && !isDeptDirector)
  153. {
  154. return Fail("该请假申请大于2天,需要由系主任审核!");
  155. }
  156. return Success("");
  157. }
  158. /// <summary>
  159. /// 审核学生请假
  160. /// <param name="_"></param>
  161. /// <summary>
  162. /// <returns></returns>
  163. public Response SaveCheckForm(dynamic _)
  164. {
  165. var loginInfo = LoginUserInfo.Get();
  166. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  167. StuLeaveManagementEntity entity = parameter.strEntity.ToObject<StuLeaveManagementEntity>();
  168. entity.CheckUserId = loginInfo.userId;
  169. entity.CheckUserNo = loginInfo.account;
  170. entity.CheckTime = DateTime.Now;
  171. stuLeaveManagementIBLL.SaveEntity(parameter.keyValue, entity);
  172. return Success("保存成功!");
  173. }
  174. #endregion
  175. #region 私有类
  176. /// <summary>
  177. /// 表单实体类
  178. /// <summary>
  179. private class ReqFormEntity
  180. {
  181. public string keyValue { get; set; }
  182. public string strEntity { get; set; }
  183. }
  184. #endregion
  185. }
  186. }