SysInfoController.cs 3.48 KB
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.Response;
using Hh.Mes.Service;
using Hh.Mes.Service.SystemAuth;
using Hh.Mes.Service.WebService.Base;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using WebMvc.Aop;


namespace WebMvc
{
    /// <summary>
	/// 系统信息
	/// </summary>
    [Area("base")]
    public class SysInfoController : BaseController
    {
        private readonly SysInfoService service;
        
        public SysInfoController(IAuth authUtil, SysInfoService service) : base(authUtil)
        {
            this.service = service;
            this.service.sysWebUser = authUtil.GetCurrentUser().User;
        }

        #region 视图功能
        /// <summary>
        /// 默认视图Action
        /// </summary>
        /// <returns></returns>
        [Authenticate]
        [ServiceFilter(typeof(OperLogFilter))]
        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, SysInfo entity)
        {
            return Serialize(service.Load(pageRequest, entity));
        }
        #endregion

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

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

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

        #region 导出数据
        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="entity">请求条件实例</param>
        /// <returns></returns>
        [HttpPost]
        public string Export(SysInfo entity)
        {
            return Serialize(service.Load(null,entity));
        }
        #endregion

        #region 导出模板
        /// <summary>
        /// 导出模板
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string GetTemplate()
        {
            var result = new Response();
            List<SysInfo> listSysInfo = new List<SysInfo>();
            SysInfo entity = service.Context.Queryable<SysInfo>().First(u => u.Id > 0);
            if (entity != null)
            {
                listSysInfo.Add(entity);
            }
            else
            {
                listSysInfo.Add(new SysInfo());
            }
 
            result.Result = listSysInfo;
            result.Count = listSysInfo.Count;

            return Serialize(result);
        }
        #endregion

         

        #region 自定义方法

        #endregion
    }
}