package cn.ibizlab.core.util.job;

import com.baomidou.jobs.api.JobsResponse;
import com.baomidou.jobs.exception.JobsException;
import com.baomidou.jobs.handler.IJobsHandler;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component("RuleExecJobHandler")
public class RuleExecJobHandler implements IJobsHandler {

    @Autowired
    @Lazy
    protected cn.ibizlab.core.rule.service.IRuleEngineService ruleengineService;

    @Override
    public JobsResponse execute(String tenantId, String param) throws JobsException {
        cn.ibizlab.core.rule.domain.RuleEngine entity=new cn.ibizlab.core.rule.domain.RuleEngine();
        entity.set("tenantid",tenantId);
        entity.set("param",param);
        ruleengineService.run(entity);
        log.info("执行 DemoJobHandler tenantId=" + tenantId + ",param=" + param);
        return JobsResponse.ok();
    }
}
