Quellcode durchsuchen

添加个人回复评论,添加民宿评价

liu vor 2 Jahren
Ursprung
Commit
ad915684bf

+ 20 - 0
mhotel/src/com/happy/Model/BookingComment.java

@@ -10,6 +10,10 @@ public class BookingComment {
 
     //    回复评论id
     private String commentId;
+    //  回复主评论id
+    private String commentParentId;
+    //    回复人名称
+    private String commentName;
 
     //    评论订单id
     private String bookingId;
@@ -80,6 +84,22 @@ public class BookingComment {
         this.bookingId = bookingId;
     }
 
+    public String getCommentParentId() {
+        return commentParentId;
+    }
+
+    public void setCommentParentId(String commentParentId) {
+        this.commentParentId = commentParentId;
+    }
+
+    public String getCommentName() {
+        return commentName;
+    }
+
+    public void setCommentName(String commentName) {
+        this.commentName = commentName;
+    }
+
     public String getHotelId() {
         return hotelId;
     }

+ 142 - 6
mhotel/src/com/happy/action/AppBookingCommentAction.java

@@ -3,8 +3,12 @@ package com.happy.action;
 import com.happy.Model.BookingComment;
 import com.happy.Until.Func;
 import com.happy.Until.ResUtil;
+import com.happy.Until.ResponseUtil;
+import com.happy.dto.IPage;
 import com.happy.dto.OrderRateDto;
 import com.happy.service.BookingCommentService;
+import com.happy.vo.BookingCommentPageVo;
+import com.happy.vo.EvaluatePageVo;
 import com.opensymphony.xwork2.ActionSupport;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.struts2.ServletActionContext;
@@ -54,6 +58,13 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
     public BookingCommentService bookingCommentService;
 
 
+    //    回复评论id
+    public String commentId;
+    //    回复主评论id
+    public String commentParentId;
+    //    回复人名称
+    public String commentName;
+
     //    评论订单id
     public String bookingId;
 
@@ -66,6 +77,9 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
     //    内容
     public String content;
 
+    //    评价状态
+    public String commentStatus;
+
     //    总评分
     public Double score;
 
@@ -110,6 +124,30 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
         this.bookingId = bookingId;
     }
 
+    public String getCommentId() {
+        return commentId;
+    }
+
+    public void setCommentId(String commentId) {
+        this.commentId = commentId;
+    }
+
+    public String getCommentParentId() {
+        return commentParentId;
+    }
+
+    public void setCommentParentId(String commentParentId) {
+        this.commentParentId = commentParentId;
+    }
+
+    public String getCommentName() {
+        return commentName;
+    }
+
+    public void setCommentName(String commentName) {
+        this.commentName = commentName;
+    }
+
     public String getHotelId() {
         return hotelId;
     }
@@ -206,6 +244,34 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
         this.modifyDate = modifyDate;
     }
 
