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

namespace Edu.Repository.EduTask
{
    /// <summary>
    /// 教务单据审核人员信息仓储层
    /// </summary>
    public class RB_Education_RelevanceRepository : BaseRepository<RB_Education_Relevance>
    {
        /// <summary>
        /// 获取教务审核列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Education_Relevance_ViewModel> GetEducationRelevanceListRepository(RB_Education_Relevance_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT * 
FROM RB_Education_Relevance
WHERE 1=1
");
            if (query != null)
            {
                if (query.ConditionId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Education_Relevance_ViewModel.ConditionId), query.ConditionId);
                }
                if (query.Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Education_Relevance_ViewModel.Id), query.Id);
                }
                if (!string.IsNullOrEmpty(query.QConditionIds))
                {
                    builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Education_Relevance_ViewModel.ConditionId), query.QConditionIds);
                }
            }
            builder.AppendFormat(" ORDER BY Sort ASC ");
            return Get<RB_Education_Relevance_ViewModel>(builder.ToString()).ToList();
        }
    }
}