|
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using static Learun.Application.WebApi.Modules.StuInfoFreshApi;
- using System;
- using System.IO;
- using System.Linq;
- using Learun.Application.Base.SystemModule;
- using Learun.Application.OA;
- using Learun.Application.OA.File.FileInfo;
- using Learun.Application.TwoDevelopment.LogisticsManagement;
- using Learun.Application.TwoDevelopment.LR_Desktop;
- using Learun.Application.WorkFlow;
- using Microsoft.Ajax.Utilities;
-
- namespace Learun.Application.WebApi
- {
- ///2022.11.14
- /// <summary>
- /// 学生请假
- /// </summary>
-
- public class StuLeaveManagementApi : BaseApi
- {
-
- private StuLeaveManagementIBLL stuLeaveManagementIBLL = new StuLeaveManagementBLL();
- private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL();
-
- /// <summary>
- /// 注册接口
- /// <summary>
- public StuLeaveManagementApi()
- : base("/Learun/adms/EducationalAdministration/StuLeaveManagement")
- {
- Get["/pagelist"] = GetPageList;
- Get["/form"] = GetForm;
- Post["/delete"] = DeleteForm;
- Post["/save"] = SaveForm;
-
- //判断是否可以审核
- Get["/ischeck"] = IsCheck;
- //学生请假--教师审核列表
- Get["/checkpagelist"] = GetCheckPageList;
- //审核学生请假
- Post["/savecheck"] = SaveCheckForm;
-
- Post["/submit"] = Submit;
- Get["/shList"] = GetshList;
-
- }
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = stuLeaveManagementIBLL.GetPageList(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetshList(dynamic _)
- {
- StuLeaveManagementEntity parameter = this.GetReqData<StuLeaveManagementEntity>();
- var stuLeaveManagementData = stuLeaveManagementIBLL.GetEntityByProcessId(parameter.ProcessId);
- var jsonData = new
- {
- stuLeaveManagement = stuLeaveManagementData,
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 学生请假--教师审核列表
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetCheckPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = stuLeaveManagementIBLL.GetCheckPageList(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var StuLeaveManagementData = stuLeaveManagementIBLL.GetStuLeaveManagementEntity(keyValue);
- var jsonData = new
- {
- StuLeaveManagement = StuLeaveManagementData,
- };
- return Success(jsonData);
- }
-
-
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response DeleteForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- stuLeaveManagementIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- var loginInfo = LoginUserInfo.Get();
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- StuLeaveManagementEntity entity = parameter.strEntity.ToObject<StuLeaveManagementEntity>();
- if (string.IsNullOrEmpty(parameter.keyValue))
- {
- entity.CreateUserId = loginInfo.userId;
- entity.CreateUserNo = loginInfo.account;
- entity.CreateTime = DateTime.Now;
- }
- stuLeaveManagementIBLL.SaveEntity(parameter.keyValue, entity);
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 判断是否可以审核
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response IsCheck(dynamic _)
- {
- string keyValue = this.GetReqData();
- var stuLeaveManagementData = stuLeaveManagementIBLL.GetStuLeaveManagementEntity(keyValue);
- bool isDeptDirector = false; //登录用户是否是系主任标识
- var deptDirectorRoleId = Config.GetValue("DeptDirectorRoleId");
- var loginInfoRoleIds = LoginUserInfo.Get().roleIds;
- if (loginInfoRoleIds.IndexOf(',') == -1)
- {
- if (loginInfoRoleIds == deptDirectorRoleId)
- {
- isDeptDirector = true;
- }
- }
- else
- {
- if (loginInfoRoleIds.Split(',').Contains(deptDirectorRoleId))
- {
- isDeptDirector = true;
- }
- }
- if (stuLeaveManagementData.LeaveDay > 2 && !isDeptDirector)
- {
- return Fail("该请假申请大于2天,需要由系主任审核!");
- }
-
- return Success("");
- }
-
- /// <summary>
- /// 审核学生请假
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveCheckForm(dynamic _)
- {
- var loginInfo = LoginUserInfo.Get();
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- StuLeaveManagementEntity entity = parameter.strEntity.ToObject<StuLeaveManagementEntity>();
- entity.CheckUserId = loginInfo.userId;
- entity.CheckUserNo = loginInfo.account;
- entity.CheckTime = DateTime.Now;
- stuLeaveManagementIBLL.SaveEntity(parameter.keyValue, entity);
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 提交
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response Submit(dynamic _)
- {
- string keyValue = this.GetReqData();
- var processId = Guid.NewGuid().ToString();
- stuLeaveManagementIBLL.ChangeStatusById(keyValue, 1, processId);
- UserInfo userInfo = LoginUserInfo.Get();
- nWFProcessIBLL.CreateFlow("StuLeaveManagement", processId, "", 1, "", userInfo);
- return Success("提交成功!");
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- }
- #endregion
-
- }
-
- }
|