using Edu.Model.Entity.Scroll;
using Edu.Model.ViewModel.Scroll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.Scroll
{
///
/// 学员预约子表仓储层
///
public class RB_Plan_Appointment_DetailsRepository : BaseRepository
{
///
/// 获取学员预约详情列表
///
///
///
public List GetPlanAppointmentDetailsListRepository(RB_Plan_Appointment_Details_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Plan_Appointment_Details AS A
WHERE 1=1
");
if (query != null)
{
if (query.PlanAppointmentId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Plan_Appointment_Details_ViewModel.PlanAppointmentId), query.PlanAppointmentId);
}
if (!string.IsNullOrEmpty(query.QPlanAppointmentIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Plan_Appointment_Details_ViewModel.PlanAppointmentId), query.QPlanAppointmentIds);
}
if (query.StuId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Plan_Appointment_Details_ViewModel.StuId), query.StuId);
}
if (!string.IsNullOrEmpty(query.QStuIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Plan_Appointment_Details_ViewModel.StuId), query.QStuIds);
}
}
return Get(builder.ToString()).ToList();
}
///
/// 获取学员预约列表
///
///
///
public List GetPlanAppointmentStaticRepository(RB_Plan_Appointment_Details_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,B.Date,B.StartTime,B.EndTime,IFNULL(C.StuName,'') StuName
FROM RB_Plan_Appointment_Details AS A INNER JOIN RB_Plan_Appointment AS B ON A.PlanAppointmentId=B.Id
LEFT JOIN rb_student AS C ON A.StuId=C.StuId
WHERE 1=1 ");
if (query != null)
{
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND B.{0}={1} ", nameof(RB_Plan_Appointment_ViewModel.Group_Id), query.Group_Id);
}
if (!string.IsNullOrEmpty(query.QStartDate))
{
builder.AppendFormat(" AND B.Date>='{0}' ", query.QStartDate);
}
if (!string.IsNullOrEmpty(query.QEndDate))
{
builder.AppendFormat(" AND B.Date<='{0} 23:59:59' ", query.QEndDate);
}
if (query.Account_Id > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Plan_Appointment_Details_ViewModel.Account_Id), query.Account_Id);
}
if (query.PlanAppointmentId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Plan_Appointment_Details_ViewModel.PlanAppointmentId), query.PlanAppointmentId);
}
}
var list = Get(builder.ToString()).ToList();
return list;
}
}
}