Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

288 рядки
10 KiB

  1. using Nancy;
  2. using Learun.Util;
  3. using System.Collections.Generic;
  4. using Learun.Application.TwoDevelopment.EducationalAdministration;
  5. using System;
  6. using Learun.Application.Base.SystemModule;
  7. using System.IO;
  8. using System.Web.Mvc;
  9. using Learun.Application.WebApi.Modules;
  10. namespace Learun.Application.WebApi
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  14. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2020-06-03 14:29
  17. /// 描 述:听课记录
  18. /// </summary>
  19. public class RecruiterPeopleApi : BaseNoLoginApi
  20. {
  21. private HiringRegistrationIBLL hiringRegistrationIBLL = new HiringRegistrationBLL();
  22. private WorkStaffIBLL workStaffIBLL = new WorkStaffBLL();
  23. private TalentsJoinInfoIBLL talentsJoinInfoIBLL = new TalentsJoinInfoBLL();
  24. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  25. /// <summary>
  26. /// 娄底官方(CMS)提交招聘信息
  27. /// <summary>
  28. public RecruiterPeopleApi()
  29. : base("/Learun/adms/RecruiterPeople")
  30. {
  31. //Get["/pagelist"] = GetPageList;
  32. //Get["/list"] = GetList;
  33. //Get["/form"] = GetForm;
  34. //Post["/delete"] = DeleteForm;
  35. Get["/down"] = DownAnnexesFile;
  36. Post["/upload"] = Upload;
  37. Post["/save"] = SaveForm;
  38. Post["/saveTalents"] = SaveTalentsForm;
  39. Post["/saveStaff"] = SaveStaffForm;
  40. }
  41. #region 获取数据
  42. ///// <summary>
  43. ///// 获取页面显示列表分页数据
  44. ///// <summary>
  45. ///// <param name="_"></param>
  46. ///// <returns></returns>
  47. //public Response GetPageList(dynamic _)
  48. //{
  49. // ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  50. // var data = listenClassRecordIBLL.GetPageList(parameter.pagination, parameter.queryJson);
  51. // var jsonData = new
  52. // {
  53. // rows = data,
  54. // total = parameter.pagination.total,
  55. // page = parameter.pagination.page,
  56. // records = parameter.pagination.records
  57. // };
  58. // return Success(jsonData);
  59. //}
  60. ///// <summary>
  61. ///// 获取页面显示列表数据
  62. ///// <summary>
  63. ///// <param name="_"></param>
  64. ///// <returns></returns>
  65. //public Response GetList(dynamic _)
  66. //{
  67. // string queryJson = this.GetReqData();
  68. // var data = listenClassRecordIBLL.GetList(queryJson);
  69. // return Success(data);
  70. //}
  71. ///// <summary>
  72. ///// 获取表单数据
  73. ///// <summary>
  74. ///// <param name="_"></param>
  75. ///// <returns></returns>
  76. //public Response GetForm(dynamic _)
  77. //{
  78. // string keyValue = this.GetReqData();
  79. // var ListenClassRecordData = listenClassRecordIBLL.GetListenClassRecordEntity( keyValue );
  80. // var jsonData = new {
  81. // ListenClassRecord = ListenClassRecordData,
  82. // };
  83. // return Success(jsonData);
  84. //}
  85. #endregion
  86. #region 提交数据
  87. ///// <summary>
  88. ///// 删除实体数据
  89. ///// <param name="_"></param>
  90. ///// <summary>
  91. ///// <returns></returns>
  92. //public Response DeleteForm(dynamic _)
  93. //{
  94. // string keyValue = this.GetReqData();
  95. // listenClassRecordIBLL.DeleteEntity(keyValue);
  96. // return Success("删除成功!");
  97. //}
  98. /// <summary>
  99. /// 保存实体数据(新增、修改)
  100. /// <param name="_"></param>
  101. /// <summary>
  102. /// <returns></returns>
  103. public Response SaveForm(dynamic _)
  104. {
  105. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  106. HiringRegistrationEntity entity = parameter.strEntity.ToObject<HiringRegistrationEntity>();
  107. var model = hiringRegistrationIBLL.GetIDCard(entity.IdentityCardNo);
  108. if (string.IsNullOrEmpty(parameter.keyValue))
  109. {
  110. if (model != null)
  111. {
  112. return Fail("身份证号已存在!");
  113. }
  114. }
  115. else
  116. {
  117. if (model != null && model.ID != parameter.keyValue)
  118. {
  119. return Fail("身份证号已存在!");
  120. }
  121. }
  122. hiringRegistrationIBLL.SaveEntity(parameter.keyValue, entity);
  123. return Success("保存成功!");
  124. }
  125. /// <summary>
  126. /// 保存实体数据(新增、修改)
  127. /// <param name="_"></param>
  128. /// <summary>
  129. /// <returns></returns>
  130. public Response SaveTalentsForm(dynamic _)
  131. {
  132. ReqFormEntity parameter = this.GetReqData<ReqFormEntity>();
  133. TalentsJoinInfoEntity entity = parameter.strEntity.ToObject<TalentsJoinInfoEntity>();
  134. var model = talentsJoinInfoIBLL.GetIdCard(entity.IdentityCardNo);
  135. if (string.IsNullOrEmpty(parameter.keyValue))
  136. {
  137. if (model != null)
  138. {
  139. return Fail("身份证号已存在!");
  140. }
  141. }
  142. else
  143. {
  144. if (model != null && model.ID != parameter.keyValue)
  145. {
  146. return Fail("身份证号已存在!");
  147. }
  148. }
  149. talentsJoinInfoIBLL.SaveEntity(parameter.keyValue, entity);
  150. return Success("保存成功!");
  151. }
  152. /// <summary>
  153. /// 公开选调工作人员报名表
  154. /// <param name="_"></param>
  155. /// <summary>
  156. /// <returns></returns>
  157. public Response SaveStaffForm(dynamic _)
  158. {
  159. var model = this.GetReqData<ReqFormEntity>();
  160. WorkStaffEntity entity = model.strEntity.ToObject<WorkStaffEntity>();
  161. var models = workStaffIBLL.GetIDCard(entity.IdentityCardNo);
  162. if (string.IsNullOrEmpty(model.keyValue))
  163. {
  164. if (models != null)
  165. {
  166. return Fail("身份证号已存在!");
  167. }
  168. }
  169. else
  170. {
  171. if (models != null && models.ID != model.keyValue)
  172. {
  173. return Fail("身份证号已存在!");
  174. }
  175. }
  176. workStaffIBLL.SaveEntity(model.keyValue, entity, entity.WorkStaffSonEntities);
  177. return Success("保存成功!");
  178. }
  179. #endregion
  180. #region 上传附件图片文件
  181. /// <summary>
  182. /// 上传附件图片文件
  183. /// <summary>
  184. /// <returns></returns>
  185. public Response Upload(dynamic _)
  186. {
  187. var files = (List<HttpFile>)this.Context.Request.Files;
  188. string folderId = Guid.NewGuid().ToString();
  189. string filePath = Config.GetValue("AnnexesFile");
  190. string uploadDate = DateTime.Now.ToString("yyyyMMdd");
  191. string fileEextension = Path.GetExtension(files[0].Name);
  192. string fileType = fileEextension.Replace(".", "");
  193. string fileGuid = Guid.NewGuid().ToString();
  194. string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, "system", uploadDate, fileGuid, fileEextension);
  195. //创建文件夹
  196. string path = Path.GetDirectoryName(virtualPath);
  197. Directory.CreateDirectory(path);
  198. AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity();
  199. if (!System.IO.File.Exists(virtualPath))
  200. {
  201. byte[] bytes = new byte[files[0].Value.Length];
  202. files[0].Value.Read(bytes, 0, bytes.Length);
  203. FileInfo file = new FileInfo(virtualPath);
  204. FileStream fs = file.Create();
  205. fs.Write(bytes, 0, bytes.Length);
  206. fs.Close();
  207. //文件信息写入数据库
  208. fileAnnexesEntity.F_Id = fileGuid;
  209. fileAnnexesEntity.F_FileName = files[0].Name;
  210. fileAnnexesEntity.F_FilePath = virtualPath;
  211. fileAnnexesEntity.F_FileSize = files[0].Value.Length.ToString();
  212. fileAnnexesEntity.F_FileExtensions = fileEextension;
  213. fileAnnexesEntity.F_FileType = fileType;
  214. fileAnnexesEntity.F_CreateUserId = "system";
  215. fileAnnexesEntity.F_CreateUserName = "system";
  216. annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity);
  217. }
  218. return SuccessString(folderId);
  219. }
  220. /// <summary>
  221. /// 删除文件
  222. /// </summary>
  223. /// <param name="_"></param>
  224. /// <returns></returns>
  225. public Response DeleteFile(dynamic _)
  226. {
  227. var fileId = this.GetReqData();
  228. AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId);
  229. annexesFileIBLL.DeleteEntity(fileId);
  230. //删除文件
  231. if (System.IO.File.Exists(fileInfoEntity.F_FilePath))
  232. {
  233. System.IO.File.Delete(fileInfoEntity.F_FilePath);
  234. }
  235. return Success("删除成功");
  236. }
  237. /// <summary>
  238. /// 下载文件
  239. /// </summary>
  240. /// <param name="_"></param>
  241. /// <returns></returns>
  242. public Response DownAnnexesFile(dynamic _)
  243. {
  244. string name = this.GetReqData();
  245. string fileId = name.Split('.')[0];
  246. var data = annexesFileIBLL.GetEntity(fileId);
  247. string filepath = data.F_FilePath;
  248. if (FileDownHelper.FileExists(filepath))
  249. {
  250. FileDownHelper.DownLoadnew(filepath);
  251. }
  252. return Success("");
  253. }
  254. #endregion
  255. #region 私有类
  256. /// <summary>
  257. /// 表单实体类
  258. /// <summary>
  259. private class ReqFormEntity
  260. {
  261. public string keyValue { get; set; }
  262. public string strEntity { get; set; }
  263. }
  264. #endregion
  265. }
  266. }