친구톡 json 문자열 생성 개선
This commit is contained in:
parent
86d94c545d
commit
a2468cb18b
@ -17,6 +17,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
import itn.com.cmm.util.StringUtil;
|
import itn.com.cmm.util.StringUtil;
|
||||||
import itn.let.kakao.kakaoComm.KakaoButtonVO;
|
import itn.let.kakao.kakaoComm.KakaoButtonVO;
|
||||||
import itn.let.kakao.kakaoComm.KakaoReturnVO;
|
import itn.let.kakao.kakaoComm.KakaoReturnVO;
|
||||||
@ -216,9 +221,63 @@ public class KakaoApiJsonSave {
|
|||||||
* 파일은 하나만 생성해서 동일하게 사용함.
|
* 파일은 하나만 생성해서 동일하게 사용함.
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
public String kakaoApiFTJsonSave_advc(KakaoVO kakaoVO) {
|
public String kakaoApiFTJsonSave_advc(KakaoVO kakaoVO) throws JsonProcessingException {
|
||||||
// json파일 저장
|
// json파일 저장
|
||||||
|
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
ObjectNode jo = mapper.createObjectNode();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 버튼
|
||||||
|
if (kakaoVO.getButtonVOList() != null && !kakaoVO.getButtonVOList().isEmpty()) {
|
||||||
|
ArrayNode buttonList = mapper.createArrayNode();
|
||||||
|
|
||||||
|
for (KakaoButtonVO buttonInfoVO : kakaoVO.getButtonVOList()) {
|
||||||
|
ObjectNode button = mapper.createObjectNode();
|
||||||
|
button.put("name", buttonInfoVO.getName());
|
||||||
|
button.put("type", buttonInfoVO.getLinkType());
|
||||||
|
|
||||||
|
switch (buttonInfoVO.getLinkType()) {
|
||||||
|
case "WL":
|
||||||
|
button.put("url_mobile", buttonInfoVO.getLinkMo());
|
||||||
|
button.put("url_pc", buttonInfoVO.getLinkPc());
|
||||||
|
break;
|
||||||
|
case "AL":
|
||||||
|
button.put("scheme_ios", buttonInfoVO.getLinkIos());
|
||||||
|
button.put("scheme_android", buttonInfoVO.getLinkAnd());
|
||||||
|
break;
|
||||||
|
case "BC":
|
||||||
|
// 상담톡
|
||||||
|
break;
|
||||||
|
case "BT":
|
||||||
|
// 봇 전환
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buttonList.add(button);
|
||||||
|
}
|
||||||
|
jo.set("button", buttonList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 이미지
|
||||||
|
String imageType = kakaoVO.getImageType();
|
||||||
|
if (StringUtils.isNotEmpty(imageType)) {
|
||||||
|
ObjectNode image = mapper.createObjectNode();
|
||||||
|
image.put("img_url", kakaoVO.getTemplateImageUrl());
|
||||||
|
image.put("img_link", StringUtils.isNotEmpty(kakaoVO.getImgLink()) ? kakaoVO.getImgLink() : kakaoVO.getTemplateImageUrl());
|
||||||
|
jo.set("image", image);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 문자열로 변환 (이스케이프 없음)
|
||||||
|
return mapper.writeValueAsString(jo);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
// 버튼리스트 JSON 생성
|
// 버튼리스트 JSON 생성
|
||||||
JSONArray buttonList = new JSONArray();
|
JSONArray buttonList = new JSONArray();
|
||||||
@ -249,11 +308,14 @@ public class KakaoApiJsonSave {
|
|||||||
|
|
||||||
if(StringUtils.isNotEmpty(imageType)) {
|
if(StringUtils.isNotEmpty(imageType)) {
|
||||||
templateImageInfo.put("img_url", kakaoVO.getTemplateImageUrl());
|
templateImageInfo.put("img_url", kakaoVO.getTemplateImageUrl());
|
||||||
templateImageInfo.put("img_link", kakaoVO.getImgLink());
|
templateImageInfo.put("img_link", StringUtils.isNotEmpty(kakaoVO.getImgLink()) ? kakaoVO.getImgLink() : kakaoVO.getTemplateImageUrl() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if("W".equals(imageType)) {
|
// wide 여부
|
||||||
templateImageExtInfo.put("wide", "Y");
|
if ("W".equals(imageType)) {
|
||||||
|
ObjectNode extra = mapper.createObjectNode();
|
||||||
|
extra.put("wide", "Y");
|
||||||
|
jo.set("extra", extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -274,7 +336,7 @@ public class KakaoApiJsonSave {
|
|||||||
// 입력 json 데이터를 파일로 변경
|
// 입력 json 데이터를 파일로 변경
|
||||||
String jsonStr = jo.toString();
|
String jsonStr = jo.toString();
|
||||||
|
|
||||||
return jsonStr;
|
return jsonStr;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user