Commit 2f21fd2a by huluobin

update

parent e4a78c08
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gogirl.application.product.mall.MallShoppingCartCmdService;
import com.gogirl.assembler.MallShoppingCartAssembler;
import com.gogirl.domain.order.mall.MallShoppingCart;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.mapper.order.mall.MallShoppingCartMapper;
import com.gogirl.shared.product.DecreaseCartCommand;
import com.gogirl.shared.product.MallShoppingCartCommand;
......@@ -70,14 +71,18 @@ public class MallShoppingCartCmdServiceImpl implements MallShoppingCartCmdServic
.eq(MallShoppingCart::getProductId, cmd.getProductId()));
if (mallShoppingCart != null) {
if (mallShoppingCart.getNum() > 1) {
mallShoppingCart.setNum((mallShoppingCart.getNum() - 1));
mallShoppingCart.setNum((mallShoppingCart.getNum() - 1));
if (mallShoppingCart.getNum() > 0) {
mallShoppingCartMapper.updateById(mallShoppingCart);
}
//移除购物车项
else {
else if (mallShoppingCart.getNum() == 0) {
mallShoppingCartMapper.deleteById(mallShoppingCart.getId());
}
//invalid
else {
throw new RRException("invalid num");
}
}
}
}
......@@ -57,10 +57,10 @@ public class MallShoppingCartController {
}
@ApiOperation("减少购物车项")
@GetMapping("/customer/mallCart/decreaseMallShoppingCart/{id}")
public JsonResult<Integer> decreaseMallShoppingCart(@ApiParam("产品id")
@PathVariable Long id) {
mallShoppingCartCmdService.decreaseMallShoppingCart(new DecreaseCartCommand(SessionUtils.getCustomerId(), id));
@PostMapping("/customer/mallCart/decreaseMallShoppingCart")
public JsonResult<Integer> decreaseMallShoppingCart(@RequestBody DecreaseCartCommand cmd) {
cmd.setCurrentCustomerId(SessionUtils.getCustomerId());
mallShoppingCartCmdService.decreaseMallShoppingCart(cmd);
return JsonResult.success();
}
......
......@@ -16,4 +16,6 @@ public class DecreaseCartCommand implements Serializable {
@ApiModelProperty("产品id")
private Long productId;
private Integer num;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment