package com.zswl.cloud.springBtach.server.core.job;


import com.zswl.cloud.springBtach.server.core.event.JobEvent;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;


@Component
public class StandardOrderJobDemo {

    @Resource
    private StepBuilderFactory stepBuilderFactory;

    @Autowired
    private ApplicationContext applicationContext;


    public Step checkFrom() {
        return stepBuilderFactory.get("createCommon")
                .tasklet(( contribution,  chunkContext)->{



                    return RepeatStatus.FINISHED;
                })
                .build();
    }


    public void publish(String type,Long id,Object other){
        applicationContext.publishEvent(new JobEvent(Map.of(
                "type",type,
                "id",id,
                "other",other
        )));
    }






}
