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

namespace Edu.Repository.EduTask
{
    /// <summary>
    /// 临时上课邀请申请仓储
    /// </summary>
    public class RB_Student_TempInvitationRepository : BaseRepository<RB_Student_TempInvitation>
    {
        /// <summary>
        /// 教务单据仓储层对象
        /// </summary>
        private readonly RB_Education_ReceiptRepository education_ReceiptRepository = new RB_Education_ReceiptRepository();


        /// <summary>
        /// 获取临时上课邀请申请列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Student_TempInvitation_ViewModel> GetStundetTempInvitationListRepository(RB_Student_TempInvitation_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@" 
SELECT A.*,IFNULL(B.ClassName,'') AS ClassName
FROM RB_Student_TempInvitation AS A LEFT JOIN rb_class AS B ON A.ClassId=B.ClassId
WHERE 1=1
");
            if (query != null)
            {
                if (!string.IsNullOrEmpty(query.Q_TempInvitation_Ids))
                {
                    builder.AppendFormat(@" AND A.{0} IN ({1}) ", nameof(RB_Student_TempInvitation_ViewModel.Id), query.Q_TempInvitation_Ids);
                }
            }
            return Get<RB_Student_TempInvitation_ViewModel>(builder.ToString()).ToList();
        }
    }
}
