diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/PersonnelManagement/DutyScheduleApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/PersonnelManagement/DutyScheduleApi.cs index 54b0d5975..a18aaaf04 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/PersonnelManagement/DutyScheduleApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/PersonnelManagement/DutyScheduleApi.cs @@ -1,4 +1,5 @@ -using Nancy; +using System; +using Nancy; using Learun.Util; using System.Collections.Generic; using Learun.Application.TwoDevelopment.EducationalAdministration; @@ -21,9 +22,13 @@ namespace Learun.Application.WebApi.Modules /// 注册接口 /// public DutyScheduleApi() - : base("/Learun/adms/PersonnelManagement/DutySchedule") + : base("/learun/adms/PersonnelManagement/DutySchedule") { Get["/pagelist"] = GetPageList; + Get["/list"] = GetList; + Get["/form"] = GetForm; + Post["/save"] = SaveForm; + Post["/delete"] = DeleteForm; } #region 获取数据 @@ -45,6 +50,74 @@ namespace Learun.Application.WebApi.Modules }; return Success(jsonData); } + + /// + /// 获取页面显示列表数据 + /// + /// + /// + public Response GetList(dynamic _) + { + string queryJson = this.GetReqData(); + var data = dutyScheduleIBLL.GetList(); + return Success(data); + } + /// + /// 获取表单数据 + /// + /// + /// + public Response GetForm(dynamic _) + { + string keyValue = this.GetReqData(); + var ScheduleData = dutyScheduleIBLL.GetDutyScheduleEntity(keyValue); + //ScheduleData.StartTime = Convert.ToDateTime((ScheduleData.StartTime.ToDate().ToString("yyyy-MM-dd") + " " + ScheduleData.StartTime.Substring(0, 2) + ":" + ScheduleData.StartTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm")); + //ScheduleData.EndTime = Convert.ToDateTime((ScheduleData.EndTime.ToDate().ToString("yyyy-MM-dd") + " " + ScheduleData.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 SaveForm(dynamic _) + { + ReqFormEntity parameter = this.GetReqData(); + DutyScheduleEntity entity = parameter.strEntity.ToObject(); + dutyScheduleIBLL.SaveEntity(parameter.keyValue, entity); + return Success("保存成功!"); + } + + + /// + /// 删除实体数据 + /// + /// + /// + public Response DeleteForm(dynamic _) + { + string keyValue = this.GetReqData(); + dutyScheduleIBLL.DeleteEntity(keyValue); + return Success("删除成功!"); + } + #endregion + + #region 私有类 + /// + /// 表单实体类 + /// + private class ReqFormEntity + { + public string keyValue { get; set; } + public string strEntity { get; set; } + } #endregion } } \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleBLL.cs index 45ae9380c..736a0b307 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleBLL.cs @@ -66,6 +66,28 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement } } + /// + /// 获取列表 + /// + /// 返回列表 + public IEnumerable GetList() + { + try + { + return dutyScheduleService.GetList(); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleIBLL.cs index a3120c615..4b456ae07 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleIBLL.cs @@ -27,6 +27,12 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement /// /// DutyScheduleEntity GetDutyScheduleEntity(string keyValue); + /// + /// 获取所有数据 + /// + /// + IEnumerable GetList(); + #endregion #region 提交数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleService.cs index c660b036e..a295a2b01 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/DutySchedule/DutyScheduleService.cs @@ -28,21 +28,16 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement { try { + var adms = this.BaseRepository().getDbConnection().Database; var strSql = new StringBuilder(); strSql.Append("SELECT "); - strSql.Append(@" - t.ID, - t.StartTime, - t.EndTime, - t.Person, - t.Remark,u.F_Account,F_RealName - "); - strSql.Append(" FROM DutySchedule t left join adms7ultimate2.dbo.LR_Base_User u on t.Person=u.F_UserId "); + strSql.Append(@" t.* ,u.F_Account,F_RealName "); + strSql.Append($" FROM DutySchedule t left join {adms}.dbo.LR_Base_User u on t.Person=u.F_UserId "); strSql.Append(" WHERE 1=1 "); var queryParam = queryJson.ToJObject(); // 虚拟参数 var dp = new DynamicParameters(new { }); - return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(),dp, pagination); + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination); } catch (Exception ex) { @@ -81,6 +76,29 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement } } + /// + /// 获取列表 + /// + /// 返回列表 + public IEnumerable GetList() + { + try + { + var adms = this.BaseRepository().getDbConnection().Database; + var strSql = new StringBuilder(); + strSql.Append("SELECT "); + strSql.Append(@" t.*, u.F_Account,F_RealName "); + strSql.Append($" FROM DutySchedule t left join {adms}.dbo.LR_Base_User u on t.Person=u.F_UserId "); + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString()); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + throw; + else + throw ExceptionEx.ThrowServiceException(ex); + } + } #endregion #region 提交数据 @@ -94,7 +112,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement { try { - this.BaseRepository("CollegeMIS").Delete(t=>t.ID == keyValue); + this.BaseRepository("CollegeMIS").Delete(t => t.ID == keyValue); } catch (Exception ex) { @@ -126,6 +144,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement else { entity.Create(); + entity.CreateTime = DateTime.Now; this.BaseRepository("CollegeMIS").Insert(entity); } }