实现增加评论接口和一些实体和mapper更改

This commit is contained in:
wangtongzhou 2019-05-28 18:14:10 +08:00
parent e1292e3867
commit fcd70c2bac
13 changed files with 156 additions and 95 deletions

View File

@ -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<OrderCommentCreateBO> createOrder(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
}
}

View File

@ -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<OrderCommentReplyPageBO> getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO);
/**
* 评论回复创建
* @param orderCommentReplyCreateDTO
* @return
*/
OrderCommentReplyCreateBO createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
}

View File

@ -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);
/**
* 获取评论列表的分页

View File

@ -5,7 +5,6 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*

View File

@ -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;
}

View File

@ -86,7 +86,7 @@ public class OrderCommentInfoAndMerchantReplyBO {
@Data
@Accessors(chain = true)
private static class OrderCommentReplayMerchantItem{
public static class OrderCommentReplayMerchantItem{
/**
* 回复的内容
*/

View File

@ -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
*/

View File

@ -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;
}

View File

@ -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<OrderCommentPageBO.OrderCommentItem> convert(List<OrderCommentDO> orderCommentDOList);
}

View File

@ -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<OrderCommentReplyDO> selectCommentNewMerchantReplyByCommentIds(@Param("commentIds") Collection<Integer> commentIds,
@Param("userType") Integer userType);
}

View File

@ -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 {
/**

View File

@ -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<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectCommentPage(orderCommentPageDTO);
//查询商家的回复
//总数
int totalCount=orderCommentMapper.selectCommentTotalCountByProductSkuId(orderCommentPageDTO.getProductSkuId());
orderCommentPageBO.setOrderCommentItems(OrderCommentConvert.INSTANCE.convert(orderCommentDOList));
orderCommentPageBO.setTotal(totalCount);
return orderCommentPageBO;
}
@Override

View File

@ -9,7 +9,7 @@
<!--插入-->
<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)
VALUES (#{commentId},#{replyType},#{parentId},#{parentUserId},#{parentUserNickName},#{parentUserAvatar},#{replyContent},#{replyUserId},
#{replyUserNickName},#{replyUserAvatar},#{userType},#{createTime},#{updateTime})
@ -51,4 +51,10 @@
LIMIT ${pageNo * pageSize}, ${pageSize}
</select>
<!--根据评论 id 查询商家最新的评论列表-->
<select id="selectCommentNewMerchantReplyByCommentIds" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
</select>
</mapper>