|
@@ -33,12 +33,11 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ArticleTweet queryArticleById(String id, Integer userId) {
|
|
public ArticleTweet queryArticleById(String id, Integer userId) {
|
|
|
- String caseSql = userId == null ? "" : "case ac.id when null then 0 else 1 end is_collect,";
|
|
|
|
|
|
|
+ String caseSql = userId == null ? "" : "case when ac.id is null then 0 else 1 end is_collect,";
|
|
|
String leftSql = userId == null ? "" : "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = " + userId + " ";
|
|
String leftSql = userId == null ? "" : "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = " + userId + " ";
|
|
|
|
|
|
|
|
- String sql = "SELECT " + caseSql + "(select IFNULL(count(*),0) from article_collect where article_id = :id and is_lose = 0) as collect_num,hd.name as location_name,u.user_name,at.* " +
|
|
|
|
|
|
|
+ String sql = "SELECT " + caseSql + "(select IFNULL(count(*),0) from article_collect where article_id = :id and is_lose = 0) as collect_num,hd.name as location_name,at.* " +
|
|
|
"FROM article_tweet at " +
|
|
"FROM article_tweet at " +
|
|
|
- "inner join users u on u.id = at.user_id " +
|
|
|
|
|
"left join hotel_dict hd on hd.code = 10 and hd.id = at.location_id " +
|
|
"left join hotel_dict hd on hd.code = 10 and hd.id = at.location_id " +
|
|
|
leftSql +
|
|
leftSql +
|
|
|
"WHERE at.id = :id ";
|
|
"WHERE at.id = :id ";
|
|
@@ -387,10 +386,10 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
String leftSql = "";
|
|
String leftSql = "";
|
|
|
String caseSql = "";
|
|
String caseSql = "";
|
|
|
if (type.intValue() == 0) {//发现
|
|
if (type.intValue() == 0) {//发现
|
|
|
- caseSql = "case ac.id when null then 0 else 1 end is_collect,";
|
|
|
|
|
|
|
+ caseSql = "case when ac.id is null then 0 else 1 end is_collect,";
|
|
|
leftSql = "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = :userId\n";
|
|
leftSql = "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = :userId\n";
|
|
|
} else if (type.intValue() == 1) {//关注
|
|
} else if (type.intValue() == 1) {//关注
|
|
|
- caseSql = "case ac.id when null then 0 else 1 end is_collect,";
|
|
|
|
|
|
|
+ caseSql = "case when ac.id is null then 0 else 1 end is_collect,";
|
|
|
leftSql = "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = :userId\n";
|
|
leftSql = "left join article_collect ac on ac.is_lose = 0 and ac.article_id = at.id and ac.user_id = :userId\n";
|
|
|
innSql = "inner join user_collect uc on uc.is_lose = 0 and uc.parent_userid = at.user_id and uc.user_id = :userId\n";//关注
|
|
innSql = "inner join user_collect uc on uc.is_lose = 0 and uc.parent_userid = at.user_id and uc.user_id = :userId\n";//关注
|
|
|
} else if (type.intValue() == 2) {//收藏
|
|
} else if (type.intValue() == 2) {//收藏
|
|
@@ -448,7 +447,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
public List<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int rows) {
|
|
public List<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int rows) {
|
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
int start = (page - 1) * rows;// 每页的起始下标
|
|
|
|
|
|
|
|
- String sql = "select at.id,at.location_id as town_id,hd.name as town_name,at.title,at.user_id,at.user_name,at.user_photo,case ac.id when null then 0 else 1 end is_collect,\n" +
|
|
|
|
|
|
|
+ String sql = "select at.id,at.location_id as town_id,hd.name as town_name,at.title,at.user_id,at.user_name,at.user_photo,case when ac.id is null then 0 else 1 end is_collect,\n" +
|
|
|
"(select count(*) from article_collect where is_lose = 0 and article_id = at.id) as collect_num\n" +
|
|
"(select count(*) from article_collect where is_lose = 0 and article_id = at.id) as collect_num\n" +
|
|
|
"from article_tweet at\n" +
|
|
"from article_tweet at\n" +
|
|
|
"left join hotel_dict hd on hd.id = at.location_id\n" +
|
|
"left join hotel_dict hd on hd.id = at.location_id\n" +
|