ProcessRouteController.cs 4.49 KB
using Hh.Mes.Common.Redis;
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Entity;
using Hh.Mes.Service;
using Hh.Mes.Service.Configure;
using Hh.Mes.Service.SystemAuth;
using Microsoft.AspNetCore.Mvc;
using System;
using WebMvc.Aop;


namespace WebMvc
{
    /// <summary>
	/// 工艺线路
	/// </summary>
    [Area("configure")]
    public class ProcessRouteController : BaseController
    {
        private readonly ProcessRouteService service;
        private readonly Lazy<RedisBase> cli;

        public ProcessRouteController(IAuth authUtil, ProcessRouteService Service) : base(authUtil)
        {
            service = Service;
            service.sysWebUser = authUtil.GetCurrentUser().User;

            cli = new Lazy<RedisBase>();
        }

        #region 视图功能
        [ResponseCache(Duration = 10)]
        public ActionResult Index()
        {
            return View();
        }

        #endregion

        #region 获取数据
        /// <summary>
        /// 加载及分页查询
        /// </summary>
        /// <param name="pageRequest">表单请求信息</param>
        /// <param name="entity">请求条件实例</param>
        /// <returns></returns>
        [HttpPost]
        public string Load(PageReq pageRequest, base_process_route_head entity)
        {
            return Serialize(service.Load(pageRequest, entity));
        }
        /// <summary>
        /// 加载及分页查询
        /// </summary>
        /// <param name="pageRequest">表单请求信息</param>
        /// <param name="entity">请求条件实例</param>
        /// <returns></returns>
        [HttpPost]
        public string LoadDesc(PageReq pageRequest, base_process_route_detail entity)
        {
            return Serialize(service.LoadDesc(pageRequest, entity));
        }


        #endregion

        #region 头表提交数据
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="entity">新增实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string Ins(base_process_route_head entity)
        {
            cli.Value.redisClient.Del("base_process_route_head");
            return Serialize(service.Ins(entity));
        }

        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="entity">修改实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string Upd(base_process_route_head entity)
        {
            cli.Value.redisClient.Del("base_process_route_head");
            return Serialize(service.Upd(entity));
        }

        [HttpPost]
        [ServiceFilter(typeof(OperLogFilter))]
        public string DelByIds(Guid[] ids)
        {
            cli.Value.redisClient.Del("base_process_route_head");
            return Serialize(service.DelByIds(ids));
        }
        #endregion

        #region 明细表提交数据
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="entity">新增实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string InsDesc(base_process_route_detail entity)
        {
            return Serialize(service.InsDesc(entity));
        }

        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="entity">修改实例</param>
        /// <returns></returns>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string UpdDesc(base_process_route_detail entity)
        {
            return Serialize(service.UpdDesc(entity));
        }

        [HttpPost]
        [ServiceFilter(typeof(OperLogFilter))]
        public string DelByIdsDesc(Guid[] ids)
        {
            return Serialize(service.DelByIdsDesc(ids));
        }
        #endregion

        #region 导出
        /// <summary>
        /// 导出
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Export(base_process_route_head entity)
        {
            return Serialize(service.Export(entity));
        }

        #endregion

        #region 自定义方法
        /// <summary>
        /// 返回工艺路线明细 工序
        /// </summary>
        [HttpPost]
        public string GetProcessDetail()
        {
            return Serialize(service.GetProcessDetail());
        }

        #endregion
    }

}