using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Course;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;

namespace Edu.Repository.Course
{
    /// <summary>
    /// 教务奖励仓储层
    /// </summary>
    public class RB_Teaching_RewardsRepository : BaseRepository<RB_Teaching_Rewards>
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="demodel"></param>
        /// <param name="orderIds"></param>
        /// <returns></returns>
        public List<RB_Teaching_Rewards_ViewModel> GetList(RB_Teaching_Rewards_ViewModel demodel)
        {
            string where = $@" 1=1";
            
            if (demodel.FullClassRateId > 0)
            {
                where += $@" and {nameof(RB_Teaching_Rewards.FullClassRateId)} ={demodel.FullClassRateId}";
            }
            if (!string.IsNullOrEmpty(demodel.FullClassRateIds))
            {
                where += $@" and {nameof(RB_Teaching_Rewards.FullClassRateId)} in({demodel.FullClassRateIds})";
            }
            if (demodel.TackClassRateId > 0)
            {
                where += $@" and {nameof(RB_Teaching_Rewards.TackClassRateId)} ={demodel.TackClassRateId}";
            }
            if (!string.IsNullOrEmpty(demodel.TackClassRateIds))
            {
                where += $@" and {nameof(RB_Teaching_Rewards.TackClassRateId)} in({demodel.TackClassRateIds})";
            }

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