|
- using System;
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2021-07-23 10:15
- /// 描 述:学生请销假
- /// </summary>
- public class DtStuLeaveApi : BaseApi
- {
- private DtStuLeaveIBLL dtStuLeaveIBLL = new DtStuLeaveBLL();
-
- /// <summary>
- /// 注册接口
- /// <summary>
- public DtStuLeaveApi()
- : base("/Learun/EducationalAdministration/DtStuLeave")
- {
- Get["/pagelist"] = GetPageList;
- Get["/list"] = GetList;
- Get["/form"] = GetForm;
- Post["/delete"] = DeleteForm;
- Post["/save"] = SaveForm;
- Post["/submit"] = CancelFrom;
- //Post["/cancel"] = CancelFrom;
- }
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = dtStuLeaveIBLL.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 GetList(dynamic _)
- {
- string queryJson = this.GetReqData();
- var data = dtStuLeaveIBLL.GetList(queryJson);
- return Success(data);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var DtStuLeaveData = dtStuLeaveIBLL.GetDtStuLeaveEntity(keyValue);
- var jsonData = new
- {
- DtStuLeave = DtStuLeaveData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response DeleteForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- dtStuLeaveIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- DtStuLeaveEntity entity = parameter.strEntity.ToObject<DtStuLeaveEntity>();
- if (entity.BeginDate < entity.EndDate)
- {
- TimeSpan ts = Convert.ToDateTime(entity.EndDate) - Convert.ToDateTime(entity.BeginDate);
- if (ts.Hours < 12)
- {
- entity.LeaveDay = ("0.5").ToDecimal();
- }
- else if (ts.Hours >= 12 && ts.Hours <= 24)
- {
- entity.LeaveDay = 1;
- }
- else
- {
- entity.LeaveDay = ts.Days;
- }
- entity.SchemeCode = "DtStuLeave";
- var userinfo = LoginUserInfo.Get();
- entity.CreateUserId = userinfo.userId;
- if (string.IsNullOrEmpty(parameter.keyValue))
- {
- entity.FlowNo = "0";
- entity.LeaveAddTime = DateTime.Now;
- }
- dtStuLeaveIBLL.SaveEntity(parameter.keyValue, entity);
- return Success("保存成功!");
- }
- else
- {
- return Fail("请假时间不得早于结束时间");
- }
- }
- #endregion
-
- #region 扩展代码
-
- /// <summary>
- ///
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SubmitForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- DtStuLeaveEntity entity = parameter.strEntity.ToObject<DtStuLeaveEntity>();
- entity.processId = Guid.NewGuid().ToString();
- dtStuLeaveIBLL.SaveEntity(parameter.keyValue, entity);
-
- dtStuLeaveIBLL.ModifyStatus(parameter.keyValue, 1, parameter.strEntity);
- return Success("提交成功!");
- }
- /// <summary>
- /// 休假
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response CancelFrom(dynamic _)
- {
- string keyValue = this.GetReqData();
- dtStuLeaveIBLL.IsFinish(keyValue);
- return Success("销假成功!");
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- }
- #endregion
-
- }
- }
|