package com.sptg.ad.biz.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sptg.ad.api.entity.AdContentImg;
import com.sptg.ad.biz.mapper.AdContentImgMapper;
import com.sptg.ad.biz.service.AdContentImgServiceInterface;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * title: AdContentImgServiceImpl
 * package: com.sptg.ad.biz.security.impl
 * description: 广告图片-接口实现类
 *
 *               
 *                 
 */
@Service
public class AdContentImgServiceImpl extends ServiceImpl<AdContentImgMapper, AdContentImg> implements AdContentImgServiceInterface{

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public ResultBean<Boolean> deleteImgByAdContentId(Long adContentId){
        Wrapper<AdContentImg> wrapper = new EntityWrapper<>();
        wrapper.eq("l_ad_id",adContentId);
        return new ResultBean<>(ResultEnum.SUCCESS,this.delete(wrapper));

    }

    @Override
    @Transactional(rollbackFor = Throwable.class)
    public ResultBean<Boolean> addAdContentImg(List<AdContentImg> adContentImgs) {
        return new ResultBean<>(ResultEnum.SUCCESS,this.insertBatch(adContentImgs));
    }

    @Override
    public List<AdContentImg> getAdContentImgs(Long adContentId) {
        Wrapper<AdContentImg> wrapper = new EntityWrapper<>();
        wrapper.eq("l_ad_id",adContentId);
        return this.selectList(wrapper);
    }
}
