最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

黑馬程序員Java項目實戰(zhàn)《瑞吉外賣》,輕松掌握springboot + ...

2023-06-14 17:43 作者:DothmZark  | 我要投稿

Day6老師跳過的,減少購物車商品數(shù)量的響應,為節(jié)省篇幅,我寫在controller里:

??@PostMapping("/sub")

??public R<String> sub(@RequestBody SetmealDish setmealDish){

????Long userId=BaseContext.getCurrentId();

????LambdaQueryWrapper<ShoppingCart> queryWrapper = new LambdaQueryWrapper<>();

????if (setmealDish.getSetmealId() != null) {

??????Long setmealId = setmealDish.getSetmealId();

??????queryWrapper.eq(ShoppingCart::getSetmealId, setmealId).eq(ShoppingCart::getUserId, userId);

????} else {

??????Long dishId = setmealDish.getDishId();

??????queryWrapper.eq(ShoppingCart::getDishId, dishId).eq(ShoppingCart::getUserId, userId);

????}

????ShoppingCart shoppingCart = shoppingCartService.getOne(queryWrapper);

????if (shoppingCart != null) {

??????if (shoppingCart.getNumber() == 1) {

????????shoppingCartService.removeById(shoppingCart);

??????} else {

????????shoppingCart.setNumber(shoppingCart.getNumber() - 1);

????????shoppingCartService.updateById(shoppingCart);

??????}

??????return R.success("成功");

????} else {

??????return R.error("購物車中不存在該商品");

????}

??}

黑馬程序員Java項目實戰(zhàn)《瑞吉外賣》,輕松掌握springboot + ...的評論 (共 條)

分享到微博請遵守國家法律
龙泉市| 那曲县| 聂荣县| 永登县| 南开区| 上饶市| 阿尔山市| 陇南市| 宜宾县| 六盘水市| 仁布县| 彭山县| 昌黎县| 汤原县| 惠水县| 庐江县| 噶尔县| 晋宁县| 洪江市| 屏山县| 佳木斯市| 阳春市| 镇安县| 松江区| 象山县| 保亭| 禄丰县| 大关县| 喜德县| 南江县| 南华县| 思南县| 都匀市| 龙胜| 永定县| 昌吉市| 建湖县| 三台县| 林州市| 炉霍县| 双鸭山市|