Quellcode durchsuchen

用户头像问题

夏文涛 vor 2 Jahren
Ursprung
Commit
55dc6085ef

+ 1 - 0
mhotel/src/com/happy/action/articleTweetAction.java

@@ -241,6 +241,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
         result.setUserId(data.getUserId());
         result.setUserName(data.getUserName());
+        result.setUserPhoto(data.getUserPhoto());
         //region 关注
         if (articleTweetDto.getUserId().equals(data.getUserId())) {
             result.setIsFollow(3);//自己的推文

+ 5 - 6
mhotel/src/com/happy/dao/impl/ArticleTweetImplDao.java

@@ -33,12 +33,11 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
 
     @Override
     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 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 " +
-                "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 " +
                 leftSql +
                 "WHERE at.id = :id ";
@@ -387,10 +386,10 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
         String leftSql = "";
         String caseSql = "";
         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";
         } 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";
             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) {//收藏
@@ -448,7 +447,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
     public List<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int 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" +
                 "from article_tweet at\n" +
                 "left join hotel_dict hd on hd.id = at.location_id\n" +

+ 5 - 0
mhotel/src/com/happy/vo/ArticleDetailVo.java

@@ -32,6 +32,11 @@ public class ArticleDetailVo {
     private String userName;
 
     /**
+     * 发布人头像
+     */
+    private String userPhoto;
+
+    /**
      * 是否关注
      * 未关注:0
      * 已关注:1