夏文涛 il y a 2 ans
Parent
commit
8399983413

+ 47 - 8
mhotel/src/com/happy/action/articleTweetAction.java

@@ -515,7 +515,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
         if (childs != null && childs.size() > 0) {
             for (ArticleCommentVo data : result.getPageList()) {
-                List<ArticleCommentVo> comments = QueryTreeDatas(data.getId(), childs);
+                List<ArticleCommentVo> comments = QueryTreeDatas(data.getId(), data.getUserName(), childs);
                 data.setChildrens(comments);
             }
         }
@@ -537,14 +537,14 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
      * @param lists    数据集合
      * @return
      */
-    private List<ArticleCommentVo> QueryTreeDatas(Integer parentID, List<ArticleCommentVo> lists) {
+    private List<ArticleCommentVo> QueryTreeDatas(Integer parentID, String parentName, List<ArticleCommentVo> lists) {
         List<ArticleCommentVo> newTrees = new ArrayList<>();
 
         List<ArticleCommentVo> datas = lists.stream().filter(e -> e.getParentId().equals(parentID)).collect(Collectors.toList());
 
         for (ArticleCommentVo data : datas) {
-
-            List<ArticleCommentVo> news = QueryTreeDatas(data.getId(), lists);
+            data.setParentName(parentName);
+            List<ArticleCommentVo> news = QueryTreeDatas(data.getId(), data.getUserName(), lists);
             if (news == null || news.size() == 0) {
                 newTrees.add(data);
                 continue;
@@ -575,7 +575,17 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
         articleUserVo result = articleTweetService.queryUserInfo(articleTweetDto.getUserId());
 
-        if(result != null){
+        //region 关注
+        if (articleTweetDto.getUserId().equals(result.getId())) {
+            result.setIsFollow(3);//自己的推文
+        } else {
+            //是否关注
+            UserCollect uc = articleTweetService.queryUserCollect(result.getId(), articleTweetDto.getUserId());
+            result.setIsFollow(uc == null ? 0 : 1);//已关注给0;未关注给1
+        }
+        //endregion
+
+        if (result != null) {
             String descript = "点击这里,填写简介";
             result.setDescript(result.getDescript() == null ? descript : result.getDescript());
         }
@@ -623,7 +633,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
                         String url = fileInfoList.get(0).getUrl();
                         if (!url.endsWith("jpg") && !url.endsWith("png")) {
                             data.setVideo(fileInfoList.get(0).getUrl());
-                        }else{
+                        } else {
                             List<String> images = new ArrayList<>();
                             images.add(url);
                             data.setImages(images);
@@ -678,7 +688,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
                         String url = fileInfoList.get(0).getUrl();
                         if (!url.endsWith("jpg") && !url.endsWith("png")) {
                             data.setVideo(fileInfoList.get(0).getUrl());
-                        }else{
+                        } else {
                             data.setImage(url);
                         }
                     }
@@ -723,7 +733,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
                         String url = fileInfoList.get(0).getUrl();
                         if (!url.endsWith("jpg") && !url.endsWith("png")) {
                             data.setVideo(fileInfoList.get(0).getUrl());
-                        }else{
+                        } else {
                             data.setImage(url);
                         }
                     }
@@ -1025,4 +1035,33 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
         return null;
     }
 
+    /**
+     * 修改用户简介
+     */
+    public String updateDescript() {
+        JSONObject jsonObject = new JSONObject();
+
+        if (articleTweetDto.getAuthorId() == null || articleTweetDto.getUserId() == null || Func.checkNull(articleTweetDto.getDescript())) {
+            jsonObject.put("code", 500);
+            jsonObject.put("message", "操作用户ID或主页用户ID或简介不能为空");
+            jsonObject.put("data", null);
+            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        if (!articleTweetDto.getAuthorId().equals(articleTweetDto.getUserId())) {
+            jsonObject.put("code", 500);
+            jsonObject.put("message", "当前用户无法修改其他人的简介信息");
+            jsonObject.put("data", null);
+            ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        int num = articleTweetService.updateDescript(articleTweetDto.getAuthorId(), articleTweetDto.getDescript());
+
+        jsonObject.put("message", "修改成功");
+        jsonObject.put("code", 200);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+    }
 }

+ 8 - 0
mhotel/src/com/happy/dao/ArticleTweetDao.java

@@ -247,4 +247,12 @@ public interface ArticleTweetDao {
      * @return
      */
     int updateArticleLike(ArticleLikes articleLikes);
+
+    /**
+     * 更新用户简介
+     * @param authorId
+     * @param descript
+     * @return
+     */
+    int updateDescript(Integer authorId, String descript);
 }

+ 19 - 7
mhotel/src/com/happy/dao/impl/ArticleTweetImplDao.java

@@ -347,11 +347,12 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
     @Override
     public List<OwnerArticleVo> queryOwnerArticlePage(Integer userId, String sqlWhere, int page, int rows) {
         int start = (page - 1) * rows;// 每页的起始下标
-        String sql = "select at.approve,at.id,at.title,at.create_date as date,at.location_id as town_id,\n" +
+        String sql = "select case when al.id is null then 0 else 1 end is_like,at.approve,at.id,at.title,at.create_date as date,at.location_id as town_id,\n" +
                 "hd.name as town_name,(select count(*) from article_likes where article_id = at.id and is_lose = 0) as like_num,\n" +
                 "(select count(*) from article_comment where article_id = at.id) as comment_num\n" +
                 "from article_tweet at\n" +
                 "left join hotel_dict hd on hd.id = at.location_id\n" +
+                "left join article_likes al on al.is_lose = 0 and al.article_id = at.id and al.like_id = :userId " +
                 "where at.user_id = :userId " + sqlWhere +
                 "ORDER BY at.create_date desc limit :start,:rows";
 
@@ -398,7 +399,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
         }
 
         String sqlWhere = townId == null ? "" : "and at.location_id = '" + townId + "' ";
-        sqlWhere = sqlWhere + (keyWord == null ? "" : "and (at.user_name like '%"+ keyWord +"%' or at.title like '%"+ keyWord +"%' or at.content like '%"+ keyWord +"%') ");
+        sqlWhere = sqlWhere + (keyWord == null ? "" : "and (at.user_name like '%" + keyWord + "%' or at.title like '%" + keyWord + "%' or at.content like '%" + keyWord + "%') ");
         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,\n" + caseSql +
                 "(select count(*) from article_collect where is_lose = 0 and article_id = at.id) as collect_num\n" +
                 "from article_tweet at\n" +
@@ -431,7 +432,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
         }
 
         String sqlWhere = townId == null ? "" : "and at.location_id = '" + townId + "' ";
-        sqlWhere = sqlWhere + (keyWord == null ? "" : "and (at.user_name like '%"+ keyWord +"%' or at.title like '%"+ keyWord +"%' or at.content like '%"+ keyWord +"%') ");
+        sqlWhere = sqlWhere + (keyWord == null ? "" : "and (at.user_name like '%" + keyWord + "%' or at.title like '%" + keyWord + "%' or at.content like '%" + keyWord + "%') ");
         String sql = "select count(*) from article_tweet at\n" +
                 innSql +
                 "where at.approve = 2 " + sqlWhere;
@@ -661,9 +662,20 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
     }
 
 
-    /**
-     * 相关推文
-     */
+    @Override
+    public int updateDescript(Integer authorId, String descript) {
+        String sql = "update users set descript = :descript where id = :authorId";
+        MapSqlParameterSource sps = new MapSqlParameterSource();
+        sps.addValue("descript", descript);
+        sps.addValue("authorId", authorId);
+
+        int num = 0;
+        try {
+            num = namedParameterJdbcTemplate.update(sql, sps);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return num;
+    }
 
-    //select * from article_tweet where location_id = '' and user_id != 1 and approve = 2
 }

+ 5 - 0
mhotel/src/com/happy/dto/ArticleTweetDto.java

@@ -56,4 +56,9 @@ public class ArticleTweetDto extends ArticleTweet {
      */
     public Integer authorId;
 
+    /**
+     * 简介
+     */
+    public String descript;
+
 }

+ 8 - 0
mhotel/src/com/happy/service/ArticleTweetService.java

@@ -217,4 +217,12 @@ public interface ArticleTweetService {
      * @return
      */
     int updateArticleLike(ArticleLikes articleLikes);
+
+    /**
+     * 更新用户简介
+     * @param authorId
+     * @param descript
+     * @return
+     */
+    int updateDescript(Integer authorId, String descript);
 }

+ 11 - 0
mhotel/src/com/happy/service/impl/ArticleTweetImplService.java

@@ -232,4 +232,15 @@ public class ArticleTweetImplService implements ArticleTweetService {
         int num = articleTweetDao.updateArticleLike(articleLikes);
         return num;
     }
+
+    /**
+     * 更新用户简介
+     * @param authorId
+     * @param descript
+     * @return
+     */
+    public int updateDescript(Integer authorId, String descript){
+        int num = articleTweetDao.updateDescript(authorId, descript);
+        return num;
+    }
 }

+ 30 - 19
mhotel/src/com/happy/service/impl/HouseNumberStatusImplService.java

@@ -196,25 +196,36 @@ public class HouseNumberStatusImplService implements HouseNumberStatusService {
             List<Holiday> holidays = houseNumberStatusDao.queryHolidays( String.valueOf(LocalDate.now().getYear()),TimeExchange.DateToString(startDate,"yyyy-MM-dd"),TimeExchange.DateToString(endDate,"yyyy-MM-dd"));
 
             ArrayList<JSONObject> dataTimes = new ArrayList<>();
-            dateListBetween.forEach(date -> {
-                JSONObject dataTime = new JSONObject();
-                dataTime.put("dateStr", date);
-                dataTime.put("roomSum", getSum(date, houseNumberList));
-                //2023-09-20 A-jax 添加 星期 节假日 是否休息
-                try {
-                    dataTime.put("weekStr", TimeExchange.getWeek(date));//星期
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                }
-                Optional<Holiday> holiday = holidays.stream().filter(e -> e.getDate().equals(date)).findFirst();
-                String holidayStr = null;
-                if(holiday != null && holiday.isPresent()){
-                    Holiday data = holiday.get();
-                    holidayStr = data.getIsRest().intValue() == 1 ? data.getName() : "班";
-                }
-                dataTime.put("holiday",holidayStr);//节假日
-                dataTimes.add(dataTime);
-            });
+            try{
+
+                dateListBetween.forEach(date -> {
+                    System.out.println("测试服务器进来了");
+                    JSONObject dataTime = new JSONObject();
+                    dataTime.put("dateStr", date);
+                    dataTime.put("roomSum", getSum(date, houseNumberList));
+                    //2023-09-20 A-jax 添加 星期 节假日 是否休息
+                    try {
+                        dataTime.put("weekStr", TimeExchange.getWeek(date));//星期
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                    System.out.println("测试服务器进来了1");
+                    String holidayStr = null;
+                    if(holidays != null && holidays.size() > 0){
+                        Optional<Holiday> holiday = holidays.stream().filter(e -> e.getDate().equals(date)).findFirst();
+                        holidayStr = null;
+                        if(holiday != null && holiday.isPresent()){
+                            Holiday data = holiday.get();
+                            holidayStr = data.getIsRest().intValue() == 1 ? data.getName() : "班";
+                        }
+                    }
+
+                    dataTime.put("holiday",holidayStr);//节假日
+                    dataTimes.add(dataTime);
+                });
+            }catch (Exception e){
+                System.out.println("错误信息:"+e.getMessage());
+            }
 
             result.put("dateTimes", dataTimes);
             result.put("datas", datas);

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

@@ -23,6 +23,11 @@ public class ArticleCommentVo {
     private Integer parentId;
 
     /**
+     * 父级名称
+     */
+    private String parentName;
+
+    /**
      * 评论人ID
      */
     private Integer userId;

+ 8 - 0
mhotel/src/com/happy/vo/OwnerArticleVo.java

@@ -61,6 +61,14 @@ public class OwnerArticleVo {
     private Integer likeNum;
 
     /**
+     * 是否点赞
+     * 是否点赞文章
+     * 未点赞:0
+     * 已点赞:1
+     */
+    private Integer isLike;
+
+    /**
      * 评论数
      */
     private Integer commentNum;

+ 9 - 1
mhotel/src/com/happy/vo/articleUserVo.java

@@ -11,7 +11,7 @@ import lombok.Data;
 @Data
 public class articleUserVo {
     /**
-     * 数据ID
+     * 用户ID
      */
     private Integer id;
 
@@ -26,6 +26,14 @@ public class articleUserVo {
     private String userName;
 
     /**
+     * 是否关注
+     * 未关注:0
+     * 已关注:1
+     * 自己的推文:2
+     */
+    private Integer isFollow;
+
+    /**
      * 简介
      */
     private String descript;