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

import cn.com.ctop.common.module.utils.Check;
import cn.com.ctop.common.module.utils.HttpUtils2;
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class KuaishouCreateUnitJob {


    @Autowired
    private IKuaiShouGroupTemplateService groupTemplateService;

    @XxlJob("kuaihouCreateUnit")
    public void execute() {

        List<Long> idList = groupTemplateService.getIdList();
        if (Check.isNull(idList)) {
            XxlJobHelper.log("批量2.0暂时没有未创建的组");
            return;
        }
        String url = "http://api.tjyourong.com.cn/jeecg-boot/batch/kuaiShouGroupTemplate/createUnit";
        for (int i = 0; i < idList.size(); i++) {
            Long id = idList.get(i);
            Map<String, Object> requestMap = new HashMap<>();
            requestMap.put("id", id);
            HttpUtils2.httpGet(url, requestMap, null);
        }


    }
}
