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

import com.github.microservice.auth.client.content.ResultContent;
import com.github.microservice.auth.client.content.ResultState;
import com.zswl.cloud.springBtach.server.core.job.standard.StandarVerificationJob;
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 PcodeVerificationJob {

    @Autowired
    @Delegate
    StandarVerificationJob standarVerificationJob;

    public Step pcodeVerificationStep() {


        return getStepBuilderFactory().get("pcodeVerificationStep").tasklet((it, ii) -> {
            getResultContent().set(ResultContent.build(ResultState.Fail, "二维码商品不需要核销"));
            return RepeatStatus.FINISHED;
        }).build();
    }

    @Bean
    public Job pcodVerificationJob() {
        return getJobBuilderFactory().get("pcodeVerificationJob")
                .start(pcodeVerificationStep())
                .incrementer(new RunIdIncrementer())
                .build();
    }
}
