public List<Cart> queryCartList() { Long userId = UserThreadLocal.get().getId(); Example example = new Example(Cart.class); example.setOrderByClause("created DESC"); example.createCriteria().andEqualTo("userId", userId); List<Cart> cartList = cartDao.selectByExample(example); return cartList; }
public void updateItemNum(Long itemId, Integer num) { Example example = new Example(Cart.class); example.createCriteria().andEqualTo("userId", UserThreadLocal.get().getId()); Cart cart = new Cart(); cart.setItemId(itemId); cart.setNum(num); cartDao.updateByExample(cart, example); }
public void deleteItemFromCart(Long itemId) { Cart cart = new Cart(); cart.setItemId(itemId); cart.setUserId(UserThreadLocal.get().getId()); cartDao.delete(cart); }