using System; using System.Collections.Generic; using System.Linq; using System.Text; using Edu.Common.Enum; using Edu.Model.Entity.App; using Edu.Model.ViewModel.App; namespace Edu.Repository.App { /// /// 学生app系统消息 /// public class RB_Student_SystemMsgRepository : BaseRepository { /// /// 获取学生app系统消息 /// /// /// public List GetStudentSystemMsgList(RB_Student_SystemMsg_ViewModel query) { StringBuilder builder = new StringBuilder(); builder.AppendFormat(@" SELECT * FROM RB_Student_SystemMsg WHERE 1=1 "); builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.Status), (int)DateStateEnum.Normal); if (query != null) { if (query.Group_Id > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.Group_Id), query.Group_Id); } if (query.School_Id > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.School_Id), query.School_Id); } if (query.Student_Id > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.Student_Id), query.Student_Id); } if (query.MsgId > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.MsgId), query.MsgId); } if (query.IsRead > -1) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.IsRead), query.IsRead); } if (query.MsgType.HasValue && query.MsgType.Value > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.MsgType), (int)query.MsgType); } if (query.StudentType.HasValue && query.StudentType.Value > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.StudentType), (int)query.StudentType); } } return Get(builder.ToString()).ToList(); } /// /// 获取学生app系统分页列表 /// /// 当前页 /// 每页显示条数 /// 总条数 /// 查询条件 /// public List GetStudentSystemMsgPageListRepository(int pageIndex, int pageSize, out long rowsCount, RB_Student_SystemMsg_ViewModel query) { StringBuilder builder = new StringBuilder(); builder.AppendFormat(@" SELECT * FROM RB_Student_SystemMsg WHERE 1=1 "); if (query != null) { if (query.Group_Id > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.Group_Id), query.Group_Id); } if (query.School_Id > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.School_Id), query.School_Id); } if (query.Student_Id > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.Student_Id), query.Student_Id); } if (query.IsRead > -1) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.IsRead), query.IsRead); } if (query.MsgType.HasValue && query.MsgType.Value > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.MsgType), (int)query.MsgType); } if (query.StudentType.HasValue && query.StudentType.Value > 0) { builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_SystemMsg.StudentType), (int)query.StudentType); } } builder.Append(" ORDER BY MsgId DESC "); return GetPage(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList(); } } }