diff --git a/pom.xml b/pom.xml index 53a875d..14b32bd 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,17 @@ xit-gpki 23.04.01-SNAPSHOT + + + org.springdoc + springdoc-openapi-ui + 1.7.0 + + + org.springdoc + springdoc-openapi-javadoc + 1.7.0 + org.mariadb.jdbc diff --git a/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolMessenger.java b/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolMessenger.java index 4874c9d..3899cf1 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolMessenger.java +++ b/src/main/java/cokr/xit/interfaces/saeol/service/bean/SaeolMessenger.java @@ -11,7 +11,7 @@ public class SaeolMessenger { public void send(SaeolMessage msg) { String interfaceID = msg.interfaceID(), - xml = xmlSupport.stringify(msg.getRequest(), true); + xml = xmlSupport.stringify(msg.getRequest()); HttpResponse hresp = webClient.post(req -> req.uri(Configuration.target().getUrl(interfaceID)) @@ -26,6 +26,6 @@ public class SaeolMessenger { .bodyData(xml) ); - xmlSupport.parse(msg, hresp.body(), true); + xmlSupport.parse(msg, hresp.body()); } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/interfaces/saeol/service/bean/XmlSupport.java b/src/main/java/cokr/xit/interfaces/saeol/service/bean/XmlSupport.java index 2fe7ae6..fb97081 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/service/bean/XmlSupport.java +++ b/src/main/java/cokr/xit/interfaces/saeol/service/bean/XmlSupport.java @@ -7,8 +7,6 @@ import cokr.xit.foundation.AbstractComponent; import cokr.xit.foundation.data.XML; import cokr.xit.interfaces.gpki.GPKI; import cokr.xit.interfaces.saeol.SaeolMessage; -import cokr.xit.interfaces.saeol.SaeolMessage.Header; -import cokr.xit.interfaces.saeol.SaeolMessage.Request; import cokr.xit.interfaces.saeol.SaeolMessage.Response; public class XmlSupport extends AbstractComponent { @@ -49,10 +47,10 @@ public class XmlSupport extends AbstractComponent { return str.substring(start, end); } - public String stringify(SaeolMessage.Request request, boolean encrypt) { + public String stringify(SaeolMessage.Request request) { return ENVELOPE .replace("{header}", stringify(request.header())) - .replace("{message-body}", toString(request, encrypt)); + .replace("{message-body}", toString(request)); } private String stringify(SaeolMessage.Header header) { @@ -61,7 +59,7 @@ public class XmlSupport extends AbstractComponent { .replace("\n", ""); } - private String toString(SaeolMessage.Request request, boolean encrypt) { + private String toString(SaeolMessage.Request request) { String className = request.getClass().getSimpleName(), messageBody = xml.stringify(request, true); @@ -73,15 +71,14 @@ public class XmlSupport extends AbstractComponent { messageBody = "\n \n " + messageBody; messageBody += "\n \n"; - if (encrypt) - messageBody = encrypt(messageBody); + messageBody = encrypt(messageBody); return messageBody; } - public void parse(SaeolMessage msg, String resp, boolean decrypt) { + public void parse(SaeolMessage msg, String resp) { SaeolMessage.Header header = parseHeader(resp); - parseBody(msg, resp, decrypt); + parseBody(msg, resp); msg.getResponse().setHeader(header); } @@ -91,10 +88,8 @@ public class XmlSupport extends AbstractComponent { return xml.parse(head, SaeolMessage.Header.class); } - private void parseBody(SaeolMessage msg, String resp, boolean decrypt) { - String body = textBetween(resp, "", ""); - if (decrypt) - body = decrypt(body); + private void parseBody(SaeolMessage msg, String resp) { + String body = decrypt(textBetween(resp, "", "")); Class klass = msg.responseType(); String className = klass.getSimpleName(); diff --git a/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java b/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java index 8ea380c..6052389 100644 --- a/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java +++ b/src/main/java/cokr/xit/interfaces/saeol/web/SaeolController.java @@ -2,36 +2,35 @@ package cokr.xit.interfaces.saeol.web; import javax.annotation.Resource; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.ModelAndView; import cokr.xit.foundation.web.AbstractController; import cokr.xit.interfaces.saeol.SOHNN00004; import cokr.xit.interfaces.saeol.SOHNN00011; import cokr.xit.interfaces.saeol.service.SaeolService; +import io.swagger.v3.oas.annotations.Operation; -@RestController -@RequestMapping(value = {"/intf/saeol", "/intf/saeol/xml"}, name = "새올 연계") +@RestController("saeolJsonApi") +@RequestMapping(value = "/intf/saeol", name = "새올 JSON 연계", produces = MediaType.APPLICATION_JSON_VALUE) public class SaeolController extends AbstractController { @Resource(name = "saeolService") private SaeolService saeolService; @PostMapping("/sohnn00004") - public ModelAndView getSOHNN00004(@RequestBody SOHNN00004.Request req) { - return new ModelAndView(viewName()) - .addObject(saeolService.getSOHNN00004(req)); - } - - private String viewName() { - return !currentAccess().getAction().contains("/xml") ? "jsonView" : "xmlView"; + @Operation(summary = "민원목록 조회", tags = "SOHNN00004") + public SOHNN00004.Response getSOHNN00004(@RequestBody SOHNN00004.Request req) { + req.setHeader(null); + return saeolService.getSOHNN00004(req); } @PostMapping("/sohnn00011") - public ModelAndView getSOHNN00011(@RequestBody SOHNN00011.Request req) { - return new ModelAndView(viewName()) - .addObject(saeolService.getSOHNN00011(req)); + @Operation(summary = "민원상세 조회", tags = "SOHNN00011") + public SOHNN00011.Response getSOHNN00011(@RequestBody SOHNN00011.Request req) { + req.setHeader(null); + return saeolService.getSOHNN00011(req); } } \ No newline at end of file diff --git a/src/main/java/cokr/xit/interfaces/saeol/web/SaeolXmlController.java b/src/main/java/cokr/xit/interfaces/saeol/web/SaeolXmlController.java new file mode 100644 index 0000000..7d5f3e7 --- /dev/null +++ b/src/main/java/cokr/xit/interfaces/saeol/web/SaeolXmlController.java @@ -0,0 +1,9 @@ +package cokr.xit.interfaces.saeol.web; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController("saeolXmlApi") +@RequestMapping(value = "/intf/saeol/xml", name = "새올 XML 연계", produces = MediaType.APPLICATION_XML_VALUE) +public class SaeolXmlController extends SaeolController {} \ No newline at end of file diff --git a/src/main/resources/intf-conf/gpki.conf b/src/main/resources/intf-conf/gpki.conf index c0c18cb..d989a36 100644 --- a/src/main/resources/intf-conf/gpki.conf +++ b/src/main/resources/intf-conf/gpki.conf @@ -1,6 +1,6 @@ { + "enabled": true, /* 활성화(사용) 여부 */ "license": "C:\\GPKI\\Lic", /* 이용기관 GPKI API 라이센스 디렉토리 */ - "charset": "UTF-8", /* 문자셋 */ "server": { diff --git a/src/test/java/cokr/xit/interfaces/saeol/SaeolMessageTest.java b/src/test/java/cokr/xit/interfaces/saeol/SaeolMessageTest.java index b9c0828..34e0497 100644 --- a/src/test/java/cokr/xit/interfaces/saeol/SaeolMessageTest.java +++ b/src/test/java/cokr/xit/interfaces/saeol/SaeolMessageTest.java @@ -24,7 +24,7 @@ public class SaeolMessageTest { @Test void request() { List.of(new SOHNN00004(), new SOHNN00011()).forEach(msg -> - System.out.println("req msg:\n" + xmlSupport.stringify(msg.getRequest(), false)) + System.out.println("req msg:\n" + xmlSupport.stringify(msg.getRequest())) ); } @@ -32,10 +32,10 @@ public class SaeolMessageTest { void response() { List.of(new SOHNN00004(), new SOHNN00011()).forEach(msg -> { SaeolMessage.Request req = msg.getRequest(); - String body = xmlSupport.stringify(req, false); + String body = xmlSupport.stringify(req); - xmlSupport.parse(msg, body, false); - System.out.println("req msg:\n" + xmlSupport.stringify(req, false)); + xmlSupport.parse(msg, body); + System.out.println("req msg:\n" + xmlSupport.stringify(req)); }); } } \ No newline at end of file