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

namespace Edu.Repository.Course
{
    public class RB_Course_JobRepository : BaseRepository<Model.Entity.Course.RB_Course_Job>
    {
        /// <summary>
        /// 获取课程作业分页列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="rowsCount"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<RB_Course_Job_ViewModel> GetCourseJobPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Course_Job_ViewModel query)
        {
            rowsCount = 0;
            if (query == null)
            {
                return new List<RB_Course_Job_ViewModel>();
            }
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat(@"
SELECT * 
FROM  RB_Course_Job
WHERE 1=1 
");
            if (query.CourseId > 0)
            {
                builder.AppendFormat(" AND {0}={1} ", nameof(RB_Course_Job_ViewModel.CourseId), query.CourseId);
            }
            return GetPage<RB_Course_Job_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
        }
    }
}
