package com.sqx.modules.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.Result;
import com.sqx.modules.goods.dao.GoodsSkuDao;
import com.sqx.modules.goods.entity.GoodsSku;
import com.sqx.modules.goods.service.GoodsSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuDao, GoodsSku> implements GoodsSkuService {

    @Autowired
    private GoodsSkuDao goodsSkuDao;

    @Override
    public Result insertSku(GoodsSku goodsSku) {
        baseMapper.insert(goodsSku);
        return Result.success();
    }

    @Override
    public List<GoodsSku> selectGoodsSkuByGoodsId(Long goodsId){
        return baseMapper.selectList(new QueryWrapper<GoodsSku>().eq("goods_id",goodsId));
    }

    @Override
    public int deleteGoodsSkuByGoodsId(Long goodsId){
        return baseMapper.delete(new QueryWrapper<GoodsSku>().eq("goods_id",goodsId));
    }


}
