|
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.PersonnelManagement;
- using System.Web.Mvc;
- using System.Collections.Generic;
- using Quanjiang.DigitalScholl.SendSms;
- using System;
- using Learun.Cache.Redis;
-
- namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2021-05-17 10:11
- /// 描 述:访客管理
- /// </summary>
- public class VisitorInfoController : MvcControllerBase
- {
- private VisitorInfoIBLL visitorInfoIBLL = new VisitorInfoBLL();
- CacheByRedis _redis = new CacheByRedis();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult FormAdd()
- {
- return View();
- }
- /// <summary>
- ///
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ExamineForm()
- {
- return View();
- }
-
- #endregion
-
- #region 获取数据
- /// <summary>
- /// 生成验证码
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult VerifyCode()
- {
- return File(new VerifyCode().GetVerifyCode(), @"image/Gif");
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = visitorInfoIBLL.GetPageList(paginationobj, queryJson);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var VisitorInfoData = visitorInfoIBLL.GetVisitorInfoEntity(keyValue);
- var jsonData = new
- {
- VisitorInfo = VisitorInfoData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- visitorInfoIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="strEntity">实体</param>
- /// <param name="verifycode">图片验证码</param>
- /// <param name="phonecode">手机验证码</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity, string verifycode, string phonecode)
- {
- VisitorInfoEntity entity = strEntity.ToObject<VisitorInfoEntity>();
- var VisitorInfoData = visitorInfoIBLL.GetEntityByPhone(entity.VPhone);
- if (string.IsNullOrEmpty(keyValue) && VisitorInfoData != null)
- return Fail("手机号已存在!");
- else if (!string.IsNullOrEmpty(keyValue) && VisitorInfoData.VID != keyValue)
- return Fail("手机号已存在!");
-
- //验证图片验证码
- verifycode = Md5Helper.Encrypt(verifycode.ToLower(), 16);
- if (Session["session_verifycode"].IsEmpty() || verifycode != Session["session_verifycode"].ToString())
- {
- return Fail("图片验证码错误");
- }
- //验证手机验证码
- var type = (SmsType)Enum.Parse(typeof(SmsType), "0");
- var smscode = _redis.Read<string>($"checkcode_{type}_{entity.VPhone}");
- if (!string.IsNullOrEmpty(smscode))
- {
- if (smscode != phonecode)
- {
- return Fail("手机验证码不正确,请核对!");
- }
- }
-
- entity.VState = 0;
- entity.VApplyTime = DateTime.Now;
- visitorInfoIBLL.SaveEntity(keyValue, entity);
- if (string.IsNullOrEmpty(keyValue))
- {
- }
- return Success("保存成功!");
- }
-
- /// <summary>
- /// 审核
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult Check(string keyValue,string strEntity)
- {
- //var keyValueArr = keyValue.Split(',');
- //var keyValues = "'" + string.Join("','", keyValueArr) + "'";
- VisitorInfoEntity entity = strEntity.ToObject<VisitorInfoEntity>();
-
- visitorInfoIBLL.Check(keyValue, entity.VExamineRemarks);
-
- return Success("审核成功!");
- }
-
- /// <summary>
- /// 取消审核
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult UnCheck(string keyValue)
- {
- var keyValueArr = keyValue.Split(',');
- var keyValues = "'" + string.Join("','", keyValueArr) + "'";
- visitorInfoIBLL.UnCheck(keyValues);
- return Success("取消审核成功!");
- }
-
-
- /// <summary>
- /// 全部审核
- /// <param name="keyValue">主键</param>
- /// <summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult CheckAll()
- {
- visitorInfoIBLL.CheckAll();
- return Success("全部审核成功!");
- }
-
- /// <summary>
- /// 生成帐号
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult Generate()
- {
- visitorInfoIBLL.GenerateAccout();
- return Success("生成成功!");
- }
- #endregion
-
- }
- }
|