From fcd70c2bac2e299aa5f48a680e7bad38d6e2c4e6 Mon Sep 17 00:00:00 2001 From: wangtongzhou Date: Tue, 28 May 2019 18:14:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=8E=A5=E5=8F=A3=E5=92=8C=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=AE=9E=E4=BD=93=E5=92=8Cmapper=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/OrderCommentController.java | 44 +++++++++ .../order/api/OrderCommentReplyService.java | 10 ++ .../mall/order/api/OrderCommentService.java | 8 -- .../mall/order/api/bo/OrderCommentBO.java | 1 - .../order/api/bo/OrderCommentCreateBO.java | 11 ++- .../OrderCommentInfoAndMerchantReplyBO.java | 2 +- .../mall/order/api/bo/OrderCommentPageBO.java | 31 ++++--- .../order/api/dto/OrderCommentCreateDTO.java | 92 ++++++++----------- .../biz/convert/OrderCommentConvert.java | 9 +- .../biz/dao/OrderCommentReplayMapper.java | 10 ++ .../order/biz/dataobject/OrderCommentDO.java | 2 +- .../biz/service/OrderCommentServiceImpl.java | 23 +++-- .../mapper/OrderCommentReplayMapper.xml | 8 +- 13 files changed, 156 insertions(+), 95 deletions(-) create mode 100644 order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java new file mode 100644 index 000000000..1e1915b4a --- /dev/null +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java @@ -0,0 +1,44 @@ +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.OrderCommentService; +import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO; +import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO; +import cn.iocoder.mall.user.sdk.annotation.RequiresLogin; +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-27 20:46 + */ +@RestController +@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment") +@Api("用户评论模块") +public class OrderCommentController { + + @Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}") + private OrderCommentService orderCommentService; + + + @PostMapping("create_order_comment") + //@RequiresLogin + @ApiOperation(value = "创建订单") + public CommonResult createOrder(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) { + return success(orderCommentService.createOrderComment(orderCommentCreateDTO)); + } +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentReplyService.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentReplyService.java index 6cb72086a..5ea73ea9a 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentReplyService.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentReplyService.java @@ -1,6 +1,8 @@ package cn.iocoder.mall.order.api; +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 java.util.List; @@ -21,4 +23,12 @@ public interface OrderCommentReplyService { * @return */ List getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO); + + + /** + * 评论回复创建 + * @param orderCommentReplyCreateDTO + * @return + */ + OrderCommentReplyCreateBO createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO); } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentService.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentService.java index 62fc8ea70..dbd0ec4d3 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentService.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderCommentService.java @@ -3,10 +3,8 @@ 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.OrderCommentPageBO; -import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum; import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO; import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO; -import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO; /** * 订单评论模块 @@ -24,12 +22,6 @@ public interface OrderCommentService { OrderCommentCreateBO createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO); - /** - * 评论回复创建 - * @param orderCommentReplyCreateDTO - * @return - */ - Boolean createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO); /** * 获取评论列表的分页 diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentBO.java index a5790b506..5c4c31ff2 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentBO.java @@ -5,7 +5,6 @@ import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; -import java.util.List; /** * diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentCreateBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentCreateBO.java index deac1875f..5d1da4fe7 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentCreateBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentCreateBO.java @@ -1,5 +1,10 @@ package cn.iocoder.mall.order.api.bo; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; + /** * * 订单评论创建 @@ -8,10 +13,12 @@ package cn.iocoder.mall.order.api.bo; * @time 2019-05-19 18:32 * */ -public class OrderCommentCreateBO { +@Data +@Accessors(chain = true) +public class OrderCommentCreateBO implements Serializable { /** * 订单评论 id */ - private Integer commentId; + private Integer id; } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentInfoAndMerchantReplyBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentInfoAndMerchantReplyBO.java index 9d63fe692..5e317a36b 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentInfoAndMerchantReplyBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentInfoAndMerchantReplyBO.java @@ -86,7 +86,7 @@ public class OrderCommentInfoAndMerchantReplyBO { @Data @Accessors(chain = true) - private static class OrderCommentReplayMerchantItem{ + public static class OrderCommentReplayMerchantItem{ /** * 回复的内容 */ diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentPageBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentPageBO.java index 1d6dbf40f..e5221ca13 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentPageBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderCommentPageBO.java @@ -24,20 +24,21 @@ public class OrderCommentPageBO implements Serializable { */ private Integer total; - /** - * 好评 - */ - private Integer positiveTotal; - - /** - * 中评 - */ - private Integer moderateTotal; - - /** - * 差评 - */ - private Integer negativeTotal; +// 评论标签化等等在做 +// /** +// * 好评 +// */ +// private Integer positiveTotal; +// +// /** +// * 中评 +// */ +// private Integer moderateTotal; +// +// /** +// * 差评 +// */ +// private Integer negativeTotal; /** * 评论列表 @@ -47,7 +48,7 @@ public class OrderCommentPageBO implements Serializable { @Data @Accessors(chain = true) - private static class OrderCommentItem{ + public static class OrderCommentItem{ /** * 评论 id */ diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCommentCreateDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCommentCreateDTO.java index 9e021d59b..576ffa605 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCommentCreateDTO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCommentCreateDTO.java @@ -1,8 +1,12 @@ package cn.iocoder.mall.order.api.dto; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.io.Serializable; /** @@ -12,92 +16,70 @@ import java.io.Serializable; * @time 2019-05-15 20:42 * */ +@ApiModel("订单创建 DTO") @Data @Accessors(chain = true) public class OrderCommentCreateDTO implements Serializable { - /** - * 订单 id - */ - private int orderId; - /** - * 订单编号 - */ + @ApiModelProperty(value = "订单 id", required = true) + @NotNull(message = "订单 id 不能为空") + private Integer orderId; + + @ApiModelProperty(value = "订单编号", required = true) + @NotEmpty(message = "订单编号不能为空") private String orderNo; - /** - * 商品 spu id - */ - private int productSpuId; + @ApiModelProperty(value = "商品 spu id", required = true) + @NotNull(message = "商品的 spu id 不能为空") + private Integer productSpuId; - /** - * 商品 spu 名字 spu 这两个属性待考量我认为加入进去以后后期一些分析可能好做一些 - */ + @ApiModelProperty(value = "商品 spu name", required = true) + @NotEmpty(message = "商品的 spu name 不能为空") private String productSpuName; - /** - * 商品 sku id - */ - private int productSkuId; + @ApiModelProperty(value = "商品 sku id", required = true) + @NotNull(message = "商品的 sku id 不能为空") + private Integer productSkuId; - /** - * 商品 sku 属性 - */ + @ApiModelProperty(value = "商品 sku attrs", required = true) + @NotEmpty(message = "商品的 sku attrs 不能为空") private String productSkuAttrs; - /** - * 商品 sku 价格 - */ - private int productSkuPrice; + @ApiModelProperty(value = "商品 sku price", required = true) + @NotNull(message = "商品的 sku price 不能为空") + private Integer productSkuPrice; - /** - * 商品 sku 地址 - */ + @ApiModelProperty(value = "商品 sku url", required = true) + @NotEmpty(message = "商品的 sku url 不能为空") private String productSkuPicUrl; - /** - * 用户 id - */ + @ApiModelProperty(value = "用户 id", required = true) + @NotNull(message = "用户 id 不能为空") private Integer userId; - /** - * 用户头像 - */ + @ApiModelProperty(value = "用户头像", required = true) private String userAvatar; - /** - * 用户昵称 - */ + @ApiModelProperty(value = "用户昵称", required = true) + @NotEmpty(message = "用户昵称不能为空") private String userNickName; - /** - * 星 - */ + @ApiModelProperty(value = "评价星级", required = true,example = "1-5") private Integer star; - /** - * 产品描述 - */ + @ApiModelProperty(value = "商品描述星级", required = true,example = "1-5") private Integer productDescriptionStar; - /** - * 物流评价 - */ + @ApiModelProperty(value = "物流评价星级", required = true,example = "1-5") private Integer logisticsStar; - /** - * 商家评价 - */ + @ApiModelProperty(value = "商家评价星级", required = true,example = "1-5") private Integer merchantStar; - /** - * 评论内容 - */ + @ApiModelProperty(value = "商家评价内容", required = true,example = "1-5") private String commentContent; - /** - * 评论图片 - */ + @ApiModelProperty(value = "评价图片", required = true) private String commentPics; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderCommentConvert.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderCommentConvert.java index 54769cbd9..8ff2bac61 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderCommentConvert.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderCommentConvert.java @@ -1,13 +1,15 @@ package cn.iocoder.mall.order.biz.convert; -import cn.iocoder.mall.order.api.bo.OrderCommentBO; 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.biz.dataobject.OrderCommentDO; -import org.apache.ibatis.annotations.Mapper; +import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; +import java.util.List; + /** * 订单评论 convert */ @@ -21,4 +23,7 @@ public interface OrderCommentConvert { @Mappings({}) OrderCommentCreateBO convert(OrderCommentDO orderCommentDO); + + @Mappings({}) + List convert(List orderCommentDOList); } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentReplayMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentReplayMapper.java index b91220312..5345c1d9e 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentReplayMapper.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentReplayMapper.java @@ -7,6 +7,7 @@ import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.Collection; import java.util.List; /** @@ -50,4 +51,13 @@ public interface OrderCommentReplayMapper { int selectCommentReplyTotalCountByCommentId(@Param("commentId") Integer commentId, @Param("userType") Integer userType); + + /** + * 根据评论 id 查询最新的商家回复 + * @param commentIds + * @return + */ + List selectCommentNewMerchantReplyByCommentIds(@Param("commentIds") Collection commentIds, + @Param("userType") Integer userType); + } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCommentDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCommentDO.java index 3a9ac5014..d04312bfc 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCommentDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCommentDO.java @@ -12,9 +12,9 @@ import lombok.experimental.Accessors; * @time 2019-05-14 20:48 * */ +@TableName(value = "order_comment") @Data @Accessors(chain = true) -@TableName(value = "order_comment") public class OrderCommentDO extends BaseDO { /** diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java index 434177130..a7320f38e 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java @@ -6,7 +6,6 @@ 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; -import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO; import cn.iocoder.mall.order.biz.convert.OrderCommentConvert; import cn.iocoder.mall.order.biz.dao.OrderCommentMapper; import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper; @@ -15,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.List; /** * @@ -24,14 +24,15 @@ import java.util.Date; * @time 2019 */ @Service -@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OrderService.version}") +@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.OrderCommentService.version}") public class OrderCommentServiceImpl implements OrderCommentService { @Autowired private OrderCommentMapper orderCommentMapper; + @Autowired - private OrderCommentReplayMapper orderCommentReplayMapper; + private OrderCommentService orderCommentService; @Override public OrderCommentCreateBO createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO) { @@ -40,18 +41,22 @@ public class OrderCommentServiceImpl implements OrderCommentService { //接下来就是入库 OrderCommentDO orderCommentDO=OrderCommentConvert.INSTANCE.convert(orderCommentCreateDTO); orderCommentDO.setCreateTime(new Date()); + orderCommentDO.setUpdateTime(new Date()); orderCommentMapper.insert(orderCommentDO); return OrderCommentConvert.INSTANCE.convert(orderCommentDO); } - @Override - public Boolean createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO) { - return null; - } - @Override public OrderCommentPageBO getOrderCommentPage(OrderCommentPageDTO orderCommentPageDTO) { - return null; + OrderCommentPageBO orderCommentPageBO=new OrderCommentPageBO(); + //分页内容 + List orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO); + //查询商家的回复 + //总数 + int totalCount=orderCommentMapper.selectCommentTotalCountByProductSkuId(orderCommentPageDTO.getProductSkuId()); + orderCommentPageBO.setOrderCommentItems(OrderCommentConvert.INSTANCE.convert(orderCommentDOList)); + orderCommentPageBO.setTotal(totalCount); + return orderCommentPageBO; } @Override diff --git a/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml index bf3face2b..17906b50b 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml @@ -9,7 +9,7 @@ - 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) VALUES (#{commentId},#{replyType},#{parentId},#{parentUserId},#{parentUserNickName},#{parentUserAvatar},#{replyContent},#{replyUserId}, #{replyUserNickName},#{replyUserAvatar},#{userType},#{createTime},#{updateTime}) @@ -51,4 +51,10 @@ LIMIT ${pageNo * pageSize}, ${pageSize} + + + + From 7bdf751d254dca464ae077526cb7c30baa497554 Mon Sep 17 00:00:00 2001 From: wangtongzhou Date: Tue, 28 May 2019 18:22:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=89=88=E6=9C=AC=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/order/order-service-impl/src/main/resources/config/application.yaml b/order/order-service-impl/src/main/resources/config/application.yaml index 0b8692982..003a413e8 100644 --- a/order/order-service-impl/src/main/resources/config/application.yaml +++ b/order/order-service-impl/src/main/resources/config/application.yaml @@ -43,6 +43,8 @@ dubbo: version: 1.0.0 OrderLogisticsService: version: 1.0.0 + OrderCommentService: + version: 1.0.0 consumer: timeout: 120000 # 设置长一点,方便调试代码 ProductSpuService: