完成评论回复列表和评论商家详情列表,用户验证暂时等下次增加点赞接口以后加上

This commit is contained in:
wangtongzhou 2019-06-03 21:49:31 +08:00
parent 3a7291a399
commit 2c57d29428
16 changed files with 225 additions and 117 deletions

View File

@ -2,8 +2,10 @@ package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderCommentReplyService;
import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
@ -31,6 +33,9 @@ public class OrderCommentController {
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
private OrderCommentService orderCommentService;
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentReplyService.version}")
private OrderCommentReplyService orderCommentReplyService;
@PostMapping("create_order_comment")
//@RequiresLogin
@ -39,11 +44,21 @@ public class OrderCommentController {
return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
}
@GetMapping("getOrderCommentPage")
@GetMapping("order_comment_page")
//@RequiresLogin
@ApiOperation(value = "获取评论分页")
public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
}
@GetMapping("order_comment_info_merchant_reply")
//@RequiresLogin
@ApiOperation(value = "获取评论和商家回复")
public CommonResult<OrderCommentInfoAndMerchantReplyBO> geOrderCommentInfoAndMerchantReply(@RequestParam("commentId") Integer commentId){
OrderCommentInfoAndMerchantReplyBO orderCommentInfoAndMerchantReplyBO=new OrderCommentInfoAndMerchantReplyBO();
orderCommentInfoAndMerchantReplyBO.setOrderCommentInfoBO(orderCommentService.getOrderCommentInfo(commentId));
orderCommentInfoAndMerchantReplyBO.setOrderCommentMerchantReplyBOS(orderCommentReplyService.getOrderCommentMerchantReply(commentId));
return success(orderCommentInfoAndMerchantReplyBO);
}
}

View File

