using Edu.Common.Enum;
using Edu.Model.Entity.Scroll;
using Edu.Model.ViewModel.Scroll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB.Dapper;
namespace Edu.Repository.Scroll
{
///
/// 滚动开班班次仓储层
///
public class RB_Scroll_PlanRepository : BaseRepository
{
///
/// 获取列表
///
///
///
public List GetList(RB_Scroll_Plan_ViewModel demodel)
{
DynamicParameters parameters = new DynamicParameters();
string where = $@" 1=1 and r.{nameof(RB_Scroll_Plan_ViewModel.Status)} =0";
if (demodel.Group_Id > 0)
{
where += $@" and r.{nameof(RB_Scroll_Plan_ViewModel.Group_Id)} ={demodel.Group_Id}";
}
if (demodel.AccountId > 0)
{
where += $@" and r.{nameof(RB_Scroll_Plan_ViewModel.AccountId)} ={demodel.AccountId}";
}
if (!string.IsNullOrEmpty(demodel.STime))
{
where += $@" and r.{nameof(RB_Scroll_Plan_ViewModel.Date)} >='{demodel.STime}'";
}
if (!string.IsNullOrEmpty(demodel.ETime))
{
where += $@" and r.{nameof(RB_Scroll_Plan_ViewModel.Date)} <='{demodel.ETime} 23:59:59'";
}
string sql = $@"
SELECT r.*,a.AccountId as TeacherId From RB_Scroll_Plan r
inner join rb_account a on r.AccountId = a.Id
WHERE {where}
ORDER BY r.Id asc ";
return Get(sql, parameters).ToList();
}
///
/// 获取日期范围老师排课列表
///
///
///
///
///
public List GetTeacherPlanForDay(string date, int schoolId, int group_Id, int teacherId =0)
{
string sql = $@"SELECT p.*,a.AccountId as TeacherId,t.TeacherName,t.TeacherHead,t.TeacherIntro,r.RoomName,s.SName as SchoolName FROM rb_scroll_plan p
inner join rb_account a on p.AccountId = a.Id
inner join rb_teacher t on a.AccountId = t.TId
inner join rb_class_room r on p.RoomId = r.RoomId
inner join rb_school s on r.School_Id = s.SId
WHERE p.`Status` =0 and p.Group_Id ={group_Id} and p.Date ='{date}' and p.ShiftId >0";
if (schoolId >= 0) {
sql += $@" and r.School_Id ={schoolId}";
}
if (teacherId > 0) {
sql += $@" and t.TId ={teacherId}";
}
return Get(sql).ToList();
}
}
}