|
@@ -17,7 +17,6 @@ import com.yami.shop.bean.app.dto.ProdCommDto;
|
|
|
import com.yami.shop.bean.app.param.ProdCommParam;
|
|
import com.yami.shop.bean.app.param.ProdCommParam;
|
|
|
import com.yami.shop.bean.enums.OrderStatus;
|
|
import com.yami.shop.bean.enums.OrderStatus;
|
|
|
import com.yami.shop.bean.model.Order;
|
|
import com.yami.shop.bean.model.Order;
|
|
|
-import com.yami.shop.bean.model.OrderItem;
|
|
|
|
|
import com.yami.shop.bean.model.ProdComm;
|
|
import com.yami.shop.bean.model.ProdComm;
|
|
|
import com.yami.shop.common.exception.GlobalException;
|
|
import com.yami.shop.common.exception.GlobalException;
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
import com.yami.shop.common.util.PageParam;
|
|
@@ -46,20 +45,16 @@ public class ProdCommController {
|
|
|
|
|
|
|
|
private final OrderService orderService;
|
|
private final OrderService orderService;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@GetMapping("/prodCommPageByUser")
|
|
@GetMapping("/prodCommPageByUser")
|
|
|
@ApiOperation(value = "根据用户返回评论分页数据", notes = "传入页码")
|
|
@ApiOperation(value = "根据用户返回评论分页数据", notes = "传入页码")
|
|
|
public ResponseEntity<IPage<ProdCommDto>> getProdCommPage(PageParam page) {
|
|
public ResponseEntity<IPage<ProdCommDto>> getProdCommPage(PageParam page) {
|
|
|
return ResponseEntity.ok(prodCommService.getProdCommDtoPageByUserId(page, SecurityUtils.getUser().getUserId()));
|
|
return ResponseEntity.ok(prodCommService.getProdCommDtoPageByUserId(page, SecurityUtils.getUser().getUserId()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
@ApiOperation(value = "添加评论")
|
|
@ApiOperation(value = "添加评论")
|
|
|
public ResponseEntity<Void> saveProdCommPage(@Valid @RequestBody ProdCommParam prodCommParam) {
|
|
public ResponseEntity<Void> saveProdCommPage(@Valid @RequestBody ProdCommParam prodCommParam) {
|
|
|
Long orderItemId = prodCommParam.getOrderItemId();
|
|
Long orderItemId = prodCommParam.getOrderItemId();
|
|
|
-
|
|
|
|
|
Order orderServiceById = orderService.getById(orderItemId);
|
|
Order orderServiceById = orderService.getById(orderItemId);
|
|
|
if (orderServiceById == null) {
|
|
if (orderServiceById == null) {
|
|
|
throw new GlobalException("订单项不存在");
|
|
throw new GlobalException("订单项不存在");
|
|
@@ -69,23 +64,21 @@ public class ProdCommController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
-
|
|
|
|
|
Order order = orderService.getOrderByOrderNumberAndUserId(orderServiceById.getOrderNumber(),userId, true);
|
|
Order order = orderService.getOrderByOrderNumberAndUserId(orderServiceById.getOrderNumber(),userId, true);
|
|
|
-
|
|
|
|
|
if (!Objects.equals(order.getHbOrderStatus(), OrderStatus.SUCCESS.value())) {
|
|
if (!Objects.equals(order.getHbOrderStatus(), OrderStatus.SUCCESS.value())) {
|
|
|
throw new GlobalException("请确认收货后再进行评论");
|
|
throw new GlobalException("请确认收货后再进行评论");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
prodCommService.comm(orderServiceById, prodCommParam);
|
|
prodCommService.comm(orderServiceById, prodCommParam);
|
|
|
-
|
|
|
|
|
return ResponseEntity.ok().build();
|
|
return ResponseEntity.ok().build();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/getProdComment")
|
|
@GetMapping("/getProdComment")
|
|
|
@ApiOperation(value = "根据itemId获取评论", notes = "根据itemId获取评论")
|
|
@ApiOperation(value = "根据itemId获取评论", notes = "根据itemId获取评论")
|
|
|
public ResponseEntity<ProdComm> getProdComment(Long orderItemId) {
|
|
public ResponseEntity<ProdComm> getProdComment(Long orderItemId) {
|
|
|
-
|
|
|
|
|
- ProdComm prodComm = prodCommService.getOne(new LambdaUpdateWrapper<ProdComm>().eq(ProdComm::getOrderItemId, orderItemId).eq(ProdComm::getUserId,SecurityUtils.getUser().getUserId()));
|
|
|
|
|
|
|
+ ProdComm prodComm = prodCommService.getOne(new LambdaUpdateWrapper<ProdComm>()
|
|
|
|
|
+ .eq(ProdComm::getOrderItemId, orderItemId)
|
|
|
|
|
+ .eq(ProdComm::getUserId,SecurityUtils.getUser().getUserId()));
|
|
|
return ResponseEntity.ok(prodComm);
|
|
return ResponseEntity.ok(prodComm);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|