fun.bigtable.kraken.pre.ContextCheckHelper Maven / Gradle / Ivy
package fun.bigtable.kraken.pre;
import fun.bigtable.kraken.pre.dto.CheckContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
/**
* 业务检查器
*/
@Component
public class ContextCheckHelper {
@Autowired
List> checkers;
private static final Logger log = LoggerFactory.getLogger(ContextCheckHelper.class);
public void createContextAndCheck(IPreChecker.PreCheckerType checkerType, D iCheckBizData, C generate) {
List> collect = checkers.stream()
.filter(check -> check.type().equals(checkerType))
.map(check -> (IPreChecker) check)
.collect(Collectors.toList());
if (collect.isEmpty()) {
log.warn("未找到关联的检查器 {} 业务ID {}", checkerType.getName(), iCheckBizData.getId());
return;
}
for (IPreChecker preChecker : collect) {
preChecker.setContext(generate, iCheckBizData);
}
for (IPreChecker preChecker : collect) {
preChecker.check(generate, iCheckBizData);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy