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

namespace Edu.Repository.Course
{
    public class RB_Class_LessonCommentRepository : BaseRepository<RB_Class_LessonComment>
    {
        /// <summary>
        /// 获取备案分页列表
        /// </summary>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页显示条数</param>
        /// <param name="rowsCount">总条数</param>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public List<RB_Class_LessonComment_ViewModel> GetLessonCommentList(RB_Class_LessonComment_ViewModel query)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"SELECT *  FROM RB_Class_LessonComment  WHERE 1=1  AND Status=0");
            if (query != null)
            {
                if (query.Group_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Class_LessonComment_ViewModel.Group_Id), query.Group_Id);
                }
                if (query.School_Id > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Class_LessonComment_ViewModel.School_Id), query.School_Id);
                }
                if (query.ClassId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Class_LessonComment_ViewModel.ClassId), query.ClassId);
                }
                if (query.ClassPlanId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Class_LessonComment_ViewModel.ClassPlanId), query.ClassPlanId);
                }
                if (query.LessonPlanId > 0)
                {
                    builder.AppendFormat(" AND {0}={1} ", nameof(RB_Class_LessonComment_ViewModel.LessonPlanId), query.LessonPlanId);
                }
            }
            builder.Append(" ORDER BY CreateTime DESC ");
            return Get<RB_Class_LessonComment_ViewModel>(builder.ToString()).ToList();
        }
    }
}
