package org.jeecg.modules.ctop.job;

import cn.com.ctop.common.module.entity.BindAccountLogin;
import cn.com.ctop.common.module.service.IBindAccountLoginService;
import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class PangolinDataJob implements Job {
    @Autowired
    private IBindAccountLoginService bindAccountLoginService;
    @Autowired
    private PangolinCrawlerService pangolinCrawlerService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("login_type", "pangolin");
        queryWrapper.eq("status", 1);
        queryWrapper.isNotNull("cookie");
        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
        if (list != null && !list.isEmpty()) {
            for (BindAccountLogin bindAccountLogin : list) {
                pangolinCrawlerService.getNowData(bindAccountLogin);
            }
        }
    }
}
