From 09d2d5219cd352e91c89e472cf7236cccab1ad4b Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Sun, 26 Jun 2022 20:57:55 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20sql=20parser=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/sql/parser/QueryGenerator.java | 22 +++++++++++++++++++ src/main/resources/sql/board-mapper.xml | 3 ++- .../com/xit/core/JasyptApplicationTests.java | 6 ----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/xit/core/support/sql/parser/QueryGenerator.java b/src/main/java/com/xit/core/support/sql/parser/QueryGenerator.java index 258e48b..8778311 100644 --- a/src/main/java/com/xit/core/support/sql/parser/QueryGenerator.java +++ b/src/main/java/com/xit/core/support/sql/parser/QueryGenerator.java @@ -14,9 +14,31 @@ import java.util.Iterator; import java.util.Map; /** + *
+ *
+ *   query xml : mybatis 기본 문법 지원
+ *   #{var} --> .setParameter("var", "")
+ *   ? --> .setParameter(1, "")
+ *    and id in (:ids)
+ *   --> .setParameter("ids", Arrays.asList("id1", "id2")
+ *
+ *  
+ *      AND ...
+ *      AND ...
+ *  
+ *
+ *  
+ *      ...
+ *      ...
+ *      
+ *          .....
+ *      
+ *  
+ *
  * lib use
  * implementation 'dom4j:dom4j:1.6.1'
  * implementation 'jaxen:jaxen:1.2.0'
+ * 
*/ public class QueryGenerator { diff --git a/src/main/resources/sql/board-mapper.xml b/src/main/resources/sql/board-mapper.xml index 939a835..cae8c18 100644 --- a/src/main/resources/sql/board-mapper.xml +++ b/src/main/resources/sql/board-mapper.xml @@ -17,10 +17,11 @@ FROM min_civ_board680 MCB LEFT OUTER JOIN min_userinfo MU ON MCB.ci_id = MU.userid - WHERE 1=1 + AND INSTR(MCB.ci_title, #{ciTitle}) > 0 AND MCB.ci_name like #{ciName}||'%' AND INSTR(MCB.ci_contents, #{ciContents}) > 0 + ORDER BY MCB.ci_ref DESC, MCB.ci_step ASC, MCB.ci_code DESC diff --git a/src/test/java/com/xit/core/JasyptApplicationTests.java b/src/test/java/com/xit/core/JasyptApplicationTests.java index 52cf954..62a8b2d 100644 --- a/src/test/java/com/xit/core/JasyptApplicationTests.java +++ b/src/test/java/com/xit/core/JasyptApplicationTests.java @@ -1,6 +1,5 @@ package com.xit.core; -import com.xit.core.util.CommUtil; import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @@ -25,11 +24,6 @@ class JasyptApplicationTests { System.out.println(jasyptEncoding(password)); } - @Test - void xmlSql() { - CommUtil.getXmlSql("/sql/board2-mapper", "select"); - } - private String jasyptEncoding(String value) { String key = "xit_jasypt_key";