builder.AppendFormat(@" SELECT A.* FROM RB_Duty_Config AS A WHERE 1=1 ");
builder.AppendFormat(@" SELECT A.*,(SELECT GROUP_CONCAT(`Name`) from rb_duty_frequency where `Status`=0 and FIND_IN_SET(Id,a.Shifts) GROUP BY `Status`=0) as ShiftsName,B.SName AS SchoolName FROM RB_Duty_Config AS A LEFT JOIN rb_school AS B ON A.School_Id=B.SId WHERE 1=1 ");
if(query!=null)
{
if(query.Group_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Config_ViewModel.Group_Id),query.Group_Id);
}
if(query.Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Config_ViewModel.Id),query.Id);
}
if(query.School_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Config_ViewModel.School_Id),query.School_Id);
builder.AppendFormat(@" SELECT A.*,(SELECT GROUP_CONCAT(SName) from rb_school where `Status`=0 and FIND_IN_SET(SId,a.School_Ids) GROUP BY `Status`=0) as SchoolName FROM RB_Duty_Frequency AS A WHERE 1=1 ");
if(query!=null)
...
...
@@ -36,7 +36,34 @@ namespace Edu.Repository.Duty
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Frequency_ViewModel.Status),(int)query.Status);
builder.AppendFormat(@" SELECT A.*,(SELECT GROUP_CONCAT(SName) from rb_school where `Status`=0 and FIND_IN_SET(SId,a.ItemSchools) GROUP BY `Status`=0) as SchoolName,
(SELECT GROUP_CONCAT(`Name`) from rb_duty_frequency where `Status`=0 and FIND_IN_SET(Id,a.Shifts) GROUP BY `Status`=0) as ShiftsName
FROM RB_Duty_Item AS A WHERE 1=1 ");
if(query!=null)
{
if(query.Group_Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Item_ViewModel.Group_Id),query.Group_Id);
}
if(query.Id>0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Item_ViewModel.Id),query.Id);
}
if(query.Status>=0)
{
builder.AppendFormat(" AND A.{0}={1} ",nameof(RB_Duty_Item_ViewModel.Status),(int)query.Status);
builder.AppendFormat($@"SELECT * from rb_school as a where a.`Status`=0 and a.Group_Id={Group_Id}");
if(!string.IsNullOrWhiteSpace(FrequencyIds))
{
builder.AppendFormat($" and FIND_IN_SET(a.SId,(SELECT GROUP_CONCAT(School_Ids) from rb_duty_frequency where `Status`=0 and id in({FrequencyIds}) GROUP BY `Status`)) ");