package beilv.carousel.service.impl;

import java.util.Collections;
import java.util.List;

import beilv.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import beilv.carousel.mapper.BeilvCarouselMapper;
import beilv.carousel.domain.BeilvCarousel;
import beilv.carousel.service.IBeilvCarouselService;
import beilv.common.core.text.Convert;

/**
 * 轮播Service业务层处理
 *
 * @author ruoyi
 * @date 2025-11-18
 */
@Service
public class BeilvCarouselServiceImpl implements IBeilvCarouselService {
    @Autowired
    private BeilvCarouselMapper beilvCarouselMapper;

    /**
     * 查询轮播
     *
     * @param id 轮播主键
     * @return 轮播
     */
    @Override
    public BeilvCarousel selectBeilvCarouselById(Long id) {
        return beilvCarouselMapper.selectBeilvCarouselById(id);
    }

    /**
     * 查询轮播列表
     *
     * @param beilvCarousel 轮播
     * @return 轮播
     */
    @Override
    public List<BeilvCarousel> selectBeilvCarouselList(BeilvCarousel beilvCarousel) {
        return beilvCarouselMapper.selectBeilvCarouselList(beilvCarousel);
    }

    /**
     * 新增轮播
     *
     * @param beilvCarousel 轮播
     * @return 结果
     */
    @Override
    public int insertBeilvCarousel(BeilvCarousel beilvCarousel) {
        beilvCarousel.setCreateTime(DateUtils.getNowDate());
        return beilvCarouselMapper.insertBeilvCarousel(beilvCarousel);
    }

    /**
     * 修改轮播
     *
     * @param beilvCarousel 轮播
     * @return 结果
     */
    @Override
    public int updateBeilvCarousel(BeilvCarousel beilvCarousel) {
        return beilvCarouselMapper.updateBeilvCarousel(beilvCarousel);
    }

    /**
     * 批量删除轮播
     *
     * @param ids 需要删除的轮播主键
     * @return 结果
     */
    @Override
    public int deleteBeilvCarouselByIds(String ids) {
        return beilvCarouselMapper.deleteBeilvCarouselByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除轮播信息
     *
     * @param id 轮播主键
     * @return 结果
     */
    @Override
    public int deleteBeilvCarouselById(Long id) {
        return beilvCarouselMapper.deleteBeilvCarouselById(id);
    }

    @Override
    public List<BeilvCarousel> selectAppCarouselList() {
        return beilvCarouselMapper.selectAppCarouselList();
    }
}
