
package com.tmerclub.cloud.seckill.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.util.PageUtil;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.seckill.dto.SeckillStockPointSkuDTO;
import com.tmerclub.cloud.seckill.mapper.SeckillStockPointSkuMapper;
import com.tmerclub.cloud.seckill.model.SeckillStockPointSku;
import com.tmerclub.cloud.seckill.service.SeckillStockPointSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 *
 * @author tmerclub
 * @date 2023-11-23 15:32:01
 */
@Service
public class SeckillStockPointSkuServiceImpl implements SeckillStockPointSkuService {

    @Autowired
    private SeckillStockPointSkuMapper seckillStockPointSkuMapper;

    @Override
    public PageVO<SeckillStockPointSku> page(PageDTO pageDTO) {
        return PageUtil.doPage(pageDTO, () -> seckillStockPointSkuMapper.list());
    }

    @Override
    public SeckillStockPointSku getBySeckillStockPointSkuId(Long seckillStockPointSkuId) {
        return seckillStockPointSkuMapper.getBySeckillStockPointSkuId(seckillStockPointSkuId);
    }

    @Override
    public void save(SeckillStockPointSku seckillStockPointSku) {
        seckillStockPointSkuMapper.save(seckillStockPointSku);
    }

    @Override
    public void update(SeckillStockPointSku seckillStockPointSku) {
        seckillStockPointSkuMapper.update(seckillStockPointSku);
    }

    @Override
    public void deleteById(Long seckillStockPointSkuId) {
        seckillStockPointSkuMapper.deleteById(seckillStockPointSkuId);
    }

    @Override
    public void batchSave(List<SeckillStockPointSkuDTO> stockPointDTOList) {
        if (CollectionUtil.isEmpty(stockPointDTOList)) {
            return;
        }
        seckillStockPointSkuMapper.batchSave(stockPointDTOList);
    }
}
