using Nancy; using Learun.Util; using System.Collections.Generic; using Learun.Application.TwoDevelopment.PersonnelManagement; using Learun.Application.OA.Schedule; using System; namespace Learun.Application.WebApi { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创 建:超级管理员 /// 日 期:2019-12-25 14:53 /// 描 述:日程安排 /// public class ScheduleApi : BaseApi { private ScheduleIBLL ScheduleIBLL = new ScheduleBLL(); /// /// 注册接口 /// public ScheduleApi() : base("/Learun/adms/PersonnelManagement/Schedule") { Get["/pagelist"] = GetPageList; Get["/list"] = GetList; Get["/form"] = GetForm; Post["/delete"] = DeleteForm; Post["/save"] = SaveForm; } #region 获取数据 /// /// 获取页面显示列表分页数据 /// /// /// public Response GetPageList(dynamic _) { ReqPageParam parameter = this.GetReqData(); var data = ScheduleIBLL.GetPageListByUserId(parameter.pagination, parameter.queryJson, this.userInfo.userId); var jsonData = new { rows = data, total = parameter.pagination.total, page = parameter.pagination.page, records = parameter.pagination.records }; return Success(jsonData); } /// /// 获取页面显示列表数据 /// /// /// public Response GetList(dynamic _) { string queryJson = this.GetReqData(); var data = ScheduleIBLL.GetList(); return Success(data); } /// /// 获取表单数据 /// /// /// public Response GetForm(dynamic _) { string keyValue = this.GetReqData(); var ScheduleData = ScheduleIBLL.GetEntity(keyValue); ScheduleData.F_StartDate = Convert.ToDateTime((ScheduleData.F_StartDate.ToDate().ToString("yyyy-MM-dd") + " " + ScheduleData.F_StartTime.Substring(0, 2) + ":" + ScheduleData.F_StartTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm")); ScheduleData.F_EndDate = Convert.ToDateTime((ScheduleData.F_EndDate.ToDate().ToString("yyyy-MM-dd") + " " + ScheduleData.F_EndTime.Substring(0, 2) + ":" + ScheduleData.F_EndTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm")); var jsonData = new { Schedule = ScheduleData, }; return Success(jsonData); } #endregion #region 提交数据 /// /// 删除实体数据 /// /// /// public Response DeleteForm(dynamic _) { string keyValue = this.GetReqData(); ScheduleIBLL.RemoveForm(keyValue); return Success("删除成功!"); } /// /// 保存实体数据(新增、修改) /// /// /// public Response SaveForm(dynamic _) { ReqFormEntity parameter = this.GetReqData(); ScheduleEntity entity = parameter.strEntity.ToObject(); entity.F_StartDate = entity.F_StartDate.ToDate(); entity.F_EndDate = entity.F_EndDate.ToDate(); entity.F_StartTime = entity.F_StartDate.ToTimeString().Replace(":", "").Substring(0, 4); entity.F_EndTime = entity.F_EndDate.ToTimeString().Replace(":", "").Substring(0, 4); ScheduleIBLL.SaveForm(parameter.keyValue, entity); return Success("保存成功!"); } #endregion #region 私有类 /// /// 表单实体类 /// private class ReqFormEntity { public string keyValue { get; set; } public string strEntity { get; set; } } #endregion } }