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

namespace Edu.Repository.Exam
{
    /// <summary>
    /// 考试配置仓储类
    /// </summary>
    public class RB_Examination_ConfigureRepository : BaseRepository<RB_Examination_Configure>
    {
        /// <summary>
        /// 获取配置列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Examination_Configure_ViewModel> GetExaminationConfigureListRepository(RB_Examination_Configure_ViewModel query)
        {
            var parameters = new DynamicParameters();
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT A.*
FROM RB_Examination_Configure AS A
WHERE 1=1 
");
            builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Examination_Configure_ViewModel.Status), 0);
            if (query != null)
            {
                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Examination_Configure_ViewModel.Group_Id), query.Group_Id);
                }
            }
            return Get<RB_Examination_Configure_ViewModel>(builder.ToString(), parameters).ToList();
        }
    }
}
