diff --git a/src/main/java/cokr/xit/interfaces/lntris/LntrisBean.java b/src/main/java/cokr/xit/interfaces/lntris/LntrisBean.java new file mode 100644 index 0000000..962bf22 --- /dev/null +++ b/src/main/java/cokr/xit/interfaces/lntris/LntrisBean.java @@ -0,0 +1,31 @@ +package cokr.xit.interfaces.lntris; + +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Function; + +import cokr.xit.foundation.component.ScheduledBean; + +public abstract class LntrisBean extends ScheduledBean { + protected Requestor requestor = new Requestor(); + + protected > void pagingRequest( + T info, + Function> getDetails, + BiConsumer insertResps, + BiConsumer updateReq, + int start + ) { + requestor.request(info); + List details = getDetails.apply(info); + int found = details.size(); + boolean empty = found < 1; + if (!empty) + InterfaceConfig.databaseActive(() -> insertResps.accept(info, start)); + if (found < 100) return; // 페이징 사이즈 = 100 + + updateReq.accept(info.getRequest(), details.get(found - 1)); + + pagingRequest(info, getDetails, insertResps, updateReq, start + found); + } +} \ No newline at end of file