using System.Collections.Generic;
using System.Linq;
using System.Text;
using Edu.Common.Enum;
using Edu.Model.Entity.Finance;
using Edu.Model.ViewModel.Finance;

namespace Edu.Repository.Finance
{
    /// <summary>
    /// 简易报表仓储层
    /// </summary>
    public partial class RB_SimpleReportRepository : BaseRepository<RB_SimpleReport>
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<RB_SimpleReport_Extend> GetList(RB_SimpleReport_Extend model)
        {
            string where = " 1=1 ";
            if (model.Year > 0)
            {
                where += string.Format(" AND A." + nameof(RB_SimpleReport_Extend.Year) + "=" + model.Year);
            }
            if (model.Rb_Group_Id > 0)
            {
                where += string.Format(" AND A." + nameof(RB_SimpleReport_Extend.Rb_Group_Id) + "=" + model.Rb_Group_Id);
            }
            if (model.BranchId >= -1)
            {
                where += string.Format(" AND A." + nameof(RB_SimpleReport_Extend.BranchId) + "=" + model.BranchId);
            }
            if (!string.IsNullOrEmpty(model.Abstract))
            {
                where += string.Format(" AND A." + nameof(RB_SimpleReport_Extend.Abstract) + "='{0}'", model.Abstract);
            }
            if (model.IsSelectAllCompany == 1)
            {
                where += string.Format(" AND A." + nameof(RB_SimpleReport_Extend.BranchId) + " !=-1 ");
            }
            string sql = string.Format(@"SELECT * FROM {0} AS A WHERE {1} ", nameof(RB_SimpleReport), where);
            return Get<RB_SimpleReport_Extend>(sql).ToList();
        }
    }
}
