package cn.com.ctop.job.kuaishou.handler;

import cn.com.ctop.common.module.entity.CtopOauthToken;
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.jeecg.common.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component
public class KuaishouAiSuzaoVideoJob {
    @Autowired
    private IKuaishouInterfaceService kuaishouInterfaceService;
    @Autowired
    IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
    @Autowired
    private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
    @Autowired
    private ICtopOauthTokenService tokenService;
    @XxlJob("kuaishouAiSuzaoVideoJob")
    public void kuaishouAiSuzaoVideoJob() {
        List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
        if(null==accountTargetTemplates||accountTargetTemplates.isEmpty()){
            return;
        }
        accountTargetTemplates.forEach(targetTemplate -> {
            CtopOauthToken token = tokenService.getTokenByAccountId(targetTemplate.getAccountId());
            int timeStart = -3;
            int timeEnd = 0;
            Long now = System.currentTimeMillis();
            String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
            String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
           // kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime,endTime);
        });
    }
}
