sql mapper 추가

master
mjkhan21 7 months ago
parent c28d281aff
commit 057b00c823

@ -187,15 +187,15 @@ public class WebClient {
}
private <T> HttpResponse<T> handleRequest(boolean async, HttpRequest hreq, HttpResponse.BodyHandler<T> bodyHandler, Consumer<HttpResponse<T>> 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<T> resp = client().send(hreq, bodyHandler);
Log.get(getClass()).debug("Received response");
log().debug("Received response");
return resp;
} else {
CompletableFuture<HttpResponse<T>> 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 <T> body
* @param configurer "POST"
@ -298,9 +302,9 @@ public class WebClient {
private JSON json;
private Consumer<HttpResponse<String>> 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<HttpResponse<InputStream>> downloadHandler = hresp -> {};
private Consumer<Throwable> 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;
}

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cokr.xit.foundation.test.TestMapper">
<select id="select" parameterType="map" resultType="dataobject">${sql}</select>
<insert id="insert" parameterType="map">${sql}</insert>
<update id="update" parameterType="map">${sql}</update>
<delete id="delete" parameterType="map">${sql}</delete>
<update id="commit">COMMIT</update>
</mapper>

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="utility">
<!-- For Maria DB -->
<sql id="paging-prefix"><if test="fetchSize != null and fetchSize &gt; 0">
SELECT QROWS.* FROM (
SELECT ROW_NUMBER() OVER(<include refid="utility.sortBy" />) ROW_NUM
, COUNT(*) OVER() TOT_CNT, QBODY.*
FROM (</if></sql>
<sql id="paging-suffix"><if test="fetchSize != null and fetchSize &gt; 0"> ) QBODY
) QROWS
WHERE ROW_NUM BETWEEN ((#{pageNum} - 1) * #{fetchSize}) + 1 AND (#{pageNum} * #{fetchSize})</if></sql>
<select id="foundRows" resultType="dataobject">/* 전체 결과수 가져오기(utility.foundRows) */
SELECT FOUND_ROWS() TOT_CNT</select>
<sql id="sortBy"><if test="orderBy != null and orderBy != ''">ORDER BY ${orderBy}</if></sql>
<sql id="orderBy"><if test="fetchSize == null or fetchSize &lt; 1"><include refid="utility.sortBy" /></if></sql>
<sql id="now"><if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s')</if>
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMMDDHH24MISS')</if></sql>
<sql id="selectNow">SELECT<include refid="utility.now" />NOW FROM DUAL</sql>
<sql id="today"><if test="_databaseId == 'mariadb'">DATE_FORMAT(CURRENT_DATE, '%Y%m%d')</if>
<if test="_databaseId == 'oracle'">TO_CHAR(CURRENT_DATE, 'YYYYMMDD')</if></sql>
<sql id="selectToday">SELECT<include refid="utility.today" />TODAY FROM DUAL</sql>
<sql id="thisDay">IFNULL(#{thisDay},<include refid="utility.today" />)</sql>
<sql id="selectThisDay">SELECT<include refid="utility.thisDay" />THIS_DAY</sql>
</mapper>
Loading…
Cancel
Save