增加评论回复接口和评论列表接口实现以及部分实体调整
This commit is contained in:
parent
685a373360
commit
4f50605455
@ -1,7 +1,12 @@
|
|||||||
package cn.iocoder.mall.order.application;
|
package cn.iocoder.mall.order.application;
|
||||||
|
|
||||||
|
import org.apache.catalina.connector.Connector;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.order"})
|
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.order"})
|
||||||
public class OrderApplication {
|
public class OrderApplication {
|
||||||
@ -10,4 +15,26 @@ public class OrderApplication {
|
|||||||
SpringApplication.run(OrderApplication.class, args);
|
SpringApplication.run(OrderApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解决异常信息:
|
||||||
|
* java.lang.IllegalArgumentException:
|
||||||
|
* Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ConfigurableServletWebServerFactory webServerFactory() {
|
||||||
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
@Override
|
||||||
|
public void customize(Connector connector) {
|
||||||
|
connector.setProperty("relaxedQueryChars", "|{}[]");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,17 +4,14 @@ import cn.iocoder.common.framework.constant.MallConstants;
|
|||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
import cn.iocoder.mall.order.api.OrderCommentService;
|
import cn.iocoder.mall.order.api.OrderCommentService;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
||||||
|
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
|
||||||
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
||||||
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
|
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.dubbo.config.annotation.Reference;
|
import org.apache.dubbo.config.annotation.Reference;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
@ -41,4 +38,12 @@ public class OrderCommentController {
|
|||||||
public CommonResult<OrderCommentCreateBO> createOrder(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
|
public CommonResult<OrderCommentCreateBO> createOrder(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
|
||||||
return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
|
return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("getOrderCommentPage")
|
||||||
|
//@RequiresLogin
|
||||||
|
@ApiOperation(value = "获取评论分页")
|
||||||
|
public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
|
||||||
|
return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
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.dto.OrderCommentReplyCreateDTO;
|
||||||
|
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 static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 评论回复模块 Api(user)
|
||||||
|
*
|
||||||
|
* @author wtz
|
||||||
|
* @time 2019-05-31 18:00
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment_reply")
|
||||||
|
@Api("用户评论回复模块 ")
|
||||||
|
public class OrderCommentReplyController {
|
||||||
|
|
||||||
|
@Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
|
||||||
|
private OrderCommentReplyService orderCommentReplyService;
|
||||||
|
|
||||||
|
@PostMapping("create_order_comment")
|
||||||
|
//@RequiresLogin
|
||||||
|
@ApiOperation(value = "创建订单")
|
||||||
|
public CommonResult<OrderCommentReplyCreateBO> createOrderCommentReply(@RequestBody @Validated OrderCommentReplyCreateDTO orderCommentReplyCreateDTO){
|
||||||
|
return success(orderCommentReplyService.createOrderCommentReply(orderCommentReplyCreateDTO));
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,11 @@ server:
|
|||||||
context-path: /order-api/
|
context-path: /order-api/
|
||||||
|
|
||||||
swagger:
|
swagger:
|
||||||
enable: false
|
enable: true # 暂时不去掉
|
||||||
|
title: 订单子系统
|
||||||
|
description: 订单子系统
|
||||||
|
version: 1.0.0
|
||||||
|
base-package: cn.iocoder.mall.order.application.controller
|
||||||
|
|
||||||
management:
|
management:
|
||||||
endpoints:
|
endpoints:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.mall.order.api.bo;
|
package cn.iocoder.mall.order.api.bo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ public class OrderCommentPageBO implements Serializable {
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@AllArgsConstructor
|
||||||
public static class OrderCommentItem{
|
public static class OrderCommentItem{
|
||||||
/**
|
/**
|
||||||
* 评论 id
|
* 评论 id
|
||||||
@ -87,7 +89,7 @@ public class OrderCommentPageBO implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 点赞数
|
* 点赞数
|
||||||
*/
|
*/
|
||||||
private Integer collectCount;
|
private Integer likeCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
@ -98,7 +100,7 @@ public class OrderCommentPageBO implements Serializable {
|
|||||||
* 商家回复列表
|
* 商家回复列表
|
||||||
* 只展示最近的一条
|
* 只展示最近的一条
|
||||||
*/
|
*/
|
||||||
private String MerchantRaplayContent;
|
private String replyContent;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package cn.iocoder.mall.order.api.bo;
|
package cn.iocoder.mall.order.api.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 订单回复创建
|
* 订单回复创建
|
||||||
@ -7,5 +12,13 @@ package cn.iocoder.mall.order.api.bo;
|
|||||||
* @author wtz
|
* @author wtz
|
||||||
* @time 2019-05-19 18:35
|
* @time 2019-05-19 18:35
|
||||||
*/
|
*/
|
||||||
public class OrderCommentReplyCreateBO {
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class OrderCommentReplyCreateBO implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论回复 id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.mall.order.api.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 评论回复类型
|
||||||
|
*
|
||||||
|
* @author wtz
|
||||||
|
* @time 2019-06-01 10:30:00
|
||||||
|
*/
|
||||||
|
public enum OrderCommentRelpyTypeEnum {
|
||||||
|
|
||||||
|
REPLY_REPLY(0, "回复的回复"),
|
||||||
|
COMMENT_REPLY(1, "评论的回复");
|
||||||
|
/**
|
||||||
|
* 状态值
|
||||||
|
*/
|
||||||
|
private Integer value;
|
||||||
|
/**
|
||||||
|
* 状态名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
OrderCommentRelpyTypeEnum(Integer value, String name) {
|
||||||
|
this.value = value;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
@ -9,8 +9,8 @@ package cn.iocoder.mall.order.api.constant;
|
|||||||
*/
|
*/
|
||||||
public enum OrderReplyUserTypeEnum {
|
public enum OrderReplyUserTypeEnum {
|
||||||
|
|
||||||
USER(1, "普通用户"),
|
USER(0, "普通用户"),
|
||||||
MERCHANT(2, "商家");
|
MERCHANT(1, "商家");
|
||||||
/**
|
/**
|
||||||
* 状态值
|
* 状态值
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,9 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单评论 convert
|
* 订单评论 convert
|
||||||
|
*
|
||||||
|
* @author wtz
|
||||||
|
* @time 2019-05-30 18:30
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface OrderCommentConvert {
|
public interface OrderCommentConvert {
|
||||||
@ -24,6 +27,4 @@ public interface OrderCommentConvert {
|
|||||||
@Mappings({})
|
@Mappings({})
|
||||||
OrderCommentCreateBO convert(OrderCommentDO orderCommentDO);
|
OrderCommentCreateBO convert(OrderCommentDO orderCommentDO);
|
||||||
|
|
||||||
@Mappings({})
|
|
||||||
List<OrderCommentPageBO.OrderCommentItem> convert(List<OrderCommentDO> orderCommentDOList);
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.mall.order.biz.convert;
|
||||||
|
|
||||||
|
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 评论回复 convert
|
||||||
|
*
|
||||||
|
* @author wtz
|
||||||
|
* @time 2019-05-31 18:30
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface OrderCommentReplyConvert {
|
||||||
|
|
||||||
|
OrderCommentReplyConvert INSTANCE = Mappers.getMapper(OrderCommentReplyConvert.class);
|
||||||
|
|
||||||
|
@Mappings({})
|
||||||
|
OrderCommentReplyDO convert(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
|
||||||
|
|
||||||
|
@Mappings({})
|
||||||
|
OrderCommentReplyCreateBO convert(OrderCommentReplyDO orderCommentReplyDO);
|
||||||
|
}
|
@ -39,10 +39,14 @@ public interface OrderCommentMapper{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据 sku id 分页查询评论
|
* 根据 sku id 分页查询评论
|
||||||
* @param orderCommentPageDTO
|
* @param productSkuId
|
||||||
|
* @param offset
|
||||||
|
* @param limit
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<OrderCommentDO> selectCommentPage(OrderCommentPageDTO orderCommentPageDTO);
|
List<OrderCommentDO> selectCommentPage(@Param("productSkuId") Integer productSkuId,
|
||||||
|
@Param("offset") Integer offset,
|
||||||
|
@Param("limit") Integer limit);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ public class OrderCommentReplyDO extends BaseDO {
|
|||||||
private String parentUserAvatar;
|
private String parentUserAvatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回复的数量
|
* 回复的内容
|
||||||
*/
|
*/
|
||||||
private String replyContent;
|
private String replyContent;
|
||||||
|
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package cn.iocoder.mall.order.biz.service;
|
||||||
|
|
||||||
|
import cn.iocoder.mall.order.api.OrderCommentReplyService;
|
||||||
|
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.dto.OrderCommentReplyCreateDTO;
|
||||||
|
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
|
||||||
|
import cn.iocoder.mall.order.biz.convert.OrderCommentReplyConvert;
|
||||||
|
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
|
||||||
|
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 订单评论回复 service impl
|
||||||
|
*
|
||||||
|
* @author wtz
|
||||||
|
* @time 2019-05-31 18:30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@org.apache.dubbo.config.annotation.Service(validation = "true",version = "${dubbo.provider.OrderCommentReplyService.version}")
|
||||||
|
public class OrderCommentReplyServiceImpl implements OrderCommentReplyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderCommentReplayMapper orderCommentReplayMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderCommentReplyPageBO> getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建评论回复
|
||||||
|
* @param orderCommentReplyCreateDTO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OrderCommentReplyCreateBO createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO) {
|
||||||
|
OrderCommentReplyDO orderCommentReplyDO=OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyCreateDTO);
|
||||||
|
orderCommentReplyDO.setCreateTime(new Date());
|
||||||
|
orderCommentReplyDO.setUpdateTime(new Date());
|
||||||
|
|
||||||
|
Integer replyType=orderCommentReplyCreateDTO.getCommentId()==orderCommentReplyCreateDTO.getParentId()?
|
||||||
|
OrderCommentRelpyTypeEnum.COMMENT_REPLY.getValue():OrderCommentRelpyTypeEnum.REPLY_REPLY.getValue();
|
||||||
|
|
||||||
|
orderCommentReplyDO.setReplyType(replyType);
|
||||||
|
|
||||||
|
orderCommentReplayMapper.insert(orderCommentReplyDO);
|
||||||
|
|
||||||
|
return OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyDO);
|
||||||
|
}
|
||||||
|
}
|
@ -4,17 +4,21 @@ import cn.iocoder.mall.order.api.OrderCommentService;
|
|||||||
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
|
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
|
||||||
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
|
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
|
||||||
|
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
|
||||||
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
||||||
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
|
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
|
||||||
import cn.iocoder.mall.order.biz.convert.OrderCommentConvert;
|
import cn.iocoder.mall.order.biz.convert.OrderCommentConvert;
|
||||||
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
|
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
|
||||||
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
|
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
|
||||||
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
|
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
|
||||||
|
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -30,6 +34,9 @@ public class OrderCommentServiceImpl implements OrderCommentService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderCommentMapper orderCommentMapper;
|
private OrderCommentMapper orderCommentMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderCommentReplayMapper orderCommentReplayMapper;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderCommentService orderCommentService;
|
private OrderCommentService orderCommentService;
|
||||||
@ -50,11 +57,24 @@ public class OrderCommentServiceImpl implements OrderCommentService {
|
|||||||
public OrderCommentPageBO getOrderCommentPage(OrderCommentPageDTO orderCommentPageDTO) {
|
public OrderCommentPageBO getOrderCommentPage(OrderCommentPageDTO orderCommentPageDTO) {
|
||||||
OrderCommentPageBO orderCommentPageBO=new OrderCommentPageBO();
|
OrderCommentPageBO orderCommentPageBO=new OrderCommentPageBO();
|
||||||
//分页内容
|
//分页内容
|
||||||
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO);
|
int offset = (orderCommentPageDTO.getPageNo() - 1) * orderCommentPageDTO.getPageSize();
|
||||||
//查询商家的回复
|
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO.getProductSkuId(),
|
||||||
|
offset,orderCommentPageDTO.getPageSize());
|
||||||
|
//分页评论的 id
|
||||||
|
List<Integer> commentIds=orderCommentDOList.stream().map(x->x.getId()).collect(Collectors.toList());
|
||||||
|
//获取商家最新的评论回复
|
||||||
|
List<OrderCommentReplyDO> orderCommentReplyDOList=orderCommentReplayMapper.selectCommentNewMerchantReplyByCommentIds(commentIds,
|
||||||
|
OrderReplyUserTypeEnum.MERCHANT.getValue());
|
||||||
|
//评论组装
|
||||||
|
List<OrderCommentPageBO.OrderCommentItem> orderCommentItemList=orderCommentDOList.stream()
|
||||||
|
.flatMap(x->orderCommentReplyDOList.stream()
|
||||||
|
.filter(y->x.getId()==y.getCommentId())
|
||||||
|
.map(y->new OrderCommentPageBO.OrderCommentItem(x.getId(),x.getUserAvatar(),x.getUserNickName(),x.getStar(),
|
||||||
|
x.getCommentContent(),x.getCommentPics(),x.getReplayCount(),x.getLikeCount(),x.getCreateTime(),y.getReplyContent()))
|
||||||
|
).collect(Collectors.toList());
|
||||||
//总数
|
//总数
|
||||||
int totalCount=orderCommentMapper.selectCommentTotalCountByProductSkuId(orderCommentPageDTO.getProductSkuId());
|
int totalCount=orderCommentMapper.selectCommentTotalCountByProductSkuId(orderCommentPageDTO.getProductSkuId());
|
||||||
orderCommentPageBO.setOrderCommentItems(OrderCommentConvert.INSTANCE.convert(orderCommentDOList));
|
orderCommentPageBO.setOrderCommentItems(orderCommentItemList);
|
||||||
orderCommentPageBO.setTotal(totalCount);
|
orderCommentPageBO.setTotal(totalCount);
|
||||||
return orderCommentPageBO;
|
return orderCommentPageBO;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<!--根据 sku id 获取评论总数-->
|
<!--根据 sku id 获取评论总数-->
|
||||||
<select id="selectCommentTotalCountByProductSkuId" parameterType="Integer" resultType="java.lang.Integer">
|
<select id="selectCommentTotalCountByProductSkuId" parameterType="Integer" resultType="java.lang.Integer">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT (*)
|
COUNT(*)
|
||||||
FROM order_comment
|
FROM order_comment
|
||||||
WHERE
|
WHERE
|
||||||
product_sku_id = #{productSkuId}
|
product_sku_id = #{productSkuId}
|
||||||
@ -35,7 +35,7 @@
|
|||||||
WHERE
|
WHERE
|
||||||
product_sku_id = #{productSkuId}
|
product_sku_id = #{productSkuId}
|
||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
LIMIT ${pageNo * pageSize}, ${pageSize}
|
LIMIT #{offset}, #{limit}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--根据评论 id 获取用户详情-->
|
<!--根据评论 id 获取用户详情-->
|
||||||
@ -46,7 +46,7 @@
|
|||||||
WHERE
|
WHERE
|
||||||
id = #{id}
|
id = #{id}
|
||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
LIMIT ${pageNo * pageSize}, ${pageSize}
|
LIMIT ${ pageNo * pageSize },${ pageSize }
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<!--插入-->
|
<!--插入-->
|
||||||
<insert id="insert" parameterType="OrderCommentReplyDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
<insert id="insert" parameterType="OrderCommentReplyDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||||
INSERT INTO order_comment_replay(comment_id,reply_type,parent_id,parent_user_id,parent_user_nick_name,parent_user_avatar,reply_content,reply_user_id
|
INSERT INTO order_comment_replay(comment_id,reply_type,parent_id,parent_user_id,parent_user_nick_name,parent_user_avatar,reply_content,reply_user_id,
|
||||||
reply_user_nick_name,reply_user_avatar,user_type,create_time,update_time)
|
reply_user_nick_name,reply_user_avatar,user_type,create_time,update_time)
|
||||||
VALUES (#{commentId},#{replyType},#{parentId},#{parentUserId},#{parentUserNickName},#{parentUserAvatar},#{replyContent},#{replyUserId},
|
VALUES (#{commentId},#{replyType},#{parentId},#{parentUserId},#{parentUserNickName},#{parentUserAvatar},#{replyContent},#{replyUserId},
|
||||||
#{replyUserNickName},#{replyUserAvatar},#{userType},#{createTime},#{updateTime})
|
#{replyUserNickName},#{replyUserAvatar},#{userType},#{createTime},#{updateTime})
|
||||||
@ -51,10 +51,29 @@
|
|||||||
LIMIT ${pageNo * pageSize}, ${pageSize}
|
LIMIT ${pageNo * pageSize}, ${pageSize}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<!--根据评论 id 查询商家最新的评论列表-->
|
<!--根据评论 id 查询商家最新的评论列表-->
|
||||||
<select id="selectCommentNewMerchantReplyByCommentIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
|
<select id="selectCommentNewMerchantReplyByCommentIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
|
||||||
|
SELECT
|
||||||
|
<include refid="FIELDS" />
|
||||||
|
FROM order_comment_replay
|
||||||
|
WHERE
|
||||||
|
create_time=(SELECT
|
||||||
|
a.maxtime
|
||||||
|
FROM
|
||||||
|
(SELECT
|
||||||
|
MAX(create_time) AS maxtime,comment_id
|
||||||
|
FROM order_comment_replay
|
||||||
|
WHERE
|
||||||
|
comment_id IN
|
||||||
|
<foreach collection="commentIds" item="commentId" separator="," open="(" close=")">
|
||||||
|
#{commentId}
|
||||||
|
</foreach>
|
||||||
|
GROUP BY comment_id ) AS a)
|
||||||
|
AND
|
||||||
|
comment_id IN
|
||||||
|
<foreach collection="commentIds" item="commentId" separator="," open="(" close=")">
|
||||||
|
#{commentId}
|
||||||
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user