feat(商城): 购物车模块

优化购物车模块
master
wayn 4 years ago
parent fa3a4c4549
commit 84d0a4ac8a

@ -44,6 +44,11 @@ public class CartController extends BaseController {
return R.result(iCartService.updateById(cart));
}
@PostMapping("changeNum/{cartId}/{number}")
public R changeNum(@PathVariable Long cartId, @PathVariable Integer number) {
return iCartService.changeNum(cartId, number);
}
@PostMapping("addNum/{cartId}/{number}")
public R addNum(@PathVariable Long cartId, @PathVariable Integer number) {
return iCartService.addNum(cartId, number);

@ -16,6 +16,7 @@ public interface ICartService extends IService<Cart> {
/**
*
*
* @param userId
* @param goodsId
* @param productId
@ -36,18 +37,43 @@ public interface ICartService extends IService<Cart> {
/**
*
*
* @return R
*/
R goodsCount();
/**
*
*
* @param userId ID
* @return R
*/
R list(Long userId);
/**
*
*
* @param cartId ID
* @param number
* @return r
*/
R changeNum(Long cartId, Integer number);
/**
*
*
* @param cartId ID
* @param number
* @return r
*/
R addNum(Long cartId, Integer number);
/**
*
*
* @param cartId ID
* @param number
* @return r
*/
R minusNum(Long cartId, Integer number);
}

@ -111,6 +111,11 @@ public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements IC
return R.success().add("data", cartList);
}
@Override
public R changeNum(Long cartId, Integer number) {
return R.result(update().setSql("number = " + number).eq("id", cartId).update(), "修改失败");
}
@Override
public R addNum(Long cartId, Integer number) {
return R.result(update().setSql("number = number + 1").eq("id", cartId).update(), "添加失败");

Loading…
Cancel
Save