Ver código fonte

评价回复详情接口修改

lijie 2 anos atrás
pai
commit
09e34f628d

+ 0 - 3
mhotel/src/com/happy/dao/BookingCommentDao.java

@@ -1,14 +1,11 @@
 package com.happy.dao;
 package com.happy.dao;
 
 
 import com.happy.Model.BookingComment;
 import com.happy.Model.BookingComment;
-import com.happy.dto.IPage;
 import com.happy.vo.BookingCommentPageVo;
 import com.happy.vo.BookingCommentPageVo;
 import com.happy.vo.EvaluatePageVo;
 import com.happy.vo.EvaluatePageVo;
 
 
 import java.util.List;
 import java.util.List;
 
 
-import java.util.List;
-
 public interface BookingCommentDao {
 public interface BookingCommentDao {
     String insertBookingComment(BookingComment bookingComment);
     String insertBookingComment(BookingComment bookingComment);
 
 

+ 1 - 1
mhotel/src/com/happy/dao/impl/BookingCommentDaoImpl.java

@@ -368,7 +368,7 @@ public class BookingCommentDaoImpl implements BookingCommentDao {
 
 
     @Override
     @Override
     public List<BookingComment> getByParentId(String parentId) {
     public List<BookingComment> getByParentId(String parentId) {
-        String sql = selectSql + " and a.comment_parent_id = :id and status != 0";
+        String sql = selectSql + " and a.comment_parent_id = :id and a.comment_id = :id  and status != 0";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("id",parentId);
         sps.addValue("id",parentId);
         List<BookingComment> list = new ArrayList<>();
         List<BookingComment> list = new ArrayList<>();

+ 25 - 26
mhotel/src/com/happy/service/impl/BookingCommentImplService.java

@@ -171,10 +171,11 @@ public class BookingCommentImplService implements BookingCommentService {
         }
         }
         for (BookingComment bookingComment : list){
         for (BookingComment bookingComment : list){
             List<BookingComment> listByParentId = bookingCommentDao.getByParentId(bookingComment.getId());
             List<BookingComment> listByParentId = bookingCommentDao.getByParentId(bookingComment.getId());
+            List<BookingComment> bookingCommentList = new ArrayList<>();
             for (BookingComment parentComment : listByParentId){
             for (BookingComment parentComment : listByParentId){
-                getComment(parentComment);
+                bookingCommentList.add(getComment(parentComment));
             }
             }
-            bookingComment.setLowCommentList(listByParentId);
+            bookingComment.setLowCommentList(bookingCommentList);
         }
         }
         bookCommentDto.setBookingCommentList(list);
         bookCommentDto.setBookingCommentList(list);
         return bookCommentDto;
         return bookCommentDto;
@@ -182,41 +183,39 @@ public class BookingCommentImplService implements BookingCommentService {
     public BookingComment getComment(BookingComment parentComment){
     public BookingComment getComment(BookingComment parentComment){
       if(parentComment!=null){
       if(parentComment!=null){
          List<BookingComment> parentCommentList = bookingCommentDao.getByCommentId(parentComment.getId());
          List<BookingComment> parentCommentList = bookingCommentDao.getByCommentId(parentComment.getId());
+         List<BookingComment> list = new ArrayList<>();
           if(parentComment != null && parentCommentList != null){
           if(parentComment != null && parentCommentList != null){
               for(BookingComment low : parentCommentList){//一级评论
               for(BookingComment low : parentCommentList){//一级评论
-                  getLowcomment(low);
+                  list.add(low);
+                  getLowcomment(low,list);
               }
               }
+              parentComment.setLowCommentList(list);
           }
           }
       }
       }
       return parentComment;
       return parentComment;
     };
     };
 
 
-    private void getLowcomment(BookingComment comment){
+//    private void getLowcomment(BookingComment comment){
+//        List<BookingComment> list = new ArrayList<>();
+//        if (comment.getLowCommentList()!=null) {
+//            list = comment.getLowCommentList();
+//        }
+//        List<BookingComment> low = bookingCommentDao.getByCommentId(comment.getId());
+//        if(low != null){
+//            list.addAll(low);
+//            for(BookingComment low1 : list){
+//                getLowcomment(low1,comment);
+//            }
+//        }
+//    }
+
+    private void getLowcomment(BookingComment comment,List<BookingComment> parentCommentList){
         List<BookingComment> list = new ArrayList<>();
         List<BookingComment> list = new ArrayList<>();
-        if (comment.getLowCommentList()!=null) {
-            list = comment.getLowCommentList();
-        }
-        List<BookingComment> low = bookingCommentDao.getByCommentId(comment.getId());
-        if(low != null){
-            list.addAll(low);
-            comment.setLowCommentList(list);
-            for(BookingComment low1 : list){
-                getLowcomment(low1,comment);
-            }
-        }
-    }
-
-    private void getLowcomment(BookingComment comment,BookingComment parentCommentList){
-        List<BookingComment> list = new ArrayList<>();
-        if (parentCommentList.getLowCommentList()!=null) {
-            list = parentCommentList.getLowCommentList();
-        }
         List<BookingComment> low = bookingCommentDao.getByCommentId(comment.getId());
         List<BookingComment> low = bookingCommentDao.getByCommentId(comment.getId());
         if(low!=null){
         if(low!=null){
-            list.addAll(low);
-            comment.setLowCommentList(low);
-            for(BookingComment low1 : list){
-                getLowcomment(low1,comment);
+            for(BookingComment low1 : low){
+                parentCommentList.add(low1);
+                getLowcomment(low1,parentCommentList);
             }
             }
         }
         }
     }
     }