@ -3,17 +3,15 @@ package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderCommentReplyService;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@ -33,10 +31,17 @@ public class OrderCommentReplyController {
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
private OrderCommentReplyService orderCommentReplyService;
@PostMapping("create_order_comment")
@PostMapping("create_order_comment_reply")
//@RequiresLogin
@ApiOperation(value = "创建订单")
@ApiOperation(value = "创建订单回复")
public CommonResult<OrderCommentReplyCreateBO> createOrderCommentReply(@RequestBody @Validated OrderCommentReplyCreateDTO orderCommentReplyCreateDTO){
return success(orderCommentReplyService.createOrderCommentReply(orderCommentReplyCreateDTO));
}
@GetMapping("order_comment_reply_page")
//@RequiresLogin
@ApiOperation(value = "分页获取评论回复")
public CommonResult<OrderCommentReplyPageBO> getOrderCommentReplyPage(@Validated OrderCommentReplyPageDTO orderCommentReplyCreateDTO){
return success(orderCommentReplyService.getOrderCommentReplyPage(orderCommentReplyCreateDTO));
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.mall.order.api.bo.OrderCommentMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
@ -22,7 +23,7 @@ public interface OrderCommentReplyService {
* @param orderCommentReplyPageDTO
* @return
*/
List<OrderCommentReplyPageBO> getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO);
OrderCommentReplyPageBO getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO);
/**
@ -31,4 +32,15 @@ public interface OrderCommentReplyService {
* @return
*/
OrderCommentReplyCreateBO createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
/**
* 获取商家评论回复
* @param commentId
* @return
*/
List<OrderCommentMerchantReplyBO> getOrderCommentMerchantReply(Integer commentId);
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
@ -32,11 +32,11 @@ public interface OrderCommentService {
/**
* 获取评论详情和商家回复
* 获取评论详情
* @param commentId
* @return
*/
OrderCommentInfoAndMerchantReplyBO getOrderCommentInfo(Integer commentId, Integer userType);
OrderCommentInfoBO getOrderCommentInfo(Integer commentId);

View File

@ -3,97 +3,27 @@ package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
*
* 订单回复评价详情和商加回复
* 评论详情和商家评论回复
*
* @author wtz
* @time 2019-05-16 18:40
*
* @time 2019-06-03 20:30
*/
@Data
@Accessors(chain = true)
public class OrderCommentInfoAndMerchantReplyBO {
/**
* 评论 id
* 评论详情
*/
private Integer id;
private OrderCommentInfoBO orderCommentInfoBO;
/**
* 用户头像
* 商家评论回复
*/
private String userAvatar;
/**
* 用户昵称
*/
private String userNickName;
/**
* 评价星
*/
private Integer star;
/**
* 评论的内容
*/
private String commentContent;
/**
* 评论的图片地址
*/
private String commentPics;
/**
* 点赞数
*/
private Integer collectCount;
/**
* 创建时间
*/
private Date createTime;
/**
* 商品 sku id
*/
private int productSkuId;
/**
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品 sku 价格
*/
private String productSkuPrice;
/**
* 商品 sku 地址
*/
private String productSkuPicUrl;
/**
* 商家回复
*/
List<OrderCommentReplayMerchantItem> orderCommentReplayMerchantItems;
@Data
@Accessors(chain = true)
public static class OrderCommentReplayMerchantItem{
/**
* 回复的内容
*/
private String replyContent;
}
private List<OrderCommentMerchantReplyBO> orderCommentMerchantReplyBOS;
}

View File

@ -0,0 +1,83 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
* 订单回复评价详情
*
* @author wtz
* @time 2019-05-16 18:40
*
*/
@Data
@Accessors(chain = true)
public class OrderCommentInfoBO {
/**
* 评论 id
*/
private Integer id;
/**
* 用户头像
*/
private String userAvatar;
/**
* 用户昵称
*/
private String userNickName;
/**
* 评价星
*/
private Integer star;
/**
* 评论的内容
*/
private String commentContent;
/**
* 评论的图片地址
*/
private String commentPics;
/**
* 点赞数
*/
private Integer collectCount;
/**
* 创建时间
*/
private Date createTime;
/**
* 商品 sku id
*/
private int productSkuId;
/**
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品 sku 价格
*/
private String productSkuPrice;
/**
* 商品 sku 地址
*/
private String productSkuPicUrl;
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
/**
*
* 商家评论回复
*
* @author wtz
* @time 2019-06-03 19:30
*/
@Data
@Accessors(chain = true)
public class OrderCommentMerchantReplyBO {
/**
* 商家评论回复
*/
private String replyContent;
}

View File

@ -15,19 +15,24 @@ import java.util.List;
* @time 2019-05-19 14:19
*
*/
@Data
@Accessors(chain = true)
public class OrderCommentReplyPageBO {
/**
* 评论回复总数
*/
private Integer total;
/**
* 用户回复
*/
List<OrderCommentReplayUserItem> orderCommentReplayUserItems;
List<OrderCommentReplayItem> orderCommentReplayItems;
@Data
@Accessors(chain = true)
private static class OrderCommentReplayUserItem{
public static class OrderCommentReplayItem{
/**
* 回复 id
*/

View File

@ -1,6 +1,7 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
@ -27,4 +28,7 @@ public interface OrderCommentConvert {
@Mappings({})
OrderCommentCreateBO convert(OrderCommentDO orderCommentDO);
@Mappings({})
OrderCommentInfoBO convertOrderCommentInfoBO(OrderCommentDO orderCommentDO);
}

View File

@ -1,12 +1,17 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderCommentMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import javax.validation.constraints.Max;
import java.util.List;
/**
*
* 评论回复 convert
@ -24,4 +29,10 @@ public interface OrderCommentReplyConvert {
@Mappings({})
OrderCommentReplyCreateBO convert(OrderCommentReplyDO orderCommentReplyDO);
@Mappings({})
List<OrderCommentMerchantReplyBO> convert(List<OrderCommentReplyDO> orderCommentReplyDOList);
@Mappings({})
List<OrderCommentReplyPageBO.OrderCommentReplayItem> convertOrderCommentReplayItem(List<OrderCommentReplyDO> orderCommentReplyDOList);
}

View File

@ -38,15 +38,11 @@ public interface OrderCommentMapper{
/**
* 根据 sku id 分页查询评论
* @param productSkuId
* @param offset
* @param limit
* 分页获取评论
* @param orderCommentPageDTO
* @return
*/
List<OrderCommentDO> selectCommentPage(@Param("productSkuId") Integer productSkuId,
@Param("offset") Integer offset,
@Param("limit") Integer limit);
List<OrderCommentDO> selectCommentPage(OrderCommentPageDTO orderCommentPageDTO);
/**

View File

@ -31,12 +31,12 @@ public interface OrderCommentReplayMapper {
* @param commentId,userType
* @return
*/
List<OrderCommentReplyDO> selectCommentMerchantReplyByCommentId(@Param("commentId") Integer commentId,
List<OrderCommentReplyDO> selectCommentMerchantReplyByCommentIdAndUserType(@Param("commentId") Integer commentId,
@Param("userType") Integer userType);
/**
* 评论回复分页
* 分页获取评论回复
* @param orderCommentReplyPageDTO
* @return
*/

View File

@ -1,9 +1,11 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.mall.order.api.OrderCommentReplyService;
import cn.iocoder.mall.order.api.bo.OrderCommentMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.constant.OrderCommentRelpyTypeEnum;
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
import cn.iocoder.mall.order.biz.convert.OrderCommentReplyConvert;
@ -12,6 +14,7 @@ import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -29,9 +32,22 @@ public class OrderCommentReplyServiceImpl implements OrderCommentReplyService {
@Autowired
private OrderCommentReplayMapper orderCommentReplayMapper;
/**
* 分页获取评论回复
* @param orderCommentReplyPageDTO
* @return
*/
@Override
public List<OrderCommentReplyPageBO> getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO) {
return null;
public OrderCommentReplyPageBO getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO) {
OrderCommentReplyPageBO orderCommentReplyPageBO=new OrderCommentReplyPageBO();
//评论回复总数
Integer totalCount=orderCommentReplayMapper.selectCommentReplyTotalCountByCommentId(orderCommentReplyPageDTO.getCommentId(),
orderCommentReplyPageDTO.getUserType());
//分页获取评论回复
List<OrderCommentReplyDO> orderCommentReplyDOList=orderCommentReplayMapper.selectCommentReplyPage(orderCommentReplyPageDTO);
orderCommentReplyPageBO.setTotal(totalCount);
orderCommentReplyPageBO.setOrderCommentReplayItems(OrderCommentReplyConvert.INSTANCE.convertOrderCommentReplayItem(orderCommentReplyDOList));
return orderCommentReplyPageBO;
}
@ -55,4 +71,16 @@ public class OrderCommentReplyServiceImpl implements OrderCommentReplyService {
return OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyDO);
}
/**
* 获取商家评论回复
* @param commentId
* @return
*/
@Override
public List<OrderCommentMerchantReplyBO> getOrderCommentMerchantReply(Integer commentId) {
List<OrderCommentReplyDO> orderCommentReplyDOList=orderCommentReplayMapper.selectCommentMerchantReplyByCommentIdAndUserType(commentId,
OrderReplyUserTypeEnum.MERCHANT.getValue());
return OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyDOList);
}
}

View File

@ -2,7 +2,7 @@ package cn.iocoder.mall.order.biz.service;
import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
@ -15,7 +15,6 @@ import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -57,9 +56,7 @@ public class OrderCommentServiceImpl implements OrderCommentService {
public OrderCommentPageBO getOrderCommentPage(OrderCommentPageDTO orderCommentPageDTO) {
OrderCommentPageBO orderCommentPageBO=new OrderCommentPageBO();
//分页内容
int offset = (orderCommentPageDTO.getPageNo() - 1) * orderCommentPageDTO.getPageSize();
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO.getProductSkuId(),
offset,orderCommentPageDTO.getPageSize());
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO);
//分页评论的 id
List<Integer> commentIds=orderCommentDOList.stream().map(x->x.getId()).collect(Collectors.toList());
//获取商家最新的评论回复
@ -79,9 +76,12 @@ public class OrderCommentServiceImpl implements OrderCommentService {
return orderCommentPageBO;
}
@Override
public OrderCommentInfoAndMerchantReplyBO getOrderCommentInfo(Integer commentId, Integer userType) {
return null;
public OrderCommentInfoBO getOrderCommentInfo(Integer commentId) {
//查询评论详情
OrderCommentDO orderCommentDO=orderCommentMapper.selectCommentInfoByCommentId(commentId);
return OrderCommentConvert.INSTANCE.convertOrderCommentInfoBO(orderCommentDO);
}
@Override

View File

@ -35,7 +35,7 @@
WHERE
product_sku_id = #{productSkuId}
ORDER BY create_time DESC
LIMIT #{offset}, #{limit}
LIMIT ${pageNo*pageSize},${pageSize}
</select>
<!--根据评论 id 获取用户详情-->
@ -45,8 +45,6 @@
FROM order_comment
WHERE
id = #{id}
ORDER BY create_time DESC
LIMIT ${ pageNo * pageSize },${ pageSize }
</select>
</mapper>

View File

@ -16,7 +16,7 @@
</insert>
<!--根据评论 id 和用户类型获取商家回复列表-->
<select id="selectCommentMerchantReplyByCommentId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
<select id="selectCommentMerchantReplyByCommentIdAndUserType" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
SELECT
<include refid="FIELDS" />
FROM order_comment_replay
@ -30,7 +30,7 @@
<!--根据评论 id 和用户类型获取评论总数-->
<select id="selectCommentReplyTotalCountByCommentId" parameterType="Integer" resultType="java.lang.Integer">
SELECT
COUNT (*)
COUNT(*)
FROM order_comment_replay
WHERE
comment_id = #{commentId}
@ -48,7 +48,7 @@
AND
user_type = #{userType}
ORDER BY create_time DESC
LIMIT ${pageNo * pageSize}, ${pageSize}
LIMIT ${pageNo*pageSize},${pageSize}
</select>
<!--根据评论 id 查询商家最新的评论列表-->