From 0c322e24afb3b209eca43c8bf00c165233b6d181 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 29 Feb 2024 14:19:02 +0900 Subject: [PATCH] =?UTF-8?q?LntrisBean=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/interfaces/lntris/LntrisBean.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/main/java/cokr/xit/interfaces/lntris/LntrisBean.java 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