|
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using Learun.Application.TwoDevelopment.PersonnelManagement;
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2020-02-03 14:37
- /// 描 述:疫情记录
- /// </summary>
- public class EpidemicSituationCopyApi : BaseApi
- {
- private EpidemicSituationIBLL epidemicSituationIBLL = new EpidemicSituationBLL();
- private CdDeptIBLL cdDeptIbll = new CdDeptBLL();
- private CdMajorIBLL cdMajorIbll = new CdMajorBLL();
- private ClassInfoIBLL classInfoIbll = new ClassInfoBLL();
- private StuInfoBasicIBLL stuInfoBasicIbll = new StuInfoBasicBLL();
- private EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
-
- /// <summary>
- /// 注册接口
- /// <summary>
- public EpidemicSituationCopyApi()
- : base("/Learun/PersonnelManagement/EpidemicSituationCopy")
- {
- Get["/pagelist"] = GetPageList;
- Get["/list"] = GetList;
- Get["/form"] = GetForm;
- Post["/delete"] = DeleteForm;
- Post["/save"] = SaveForm;
- Get["/getStuSource"] = GetStudentSource;
- Get["/getUserSource"] = GetEmpSource;
- }
- #region 获取数据
-
-
- public Response GetStudentSource(dynamic _)
- {
- string keyValue = this.GetReqData();
- var res = "";
- var stuEntity = stuInfoBasicIbll.GetStuInfoBasicEntityByStuNo(keyValue);
- if (stuEntity != null)
- {
- var detptName = cdDeptIbll.GetCdDeptEntityByNo(stuEntity.DeptNo)?.DeptName;
- var majorName = cdMajorIbll.GetCdMajorEntityByMajorNo(stuEntity.MajorNo)?.MajorName;
- var className = classInfoIbll.GetClassInfoEntityByClassNo(stuEntity.ClassNo)?.ClassName;
- res = $"{detptName} {majorName} {className}";
- }
-
- return Success(new { res, Address = stuEntity?.MailAddress });
-
- }
-
-
- public Response GetEmpSource(dynamic _)
- {
- string keyValue = this.GetReqData();
- var stuEntity = empInfoIBLL.GetEmpInfoEntity(keyValue);
- return Success(new { Address = stuEntity?.Homeaddress });
- }
-
- /// <summary>
- /// 获取页面显示列表分页数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = epidemicSituationIBLL.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 = epidemicSituationIBLL.GetList(queryJson);
- return Success(data);
- }
- /// <summary>
- /// 获取表单数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- var EpidemicSituationData = epidemicSituationIBLL.GetEpidemicSituationEntity(keyValue);
- var ContactsDetailsData = epidemicSituationIBLL.GetContactsDetailsList(EpidemicSituationData.ID);
- var PassPlaceData = epidemicSituationIBLL.GetPassPlaceList(EpidemicSituationData.ID);
- var PeopleDetailsData = epidemicSituationIBLL.GetPeopleDetailslist(EpidemicSituationData.ID);
- var jsonData = new
- {
- EpidemicSituation = EpidemicSituationData,
- ContactsDetails = ContactsDetailsData,
- PassPlaces = PassPlaceData,
- PeopleDetails = PeopleDetailsData
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response DeleteForm(dynamic _)
- {
- string keyValue = this.GetReqData();
- epidemicSituationIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
-
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- EpidemicSituationEntity entity = parameter.strEntity.ToObject<EpidemicSituationEntity>();
-
- if (string.IsNullOrEmpty(parameter.keyValue))
- {
- var userId = entity.Creater;
- if (epidemicSituationIBLL.HasTodayValue(userId))
- {
- return Success("不能重复提交");
- }
- }
-
- List<ContactsDetailsEntity> contactsDetailsList = parameter.strcontactsDetailsList.ToObject<List<ContactsDetailsEntity>>();
- List<PassPlaceEntity> passPlaceList = parameter.strpassPlaceList.ToObject<List<PassPlaceEntity>>();
- List<PeopleDetailsEntity> peopleDetails = parameter.strpeopleDetailsList.ToObject<List<PeopleDetailsEntity>>();
- epidemicSituationIBLL.SaveEntity(this.userInfo, parameter.keyValue, entity, contactsDetailsList, passPlaceList, peopleDetails);
- return Success("保存成功!");
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- public string strcontactsDetailsList { get; set; }
- public string strpassPlaceList { get; set; }
- public string strpeopleDetailsList { get; set; }
- }
- #endregion
-
- }
- }
|