苍穹外卖--清空购物车
This commit is contained in:
@@ -36,4 +36,13 @@ public class ShoppingCartController {
|
||||
List<ShoppingCart> list = shoppingCartService.showShoppingCart();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
@DeleteMapping("/clean")
|
||||
@ApiOperation("清空购物车")
|
||||
public Result cleanShoppingCart(){
|
||||
log.info("清空购物车");
|
||||
shoppingCartService.cleanShoppingCart();
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.sky.mapper;
|
||||
|
||||
import com.sky.dto.ShoppingCartDTO;
|
||||
import com.sky.entity.ShoppingCart;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,4 +23,7 @@ public interface ShoppingCartMapper {
|
||||
@Insert("insert into shopping_cart (name, user_id, dish_id, setmeal_id, dish_flavor, number, amount, image, create_time) " +
|
||||
"values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
|
||||
void insert(ShoppingCart cart);
|
||||
|
||||
@Delete("delete from shopping_cart where user_id = #{userId}")
|
||||
void deleteByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -15,4 +15,9 @@ public interface ShoppingCartService {
|
||||
查看购物车
|
||||
*/
|
||||
List<ShoppingCart> showShoppingCart();
|
||||
|
||||
/*
|
||||
清空购物车
|
||||
*/
|
||||
void cleanShoppingCart();
|
||||
}
|
||||
|
||||
@@ -104,4 +104,13 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
|
||||
|
||||
return shoppingCartMapper.list(cart);
|
||||
}
|
||||
|
||||
/*
|
||||
清空购物车
|
||||
*/
|
||||
@Override
|
||||
public void cleanShoppingCart() {
|
||||
|
||||
shoppingCartMapper.deleteByUserId(BaseContext.getCurrentId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user