Browse Source

修改缺少商家头像和商家名字的问题

liu 2 years ago
parent
commit
4da2aa5a20
1 changed files with 17 additions and 7 deletions
  1. 17 7
      mhotel/src/com/happy/Until/TreeRecordsUtil.java

+ 17 - 7
mhotel/src/com/happy/Until/TreeRecordsUtil.java

@@ -9,9 +9,10 @@ import java.util.stream.Collectors;
 
 
 public class TreeRecordsUtil {
 public class TreeRecordsUtil {
     /**
     /**
-     * 根据父类ID获取树形菜单数据
-     * @param parentID 父级ID
-     * @param lists 数据集合
+     * 锟斤拷锟捷革拷锟斤拷ID锟斤拷取锟斤拷锟轿菜碉拷锟斤拷锟斤拷
+     *
+     * @param parentID 锟斤拷锟斤拷ID
+     * @param lists    锟斤拷锟捷硷拷锟斤拷
      * @return
      * @return
      */
      */
     public static List<CommentListVo> queryCommentTreeRecords(String parentID, List<CommentVo> lists) {
     public static List<CommentListVo> queryCommentTreeRecords(String parentID, List<CommentVo> lists) {
@@ -20,14 +21,23 @@ public class TreeRecordsUtil {
         List<CommentVo> datas = lists.stream().filter(e -> e.getCommentId().equals(parentID)).collect(Collectors.toList());
         List<CommentVo> datas = lists.stream().filter(e -> e.getCommentId().equals(parentID)).collect(Collectors.toList());
 
 
         for (CommentVo data : datas) {
         for (CommentVo data : datas) {
+            String headPhoto = data.getHeadPhoto();
+            String userName = data.getUserName();
+//    鍟嗗�娌℃湁澶村儚鍜岀敤鎴峰悕
+            if (headPhoto == null) {
+                headPhoto = "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png";
+            }
+            if (userName == null) {
+                userName = "鍟嗗�";
+            }
             CommentListVo item = CommentListVo.builder()
             CommentListVo item = CommentListVo.builder()
                     .id(data.getId())
                     .id(data.getId())
                     .commentId(data.getCommentId())
                     .commentId(data.getCommentId())
                     .commentName(data.getCommentName())
                     .commentName(data.getCommentName())
-                    .userName(data.getUserName())
-                    .headPhoto(data.getHeadPhoto())
-            // 将时间转化为 yyyy/MM/dd
-                    .dateTime( data.getDateTime().substring(0,19))
+                    .userName(userName)
+                    .headPhoto(headPhoto)
+                    //截取时间,这个时间会多一个0 yyyy/MM/dd
+                    .dateTime(data.getDateTime().substring(0, 19))
                     .content(data.getContent())
                     .content(data.getContent())
                     .build();
                     .build();
             List<CommentListVo> news = queryCommentTreeRecords(item.getId(), lists);
             List<CommentListVo> news = queryCommentTreeRecords(item.getId(), lists);