添加订单评论和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

@ -48,6 +48,12 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- mongodb 相关-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>org.mapstruct</groupId>

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

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

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.users;
package cn.iocoder.mall.order.rest.controller.cart;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.users;
package cn.iocoder.mall.order.rest.controller.comment;
import cn.iocoder.common.framework.constant.MallConstants;
import io.swagger.annotations.Api;

View File

@ -0,0 +1,48 @@
package cn.iocoder.mall.order.rest.controller.comment;
import cn.iocoder.common.framework.constant.MallConstants;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.biz.service.comment.OrderCommentService;
import cn.iocoder.mall.order.rest.convert.comment.UsersOrderCommentConvert;
import cn.iocoder.mall.order.rest.request.comment.UsersOrderCommentAddRequest;
import cn.iocoder.mall.security.core.context.UserSecurityContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
/**
* UsersOrderCommentController
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/12 22:56
*/
@RestController
@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment")
@Api("订单商品评论模块")
public class UsersOrderCommentController {
private final OrderCommentService orderCommentService;
public UsersOrderCommentController(
OrderCommentService orderCommentService) {
this.orderCommentService = orderCommentService;
}
@PostMapping("/add")
@ApiOperation(value = "添加订单评论")
public CommonResult<Boolean> add(
@RequestBody @Validated UsersOrderCommentAddRequest request) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
request.setUserId(userId);
return CommonResult.success(orderCommentService.addOrderComment(
UsersOrderCommentConvert.INSTANCE.convert(request)));
}
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.admins;
package cn.iocoder.mall.order.rest.controller.order;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.admins;
package cn.iocoder.mall.order.rest.controller.order;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.users;
package cn.iocoder.mall.order.rest.controller.order;
import io.swagger.annotations.Api;
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("users/order")
@Api(description = "用户订单") // TODO FROM 芋艿 to 小范description 已经废弃啦
public class OrderController {
public class UsersOrderController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
// private OrderService orderService;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.users;
package cn.iocoder.mall.order.rest.controller.order;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("users/order_logistics")
@Api(description = "订单物流信息")
public class OrderLogisticsController {
public class UsersOrderLogisticsController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderLogisticsService.version}")
// private OrderLogisticsService orderLogisticsService;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.order.rest.controller.users;
package cn.iocoder.mall.order.rest.controller.order;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping("users/order_return")
public class OrderReturnController {
public class UsersOrderReturnController {
// @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
// private OrderReturnService orderReturnService;

View File

@ -1,61 +0,0 @@
package cn.iocoder.mall.order.rest.controller.users;
import cn.iocoder.common.framework.constant.MallConstants;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
* 订单评论 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;
//
// @Reference(validation = "true", version = "${dubbo.provider.OrderCommentReplyService.version}")
// private OrderCommentReplyService orderCommentReplyService;
//
//
// @PostMapping("create_order_comment")
// //@RequiresLogin
// @ApiOperation(value = "创建订单评论")
// public CommonResult<OrderCommentCreateBO> createOrderComment(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
// Integer userId = UserSecurityContextHolder.getContext().getUserId();
// orderCommentCreateDTO.setUserId(userId);
// return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
// }
//
// @GetMapping("order_comment_page")
// @ApiOperation(value = "获取评论分页")
// public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
// return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
// }
//
// @GetMapping("order_comment_info_merchant_reply")
// @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);
// }
//
// @GetMapping
// //@RequiresLogin
// @ApiOperation(value = "获取订单评论状态分页")
// public CommonResult<OrderCommentStateInfoPageBO> getOrderCommentStateInfoPage(@Validated OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO){
// //Integer userId = UserSecurityContextHolder.getContext().getUserId();
// //orderCommentStateInfoPageDTO.setUserId(userId);
// return success(orderCommentService.getOrderCommentStateInfoPage(orderCommentStateInfoPageDTO));
// }
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.mall.order.rest.convert.comment;
import cn.iocoder.mall.order.biz.dto.comment.OrderCommentAddDTO;
import cn.iocoder.mall.order.rest.request.comment.UsersOrderCommentAddRequest;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* UsersOrderCommentConvert
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/13 0:15
*/
@Mapper
public interface UsersOrderCommentConvert {
UsersOrderCommentConvert INSTANCE = Mappers.getMapper(UsersOrderCommentConvert.class);
/**
* 保存订单评论参数转换
*
* @param request
* @return
*/
OrderCommentAddDTO convert(UsersOrderCommentAddRequest request);
}

View File

@ -1,26 +1,23 @@
package cn.iocoder.mall.order.biz.dto.comment;
package cn.iocoder.mall.order.rest.request.comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 订单评论创建
*
* @author wtz
* @time 2019-05-15 20:42
* 添加订单评论
*
* @author xiaofeng
* @version 1.0
* @date 2020/05/12 23:02
*/
@ApiModel("订单创建 DTO")
@ApiModel("用户 - Order 模块 - 添加订单评论")
@Data
@Accessors(chain = true)
public class OrderCommentCreateDTO implements Serializable {
public class UsersOrderCommentAddRequest {
@ApiModelProperty(value = "订单 id", required = true)
@NotNull(message = "订单 id 不能为空")
@ -64,21 +61,22 @@ public class OrderCommentCreateDTO implements Serializable {
@NotEmpty(message = "用户昵称不能为空")
private String userNickName;
@ApiModelProperty(value = "评价星级", required = true,example = "1-5")
@ApiModelProperty(value = "评价星级", required = true, example = "1-5")
private Integer star;
@ApiModelProperty(value = "商品描述星级", required = true,example = "1-5")
@ApiModelProperty(value = "商品描述星级", required = true, example = "1-5")
private Integer productDescriptionStar;
@ApiModelProperty(value = "物流评价星级", required = true,example = "1-5")
@ApiModelProperty(value = "物流评价星级", required = true, example = "1-5")
private Integer logisticsStar;
@ApiModelProperty(value = "商家评价星级", required = true,example = "1-5")
@ApiModelProperty(value = "商家评价星级", required = true, example = "1-5")
private Integer merchantStar;
@ApiModelProperty(value = "商家评价内容", required = true,example = "1-5")
@ApiModelProperty(value = "商家评价内容", required = true, example = "1-5")
private String commentContent;
@ApiModelProperty(value = "评价图片", required = true)
private String commentPics;
}