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.PangolinLoginService;
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 PangolinLoginJob implements Job {
    @Autowired
    private IBindAccountLoginService bindAccountLoginService;
    @Autowired
    private PangolinLoginService pangolinLoginService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("login_type","pangolin");
        queryWrapper.eq("status",1);
        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
        if(list!=null&&!list.isEmpty()){
            for (BindAccountLogin login:list) {
                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
                    pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
                }
            }
        }
    }
}
