toCols(), toRows() 추가

master
mjkhan21 7 months ago
parent 06647e1200
commit f2562d2437

@ -3,12 +3,16 @@ package cokr.xit.interfaces.postplus.post;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.data.DataObject;
import cokr.xit.foundation.data.Named;
import cokr.xit.interfaces.postplus.Postplus;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* @author mjkhan
@ -17,6 +21,9 @@ public class PstMsr extends AbstractComponent {
/**
* @author mjkhan
*/
@Getter
@Setter
@Accessors(chain = true)
public static class Master {
private static final List<String> cols = List.of(new String[] {
"버전", "테스트여부", "서비스", "연계식별키", "봉투",
@ -77,236 +84,21 @@ public class PstMsr extends AbstractComponent {
/** 발송인전화번호 */
private String senderPhoneNo;
/** .
* @param version
* @return Master
*/
public Master setVersion(String version) {
this.version = version;
return this;
}
/** .
* @param testYN
* @return Master
*/
public Master setTestYN(String testYN) {
this.testYN = testYN;
return this;
}
/** .
* @param service
* @return Master
*/
public Master setService(String service) {
this.service = service;
return this;
}
/** .
* @param intfID
* @return Master
*/
public Master setIntfID(String intfID) {
this.intfID = intfID;
return this;
}
/** .
* @param envelop
* @return Master
*/
public Master setEnvelop(String envelop) {
this.envelop = envelop;
return this;
}
/** .
* @param envelopWindow
* @return Master
*/
public Master setEnvelopWindow(String envelopWindow) {
this.envelopWindow = envelopWindow;
return this;
}
/** .
* @param bwColor
* @return Master
*/
public Master setBwColor(String bwColor) {
this.bwColor = bwColor;
return this;
}
/** .
* @param faceType
* @return Master
*/
public Master setFaceType(String faceType) {
this.faceType = faceType;
return this;
}
/** .
* @param delivery
* @return Master
*/
public Master setDelivery(String delivery) {
this.delivery = delivery;
return this;
}
/**릿 .
* @param templateCode 릿
* @return Master
*/
public Master setTemplateCode(String templateCode) {
this.templateCode = templateCode;
return this;
}
/**릿 .
* @param templatePrint 릿
* @return Master
*/
public Master setTemplatePrint(String templatePrint) {
this.templatePrint = templatePrint;
return this;
}
/** .
* @param recipientCount
* @return Master
*/
public Master setRecipientCount(String recipientCount) {
this.recipientCount = recipientCount;
return this;
}
/** .
* @param marginYN
* @return Master
*/
public Master setMarginYN(String marginYN) {
this.marginYN = marginYN;
return this;
}
/** .
* @param addressPageYN
* @return Master
*/
public Master setAddressPageYN(String addressPageYN) {
this.addressPageYN = addressPageYN;
return this;
}
/** .
* @param orderYN
* @return Master
*/
public Master setOrderYN(String orderYN) {
this.orderYN = orderYN;
return this;
}
/** .
* @param mailMergeYN
* @return Master
*/
public Master setMailMergeYN(String mailMergeYN) {
this.mailMergeYN = mailMergeYN;
return this;
}
/** .
* @param enclosedYN
* @return Master
*/
public Master setEnclosedYN(String enclosedYN) {
this.enclosedYN = enclosedYN;
return this;
}
/** .
* @param returnYN
* @return Master
*/
public Master setReturnYN(String returnYN) {
this.returnYN = returnYN;
return this;
}
/** .
* @param staplerYN
* @return Master
*/
public Master setStaplerYN(String staplerYN) {
this.staplerYN = staplerYN;
return this;
}
/** .
* @param logoFile
* @return Master
*/
public Master setLogoFile(String logoFile) {
this.logoFile = logoFile;
return this;
}
/** .
* @param senderName
* @return Master
*/
public Master setSenderName(String senderName) {
this.senderName = senderName;
return this;
}
/** .
* @param senderZipcode
* @return Master
*/
public Master setSenderZipcode(String senderZipcode) {
this.senderZipcode = senderZipcode;
return this;
}
/** .
* @param senderAddress
* @return Master
*/
public Master setSenderAddress(String senderAddress) {
this.senderAddress = senderAddress;
return this;
}
/** .
* @param senderDetailAddress
* @return Master
/** .
* @return
*/
public Master setSenderDetailAddress(String senderDetailAddress) {
this.senderDetailAddress = senderDetailAddress;
return this;
public DataObject toRequest() {
return new DataObject()
.set("cols", toCols())
.set("rows", toRows());
}
/** .
* @param senderPhoneNo
* @return Master
*/
public Master setSenderPhoneNo(String senderPhoneNo) {
this.senderPhoneNo = senderPhoneNo;
return this;
protected List<String> toCols() {
return cols;
}
/** .
* @return
*/
public DataObject toRequest() {
List<String> row = List.of(new String[] {
protected List<String> toRows() {
return List.of(new String[] {
ifEmpty(version, Postplus.get()::getVersion),
ifEmpty(testYN, Postplus.get()::getTest),
ifEmpty(service, Postplus.Service.PST::getCode),
@ -333,31 +125,39 @@ public class PstMsr extends AbstractComponent {
blankIfEmpty(senderDetailAddress),
blankIfEmpty(senderPhoneNo)
});
return new DataObject()
.set("cols", cols)
.set("rows", row);
}
}
/**
* @author mjkhan
*/
@Getter
@Setter
@Accessors(chain = true)
public static class Detail {
private static final List<String> cols = List.of(new String[] {
"순번", "이름", "우편번호", "주소", "상세주소",
"전화번호", "첨부파일", "가변1", "가변2", "가변3", "가변4"
});
protected List<String> toCols() {
return cols;
}
public static DataObject toRequest(List<Detail> details) {
DataObject req = new DataObject();
if (isEmpty(details)) return req;
Detail first = details.get(0);
req.set("cols", first.toCols());
List<List<String>> rows = details.stream()
.map(Detail::toRow)
.toList();
return new DataObject()
.set("cols", cols)
.set("rows", rows);
return req.set("rows", rows);
}
/** 연계식별키 */
private String intfID;
/** 순번 */
private String seq;
/** 이름 */
@ -381,109 +181,10 @@ public class PstMsr extends AbstractComponent {
/** 가변4 */
private String variableContent4;
/** .
* @param seq
* @return Detail
*/
public Detail setSeq(String seq) {
this.seq = seq;
return this;
}
/** .
* @param name
* @return Detail
*/
public Detail setName(String name) {
this.name = name;
return this;
}
/** .
* @param zipcode
* @return Detail
*/
public Detail setZipcode(String zipcode) {
this.zipcode = zipcode;
return this;
}
/** .
* @param address
* @return Detail
*/
public Detail setAddress(String address) {
this.address = address;
return this;
}
/** .
* @param detailAddress
* @return Detail
*/
public Detail setDetailAddress(String detailAddress) {
this.detailAddress = detailAddress;
return this;
}
/** .
* @param phoneNo
* @return Detail
*/
public Detail setPhoneNo(String phoneNo) {
this.phoneNo = phoneNo;
return this;
}
/** .
* @param attachment
* @return Detail
*/
public Detail setAttachment(String attachment) {
this.attachment = attachment;
return this;
}
/**1 .
* @param variableContent1 1
* @return Detail
*/
public Detail setVariableContent1(String variableContent1) {
this.variableContent1 = variableContent1;
return this;
}
/**2 .
* @param variableContent2 2
* @return Detail
*/
public Detail setVariableContent2(String variableContent2) {
this.variableContent2 = variableContent2;
return this;
}
/**3 .
* @param variableContent3 3
* @return Detail
*/
public Detail setVariableContent3(String variableContent3) {
this.variableContent3 = variableContent3;
return this;
}
/**4 .
* @param variableContent4 4
* @return Detail
*/
public Detail setVariableContent4(String variableContent4) {
this.variableContent4 = variableContent4;
return this;
}
/** .
* @return
*/
public List<String> toRow() {
protected List<String> toRow() {
return List.of(new String[] {
blankIfEmpty(seq),
blankIfEmpty(name),
@ -516,6 +217,10 @@ public class PstMsr extends AbstractComponent {
private List<Detail> details;
private PostResponse result;
public Master getMaster() {
return master;
}
/** .
* @param master
* @return PstMsr
@ -525,14 +230,22 @@ public class PstMsr extends AbstractComponent {
return this;
}
public List<Detail> getDetails() {
return ifEmpty(details, Collections::emptyList);
}
/** .
* @param details
* @return PstMsr
*/
public PstMsr setDetails(List<Detail> details) {
int size = details != null ? details.size() : 0;
for (int i = 0; i < size; ++i)
details.get(i).setSeq(Integer.toString(i + 1));
String intfID = master.getIntfID();
for (int i = 0; i < size; ++i) {
details.get(i)
.setIntfID(intfID)
.setSeq(Integer.toString(i + 1));
}
this.details = details;
return this;

@ -6,9 +6,9 @@ import javax.annotation.Resource;
import org.junit.jupiter.api.Test;
import cokr.xit.foundation.data.JSON;
import cokr.xit.foundation.test.TestSupport;
import cokr.xit.interfaces.postplus.Postplus;
import cokr.xit.interfaces.postplus.post.PostResponse;
import cokr.xit.interfaces.postplus.post.PstMsr;
public class PostServiceTest extends TestSupport {
@ -80,7 +80,12 @@ public class PostServiceTest extends TestSupport {
.setVariableContent4("421,000,000")
);
PostResponse resp = postService.requestProduction(apiID, master, details, null);
PstMsr pstMsr = new PstMsr()
.setMaster(master)
.setDetails(details);
System.out.println(new JSON().stringify(pstMsr.toRequest(), true));
// PostResponse resp = postService.requestProduction(apiID, master, details, null);
}
@Test

Loading…
Cancel
Save