From 046203a18c53a4d2d910b87a1c2e3133064b11f4 Mon Sep 17 00:00:00 2001 From: Junling Bu Date: Sun, 11 Nov 2018 17:02:48 +0800 Subject: [PATCH] =?UTF-8?q?feat[litemall-wx-api,=20litemall-wx]:=20?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=84=E4=BB=B7=E5=88=97=E8=A1=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=95=86=E5=93=81=E8=AF=84=E4=BB=B7=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/service/LitemallCommentService.java | 18 +++++++++++++++++- .../litemall/wx/web/WxCommentController.java | 8 ++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java index fa3aec41..5fc49a03 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallCommentService.java @@ -69,9 +69,11 @@ public class LitemallCommentService { public List querySelective(String userId, String valueId, Integer page, Integer size, String sort, String order) { LitemallCommentExample example = new LitemallCommentExample(); - example.setOrderByClause(LitemallComment.Column.addTime.desc()); LitemallCommentExample.Criteria criteria = example.createCriteria(); + // type=2 是订单商品回复,这里过滤 + criteria.andTypeNotEqualTo((byte)2); + if(!StringUtils.isEmpty(userId)){ criteria.andUserIdEqualTo(Integer.valueOf(userId)); } @@ -107,4 +109,18 @@ public class LitemallCommentService { commentMapper.logicalDeleteByPrimaryKey(id); } + public String queryReply(Integer id) { + LitemallCommentExample example = new LitemallCommentExample(); + example.or().andTypeEqualTo((byte)2).andValueIdEqualTo(id); + List commentReply = commentMapper.selectByExampleSelective(example, LitemallComment.Column.content); + // 目前业务只支持回复一次 + if(commentReply.size() == 1){ + return commentReply.get(0).getContent(); + } + return null; + } + + public LitemallComment findById(Integer id) { + return commentMapper.selectByPrimaryKey(id); + } } diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java index 8766dbf7..bf6360c1 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java @@ -172,12 +172,16 @@ public class WxCommentController { List> commentVoList = new ArrayList<>(commentList.size()); for(LitemallComment comment : commentList){ Map commentVo = new HashMap<>(); - UserInfo userInfo = userInfoService.getInfo(comment.getUserId()); - commentVo.put("userInfo", userInfo); commentVo.put("addTime", comment.getAddTime()); commentVo.put("content",comment.getContent()); commentVo.put("picList", comment.getPicUrls()); + UserInfo userInfo = userInfoService.getInfo(comment.getUserId()); + commentVo.put("userInfo", userInfo); + + String reply = commentService.queryReply(comment.getId()); + commentVo.put("reply", reply); + commentVoList.add(commentVo); } Map data = new HashMap();