package com.caimei.www.service.impl;

import com.caimei.www.mapper.ShoppingCartDao;
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.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Description
 *
 * @author : Charles
 * @date : 2020/7/23
 */
@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Value("${caimei.wwwDomain}")
    private String domain;
    @Resource
    private ShoppingCartDao shoppingCartDao;

    /**
     * 顶部购物车数据
     *
     * @param userId
     * @return
     */
    @Override
    public JsonModel<List<ShoppingCart>> getHeaderCart(Integer userId) {
        if (userId == null || userId == 0) { return JsonModel.error("参数异常", null);}
        List<ShoppingCart> headCarts = shoppingCartDao.getHeadCarts(userId);
        return JsonModel.success(headCarts);
    }
}
