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.common.module.utils.CtopAdConstant;
import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
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 {
        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_PANGOLIN_PY,1);
        if(list!=null&&!list.isEmpty()){
            for (BindAccountLogin login:list) {
                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
                    pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
                }
            }
        }
    }
}
