using System; using System.Collections.Generic; using System.Linq; using System.Text; using Edu.Common.Enum; using Edu.Model.Entity.User; using Edu.Model.ViewModel.User; using VT.FW.DB.Dapper; namespace Edu.Repository.User { /// <summary> /// 学员事件记录仓储层 /// </summary> public class RB_Student_EventLogRepository : BaseRepository<RB_Student_EventLog> { /// <summary> /// 获取学员事件记录分页列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="rowsCount"></param> /// <param name="query"></param> /// <returns></returns> public List<RB_Student_EventLog_ViewModel> GetStudentEventLogPageList(int pageIndex, int pageSize, out long rowsCount, RB_Student_EventLog_ViewModel query) { var parameters = new DynamicParameters(); StringBuilder builder = new StringBuilder(); builder.AppendFormat(@" SELECT t.* FROM RB_Student_EventLog AS t WHERE 1=1 "); builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_EventLog_ViewModel.Status), (int)DateStateEnum.Normal); if (query != null) { if (query.Group_Id > 0) { builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_EventLog_ViewModel.Group_Id), query.Group_Id); } if (query.School_Id > 0) { builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_EventLog_ViewModel.School_Id), query.School_Id); } if (query.StuId > 0) { builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_EventLog_ViewModel.StuId), query.StuId); } if (query.EventType > 0) { builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_EventLog_ViewModel.EventType), query.EventType); } } builder.AppendFormat(" order by t.{0} desc ", nameof(RB_Student_EventLog_ViewModel.CreateTime)); return GetPage<RB_Student_EventLog_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList(); } } }