package com.fzm.mall.server.front.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzm.mall.server.front.goods.model.ShopNavigationGoods;
import com.fzm.mall.server.front.goods.mapper.ShopNavigationGoodsMapper;
import com.fzm.mall.server.front.goods.model.vo.GoodsVo;
import com.fzm.mall.server.front.goods.model.vo.PageVoWithTwo;
import com.fzm.mall.server.front.goods.model.vo.SaleHotVo;
import com.fzm.mall.server.front.goods.service.IShopNavigationGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 店铺中心-店铺导航管理 服务实现类
 * </p>
 *
 * @author fzm
 * @since 2021-05-31
 */
@Service
public class ShopNavigationGoodsServiceImpl extends ServiceImpl<ShopNavigationGoodsMapper, ShopNavigationGoods> implements IShopNavigationGoodsService {

    @Autowired
    private ShopNavigationGoodsMapper shopNavigationGoodsMapper;
    @Override
    public List<SaleHotVo>  getGoodsVo(PageVoWithTwo pageVoWithTwo) {
        int start = (pageVoWithTwo.getPage()-1)*pageVoWithTwo.getSize();
        int end = pageVoWithTwo.getSize();
        return  shopNavigationGoodsMapper.getGoodsVo(pageVoWithTwo.getParamA(),pageVoWithTwo.getParamB(),start,end);
    }

    @Override
    public Integer getCount(String merchantId, String navigationId) {
        QueryWrapper<ShopNavigationGoods> q = new QueryWrapper<>();
        q.eq("navigation_id",navigationId);
        q.eq("merchant_id",merchantId);
        return  count(q);
    }
}
