bugfix for query by author name and favorited username

This commit is contained in:
aisensiy
2017-08-19 09:55:24 +08:00
parent 288f2d4c14
commit 4550e5a3c5
3 changed files with 10 additions and 7 deletions

View File

@@ -41,15 +41,17 @@
left join article_tags AT on A.id = AT.article_id
left join tags T on T.id = AT.tag_id
left join article_favorites AF on AF.article_id = A.id
left join users AU on AU.id = A.user_id
left join users AFU on AFU.id = AF.user_id
<where>
<if test="tag != null">
T.name = #{tag}
</if>
<if test="author != null">
AND A.user_id = #{author}
AND AU.username = #{author}
</if>
<if test="favoritedBy != null">
AND AF.user_id = #{favoritedBy}
AND AFU.username = #{favoritedBy}
</if>
</where>
order by A.created_at desc
@@ -63,15 +65,17 @@
left join article_tags AT on A.id = AT.article_id
left join tags T on T.id = AT.tag_id
left join article_favorites AF on AF.article_id = A.id
left join users AU on AU.id = A.user_id
left join users AFU on AFU.id = AF.user_id
<where>
<if test="tag != null">
T.name = #{tag}
</if>
<if test="author != null">
AND A.user_id = #{author}
AND AU.username = #{author}
</if>
<if test="favoritedBy != null">
AND AF.user_id = #{favoritedBy}
AND AFU.username = #{favoritedBy}
</if>
</where>
</select>