diff --git a/src/main/java/cokr/xit/ens/modules/nice/model/NiceDTO.java b/src/main/java/cokr/xit/ens/modules/nice/model/NiceDTO.java index 47bc473..f0f6c31 100644 --- a/src/main/java/cokr/xit/ens/modules/nice/model/NiceDTO.java +++ b/src/main/java/cokr/xit/ens/modules/nice/model/NiceDTO.java @@ -271,9 +271,9 @@ public class NiceDTO { */ @Schema(title = "TR Code", example = " ") @Size(min = 0, max = 9, message = "트랜잭션 코드는 0~9자리 입니다.") - private String trCode = StringUtils.rightPad(StringUtils.EMPTY, 9, StringUtils.SPACE); + private String trCode; public void setTrCode(String trCode) { - this.trCode = StringUtils.rightPad(nvl(trCode), 9, StringUtils.SPACE); + this.trCode = StringUtils.trim(trCode); } //---------------------------------------------------------------------------------------------- @@ -290,7 +290,10 @@ public class NiceDTO { */ @Schema(title = "공란", example = " ") @Size(min = 16, max = 17, message = "공란(17자리)") - private String commonEmptyField = StringUtils.rightPad(StringUtils.EMPTY, 17, StringUtils.SPACE); + private String commonEmptyField; + public void setCommonEmptyField(String commonEmptyField) { + this.commonEmptyField = StringUtils.trim(commonEmptyField); + } //---------------------------------------------------------------------------------------------- // 공통부 : 100 자리 //---------------------------------------------------------------------------------------------- @@ -306,9 +309,9 @@ public class NiceDTO { */ @Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "응답 건수", example = " ") @Max(value = 48, message = "응답 최대건수는 48입니다") - private String resCnt = StringUtils.rightPad(StringUtils.EMPTY, 2, StringUtils.SPACE); - public void setResCnt(Integer resCnt) { - this.resCnt = StringUtils.rightPad(nvl(resCnt == null ? "" : resCnt.toString()), 2, StringUtils.SPACE); + private String resCnt; + public void setResCnt(String resCnt) { + this.resCnt = StringUtils.trim(resCnt); } /** @@ -323,7 +326,10 @@ public class NiceDTO { */ @Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "SMS발송요청구분코드", example = " ", allowableValues = {"0", "1", "2", "3"}) @Pattern(regexp = "[0-3]", message = "SMS발송요청구분코드 0 ~ 3 입니다(1자리)") - private String smsSndReqCode = StringUtils.SPACE;; + private String smsSndReqCode; + public void setSmsSndReq(String smsSndReqCode) { + this.smsSndReqCode = StringUtils.trim(smsSndReqCode); + } /** *
@@ -333,9 +339,9 @@ public class NiceDTO {
          */
         @Schema(title = "SMS 발송메세지", example = " ")
         @Pattern(regexp = "^$|[\\s]{10,2000}", message = "SMS발송메세지는 10 ~ 2000자리 입니다")
-        private String sndMessage = StringUtils.rightPad(StringUtils.EMPTY, 2000, StringUtils.SPACE);
+        private String sndMessage;
         public void setSndMessage(String sndMessage) {
-            this.sndMessage = StringUtils.rightPad(nvl(sndMessage), 2000, StringUtils.SPACE);
+            this.sndMessage = StringUtils.trim(sndMessage);
         }
 
         /**
@@ -346,9 +352,9 @@ public class NiceDTO {
          */
         @Schema(title = "SMS 발신번호", example = " ")
         @Pattern(regexp = "^$|[\\d]{3,12}", message = "SMS 발신번호는 3 ~ 12자리 입니다")
-        private String sndPhoneNo = StringUtils.rightPad(StringUtils.EMPTY, 12, StringUtils.SPACE);
+        private String sndPhoneNo;
         public void setSndPhoneNo(String sndPhoneNo) {
-            this.sndPhoneNo = StringUtils.rightPad(nvl(sndPhoneNo), 12, StringUtils.SPACE);
+            this.sndPhoneNo = StringUtils.trim(sndPhoneNo);
         }
 
         /**
@@ -371,7 +377,10 @@ public class NiceDTO {
          */
         @Schema(title = "공란", example = " ")
         @Size(min = 84, max = 84, message = "공란(84자리)")
-        private String privateEmptyField = StringUtils.rightPad(StringUtils.EMPTY, 84, StringUtils.SPACE);
+        private String privateEmptyField;
+        public void setPrivateEmptyField(String privateEmptyField) {
+            this.privateEmptyField = StringUtils.trim(privateEmptyField);
+        }
         //----------------------------------------------------------------------------------------------
         // 개별응답부 : 2100 자리
         //----------------------------------------------------------------------------------------------
@@ -417,20 +426,28 @@ public class NiceDTO {
                 int idx = 0;
                 nr.setTrCode(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setNiceCommon(NiceCommon.parse(tgtString));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setCommonEmptyField(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nr.setResCnt(Integer.valueOf(StringUtils.left(tgtString, parseLength[idx])));
+
+                nr.setResCnt(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setSmsSndReqCode(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setSndMessage(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setSndPhoneNo(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setContactSearchCode(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 nr.setPrivateEmptyField(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx]);
 
@@ -595,9 +612,9 @@ public class NiceDTO {
          */
         @Schema(title = "주민번호", example = " ")
         @Size(min = 13, max = 13, message = "주민번호는 13자리 입니다.")
-        private String jumin = StringUtils.rightPad(StringUtils.EMPTY, 13, StringUtils.SPACE);
+        private String jumin;
         public void setJumin(String jumin) {
-            this.jumin = StringUtils.rightPad(nvl(jumin), 13, StringUtils.SPACE);
+            this.jumin = StringUtils.trim(jumin);
         }
 
         /**
@@ -607,9 +624,9 @@ public class NiceDTO {
          */
         @Schema(title = "이름", example = " ")
         @Size(min = 20, max = 20, message = "이름은 20자리 입니다.")
-        private String name = StringUtils.rightPad(StringUtils.EMPTY, 20, StringUtils.SPACE);
+        private String name;
         public void setName(String name) {
-            this.name = StringUtils.rightPad(nvl(name), 20, StringUtils.SPACE);
+            this.name = StringUtils.trim(name);
         }
 
         /**
@@ -619,9 +636,9 @@ public class NiceDTO {
          */
         @Schema(title = "1순위연락처", example = " ")
         @Size(min = 11, max = 11, message = "1순위연락처는 11자리 입니다.")
-        private String contractOf1st = StringUtils.rightPad(StringUtils.EMPTY, 11, StringUtils.SPACE);
+        private String contractOf1st;
         public void setContractOf1st(String contractOf1st) {
-            this.contractOf1st = StringUtils.rightPad(nvl(contractOf1st), 11, StringUtils.SPACE);
+            this.contractOf1st = StringUtils.trim(contractOf1st);
         }
 
         /**
@@ -631,9 +648,9 @@ public class NiceDTO {
          */
         @Schema(title = "2순위연락처", example = " ")
         @Size(min = 11, max = 11, message = "2순위연락처는 11자리 입니다.")
-        private String contractOf2nd = StringUtils.rightPad(StringUtils.EMPTY, 11, StringUtils.SPACE);
+        private String contractOf2nd;
         public void setContractOf2nd(String contractOf2nd) {
-            this.contractOf2nd = StringUtils.rightPad(nvl(contractOf2nd), 11, StringUtils.SPACE);
+            this.contractOf2nd = StringUtils.trim(contractOf2nd);
         }
 
         /**
@@ -643,9 +660,9 @@ public class NiceDTO {
          */
         @Schema(title = "3순위연락처", example = " ")
         @Size(min = 11, max = 11, message = "3순위연락처는 11자리 입니다.")
-        private String contractOf3rd = StringUtils.rightPad(StringUtils.EMPTY, 11, StringUtils.SPACE);
+        private String contractOf3rd;
         public void setContractOf3rd(String contractOf3rd) {
-            this.contractOf3rd = StringUtils.rightPad(nvl(contractOf3rd), 11, StringUtils.SPACE);
+            this.contractOf3rd = StringUtils.trim(contractOf3rd);
         }
 
         /**
@@ -660,9 +677,9 @@ public class NiceDTO {
          */
         @Schema(title = "결과구분코드", example = " ", allowableValues = {"00", "01", "02", "10", "99"})
         @Size(min = 2, max = 2, message = "결과구분코드는 2자리 입니다.")
-        private String rsltDivCode = StringUtils.rightPad(StringUtils.EMPTY, 2, StringUtils.SPACE);
+        private String rsltDivCode;
         public void setRsltDivCode(String rsltDivCode) {
-            this.rsltDivCode = StringUtils.rightPad(nvl(rsltDivCode), 2, StringUtils.SPACE);
+            this.rsltDivCode = StringUtils.trim(rsltDivCode);
         }
 
         /**
@@ -676,7 +693,6 @@ public class NiceDTO {
          */
         @Schema(title = "SMS발송연락처순위", example = " ", allowableValues = {"0", "1", "2", "3"})
         @Size(min = 1, max = 1, message = "SMS발송연락처순위는 1자리 입니다.")
-        @Setter
         private String smsSndContractOrder = "1";
 
         /**
@@ -686,9 +702,9 @@ public class NiceDTO {
          */
         @Schema(title = "SMS발송연락처번호", example = " ")
         @Size(min = 11, max = 11, message = "SMS발송연락처번호는 11자리 입니다.")
-        private String smsSndContractNo = StringUtils.rightPad(StringUtils.EMPTY, 11, StringUtils.SPACE);
+        private String smsSndContractNo;
         public void setSmsSndContractNo(String smsSndContractNo) {
-            this.smsSndContractNo = StringUtils.rightPad(nvl(smsSndContractNo), 11, StringUtils.SPACE);
+            this.smsSndContractNo = StringUtils.trim(smsSndContractNo);
         }
 
         /**
@@ -698,9 +714,9 @@ public class NiceDTO {
          */
         @Schema(title = "SMS발송예정일시", example = " ")
         @Size(min = 14, max = 14, message = "SMS발송예정일시는 14자리 입니다.")
-        private String smsSndWillDt = StringUtils.rightPad(StringUtils.EMPTY, 14, StringUtils.SPACE);
+        private String smsSndWillDt;
         public void setSmsSndWillDt(String smsSndWillDt) {
-            this.smsSndWillDt = StringUtils.rightPad(nvl(smsSndWillDt), 14, StringUtils.SPACE);
+            this.smsSndWillDt = StringUtils.trim(smsSndWillDt);
         }
 
         /**
@@ -710,8 +726,10 @@ public class NiceDTO {
          */
         @Schema(title = "공란", example = " ")
         @Size(min = 15, max = 15, message = "공란(36자리)")
-        @Setter
-        private String emptyField = StringUtils.rightPad(StringUtils.EMPTY, 15, StringUtils.SPACE);
+        private String emptyField;
+        public void setEmptyField(String emptyField) {
+            this.emptyField = StringUtils.trim(emptyField);
+        }
 
         public String ofString() {
             StringBuilder sb = new StringBuilder();
@@ -747,26 +765,37 @@ public class NiceDTO {
             if (StringUtils.isNotBlank(tgtString) && tgtString.length()%110 == 0) {
                 ResResult rr = new ResResult();
                 int idx = 0;
+
                 rr.setIdDiv(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setJumin(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setName(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setContractOf1st(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setContractOf2nd(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setContractOf3rd(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setRsltDivCode(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setSmsSndContractOrder(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setSmsSndContractNo(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setSmsSndWillDt(StringUtils.left(tgtString, parseLength[idx]));
                 tgtString = tgtString.substring(parseLength[idx++]);
+
                 rr.setEmptyField(StringUtils.left(tgtString, parseLength[idx]));
                 return rr;
             }
@@ -964,27 +993,37 @@ public class NiceDTO {
             if (StringUtils.isNotBlank(tgtString) && tgtString.length() >= 83) {
                 NiceCommon nc = new NiceCommon();
                 int idx = 0;
-                nc.setGrpCode(StringUtils.left(tgtString, parseLength[idx]));
+                nc.setGrpCode(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setTrType(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setTrType(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setTrClassification(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setTrClassification(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setSndAndRcvFlag(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setSndAndRcvFlag(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setDeviceClassification(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setDeviceClassification(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setRsltCode(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setRsltCode(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setOrgId(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setOrgId(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setOrgMngNo(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setOrgMngNo(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setOrgSndDt(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setOrgSndDt(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setNiceMngNo(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setNiceMngNo(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 tgtString = tgtString.substring(parseLength[idx++]);
-                nc.setNiceSndDt(StringUtils.left(tgtString, parseLength[idx]));
+
+                nc.setNiceSndDt(StringUtils.trim(StringUtils.left(tgtString, parseLength[idx])));
                 return nc;
             }
             return null;
@@ -1032,49 +1071,21 @@ public class NiceDTO {
         nr.getButtonRequests().add(br);
         // nc.setNiceMngNo(StringUtils.EMPTY);
         // nc.setNiceSndDt(StringUtils.EMPTY);
-
-
-
-
         String fullText = nr.ofString();
         System.out.println(String.format("[%s] %d", fullText, fullText.length()));
 
-        ResResult resResult = new ResResult();
-        resResult.setIdDiv("1");
-        resResult.setJumin("1234567890123");
-        resResult.setName("name1");
-        resResult.setRsltDivCode("00");
-        System.out.println(resResult.ofString().length());
-
-        ResResult resResult2 = new ResResult();
-        resResult.setIdDiv("1");
-        resResult.setJumin("1234567890");
-        resResult.setName("name2");
-        resResult.setRsltDivCode("00");
-        System.out.println(resResult.ofString().length());
 
         NiceResponse res = new NiceResponse();
-        res.setTrCode("trCode");
-        res.setResCnt(24);
-        res.setSmsSndReqCode("1");
-        res.setSndMessage("~~~~~~~~~~~~~~~~~~~~~~~");
-        res.setSndPhoneNo("010");
-        res.setContactSearchCode("1");
-
-        res.setNiceCommon(nc);
-        res.resResults.add(resResult);
-        res.resResults.add(resResult2);
-
-
-        String fullText3 = res.ofString();
-        System.out.println(String.format("[%s] %d", fullText3, fullText3.length()));
-
-
-        //NiceCommon niceCommon = nc.parse(nc.ofString());
-        //System.out.println(niceCommon);
-
-        //NiceCommon niceCommon2 = nc.parse(fullText.substring(0, 9+83));
-        NiceResponse niceResponse = res.parse(fullText3);
+        String resStr = "trCode   " +
+            // NiceCommon
+            "NICEIF   020031895B503rsltorgId    orgMngNo  orgSndDt      niceMngNo niceSndDt" +
+            "                      "+
+            // 개별응답부
+            "241~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         010         1                                                                                    "+
+            // 응답반복부
+            "18401011449211name2                                                001                                        "+
+            "19412341234567이름2                                                  1                                          ";
+        NiceResponse niceResponse = res.parse(resStr);
         System.out.println(niceResponse);
     }
 }