LntrisBean 추가
parent
450aa39169
commit
0c322e24af
@ -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 <Q extends SourceMessage.Request, R extends TargetMessage.Response, T extends InterfaceInfo<Q, R>> void pagingRequest(
|
||||
T info,
|
||||
Function<T, List<?>> getDetails,
|
||||
BiConsumer<T, Integer> insertResps,
|
||||
BiConsumer<Object, Object> 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue