You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

238 lines
7.2 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.PersonnelManagement;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using Quanjiang.DigitalScholl.SendSms;
  7. using System;
  8. using Learun.Cache.Redis;
  9. namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2021-05-17 10:11
  16. /// 描 述:访客管理
  17. /// </summary>
  18. public class VisitorInfoController : MvcControllerBase
  19. {
  20. private VisitorInfoIBLL visitorInfoIBLL = new VisitorInfoBLL();
  21. CacheByRedis _redis = new CacheByRedis();
  22. #region 视图功能
  23. /// <summary>
  24. /// 主页面
  25. /// <summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public ActionResult Index()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 表单页
  34. /// <summary>
  35. /// <returns></returns>
  36. [HttpGet]
  37. public ActionResult Form()
  38. {
  39. return View();
  40. }
  41. /// <summary>
  42. /// 表单页
  43. /// <summary>
  44. /// <returns></returns>
  45. [HttpGet]
  46. public ActionResult FormAdd()
  47. {
  48. return View();
  49. }
  50. /// <summary>
  51. ///
  52. /// <summary>
  53. /// <returns></returns>
  54. [HttpGet]
  55. public ActionResult ExamineForm()
  56. {
  57. return View();
  58. }
  59. #endregion
  60. #region 获取数据
  61. /// <summary>
  62. /// 生成验证码
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult VerifyCode()
  67. {
  68. return File(new VerifyCode().GetVerifyCode(), @"image/Gif");
  69. }
  70. /// <summary>
  71. /// 获取页面显示列表数据
  72. /// </summary>
  73. /// <param name="pagination">分页参数</param>
  74. /// <param name="queryJson">查询参数</param>
  75. /// <returns></returns>
  76. [HttpGet]
  77. [AjaxOnly]
  78. public ActionResult GetPageList(string pagination, string queryJson)
  79. {
  80. Pagination paginationobj = pagination.ToObject<Pagination>();
  81. var data = visitorInfoIBLL.GetPageList(paginationobj, queryJson);
  82. var jsonData = new
  83. {
  84. rows = data,
  85. total = paginationobj.total,
  86. page = paginationobj.page,
  87. records = paginationobj.records
  88. };
  89. return Success(jsonData);
  90. }
  91. /// <summary>
  92. /// 获取表单数据
  93. /// </summary>
  94. /// <param name="keyValue">主键</param>
  95. /// <returns></returns>
  96. [HttpGet]
  97. [AjaxOnly]
  98. public ActionResult GetFormData(string keyValue)
  99. {
  100. var VisitorInfoData = visitorInfoIBLL.GetVisitorInfoEntity(keyValue);
  101. var jsonData = new
  102. {
  103. VisitorInfo = VisitorInfoData,
  104. };
  105. return Success(jsonData);
  106. }
  107. #endregion
  108. #region 提交数据
  109. /// <summary>
  110. /// 删除实体数据
  111. /// </summary>
  112. /// <param name="keyValue">主键</param>
  113. /// <returns></returns>
  114. [HttpPost]
  115. [AjaxOnly]
  116. public ActionResult DeleteForm(string keyValue)
  117. {
  118. visitorInfoIBLL.DeleteEntity(keyValue);
  119. return Success("删除成功!");
  120. }
  121. /// <summary>
  122. /// 保存实体数据(新增、修改)
  123. /// </summary>
  124. /// <param name="keyValue">主键</param>
  125. /// <param name="strEntity">实体</param>
  126. /// <param name="verifycode">图片验证码</param>
  127. /// <param name="phonecode">手机验证码</param>
  128. /// <returns></returns>
  129. [HttpPost]
  130. [ValidateAntiForgeryToken]
  131. [AjaxOnly]
  132. public ActionResult SaveForm(string keyValue, string strEntity, string verifycode, string phonecode)
  133. {
  134. VisitorInfoEntity entity = strEntity.ToObject<VisitorInfoEntity>();
  135. var VisitorInfoData = visitorInfoIBLL.GetEntityByPhone(entity.VPhone);
  136. if (string.IsNullOrEmpty(keyValue) && VisitorInfoData != null)
  137. return Fail("手机号已存在!");
  138. else if (!string.IsNullOrEmpty(keyValue) && VisitorInfoData.VID != keyValue)
  139. return Fail("手机号已存在!");
  140. //验证图片验证码
  141. verifycode = Md5Helper.Encrypt(verifycode.ToLower(), 16);
  142. if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString())
  143. {
  144. return Fail("图片验证码错误");
  145. }
  146. //验证手机验证码
  147. var type = (SmsType)Enum.Parse(typeof(SmsType), "0");
  148. var smscode = _redis.Read<string>($"checkcode_{type}_{entity.VPhone}");
  149. if (!string.IsNullOrEmpty(smscode))
  150. {
  151. if (smscode != phonecode)
  152. {
  153. return Fail("手机验证码不正确,请核对!");
  154. }
  155. }
  156. entity.VState = 0;
  157. entity.VApplyTime = DateTime.Now;
  158. visitorInfoIBLL.SaveEntity(keyValue, entity);
  159. if (string.IsNullOrEmpty(keyValue))
  160. {
  161. }
  162. return Success("保存成功!");
  163. }
  164. /// <summary>
  165. /// 审核
  166. /// <param name="keyValue">主键</param>
  167. /// <summary>
  168. /// <returns></returns>
  169. [HttpPost]
  170. [AjaxOnly]
  171. public ActionResult Check(string keyValue,string strEntity)
  172. {
  173. //var keyValueArr = keyValue.Split(',');
  174. //var keyValues = "'" + string.Join("','", keyValueArr) + "'";
  175. VisitorInfoEntity entity = strEntity.ToObject<VisitorInfoEntity>();
  176. visitorInfoIBLL.Check(keyValue, entity.VExamineRemarks);
  177. return Success("审核成功!");
  178. }
  179. /// <summary>
  180. /// 取消审核
  181. /// <param name="keyValue">主键</param>
  182. /// <summary>
  183. /// <returns></returns>
  184. [HttpPost]
  185. [AjaxOnly]
  186. public ActionResult UnCheck(string keyValue)
  187. {
  188. var keyValueArr = keyValue.Split(',');
  189. var keyValues = "'" + string.Join("','", keyValueArr) + "'";
  190. visitorInfoIBLL.UnCheck(keyValues);
  191. return Success("取消审核成功!");
  192. }
  193. /// <summary>
  194. /// 全部审核
  195. /// <param name="keyValue">主键</param>
  196. /// <summary>
  197. /// <returns></returns>
  198. [HttpPost]
  199. [AjaxOnly]
  200. public ActionResult CheckAll()
  201. {
  202. visitorInfoIBLL.CheckAll();
  203. return Success("全部审核成功!");
  204. }
  205. /// <summary>
  206. /// 生成帐号
  207. /// </summary>
  208. /// <returns></returns>
  209. [HttpPost]
  210. [AjaxOnly]
  211. public ActionResult Generate()
  212. {
  213. visitorInfoIBLL.GenerateAccout();
  214. return Success("生成成功!");
  215. }
  216. #endregion
  217. }
  218. }