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

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

/**
 * 策略模板表
 * @author jeecg-boot
 * @date   2020-12-15
 * @version V1.0
 */
@Service
public class AiKuaishouStrategyTemplateServiceImpl extends ServiceImpl<AiKuaishouStrategyTemplateMapper, AiKuaishouStrategyTemplate> implements IAiKuaishouStrategyTemplateService {

    @Override
    public AiKuaishouStrategyTemplate getOneByParams(String templateType, Integer status) {
        QueryWrapper<AiKuaishouStrategyTemplate> queryWrapper= new QueryWrapper<>();
        if(null!=templateType&&!"".equals(templateType.trim())){
            queryWrapper.eq("template_type",templateType);
        }
        if(null!=status){
            queryWrapper.eq("status",status);
        }
        queryWrapper.orderByDesc("create_time");
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
