package org.jeecg.modules.bytedance.advertise.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdDplinkInfo;
import org.jeecg.modules.bytedance.advertise.mapper.AiBytedanceAdDplinkInfoMapper;
import org.jeecg.modules.bytedance.advertise.service.IAiBytedanceAdDplinkInfoService;
import org.springframework.stereotype.Service;

/**
 * 头条计划dplink标识创建记录
 * @author jeecg-boot
 * 2021-04-26
 * @version V1.0
 */
@Service
public class AiBytedanceAdDplinkInfoServiceImpl extends ServiceImpl<AiBytedanceAdDplinkInfoMapper, AiBytedanceAdDplinkInfo> implements IAiBytedanceAdDplinkInfoService {

    @Override
    public AiBytedanceAdDplinkInfo getlatestDpLinkInfo(Long strategyId, Long accountId, Integer status) {
        QueryWrapper<AiBytedanceAdDplinkInfo> queryWrapper = new QueryWrapper<>();
        if(null!=strategyId&&strategyId!=0){
            queryWrapper.eq("strategy_id",strategyId);
        }
        if(null!=accountId&&accountId!=0){
            queryWrapper.eq("account_id",accountId);
        }
        if(null!=status){
            queryWrapper.eq("status",status);
        }
        queryWrapper.orderByDesc("id").last("limit 1");
        return this.getOne(queryWrapper);
    }
}
