where+=$@" and a.MallBaseId = {model.MallBaseId} ";
}
if(model.Id>0)
{
where+=$@" and a.Id = {model.Id} ";
}
if(model.CreateBy>0)
{
where+=$@" and a.CreateBy = {model.CreateBy} ";
}
if(model.UserId>0)
{
likeWhere+=$@" and l.UserId = {model.UserId} ";
}
}
stringsql=$@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.Photo as CrearteByPhoto
from (SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a {where} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
where+=$@" and a.MallBaseId = {model.MallBaseId} ";
}
if(model.Id>0)
{
where+=$@" and a.Id = {model.Id} ";
}
if(model.CreateBy>0)
{
where+=$@" and a.CreateBy = {model.CreateBy} ";
}
if(model.UserId>0)
{
likeWhere+=$@" and l.UserId = {model.UserId} ";
followWhere+=$@" and b.UserId = {model.UserId} and b.`Status`=0 ";
}
}
stringsql=$@"SELECT t.*,if(l.Id>0,1,0) as HasLike,e.`Name` as CreateByName,e.Photo as CrearteByPhoto
from (SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a where a.IsOpen=1 {where}
union all SELECT a.TenantId,a.MallBaseId,a.CreateBy,a.id,a.UserTeacher,a.Content,a.Files,a.LatAndLong,a.Address,a.CreateTime,a.CoverPhoto,a.FileType,a.IsOpen,a.`Status` from
Rb_Education_Dynamic a LEFT JOIN RB_MiAi_FollowMember as b on a.CreateBy=b.UserId where a.IsOpen=2 {where}{followWhere} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}