package cn.com.ctop.kuaishou.modules.ai.service.impl;

import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAccountTargetTemplateMapper;
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 账户自动投放定向模板
 * @author jeecg-boot
 * @date   2021-01-07
 * @version V1.0
 */
@Service
public class AiKuaishouAccountTargetTemplateServiceImpl extends ServiceImpl<AiKuaishouAccountTargetTemplateMapper, AiKuaishouAccountTargetTemplate> implements IAiKuaishouAccountTargetTemplateService {

    @Override
    public List<AiKuaishouAccountTargetTemplate> getAllEffectTemplate() {
        QueryWrapper<AiKuaishouAccountTargetTemplate> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",1);
        return this.list(queryWrapper);
    }

    @Override
    public AiKuaishouAccountTargetTemplate getByAccountId(Long accountId) {
        QueryWrapper<AiKuaishouAccountTargetTemplate> queryWrapper = new QueryWrapper<>();
        if(null!=accountId&&accountId!=0){
            queryWrapper.eq("account_id",accountId);
        }
        queryWrapper.eq("status",1);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
