package com.wzj.soopin.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzj.soopin.goods.domain.bo.SkuBo;
import com.wzj.soopin.goods.domain.entity.Sku;
import com.wzj.soopin.goods.domain.vo.SkuVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * sku信息Mapper接口
 *
 * @author zcc
 */
@Mapper
public interface SkuMapper extends BaseMapper<Sku> {
    /**
     * 查询sku信息列表
     *
     * @param sku sku信息
     * @return sku信息集合
     */
    List<Sku> selectByEntity(Sku sku);

    int updateStockById(@Param("skuId")Long skuId, @Param("optDate")LocalDateTime optDate, @Param("quantity")Integer quantity);

    IPage<SkuVO> getlist(@Param("page") Page<Sku> page,@Param("query") SkuBo query, @Param("tenantId") Long tenantId);


    SkuVO selectSkuByid(@Param("id") Long id);

    @Insert("<script>" +
        "INSERT INTO pms_sku (product_id, out_sku_id, price, pic, sp_data, stock) VALUES " +
        "<foreach collection='list' item='item' separator=','>" +
        "(#{item.productId}, #{item.outSkuId}, #{item.price}, #{item.pic}, #{item.spData}, #{item.stock})" +
        "</foreach>" +
        "</script>")
    void batchInsert(List<Sku> skus);
}
