diff --git a/build.gradle b/build.gradle index c213ace..44edc06 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ plugins { // buildscript group = 'com.xit' version = '0.0.1-SNAPSHOT' -description = 'xit-opst-bo' +description = 'xit-opst-be' sourceCompatibility = '11' // WAS로 배포하는 경우 : bootWar.enabled = false 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 8778311..9cc4f26 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 @@ -7,8 +7,13 @@ import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; +import org.springframework.util.ResourceUtils; import java.io.File; +import java.io.FileNotFoundException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -16,20 +21,36 @@ import java.util.Map; /** *
* + * /resources/sqlMapping.xml + * + *+ * + * + * + * sql map file + * + *+ * + * + * + * * query xml : mybatis 기본 문법 지원 * #{var} --> .setParameter("var", "") * ? --> .setParameter(1, "") - *+ * ... + * + *and id in (:ids) + *and id in (:ids) * --> .setParameter("ids", Arrays.asList("id1", "id2") * *- * * *AND ... - *AND ... + *AND ... + *AND ... *- * ... - *... + *... + *... ** ..... * @@ -44,8 +65,6 @@ public class QueryGenerator { private static volatile MapclassNameRootElementMap; - private static final String ROOT_PATH = System.getProperty("user.dir"); - private QueryGenerator() { } @@ -62,7 +81,13 @@ public class QueryGenerator { synchronized (QueryGenerator.class) { if (classNameRootElementMap == null) { classNameRootElementMap = new HashMap<>(); - File confFile = new File(ROOT_PATH + "/src/main/resources/sqlMapping.xml"); + + File confFile = null; + try { + confFile = ResourceUtils.getFile("classpath:sqlMapping.xml"); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } SAXReader saxReader = new SAXReader(); Document document = null; try { @@ -70,14 +95,20 @@ public class QueryGenerator { } catch (DocumentException e) { throw new RuntimeException(e); } + + Element rootElement = document.getRootElement(); Iterator iterator = rootElement.elementIterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); String tagName = element.getName(); - String path = ROOT_PATH + element.attributeValue("path"); + String path = element.attributeValue("path"); if (tagName.equals("file-location") || tagName.equals("directory-location")) { - loadMappingFile(new File(path)); + try { + loadMappingFile(ResourceUtils.getFile(path)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } } else { throw new RuntimeException("Invalid tag name, could only be 'file-location' or 'directory-location'"); } @@ -122,8 +153,8 @@ public class QueryGenerator { Iterator iterator = rootElement.elementIterator(); while (iterator.hasNext()) { Element element = (Element) iterator.next(); - if (element.getName().equals("named-native-query")) { - String name = element.attributeValue("name"); + if (element.getName().equals("native-query")) { + String name = element.attributeValue("id"); if (name != null && name.trim().equals(queryName.trim())) { return element; } diff --git a/src/main/java/com/xit/core/support/sql/parser/sqlNodes/CaseSqlNode.java b/src/main/java/com/xit/core/support/sql/parser/sqlNodes/CaseSqlNode.java index 3a1b013..916cb27 100644 --- a/src/main/java/com/xit/core/support/sql/parser/sqlNodes/CaseSqlNode.java +++ b/src/main/java/com/xit/core/support/sql/parser/sqlNodes/CaseSqlNode.java @@ -13,6 +13,6 @@ public class CaseSqlNode extends AbstractSqlNode { @Override public boolean display() { - return ExpressionUtils.isTrueExpression(this.element.attributeValue("text"), parameterMap); + return ExpressionUtils.isTrueExpression(this.element.attributeValue("test"), parameterMap); } } diff --git a/src/main/java/com/xit/core/support/sql/parser/sqlNodes/IfSqlNode.java b/src/main/java/com/xit/core/support/sql/parser/sqlNodes/IfSqlNode.java index 504d99b..5de6a52 100644 --- a/src/main/java/com/xit/core/support/sql/parser/sqlNodes/IfSqlNode.java +++ b/src/main/java/com/xit/core/support/sql/parser/sqlNodes/IfSqlNode.java @@ -12,10 +12,10 @@ public class IfSqlNode extends AbstractSqlNode { @Override public boolean display() { - String expression = element.attributeValue("text"); + String expression = element.attributeValue("test"); if (expression == null || expression.trim().isEmpty()) { return false; } - return ExpressionUtils.isTrueExpression(this.element.attributeValue("text"), parameterMap); + return ExpressionUtils.isTrueExpression(this.element.attributeValue("test"), parameterMap); } } diff --git a/src/main/java/com/xit/core/support/sql/parser/sqlNodes/SimpleSqlNodeFactory.java b/src/main/java/com/xit/core/support/sql/parser/sqlNodes/SimpleSqlNodeFactory.java index 065dd2f..f29d906 100644 --- a/src/main/java/com/xit/core/support/sql/parser/sqlNodes/SimpleSqlNodeFactory.java +++ b/src/main/java/com/xit/core/support/sql/parser/sqlNodes/SimpleSqlNodeFactory.java @@ -26,7 +26,7 @@ public class SimpleSqlNodeFactory { case "otherwise": result = new OtherwiseSqlNode(element, parameterMap); break; - case "named-native-query": + case "native-query": result = new BasicSqlNode(element, parameterMap); break; default: diff --git a/src/main/java/com/xit/core/util/DBUtils.java b/src/main/java/com/xit/core/util/DBUtils.java index 0775d53..a2d6ae6 100644 --- a/src/main/java/com/xit/core/util/DBUtils.java +++ b/src/main/java/com/xit/core/util/DBUtils.java @@ -131,11 +131,14 @@ public class DBUtils { field.setAccessible(true); String name = field.getName(); - boolean isSameType = entry.getValue().getClass().equals(field.getType()); + //boolean isSameType = entry.getValue().getClass().equals(field.getType()); boolean isSameName = entry.getKey().equals(name); - if (isSameType && isSameName) { - field.set(instance, map.get(name)); + //if (isSameType && isSameName) { + if (isSameName) { + if(field.getType() == Integer.class) field.set(instance, Integer.parseInt(String.valueOf(map.get(name)))); + else if(field.getType() == Long.class) field.set(instance, Long.parseLong(String.valueOf(map.get(name)))); + else field.set(instance, map.get(name)); break; } } @@ -171,4 +174,6 @@ public class DBUtils { } return convertList; } + + //private static void convertType() } diff --git a/src/main/java/com/xit/core/util/mpower/MpowerUtils.java b/src/main/java/com/xit/core/util/mpower/MpowerUtils.java index b6214be..39047bf 100644 --- a/src/main/java/com/xit/core/util/mpower/MpowerUtils.java +++ b/src/main/java/com/xit/core/util/mpower/MpowerUtils.java @@ -462,16 +462,13 @@ public class MpowerUtils { for (Field fd : clsFields) { fd.setAccessible(true); - boolean isSameType = feilds.get(j).getClass().equals(fd.getType()); - boolean isSameName = feilds.get(j).equals(fd.getName()); - - if (isSameType && isSameName) { - fd.set(instance, mpower.getString("list1", i, j)); + if (feilds.get(j).equals(fd.getName())) { + if(fd.getType() == Integer.class) fd.set(instance, Integer.parseInt(mpower.getString("list1", i, j))); + else if(fd.getType() == Long.class) fd.set(instance, Long.parseLong(mpower.getString("list1", i, j))); + else fd.set(instance, mpower.getString("list1", i, j)); break; } } - //m.put(feilds.get(j), mpower.getString("list1", i, j)); - } } list.add(instance); diff --git a/src/main/resources/sql/board-mapper.xml b/src/main/resources/sql/board-mapper.xml index cae8c18..313b891 100644 --- a/src/main/resources/sql/board-mapper.xml +++ b/src/main/resources/sql/board-mapper.xml @@ -1,6 +1,6 @@ - + + diff --git a/src/main/resources/sql/refreshToken-mapper.xml b/src/main/resources/sql/refreshToken-mapper.xml index 7e4770e..5ba9070 100644 --- a/src/main/resources/sql/refreshToken-mapper.xml +++ b/src/main/resources/sql/refreshToken-mapper.xml @@ -1,14 +1,14 @@/* board-mapper|selectBoardList|julim */ SELECT MCB.ci_code, MU.name, @@ -18,14 +18,20 @@ LEFT OUTER JOIN min_userinfo MU ON MCB.ci_id = MU.userid - ORDER BY MCB.ci_ref DESC, MCB.ci_step ASC, MCB.ci_code DESC -AND INSTR(MCB.ci_title, #{ciTitle}) > 0 -AND MCB.ci_name like #{ciName}||'%' -AND INSTR(MCB.ci_contents, #{ciContents}) > 0 ++ AND INSTR(MCB.ci_title, #{ciTitle}) > 0 + ++ AND MCB.ci_name like #{ciName}||'%' + ++ AND INSTR(MCB.ci_contents, #{ciContents}) > 0 + - \ No newline at end of file diff --git a/src/main/resources/sqlMapping.xml b/src/main/resources/sqlMapping.xml index bd10827..ac7c437 100644 --- a/src/main/resources/sqlMapping.xml +++ b/src/main/resources/sqlMapping.xml @@ -1,7 +1,7 @@+ + -/* refreshToken-mapper|selectRefreshToken|julim */ SELECT key, value FROM refresh_token WHERE key = #{key} - + + -/* refreshToken-mapper|insertRefreshToken|julim */ INSERT INTO refresh_token ( @@ -18,12 +18,12 @@ #{key}, #{value} ) - + +/* refreshToken-mapper|updateRefreshToken|julim */ UPDATE refresh_token SET value = #{value} WHERE key = #{key} - - + - \ No newline at end of file+