feat: mpower

dev
minuk926 2 years ago
parent 67ab00d00c
commit bb1c7f3447

@ -168,6 +168,10 @@ dependencies {
//-----------------------------------------------------------------------------------//
runtimeOnly 'com.h2database:h2:1.4.199' // 2.0.202
implementation 'org.postgresql:postgresql:42.3.1'
// https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//

@ -13,14 +13,21 @@ import org.springframework.mobile.device.Device;
import org.springframework.mobile.device.DeviceUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
@ -701,6 +708,88 @@ public class CommUtil {
}
return sql;
}
/**
*
* @param sqlSession SqlSessionTemplate
* @param id SQL id
* @param param Object
*/
public static String getXmlSql(SqlSession sqlSession, String id, Object param) {
BoundSql boundSql = sqlSession.getConfiguration().getMappedStatement(id).getBoundSql(param);
List<ParameterMapping> parameterMappings = new ArrayList<>(boundSql.getParameterMappings());
Map<String, Object> parameters = new HashMap<>();
if (param instanceof Map) {
parameters.putAll((Map) param);
} else {
for (ParameterMapping parameterMapping : parameterMappings) {
try {
String field = parameterMapping.getProperty();
//try {
String methodNm = "get"+field.substring(0,1).toUpperCase()+field.substring(1);
Method method = param.getClass().getMethod(methodNm);
parameters.put(field, method.invoke(param));
//parameters.put(field, param.getClass().getMethod("get"+field.substring(0,1).toUpperCase()+field.substring(1)).invoke(param));
} catch (NoSuchMethodException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
String sql = boundSql.getSql();
for (ParameterMapping par : parameterMappings) {
Object parameter = parameters.get(par.getProperty());
if (parameter == null)
sql = sql.replaceFirst("\\?", "NULL");
else
sql = sql.replaceFirst("\\?", "'" + parameter.toString() + "'");
}
return sql;
}
public static String getXmlSql(String xmlFileName, String nodeName) {
String sql = null;
try {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream is = classloader.getResourceAsStream("test.csv");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
//builder.p
Document document = builder.parse(is);
//Document document = builder.parse(new File(xmlFileName));
//List<Employee> employees = new ArrayList<>();
NodeList nodeList = document.getDocumentElement().getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) node;
return elem.getElementsByTagName(nodeName)
.item(0).getChildNodes().item(0).getNodeValue();
}
}
return sql;
} catch (ParserConfigurationException | IOException | SAXException e) {
throw new RuntimeException(e);
}
}
}

@ -2,7 +2,17 @@ package com.xit.core.util.mpower;
import com.plf.client.Client;
import lombok.extern.slf4j.Slf4j;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
@ -450,4 +460,5 @@ public class MpowerUtils {
}

@ -21,12 +21,12 @@ spring:
# ==================================================================================================================
datasource:
driver-class-name: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@211.119.124.118:1521:bustms
# username: traffic
# password: xhdgkq0
url: ENC(Du4NMmmioRvKPEusb8MiTTvNaXVoTItupOvD6qDhkeJv8vJKgdQuYR1pfx6EiejdZxw42ihrilk=)
username: ENC(MtR2JPkVe/qAf4+4ov5Oaw==)
password: ENC(6DJ2lcMsftlVjv1Ddc4d2w==)
url: jdbc:oracle:thin:@211.119.124.118:1521:bustms
username: traffic
password: xhdgkq0
# url: ENC(Du4NMmmioRvKPEusb8MiTTvNaXVoTItupOvD6qDhkeJv8vJKgdQuYR1pfx6EiejdZxw42ihrilk=)
# username: ENC(MtR2JPkVe/qAf4+4ov5Oaw==)
# password: ENC(6DJ2lcMsftlVjv1Ddc4d2w==)
hikari:
driver-class-name: ${spring.datasource.driver-class-name}
jdbc-url: ${spring.datasource.url}

@ -17,7 +17,7 @@ api:
file:
cmm:
upload:
root: /data/file/upload
root: c:/data/file/upload
# root: /Users/minuk/data/file/upload
# 공지사항
path: /kangnamSIM/simUpFile

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<select id="selectBoardList" parameterType="com.xit.biz.ctgy.dto.BoardDto" resultType="camelCaseLinkedMap">
/* board-mapper|selectBoardList|julim */
SELECT MCB.ci_code,
MU.name,
MCB.ci_contentno,
MCB.ci_title,
MCB.ci_contents,
MCB.ci_nalja,
MCB.ci_step,
MCB.ci_revel,
MCB.ci_ref,
MCB.ci_hit,
MCB.ci_pass,
MCB.ci_id
FROM min_civ_board680 MCB
LEFT OUTER JOIN min_userinfo MU
ON MCB.ci_id = MU.userid
<where>
<if test="ciTitle != null and ciTitle != ''">
AND INSTR(MCB.ci_title, #{ciTitle}) > 0
</if>
<if test='ciName != null and ciName != ""'>
AND MCB.ci_name like #{ciName}||'%'
</if>
</where>
ORDER BY MCB.ci_ref DESC,
MCB.ci_step ASC,
MCB.ci_code DESC
</select>
</mapper>
Loading…
Cancel
Save