public List <DtoStudentWrongBookInfo> GetBookList(DtoStudentWrongSearch search) { if (search == null) { return(null); } var strWhere = new StringBuilder(); var fields = "swb.*,c.Ycs_Name AS CourseName,cl.Ycl_Name AS CourseLessonName"; var orderBy = "Yws_CreateTime DESC "; var parameters = new DynamicParameters(); strWhere.Append($@"dbo.Yw_StudentWrongBook swb INNER JOIN dbo.Yw_Course c ON swb.Ywb_CourseId=c.Ycs_Id LEFT JOIN dbo.Yw_CourseLesson cl ON cl.Ycl_Id=swb.Ywb_LessonId WHERE 1=1 AND swb.Yws_Status<>{(int)StudyWrongStatusEnum.已消除}"); if (search.StudentId > 0) { strWhere.Append(" AND swb.Ywb_StudentId=@Ywb_StudentId "); parameters.Add("Ywb_StudentId", search.StudentId); } if (search.BookId > 0) { strWhere.Append(" AND swb.Ywb_Id=@Ywb_Id "); parameters.Add("Ywb_Id", search.BookId); } else { if (!search.BeginDate.IsDefaultTime()) { //strWhere.Append(" AND swb.Yws_CreateTime>@beginDate "); strWhere.Append(" AND DATEDIFF(DAY,swb.Yws_CreateTime,@beginDate)<=0"); parameters.Add("beginDate", search.BeginDate); } if (!search.EndDate.IsDefaultTime()) { strWhere.Append(" AND DATEDIFF(DAY,swb.Yws_CreateTime,@endDate)>=0"); parameters.Add("endDate", search.EndDate); } } return(base.QueryPaging <DtoStudentWrongBookInfo>(fields, strWhere._ToString(), orderBy, search.Pagination, parameters).ToList()); }
public ActionResult WrongBookList(DtoStudentWrongSearch search) { StudentWrongBookBll wrongBookBll = new StudentWrongBookBll(); search.StudentId = GetCurrentUser().StudentId; var list = wrongBookBll.GetBookList(search); #region 错误传pageinde处理 if ((list == null || list.Count == 0) && search.Pagination.PageIndex > 1 && search.Pagination.TotalCount > 0) { search.Pagination.PageIndex = 1; list = wrongBookBll.GetBookList(search); } #endregion #region testdata //list = new List<DtoStudentWrongBookInfo>(); //for (int i = 0; i < 2; i++) //{ // list.Add(new DtoStudentWrongBookInfo() // { // CourseLessonName = "CourseLessonName", // CourseName = "CourseName", // Ywb_Id = 1, // Yws_CreateTime = DateTime.Now, // Yws_Source = i % 4 == 0 ? 1 : i % 4, // Yws_Status = i % 2 == 0 ? 1 : 2, // Yws_RemoveCount = 1, // Yws_WrongCount = 3, // Yws_WrongKnowledgeCount = 1, // }); //} //search.Pagination.TotalCount = 20; #endregion var table = AbhsTableFactory.Create(list, search.Pagination.TotalCount); return(Json(table, JsonRequestBehavior.AllowGet)); }
public List <DtoStudentWrongBookInfo> GetBookList(DtoStudentWrongSearch search) { return(StudentWrongBookRepository.GetBookList(search)); }