clean shopping cart
This commit is contained in:
@@ -43,7 +43,16 @@ public class ShoppingCartController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperation("list shopping cart")
|
@ApiOperation("list shopping cart")
|
||||||
public Result<List<ShoppingCart>> list(){
|
public Result<List<ShoppingCart>> list(){
|
||||||
|
log.info("list shopping cart");
|
||||||
List<ShoppingCart> list = shoppingCartService.listShoppingCart();
|
List<ShoppingCart> list = shoppingCartService.listShoppingCart();
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/clean")
|
||||||
|
@ApiOperation("clean the shopping cart")
|
||||||
|
public Result clean(){
|
||||||
|
log.info("clean shopping cart");
|
||||||
|
shoppingCartService.cleanShoppingCart();
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.sky.mapper;
|
package com.sky.mapper;
|
||||||
|
|
||||||
import com.sky.entity.ShoppingCart;
|
import com.sky.entity.ShoppingCart;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.apache.ibatis.annotations.Insert;
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
@@ -37,4 +38,11 @@ public interface ShoppingCartMapper {
|
|||||||
@Insert("insert into sky_take_out.shopping_cart(name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) " +
|
@Insert("insert into sky_take_out.shopping_cart(name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) " +
|
||||||
"values (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
|
"values (#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
|
||||||
void insert(ShoppingCart shoppingCart);
|
void insert(ShoppingCart shoppingCart);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clean shopping cart
|
||||||
|
* @param userId
|
||||||
|
*/
|
||||||
|
@Delete("delete from sky_take_out.shopping_cart where user_id = #{userId}")
|
||||||
|
void clean(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,9 @@ public interface ShoppingCartService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ShoppingCart> listShoppingCart();
|
List<ShoppingCart> listShoppingCart();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clean shopping cart
|
||||||
|
*/
|
||||||
|
void cleanShoppingCart();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,4 +84,14 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
|
|||||||
.build();
|
.build();
|
||||||
return shoppingCartMapper.list(shoppingCart);
|
return shoppingCartMapper.list(shoppingCart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clean shopping cart
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cleanShoppingCart() {
|
||||||
|
Long userId = BaseContext.getCurrentId();
|
||||||
|
shoppingCartMapper.clean(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user