package com.ghy.goods.service.impl;

import com.ghy.goods.domain.GoodsImgs;
import com.ghy.goods.mapper.GoodsImgsMapper;
import com.ghy.goods.service.GoodsImgsService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @author clunt
 * 商品图片impl
 */
@Service
public class GoodsImgsServiceImpl implements GoodsImgsService {

    @Resource
    GoodsImgsMapper goodsImgsMapper;

    @Override
    public List<GoodsImgs> qryGoodsImgs(GoodsImgs goodsImgs) {
        return goodsImgsMapper.qryGoodsImgs(goodsImgs);
    }

    @Override
    public int batchInsert(List<GoodsImgs> goodsImgs) {
        return goodsImgsMapper.batchInsert(goodsImgs);
    }

    @Override
    public int batchUpdate(Collection<GoodsImgs> goodsImgs) {
        if (CollectionUtils.isEmpty(goodsImgs)) return 0;
        return goodsImgsMapper.batchUpdate(goodsImgs);
    }

    @Override
    public int deleteByGoodsId(@NotNull Long goodsId) {
        return goodsImgsMapper.deleteByGoodsId(goodsId);
    }

    @Override
    public int batchDelete(Collection<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) return 0;
        return goodsImgsMapper.delete(ids);
    }

    @Override
    public List<GoodsImgs> selectByGoodsId(@NotNull Long goodsId) {
        return goodsImgsMapper.selectByGoodsId(goodsId);
    }
}
