WarehouseController.cs 2.64 KB
using Hh.Mes.Common.Redis;
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Entity;
using Hh.Mes.Service;
using Hh.Mes.Service.SystemAuth;
using Hh.Mes.Service.Warehous;
using Microsoft.AspNetCore.Mvc;
using System;
using WebMvc.Aop;

namespace WebMvc.Areas.warehous.Controllers
{
    /// <summary>
	/// 仓库设置
	/// </summary>
    [Area("warehous")]
    public class WarehouseController : BaseController
    {
        private readonly WarehouseService Service;
        private readonly Lazy<RedisBase> cli;

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

            cli = new Lazy<RedisBase>();
        }

        #region 视图功能
        [Authenticate]
        public ActionResult Index()
        {
            return View();
        }
        #endregion

        #region 数据操作

        /// <summary>
        /// 加载及分页查询
        /// </summary>
        [HttpPost]
        public string Load(PageReq pageRequest, base_warehouse entity)
        {
            return Serialize(Service.Load(pageRequest, entity));
        }

        /// <summary>
        /// 新增数据
        /// </summary>
        [HttpPost]
        [XSSFilter]
        [ServiceFilter(typeof(OperLogFilter))]
        public string Ins(base_warehouse entity)
        {
            cli.Value.redisClient.Del("base_warehouse");
            return Serialize(Service.Ins(entity));
        }

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

        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        [ServiceFilter(typeof(OperLogFilter))]
        public string DelByIds(string[] ids)
        {
            cli.Value.redisClient.Del("base_warehouse");
            return Serialize(Service.DelByIds(ids));
        }

        #endregion

        #region 导出模板
        /// <summary>
        /// 导出模板
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Export(PageReq pageRequest, base_warehouse entity)
        {
            return Serialize(Service.ExportData(pageRequest, entity));
        }

        #endregion

    }
}