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

import com.github.microservice.auth.client.content.ResultContent;
import com.zswl.cloud.springBtach.server.core.job.standard.StandarOrderJob;
import lombok.Data;
import lombok.experimental.Delegate;
import lombok.extern.log4j.Log4j2;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Log4j2
@Configuration
public class PcodeOrderJob {

    @Autowired
    @Delegate
    StandarOrderJob standarOrderJob;

    public Step pcodPlatformOrder() {
        return getStepBuilderFactory().get("pcodPlatformOrder").tasklet((it, ii) -> {
            ResultContent creat = getOrderService2().creat(getParameter().get());

            getResultContent().set(creat);
            return RepeatStatus.FINISHED;
        }).build();

    }


    @Bean
    public Job pcodCreatOrder() {
        return getJobBuilderFactory()
                .get("pcodCreatOrder")
                .start(pcodPlatformOrder())
                .incrementer(new RunIdIncrementer())
                .build();
    }

}
