InventoryApp.cs 2.2 KB
using Hh.Mes.Common.Infrastructure;
using Hh.Mes.Common.Request;
using Hh.Mes.POJO.Response;
using Microsoft.AspNetCore.Hosting;
using System;
using System.Linq;
using System.Linq.Expressions;
using WebRepository;

namespace WebApp
{
    /// <summary>
    /// 库存表
    /// </summary>

    public partial class InventoryApp
    {
        private IUnitWork _unitWork;
        public IRepository<Inventory> _app;
        private static IHostingEnvironment _hostingEnvironment;
        

        public InventoryApp(IUnitWork unitWork, IRepository<Inventory> repository, IHostingEnvironment hostingEnvironment)
        {
            _unitWork = unitWork;
            _app = repository;
            _hostingEnvironment = hostingEnvironment;
        }
        
        public InventoryApp SetLoginInfo(LoginInfo loginInfo)
        {
            _app._loginInfo = loginInfo;
            return this;
        }
        
        public Response Load(PageReq pageRequest, Inventory entity)
        {
            return _app.Load(pageRequest, entity);
        }

        public void Ins(Inventory entity)
        {
            _app.Add(entity);
        }

        public void Upd(Inventory entity)
        {
            _app.Update(entity);
        }

        public void DelByIds(int[] ids)
        {
            _app.Delete(u => ids.Contains(u.Id.Value));
        }
        
        public Inventory FindSingle(Expression<Func<Inventory, bool>> exp)
        {
            return _app.FindSingle(exp);
        }

        public IQueryable<Inventory> Find(Expression<Func<Inventory, bool>> exp)
        {
            return _app.Find(exp);
        }

        public Response ExportData(Inventory entity)
        {
            return _app.ExportData(entity);
        }

        public Response Query(Inventory entity)
        {
            var result = new Response();
            var data = _app.Find(EntityToExpression<Inventory>.GetExpressions(entity));

            GetData(data, result);
            result.Count = data.Count();

            return result;
        }

        public void GetData(IQueryable<Inventory> data, Response result, PageReq pageRequest = null)
        {
            _app.GetData(data, result, pageRequest);
        }
    }
}