+    public int page; // 当前页
+    public int rows;// 每页显示的行数rows
+    public int status; //状态,0显示全部,1显示有附件,2显示有回复
+
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getRows() {
+        return rows;
+    }
+
+    public void setRows(int rows) {
+        this.rows = rows;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
+
     /**
      * 添加评论
      */
@@ -213,29 +279,32 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
         JSONObject jsonObject = new JSONObject();
         if (score == null || score < 0 || scoreFw == null || scoreFw < 0 || scoreSs == null || scoreSs < 0 || scoreWs == null || scoreWs < 0 || scoreWz == null || scoreWz < 0 || bookingId == null || hotelId == null || houseId == null) {
             jsonObject.put("code", 400);
-            jsonObject.put("message", "未传入orderRateDto数据---orderRate");
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---orderRate");
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
         }
 
         BookingComment bookingComment = BookingComment.builder().bookingId(bookingId)
-                .hotelId(hotelId).houseId(houseId).content(content)
+                .hotelId(hotelId).houseId(houseId).content(content).commentStatus(commentStatus)
                 .score(score).scoreWs(scoreWs).scoreFw(scoreFw)
                 .scoreSs(scoreSs).scoreWz(scoreWz).createId(createId)
                 .createUsername(createUsername).createDate(createDate)
                 .modifyDate(modifyDate).build();
 
 
-        int a = bookingCommentService.orderRate(bookingComment,pictureList);
+        int a = bookingCommentService.orderRate(bookingComment, pictureList);
 
 
-        if (a>0) {
+        if (a > 0) {
             jsonObject.put("code", 200);
             jsonObject.put("message", "添加成功");
+            jsonObject.put("success", true);
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
         }
         jsonObject.put("message", "未知异常");
+        jsonObject.put("success", false);
         jsonObject.put("code", 205);
         ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
         return null;
@@ -247,19 +316,86 @@ public class AppBookingCommentAction extends ActionSupport implements ServletReq
      *
      * @return
      */
-    public JSONObject evaluateList() {
+    public JSONObject evaluatePage() {
         JSONObject jsonObject = new JSONObject();
         if (Func.checkNull(hotelId)) {
             jsonObject.put("code", 400);
-            jsonObject.put("message", "未传入hotel_id数据---evaluateList");
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入hotel_id数据---evaluatePage");
             ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
             return null;
         }
 
+        if (Func.checkNull(status + "")) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入status数据---evaluatePage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        if (page <= 0 || rows <= 0) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "未传入page,rows数据---evaluatePage");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+//        获取分页数据
+        IPage<BookingCommentPageVo> iPage = bookingCommentService.evaluatePage(status, hotelId, page, rows);
+//        计算评分
+        EvaluatePageVo vo = bookingCommentService.evaluateScore(hotelId);
+
+        jsonObject.put("code", 200);
+        jsonObject.put("message", "成功");
+        jsonObject.put("success", true);
+        jsonObject.put("page", iPage);
+        jsonObject.put("score", vo);
+
+        ResponseUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+
 
         return null;
 
     }
 
+    /**
+     * 回复评论
+     *
+     * @return
+     */
+    public JSONObject replyComment() {
+        JSONObject jsonObject = new JSONObject();
+        if (Func.checkNull(content) || Func.checkNull(commentParentId)) {
+            jsonObject.put("code", 400);
+            jsonObject.put("success", false);
+            jsonObject.put("message", "缺少数据---replyComment");
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+
+        BookingComment bookingComment = BookingComment.builder().commentId(commentId).commentParentId(commentParentId).commentName(commentName).bookingId(bookingId)
+                .hotelId(hotelId).houseId(houseId).content(content).commentStatus(commentStatus)
+                .score(score).scoreWs(scoreWs).scoreFw(scoreFw)
+                .scoreSs(scoreSs).scoreWz(scoreWz).createId(createId)
+                .createUsername(createUsername).createDate(createDate)
+                .modifyDate(modifyDate).build();
+
+
+        int i = bookingCommentService.replyComment(bookingComment);
+        if (i > 0) {
+            jsonObject.put("code", 200);
+            jsonObject.put("message", "回复成功");
+            jsonObject.put("success", true);
+            ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+            return null;
+        }
+        jsonObject.put("message", "未知异常");
+        jsonObject.put("code", 205);
+        jsonObject.put("success", false);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+        return null;
+    }
+
 
 }

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

@@ -1,8 +1,27 @@
 package com.happy.dao;
 
 import com.happy.Model.BookingComment;
+import com.happy.dto.IPage;
+import com.happy.vo.BookingCommentPageVo;
+import com.happy.vo.EvaluatePageVo;
+
+import java.util.List;
 
 public interface BookingCommentDao {
     String insertBookingComment(BookingComment bookingComment);
 
+    List<BookingCommentPageVo> evaluatePage(String hotelId, int page, int rows);
+
+    int evaluateTotal(String hotelId);
+
+    List<BookingCommentPageVo> evaluatePagepicture(String hotelId, int page, int rows);
+
+    int evaluateTotalpicture(String hotelId);
+
+    List<BookingCommentPageVo> evaluatePageComment(String hotelId, int page, int rows);
+
+    int evaluateTotalComment(String hotelId);
+
+    EvaluatePageVo evaluateScore(String hotelId);
+
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 195 - 1
mhotel/src/com/happy/dao/impl/BookingCommentDaoImpl.java


+ 9 - 0
mhotel/src/com/happy/service/BookingCommentService.java

@@ -2,6 +2,8 @@ package com.happy.service;
 
 import com.happy.Model.BookingComment;
 import com.happy.Model.FileInfo;
+import com.happy.dto.IPage;
+import com.happy.vo.EvaluatePageVo;
 
 import java.util.List;
 
@@ -9,4 +11,11 @@ public interface BookingCommentService {
 
 
     int orderRate( BookingComment bookingComment,List<String> pictureList);
+
+    IPage evaluatePage(int status,String hotelId, int page, int rows);
+
+    int replyComment(BookingComment bookingComment);
+
+    EvaluatePageVo evaluateScore(String hotelId);
+
 }

+ 52 - 6
mhotel/src/com/happy/service/impl/BookingCommentImplService.java

@@ -2,9 +2,13 @@ package com.happy.service.impl;
 
 import com.happy.Model.BookingComment;
 import com.happy.Model.FileInfo;
+import com.happy.Model.Hotel;
 import com.happy.dao.BookingCommentDao;
+import com.happy.dto.IPage;
 import com.happy.service.BookingCommentService;
 import com.happy.service.FileService;
+import com.happy.vo.BookingCommentPageVo;
+import com.happy.vo.EvaluatePageVo;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -13,7 +17,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 @Service("BookingCommentService")
-
 public class BookingCommentImplService implements BookingCommentService {
 
     @Resource
@@ -23,7 +26,6 @@ public class BookingCommentImplService implements BookingCommentService {
     FileService fileService;
 
 
-
     /**
      * 添加评论
      *
@@ -33,17 +35,17 @@ public class BookingCommentImplService implements BookingCommentService {
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public int orderRate( BookingComment bookingComment,List<String> pictureList) {
+    public int orderRate(BookingComment bookingComment, List<String> pictureList) {
 
 //        添加评论表并返回主键
 
         String id = bookingCommentDao.insertBookingComment(bookingComment);
         int i = 1;
-        if (pictureList.size() > 0) {
+        if (pictureList != null && pictureList.size() > 0) {
             List<FileInfo> fileInfoList = new ArrayList<>();
             for (String s : pictureList) {
                 String[] split = s.split("/");
-                String s1 = split[split.length-1];
+                String s1 = split[split.length - 1];
                 FileInfo fileInfo = new FileInfo();
                 fileInfo.setLinkId(id);
                 fileInfo.setName(s1);
@@ -56,10 +58,54 @@ public class BookingCommentImplService implements BookingCommentService {
         }
         if (Long.valueOf(id) > 0 && i > 0) {
             return i;
-        }else {
+        } else {
+            return 0;
+        }
+
+    }
+
+    @Override
+    public IPage evaluatePage(int status, String hotelId, int page, int rows) {
+        IPage<BookingCommentPageVo> iPage = new IPage();
+        List<BookingCommentPageVo> vos = null;
+        int total = 0;
+//      全部
+        if (status == 0) {
+            vos = bookingCommentDao.evaluatePage(hotelId, page, rows);
+            total = bookingCommentDao.evaluateTotal(hotelId);
+        } else if (status == 1) {
+//            带图
+            vos = bookingCommentDao.evaluatePagepicture(hotelId, page, rows);
+            total = bookingCommentDao.evaluateTotalpicture(hotelId);
+        } else if (status == 2) {
+            vos = bookingCommentDao.evaluatePageComment(hotelId, page, rows);
+            total = bookingCommentDao.evaluateTotalComment(hotelId);
+        }
+        iPage.setPage(page);
+        iPage.setTotalPage((int) Math.ceil((double) total / rows));
+        iPage.setRows(rows);
+        iPage.setTotal(total);
+        iPage.setPageList(vos);
+        return iPage;
+
+
+    }
+
+    @Override
+    public int replyComment(BookingComment bookingComment) {
+//
+        String id = bookingCommentDao.insertBookingComment(bookingComment);
+
+        if (Long.valueOf(id) > 0) {
+            return 1;
+        } else {
             return 0;
         }
+    }
 
+    @Override
+    public EvaluatePageVo evaluateScore(String hotelId) {
+      return  bookingCommentDao.evaluateScore(hotelId);
     }
 
 

+ 121 - 0
mhotel/src/com/happy/vo/BookingCommentPageVo.java

@@ -0,0 +1,121 @@
+package com.happy.vo;
+
+public class BookingCommentPageVo {
+
+    private String id;
+//    评分
+    private Double score;
+//  用户名
+    private String userName;
+//    头像
+    private String headPhoto;
+//   入住时间
+    private String liveTime;
+//    评论时间
+    private String commentTime;
+//  房型
+    private String houseName;
+//    内容
+    private String content;
+//    照片
+    private String url;
+//    评论次数
+    private int commentCount;
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getHeadPhoto() {
+        return headPhoto;
+    }
+
+    public void setHeadPhoto(String headPhoto) {
+        this.headPhoto = headPhoto;
+    }
+
+    public String getLiveTime() {
+        return liveTime;
+    }
+
+    public void setLiveTime(String liveTime) {
+        this.liveTime = liveTime;
+    }
+
+    public String getCommentTime() {
+        return commentTime;
+    }
+
+    public void setCommentTime(String commentTime) {
+        this.commentTime = commentTime;
+    }
+
+    public String getHouseName() {
+        return houseName;
+    }
+
+    public void setHouseName(String houseName) {
+        this.houseName = houseName;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public int getCommentCount() {
+        return commentCount;
+    }
+
+    public void setCommentCount(int commentCount) {
+        this.commentCount = commentCount;
+    }
+
+    @Override
+    public String toString() {
+        return "BookingCommentPageVo{" +
+                "id='" + id + '\'' +
+                ", score=" + score +
+                ", userName='" + userName + '\'' +
+                ", headPhoto='" + headPhoto + '\'' +
+                ", liveTime='" + liveTime + '\'' +
+                ", commentTime='" + commentTime + '\'' +
+                ", houseName='" + houseName + '\'' +
+                ", content='" + content + '\'' +
+                ", url='" + url + '\'' +
+                ", commentCount=" + commentCount +
+                '}';
+    }
+}

+ 67 - 0
mhotel/src/com/happy/vo/EvaluatePageVo.java

@@ -0,0 +1,67 @@
+package com.happy.vo;
+
+
+public class EvaluatePageVo {
+
+//    总评分
+    private Double score;
+//    位置评分
+    private Double scoreWz;
+//    卫生评分
+    private Double scoreWs;
+//    设施评分
+    private Double scoreSs;
+//    服务评分
+    private Double scoreFw;
+
+    @Override
+    public String toString() {
+        return "EvaluatePageVo{" +
+                "score=" + score +
+                ", scoreWz=" + scoreWz +
+                ", scoreWs=" + scoreWs +
+                ", scoreSs=" + scoreSs +
+                ", scoreFw=" + scoreFw +
+                '}';
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    public Double getScoreWz() {
+        return scoreWz;
+    }
+
+    public void setScoreWz(Double scoreWz) {
+        this.scoreWz = scoreWz;
+    }
+
+    public Double getScoreWs() {
+        return scoreWs;
+    }
+
+    public void setScoreWs(Double scoreWs) {
+        this.scoreWs = scoreWs;
+    }
+
+    public Double getScoreSs() {
+        return scoreSs;
+    }
+
+    public void setScoreSs(Double scoreSs) {
+        this.scoreSs = scoreSs;
+    }
+
+    public Double getScoreFw() {
+        return scoreFw;
+    }
+
+    public void setScoreFw(Double scoreFw) {
+        this.scoreFw = scoreFw;
+    }
+}