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

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ss.ad.domain.Ad;
import com.ruoyi.ss.ad.domain.AdQuery;
import com.ruoyi.ss.ad.domain.AdVO;
import com.ruoyi.ss.ad.mapper.AdMapper;
import com.ruoyi.ss.ad.service.IAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 广告Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-11
 */
@Service
public class AdServiceImpl implements IAdService
{
    @Autowired
    private AdMapper adMapper;

    /**
     * 查询广告
     *
     * @param adId 广告主键
     * @return 广告
     */
    @Override
    public AdVO selectAdByAdId(Long adId)
    {
        return adMapper.selectAdByAdId(adId);
    }

    /**
     * 查询广告列表
     *
     * @param ad 广告
     * @return 广告
     */
    @Override
    public List<AdVO> selectAdList(AdQuery ad)
    {
        return adMapper.selectAdList(ad);
    }

    /**
     * 新增广告
     *
     * @param ad 广告
     * @return 结果
     */
    @Override
    public int insertAd(Ad ad)
    {
        ad.setCreateTime(DateUtils.getNowDate());
        return adMapper.insertAd(ad);
    }

    /**
     * 修改广告
     *
     * @param ad 广告
     * @return 结果
     */
    @Override
    public int updateAd(Ad ad)
    {
        ad.setUpdateTime(DateUtils.getNowDate());
        return adMapper.updateAd(ad);
    }

    /**
     * 批量删除广告
     *
     * @param adIds 需要删除的广告主键
     * @return 结果
     */
    @Override
    public int deleteAdByAdIds(Long[] adIds)
    {
        return adMapper.deleteAdByAdIds(adIds);
    }

    /**
     * 删除广告信息
     *
     * @param adId 广告主键
     * @return 结果
     */
    @Override
    public int deleteAdByAdId(Long adId)
    {
        return adMapper.deleteAdByAdId(adId);
    }

    /**
     * 逻辑删除
     *
     * @param ids
     * @return
     */
    @Override
    public int logicDel(List<Long> ids) {
        return adMapper.logicDel(ids);
    }

    @Override
    public AdVO selectOne(AdQuery query) {
        return adMapper.selectOne(query);
    }
}
