using Edu.Model.Entity.Exam;
using Edu.Model.ViewModel.Exam;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Edu.Repository.Exam
{
    /// <summary>
    /// 学员单词复习仓储层
    /// </summary>
    public class RB_StuWords_ReviewRepository : BaseRepository<RB_StuWords_Review>
    {
        /// <summary>
        /// 获取单词复习列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_StuWords_Review_Extend> GetStuWordsReviewListRepository(RB_StuWords_Review_Extend query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@" SELECT A.* FROM RB_StuWords_Review AS A WHERE 1=1 ");
            if (query != null)
            {
                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_StuWords_Review_Extend.Group_Id), query.Group_Id);
                }
                if (query.CourseId > 0)
                {
                    builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_StuWords_Review_Extend.CourseId), query.CourseId);
                }
                if (query.ChapterId > 0)
                {
                    builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_StuWords_Review_Extend.ChapterId), query.ChapterId);
                }
                if (query.Stu_Account_Id > 0)
                {
                    builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_StuWords_Review_Extend.Stu_Account_Id), query.Stu_Account_Id);
                }
            }
            return Get<RB_StuWords_Review_Extend>(builder.ToString()).ToList();
        }
    }
}
