添加订单评论和MONGODB

This commit is contained in:
xiaofeng
2020-05-19 23:28:19 +08:00
parent e47029cff2
commit c8a7e35731
19 changed files with 275 additions and 143 deletions

View File

@@ -1,44 +0,0 @@
package cn.iocoder.mall.order.biz.convert;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
*
* 订单评论 convert
*
* @author wtz
* @time 2019-05-31 18:30
*/
@Mapper
public interface OrderCommentConvert {
OrderCommentConvert INSTANCE = Mappers.getMapper(OrderCommentConvert.class);
// @Mappings({})
// OrderCommentStateInfoPageBO.OrderCommentStateInfoItem convertOrderCommentStateInfoItem(
// OrderCommentDO orderCommentDO);
//
// @Mappings({})
// List<OrderCommentStateInfoPageBO.OrderCommentStateInfoItem> convertOrderCommentStateInfoItems(
// List<OrderCommentDO> orderCommentDOList);
//
// @Mappings({})
// OrderCommentDO convertOrderCommentDO(OrderCommentCreateDTO orderCommentCreateDTO);
//
// @Mappings({})
// OrderCommentCreateBO convertOrderCommentCreateBO(OrderCommentDO orderCommentDO);
//
// @Mappings({})
// OrderCommentInfoBO convertOrderCommentInfoBO(OrderCommentDO orderCommentDO);
//
// @Mappings({})
// OrderCommentTimeOutBO convertOrderCommentTimeOutBO(OrderCommentDO orderCommentDO);
//
// @Mappings({})
// List<OrderCommentTimeOutBO> convertOrderCommentTimeOutBOList(
// List<OrderCommentDO> orderCommentDOList);
}

View File

@@ -0,0 +1,28 @@
package cn.iocoder.mall.order.biz.convert.comment;
import cn.iocoder.mall.order.biz.dataobject.comment.OrderCommentDO;
import cn.iocoder.mall.order.biz.dto.comment.OrderCommentAddDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 订单评论转换
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/19 23:06
*/
@Mapper
public interface OrderCommentConvert {
OrderCommentConvert INSTANCE = Mappers.getMapper(OrderCommentConvert.class);
/**
* 参数转成 DO
*
* @param orderCommentAddDTO
* @return
*/
OrderCommentDO convert(OrderCommentAddDTO orderCommentAddDTO);
}

View File

@@ -1,25 +1,24 @@
package cn.iocoder.mall.order.biz.dataobject;
package cn.iocoder.mall.order.biz.dataobject.comment;
import cn.iocoder.mall.mybatis.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
/**
* 订单评论
*
* @author wtz
* @time 2019-05-14 20:48
* 订单评论 MONGODB
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/19 22:30
*/
@Data
@Accessors(chain = true)
@TableName(value = "order_comment")
@Document(collection = "order_comment")
public class OrderCommentDO extends BaseDO {
/**
* 评论 id // TODO FROM 芋艿 TO wtz 中英文之间要有空格
*/
@Id
private Integer id;
/**
@@ -103,7 +102,7 @@ public class OrderCommentDO extends BaseDO {
private Integer replayCount;
/**
* 点赞数 // TODO FROM 芋艿 TO wtz collect 是收藏的意思最好换个单词噢
* 点赞数
*/
private Integer likeCount;

View File

@@ -1,84 +1,63 @@
package cn.iocoder.mall.order.biz.dto.comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 订单评论创建
*
* @author wtz
* @update xiaofeng
* @time 2019-05-15 20:42
*
* @update time 2020-05-13 0:07
*/
@ApiModel("订单创建 DTO")
@Data
@Accessors(chain = true)
public class OrderCommentCreateDTO implements Serializable {
public class OrderCommentAddDTO implements Serializable {
@ApiModelProperty(value = "订单 id", required = true)
@NotNull(message = "订单 id 不能为空")
private Integer orderId;
@ApiModelProperty(value = "订单编号", required = true)
@NotEmpty(message = "订单编号不能为空")
private String orderNo;
@ApiModelProperty(value = "商品 spu id", required = true)
@NotNull(message = "商品的 spu id 不能为空")
private Integer productSpuId;
@ApiModelProperty(value = "商品 spu name", required = true)
@NotEmpty(message = "商品的 spu name 不能为空")
private String productSpuName;
@ApiModelProperty(value = "商品 sku id", required = true)
@NotNull(message = "商品的 sku id 不能为空")
private Integer productSkuId;
@ApiModelProperty(value = "商品 sku attrs", required = true)
@NotEmpty(message = "商品的 sku attrs 不能为空")
private String productSkuAttrs;
@ApiModelProperty(value = "商品 sku price", required = true)
@NotNull(message = "商品的 sku price 不能为空")
private Integer productSkuPrice;
@ApiModelProperty(value = "商品 sku url", required = true)
@NotEmpty(message = "商品的 sku url 不能为空")
private String productSkuPicUrl;
@ApiModelProperty(value = "用户 id", required = true)
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

@@ -0,0 +1,26 @@
package cn.iocoder.mall.order.biz.service.comment;
import cn.iocoder.mall.order.biz.bo.comment.OrderCommentBO;
import cn.iocoder.mall.order.biz.dto.comment.OrderCommentAddDTO;
import javax.validation.Valid;
import org.springframework.validation.annotation.Validated;
/**
* 订单评论业务
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/17 15:24
*/
@Validated
public interface OrderCommentService {
/**
* 添加订单评论
*
* @param orderCommentAddDTO
* @return
*/
Boolean addOrderComment(@Valid OrderCommentAddDTO orderCommentAddDTO);
}

View File

@@ -0,0 +1,34 @@
package cn.iocoder.mall.order.biz.service.comment;
import cn.iocoder.mall.order.biz.convert.comment.OrderCommentConvert;
import cn.iocoder.mall.order.biz.dataobject.comment.OrderCommentDO;
import cn.iocoder.mall.order.biz.dto.comment.OrderCommentAddDTO;
import javax.validation.Valid;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
/**
* OrderCommentServiceImpl
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/17 15:32
*/
@Service
public class OrderCommentServiceImpl implements OrderCommentService {
private final MongoTemplate mongoTemplate;
public OrderCommentServiceImpl(final MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
@Override
public Boolean addOrderComment(
@Valid OrderCommentAddDTO orderCommentAddDTO) {
OrderCommentDO orderCommentDO = mongoTemplate
.save(OrderCommentConvert.INSTANCE.convert(orderCommentAddDTO));
return null != orderCommentDO ? Boolean.TRUE : Boolean.FALSE;
}
}

View File

@@ -6,6 +6,12 @@ spring:
username: root
password: 3WLiVUBEwTbvAfsh
#mongodb
data:
mongodb:
uri: mongodb://localhost/order-comment
# MyBatis Plus 配置项
mybatis-plus:
configuration: