From dbfc2ad8256b5b54c81091c25a5c792293c1125e Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Tue, 28 Nov 2023 15:06:31 +0900 Subject: [PATCH] =?UTF-8?q?xml=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interfaces/lvis/web/ApiController.java | 5 +-- .../interfaces/lvis/web/ApiXmlController.java | 14 ++++++++ .../lvis/service/BasicInfoExtTest.java | 34 +++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/main/java/cokr/xit/interfaces/lvis/web/ApiXmlController.java diff --git a/src/main/java/cokr/xit/interfaces/lvis/web/ApiController.java b/src/main/java/cokr/xit/interfaces/lvis/web/ApiController.java index 6e5d28e..a2fe7c8 100644 --- a/src/main/java/cokr/xit/interfaces/lvis/web/ApiController.java +++ b/src/main/java/cokr/xit/interfaces/lvis/web/ApiController.java @@ -6,6 +6,7 @@ import java.util.Map; import javax.annotation.Resource; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -36,8 +37,8 @@ import cokr.xit.interfaces.lvis.service.seizure.SeizureByEttffResponse; *
http(s)://{호스트}/{웹컨텍스트}/intf/lvis/{서비스별 경로}
* @author mjkhan */ -@RestController("lvisApi") -@RequestMapping(value = "/intf/lvis", name = "자동차 관리정보 api") +@RestController("lvisJsonApi") +@RequestMapping(value = "/intf/lvis", name = "자동차 관리정보 (JSON) api", produces = MediaType.APPLICATION_JSON_VALUE) public class ApiController extends AbstractController { @Resource(name="vehicleInfoService") private VehicleInfoService service; diff --git a/src/main/java/cokr/xit/interfaces/lvis/web/ApiXmlController.java b/src/main/java/cokr/xit/interfaces/lvis/web/ApiXmlController.java new file mode 100644 index 0000000..5f721ad --- /dev/null +++ b/src/main/java/cokr/xit/interfaces/lvis/web/ApiXmlController.java @@ -0,0 +1,14 @@ +package cokr.xit.interfaces.lvis.web; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/**자망 연계 서비스를 REST API로 제공하는 웹 콘트롤러
+ * 서비스 실행은 다음과 같이 한다. + *
http(s)://{호스트}/{웹컨텍스트}/intf/lvis/xml/{서비스별 경로}
+ * @author mjkhan + */ +@RestController("lvisXmlApi") +@RequestMapping(value = "/intf/lvis/xml", name = "자동차 관리정보 (XML) api", produces = MediaType.APPLICATION_XML_VALUE) +public class ApiXmlController extends ApiController {} \ No newline at end of file diff --git a/src/test/java/cokr/xit/interfaces/lvis/service/BasicInfoExtTest.java b/src/test/java/cokr/xit/interfaces/lvis/service/BasicInfoExtTest.java index dfc6971..2d98330 100644 --- a/src/test/java/cokr/xit/interfaces/lvis/service/BasicInfoExtTest.java +++ b/src/test/java/cokr/xit/interfaces/lvis/service/BasicInfoExtTest.java @@ -8,11 +8,14 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import cokr.xit.foundation.data.JSON; +import cokr.xit.foundation.data.XML; import cokr.xit.foundation.test.TestSupport; import cokr.xit.interfaces.lvis.service.bean.VehicleInfoBean; import cokr.xit.interfaces.lvis.service.reg.BasicInfoExtRequest; import cokr.xit.interfaces.lvis.service.reg.BasicInfoExtResponse; import cokr.xit.interfaces.publicinfo.ServiceMessage; +import lombok.Getter; +import lombok.Setter; public class BasicInfoExtTest extends TestSupport { @Resource(name = "vehicleInfoService") @@ -182,4 +185,35 @@ public class BasicInfoExtTest extends TestSupport { req.setVhrno("18도7733"); service.getBasicInfo(req); } + + @Test + void xml() { + XmlTest resp = new XmlTest(); + resp.setId("아이디-00"); + resp.setName("이름-00"); + + XML xml = new XML(); + try { + System.out.println(xml.stringify(resp, true)); + } catch (Exception e) { + e.printStackTrace(); + } + + String str = "\r\n" + + "\r\n" + + " 아이디-00\r\n" + + " 이름-00\r\n" + + ""; + + XmlTest resp2 = xml.parse(str, XmlTest.class); + System.out.println(resp2); + } + + @Getter + @Setter + public static class XmlTest { + private String id; + private String name; + private String contact; + } } \ No newline at end of file