From 057b00c823fa7ad97d923e0542ec551756f4ba31 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 18 Apr 2024 14:16:22 +0900 Subject: [PATCH] =?UTF-8?q?sql=20mapper=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/foundation/web/WebClient.java | 18 +++++---- src/main/resources/sql/mapper/test-mapper.xml | 15 ++++++++ src/main/resources/sql/mapper/utility.xml | 37 +++++++++++++++++++ 3 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/sql/mapper/test-mapper.xml create mode 100644 src/main/resources/sql/mapper/utility.xml diff --git a/src/main/java/cokr/xit/foundation/web/WebClient.java b/src/main/java/cokr/xit/foundation/web/WebClient.java index 82d71d2..53ea8b2 100644 --- a/src/main/java/cokr/xit/foundation/web/WebClient.java +++ b/src/main/java/cokr/xit/foundation/web/WebClient.java @@ -187,15 +187,15 @@ public class WebClient { } private HttpResponse handleRequest(boolean async, HttpRequest hreq, HttpResponse.BodyHandler bodyHandler, Consumer> respHandler) throws Exception { - Log.get(getClass()).debug("Sending request:\n{} {}", hreq.method(), hreq.uri()); + log().debug("Sending request:\n{} {}", hreq.method(), hreq.uri()); if (!async) { HttpResponse resp = client().send(hreq, bodyHandler); - Log.get(getClass()).debug("Received response"); + log().debug("Received response"); return resp; } else { CompletableFuture> future = client().sendAsync(hreq, bodyHandler); future.thenApply(resp -> { - Log.get(getClass()).debug("Received response"); + log().debug("Received response"); respHandler.accept(resp); return resp; }); @@ -203,6 +203,10 @@ public class WebClient { } } + private static Log log() { + return Log.get(WebClient.class); + } + /**"POST" 방식의 요청을 전송한다. * @param 요청의 body 핸들러 유형 * @param configurer "POST" 방식 요청의 설정자 @@ -298,9 +302,9 @@ public class WebClient { private JSON json; private Consumer> textHandler = hresp -> { HttpHeaders headers = hresp.headers(); - headers.map().forEach((k, v) -> System.out.println(k + " = " + v)); - System.out.println("status: " + hresp.statusCode()); - System.out.println(hresp.body()); + headers.map().forEach((k, v) -> log().debug("{} = {}", k, v)); + log().debug("status: {}", hresp.statusCode()); + log().debug("{}", hresp.body()); }; private Consumer> downloadHandler = hresp -> {}; private Consumer errorHandler = t -> { @@ -500,7 +504,7 @@ public class WebClient { else if (!Assert.isEmpty(keyValues)) str = json().stringify(keyValues); - Log.get(getClass()).debug("json request:\n{}", str); + log().debug("json request:\n{}", str); return str; } diff --git a/src/main/resources/sql/mapper/test-mapper.xml b/src/main/resources/sql/mapper/test-mapper.xml new file mode 100644 index 0000000..8a897ec --- /dev/null +++ b/src/main/resources/sql/mapper/test-mapper.xml @@ -0,0 +1,15 @@ + + + + + + +${sql} + +${sql} + +${sql} + +COMMIT + + \ No newline at end of file diff --git a/src/main/resources/sql/mapper/utility.xml b/src/main/resources/sql/mapper/utility.xml new file mode 100644 index 0000000..ab14fc8 --- /dev/null +++ b/src/main/resources/sql/mapper/utility.xml @@ -0,0 +1,37 @@ + + + + + + +SELECT QROWS.* FROM ( + SELECT ROW_NUMBER() OVER() ROW_NUM + , COUNT(*) OVER() TOT_CNT, QBODY.* + FROM ( + + ) QBODY + ) QROWS +WHERE ROW_NUM BETWEEN ((#{pageNum} - 1) * #{fetchSize}) + 1 AND (#{pageNum} * #{fetchSize}) + + + +ORDER BY ${orderBy} + + + +DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s') +TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISS') + +SELECTNOW FROM DUAL + +DATE_FORMAT(CURRENT_DATE, '%Y%m%d') +TO_CHAR(CURRENT_DATE, 'YYYYMMDD') + +SELECTTODAY FROM DUAL + +IFNULL(#{thisDay},) + +SELECTTHIS_DAY + + \ No newline at end of file