@@ -315,6 +315,7 @@ LEFT JOIN rb_education_talk as talk on talk.id=t.tid and talk.`Status`= 0
stringlikeWhere="";
stringfollowWhere="";
stringtalkWhere="";
stringotherWhere="";
if(model!=null)
{
if(model.TenantId>0)
...
...
@@ -330,15 +331,17 @@ LEFT JOIN rb_education_talk as talk on talk.id=t.tid and talk.`Status`= 0
where+=$@" and a.Id = {model.Id} ";
}
if(model.CreateBy>0)
if(model.CreateBy>0&&model.UserId>0)
{
where+=$@" and a.CreateBy = {model.CreateBy} ";
otherWhere+=$@" and b.CreateBy={model.CreateBy} and b.UserId={model.UserId} and b.`Status`=0 ";
}
if(model.UserId>0)
elseif(model.UserId>0)
{
likeWhere+=$@" and l.UserId = {model.UserId} ";
followWhere+=$@" and (b.UserId = {model.UserId} and b.`Status`=0 or a.CreateBy = {model.UserId} ) ";
}
if(model.TalkId>0)
{
talkWhere=$"and talk.Id = {model.TalkId} ";
...
...
@@ -348,7 +351,7 @@ LEFT JOIN rb_education_talk as talk on talk.id=t.tid and talk.`Status`= 0
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`,a.TalkId as tid 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`,a.TalkId as tid 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
Rb_Education_Dynamic a LEFT JOIN RB_MiAi_FollowMember as b on a.CreateBy=b.UserId {otherWhere} where a.IsOpen=2 {where}{followWhere} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
LEFT JOIN rb_member_user e on e.Id = t.CreateBy
LEFT JOIN rb_education_talk as talk on talk.id=t.tid and talk.`Status`= 0 where 1=1 {talkWhere}
...
...
@@ -357,6 +360,66 @@ LEFT JOIN rb_education_talk as talk on talk.id=t.tid and talk.`Status`= 0 where
where+=$@" and a.MallBaseId = {model.MallBaseId} ";
}
if(model.Id>0)
{
where+=$@" and a.Id = {model.Id} ";
}
if(model.CreateBy>0&&model.UserId>0)
{
where+=$@" and a.CreateBy = {model.CreateBy} ";
otherWhere+=$@" and b.CreateBy={model.CreateBy} and b.UserId={model.UserId} and b.`Status`=0 ";
}
elseif(model.UserId>0)
{
otherWhere+=$@" and b.CreateBy={model.UserId} and b.`Status`=0 ";
likeWhere+=$@" and l.UserId = {model.UserId} ";
// followWhere += $@" and (b.UserId = {model.UserId} and b.`Status`=0 or a.CreateBy = {model.UserId} ) ";
}
if(model.TalkId>0)
{
talkWhere=$"and talk.Id = {model.TalkId} ";
}
}
stringsql=$@"SELECT t.*,if(l.Id>0,1,0) as HasLike,talk.Id as TalkId,talk.Content as TalkContent,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`,a.TalkId as tid from
Rb_Education_Dynamic a where 1=1 and (a.IsOpen=1 or (a.IsOpen=2 and a.CreateBy={model.UserId})) {where}{followWhere}
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`,a.TalkId as tid from
Rb_Education_Dynamic a LEFT JOIN RB_MiAi_FollowMember as b on a.CreateBy=b.UserId {otherWhere} where a.IsOpen=2 and a.CreateBy !={model.UserId}{where}{followWhere} ) as t
LEFT JOIN rb_education_dynamiclike l on l.ArticleId = t.id {likeWhere}
LEFT JOIN rb_member_user e on e.Id = t.CreateBy
LEFT JOIN rb_education_talk as talk on talk.id=t.tid and talk.`Status`= 0 where 1=1 {talkWhere}