|
- using Nancy;
- using Learun.Util;
- using System.Collections.Generic;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System;
- using Learun.Application.Base.SystemModule;
- using System.IO;
- using System.Web.Mvc;
- using Learun.Application.WebApi.Modules;
-
- namespace Learun.Application.WebApi
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创 建:超级管理员
- /// 日 期:2020-06-03 14:29
- /// 描 述:听课记录
- /// </summary>
- public class RecruiterPeopleApi : BaseNoLoginApi
- {
- private HiringRegistrationIBLL hiringRegistrationIBLL = new HiringRegistrationBLL();
- private WorkStaffIBLL workStaffIBLL = new WorkStaffBLL();
- private TalentsJoinInfoIBLL talentsJoinInfoIBLL = new TalentsJoinInfoBLL();
-
- private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
-
- /// <summary>
- /// 娄底官方(CMS)提交招聘信息
- /// <summary>
- public RecruiterPeopleApi()
- : base("/Learun/adms/RecruiterPeople")
- {
- //Get["/pagelist"] = GetPageList;
- //Get["/list"] = GetList;
- //Get["/form"] = GetForm;
- //Post["/delete"] = DeleteForm;
- Get["/down"] = DownAnnexesFile;
- Post["/upload"] = Upload;
- Post["/save"] = SaveForm;
- Post["/saveTalents"] = SaveTalentsForm;
- Post["/saveStaff"] = SaveStaffForm;
- }
- #region 获取数据
-
- ///// <summary>
- ///// 获取页面显示列表分页数据
- ///// <summary>
- ///// <param name="_"></param>
- ///// <returns></returns>
- //public Response GetPageList(dynamic _)
- //{
- // ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- // var data = listenClassRecordIBLL.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 = listenClassRecordIBLL.GetList(queryJson);
- // return Success(data);
- //}
- ///// <summary>
- ///// 获取表单数据
- ///// <summary>
- ///// <param name="_"></param>
- ///// <returns></returns>
- //public Response GetForm(dynamic _)
- //{
- // string keyValue = this.GetReqData();
- // var ListenClassRecordData = listenClassRecordIBLL.GetListenClassRecordEntity( keyValue );
- // var jsonData = new {
- // ListenClassRecord = ListenClassRecordData,
- // };
- // return Success(jsonData);
- //}
- #endregion
-
- #region 提交数据
-
- ///// <summary>
- ///// 删除实体数据
- ///// <param name="_"></param>
- ///// <summary>
- ///// <returns></returns>
- //public Response DeleteForm(dynamic _)
- //{
- // string keyValue = this.GetReqData();
- // listenClassRecordIBLL.DeleteEntity(keyValue);
- // return Success("删除成功!");
- //}
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- HiringRegistrationEntity entity = parameter.strEntity.ToObject<HiringRegistrationEntity>();
- var model = hiringRegistrationIBLL.GetIDCard(entity.IdentityCardNo);
- if (string.IsNullOrEmpty(parameter.keyValue))
- {
- if (model != null)
- {
- return Fail("身份证号已存在!");
- }
- }
- else
- {
- if (model != null && model.ID != parameter.keyValue)
- {
- return Fail("身份证号已存在!");
- }
- }
- hiringRegistrationIBLL.SaveEntity(parameter.keyValue, entity);
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveTalentsForm(dynamic _)
- {
- ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
- TalentsJoinInfoEntity entity = parameter.strEntity.ToObject<TalentsJoinInfoEntity>();
- var model = talentsJoinInfoIBLL.GetIdCard(entity.IdentityCardNo);
- if (string.IsNullOrEmpty(parameter.keyValue))
- {
- if (model != null)
- {
- return Fail("身份证号已存在!");
- }
- }
- else
- {
- if (model != null && model.ID != parameter.keyValue)
- {
- return Fail("身份证号已存在!");
- }
- }
- talentsJoinInfoIBLL.SaveEntity(parameter.keyValue, entity);
- return Success("保存成功!");
- }
- /// <summary>
- /// 公开选调工作人员报名表
- /// <param name="_"></param>
- /// <summary>
- /// <returns></returns>
- public Response SaveStaffForm(dynamic _)
- {
- var model = this.GetReqData<ReqFormEntity>();
- WorkStaffEntity entity = model.strEntity.ToObject<WorkStaffEntity>();
- var models = workStaffIBLL.GetIDCard(entity.IdentityCardNo);
-
- if (string.IsNullOrEmpty(model.keyValue))
- {
- if (models != null)
- {
- return Fail("身份证号已存在!");
- }
- }
- else
- {
- if (models != null && models.ID != model.keyValue)
- {
- return Fail("身份证号已存在!");
- }
- }
- workStaffIBLL.SaveEntity(model.keyValue, entity, entity.WorkStaffSonEntities);
- return Success("保存成功!");
- }
- #endregion
-
- #region 上传附件图片文件
-
- /// <summary>
- /// 上传附件图片文件
- /// <summary>
- /// <returns></returns>
- public Response Upload(dynamic _)
- {
- var files = (List<HttpFile>)this.Context.Request.Files;
- string folderId = Guid.NewGuid().ToString();
- string filePath = Config.GetValue("AnnexesFile");
- string uploadDate = DateTime.Now.ToString("yyyyMMdd");
- string fileEextension = Path.GetExtension(files[0].Name);
- string fileType = fileEextension.Replace(".", "");
- string fileGuid = Guid.NewGuid().ToString();
-
- string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, "system", uploadDate, fileGuid, fileEextension);
-
- //创建文件夹
- string path = Path.GetDirectoryName(virtualPath);
- Directory.CreateDirectory(path);
- AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity();
- if (!System.IO.File.Exists(virtualPath))
- {
- byte[] bytes = new byte[files[0].Value.Length];
- files[0].Value.Read(bytes, 0, bytes.Length);
- FileInfo file = new FileInfo(virtualPath);
- FileStream fs = file.Create();
- fs.Write(bytes, 0, bytes.Length);
- fs.Close();
-
- //文件信息写入数据库
- fileAnnexesEntity.F_Id = fileGuid;
- fileAnnexesEntity.F_FileName = files[0].Name;
- fileAnnexesEntity.F_FilePath = virtualPath;
- fileAnnexesEntity.F_FileSize = files[0].Value.Length.ToString();
- fileAnnexesEntity.F_FileExtensions = fileEextension;
- fileAnnexesEntity.F_FileType = fileType;
- fileAnnexesEntity.F_CreateUserId = "system";
- fileAnnexesEntity.F_CreateUserName = "system";
-
- annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity);
- }
-
- return SuccessString(folderId);
- }
-
- /// <summary>
- /// 删除文件
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response DeleteFile(dynamic _)
- {
- var fileId = this.GetReqData();
- AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId);
- annexesFileIBLL.DeleteEntity(fileId);
- //删除文件
- if (System.IO.File.Exists(fileInfoEntity.F_FilePath))
- {
- System.IO.File.Delete(fileInfoEntity.F_FilePath);
- }
-
- return Success("删除成功");
- }
-
- /// <summary>
- /// 下载文件
- /// </summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response DownAnnexesFile(dynamic _)
- {
- string name = this.GetReqData();
- string fileId = name.Split('.')[0];
- var data = annexesFileIBLL.GetEntity(fileId);
- string filepath = data.F_FilePath;
- if (FileDownHelper.FileExists(filepath))
- {
- FileDownHelper.DownLoadnew(filepath);
- }
- return Success("");
- }
- #endregion
-
- #region 私有类
-
- /// <summary>
- /// 表单实体类
- /// <summary>
- private class ReqFormEntity
- {
- public string keyValue { get; set; }
- public string strEntity { get; set; }
- }
- #endregion
-
- }
- }
|