package com.caimei.www.controller.authorized;

import com.caimei.www.controller.BaseController;
import com.caimei.www.pojo.JsonModel;
import com.caimei.www.pojo.base.ShoppingCart;
import com.caimei.www.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 购物车
 *
 * @author : Charles
 * @date : 2020/7/23
 */
@Controller
public class ShoppingCartController extends BaseController {

    private ShoppingCartService shoppingCartService;
    @Autowired
    public void setShoppingCartService(ShoppingCartService shoppingCartService) {
        this.shoppingCartService = shoppingCartService;
    }

    /**
     * 顶部购物车数据
     * @return
     */
    @GetMapping("/header/cart")
    @ResponseBody
    public JsonModel<List<ShoppingCart>> getHeadCarts(Integer userId) {
        return shoppingCartService.getHeaderCart(userId);
    }

}
