package com.bonus.canteen.core.basic.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.basic.mapper.BasicCarouselImageMapper;
import com.bonus.canteen.core.basic.domain.BasicCarouselImage;
import com.bonus.canteen.core.basic.service.IBasicCarouselImageService;

/**
 * 轮播图设置Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class BasicCarouselImageServiceImpl implements IBasicCarouselImageService {
    @Autowired
    private BasicCarouselImageMapper basicCarouselImageMapper;

    /**
     * 查询轮播图设置
     * 
     * @param id 轮播图设置主键
     * @return 轮播图设置
     */
    @Override
    public BasicCarouselImage selectBasicCarouselImageById(Long id) {
        return basicCarouselImageMapper.selectBasicCarouselImageById(id);
    }

    /**
     * 查询轮播图设置列表
     * 
     * @param basicCarouselImage 轮播图设置
     * @return 轮播图设置
     */
    @Override
    public List<BasicCarouselImage> selectBasicCarouselImageList(BasicCarouselImage basicCarouselImage) {
        return basicCarouselImageMapper.selectBasicCarouselImageList(basicCarouselImage);
    }

    /**
     * 新增轮播图设置
     * 
     * @param basicCarouselImage 轮播图设置
     * @return 结果
     */
    @Override
    public int insertBasicCarouselImage(BasicCarouselImage basicCarouselImage) {
        basicCarouselImage.setCreateTime(DateUtils.getNowDate());
        basicCarouselImage.setCreateBy(SecurityUtils.getUsername());
        try {
            return basicCarouselImageMapper.insertBasicCarouselImage(basicCarouselImage);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改轮播图设置
     * 
     * @param basicCarouselImage 轮播图设置
     * @return 结果
     */
    @Override
    public int updateBasicCarouselImage(BasicCarouselImage basicCarouselImage) {
        basicCarouselImage.setUpdateTime(DateUtils.getNowDate());
        basicCarouselImage.setUpdateBy(SecurityUtils.getUsername());
        try {
            return basicCarouselImageMapper.updateBasicCarouselImage(basicCarouselImage);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除轮播图设置
     * 
     * @param ids 需要删除的轮播图设置主键
     * @return 结果
     */
    @Override
    public int deleteBasicCarouselImageByIds(Long[] ids) {
        return basicCarouselImageMapper.deleteBasicCarouselImageByIds(ids);
    }

    /**
     * 删除轮播图设置信息
     * 
     * @param id 轮播图设置主键
     * @return 结果
     */
    @Override
    public int deleteBasicCarouselImageById(Long id) {
        return basicCarouselImageMapper.deleteBasicCarouselImageById(id);
    }
}
