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

namespace Edu.Repository.Finance
{
    /// <summary>
    /// 财务流程费用配置仓储层
    /// </summary>
    public class RB_Finance_ConfigRepository : BaseRepository<RB_Finance_Config>
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <returns></returns>
        public List<RB_Finance_Config_ViewModel> GetList(RB_Finance_Config_ViewModel demodel)
        {
            string where = $@" 1=1 and Status =0";

            if (demodel.Group_Id > 0)
            {
                where += $@" and {nameof(RB_Finance_Config_ViewModel.Group_Id)} ={demodel.Group_Id}";
            }
            if (demodel.Type > 0)
            {
                where += $@" and {nameof(RB_Finance_Config_ViewModel.Type)} ={(int)demodel.Type}";
            }

            string sql = $@" select * from RB_Finance_Config where {where} order by Id desc";
            return Get<RB_Finance_Config_ViewModel>(sql).ToList();
        }
    }
}