package com.ruoyi.ss.carousel.service.impl;

import java.util.Collections;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.carousel.domain.Carousel;
import com.ruoyi.ss.carousel.domain.CarouselQuery;
import com.ruoyi.ss.carousel.domain.CarouselVO;
import com.ruoyi.ss.carousel.mapper.CarouselMapper;
import com.ruoyi.ss.carousel.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 轮播图Service业务层处理
 *
 * @author qzz
 * @date 2024-12-13
 */
@Service
public class CarouselServiceImpl implements CarouselService
{
    @Autowired
    private CarouselMapper carouselMapper;

    /**
     * 查询轮播图
     *
     * @param carouselId 轮播图主键
     * @return 轮播图
     */
    @Override
    public CarouselVO selectSsCarouselByCarouselId(Long carouselId)
    {
        return carouselMapper.selectSsCarouselByCarouselId(carouselId);
    }

    /**
     * 查询轮播图列表
     *
     * @param ssCarousel 轮播图
     * @return 轮播图
     */
    @Override
    public List<CarouselVO> selectSsCarouselList(CarouselQuery ssCarousel)
    {
        return carouselMapper.selectSsCarouselList(ssCarousel);
    }

    /**
     * 新增轮播图
     *
     * @param ssCarousel 轮播图
     * @return 结果
     */
    @Override
    public int insertSsCarousel(Carousel ssCarousel)
    {
        ssCarousel.setCreateTime(DateUtils.getNowDate());
        return carouselMapper.insertSsCarousel(ssCarousel);
    }

    /**
     * 修改轮播图
     *
     * @param ssCarousel 轮播图
     * @return 结果
     */
    @Override
    public int updateSsCarousel(Carousel ssCarousel)
    {
        ssCarousel.setUpdateTime(DateUtils.getNowDate());
        return carouselMapper.updateSsCarousel(ssCarousel);
    }

    /**
     * 批量删除轮播图
     *
     * @param carouselIds 需要删除的轮播图主键
     * @return 结果
     */
    @Override
    public int deleteSsCarouselByCarouselIds(Long[] carouselIds)
    {
        return carouselMapper.deleteSsCarouselByCarouselIds(carouselIds);
    }

    /**
     * 删除轮播图信息
     *
     * @param carouselId 轮播图主键
     * @return 结果
     */
    @Override
    public int deleteSsCarouselByCarouselId(Long carouselId)
    {
        return carouselMapper.deleteSsCarouselByCarouselId(carouselId);
    }

    /**
     * 根据店铺id查询轮播图
     * @param storeId
     * @return
     */
    @Override
    public List<CarouselVO> selectSsCarouselListByStoreId(Long storeId) {
        CarouselQuery ssCarousel = new CarouselQuery();
        ssCarousel.setStoreId(storeId);
        return carouselMapper.selectSsCarouselList(ssCarousel);
    }
}
