using CZFW.Framework.Logic;
using CZFW.Framework.Model.ViewModel;
using CZKJ.GBRS2.Entity;
using CZKJ.GBRS2.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CZKJ.GBRS2.Logic
{
    public class FilesLogic : LogicBase<FilesEntity>, IFiles
    {
        public TableModel<FilesEntity> GetTableList(int pageIndex = 1, int pageSize = 20, string name = "")
        {
            TableModel<FilesEntity> res = new TableModel<FilesEntity>();
            var query = Queryable;
            if (!string.IsNullOrWhiteSpace(name))
            {
                query = query.Where(x => x.Name.Contains(name));
            }
            res.SetData(query.ToList());
            res.Pager = new PagerModel { PageIndex = pageIndex, PageSize = pageSize, TotalItems = query.Count() };
            res.TableHeads = PropertyHelper.Get(typeof(FilesEntity));
            return res;
                    
        }
    }
}