refactor: munja send success
This commit is contained in:
parent
42db3a3d92
commit
0858957a71
@ -22,6 +22,7 @@ import com.itn.mjonApi.cmn.interceptor.CertifInterceptor;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CertifInterceptor certificationInterceptor(){
|
public CertifInterceptor certificationInterceptor(){
|
||||||
return new CertifInterceptor();
|
return new CertifInterceptor();
|
||||||
@ -29,6 +30,7 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
|
||||||
registry.addInterceptor(certificationInterceptor())
|
registry.addInterceptor(certificationInterceptor())
|
||||||
.addPathPatterns("/api/**");
|
.addPathPatterns("/api/**");
|
||||||
//.excludePathPatterns("/css/**", "/images/**", "/js/**");
|
//.excludePathPatterns("/css/**", "/images/**", "/js/**");
|
||||||
|
|||||||
27
src/main/java/com/itn/mjonApi/cmn/msg/MjonResponse.java
Normal file
27
src/main/java/com/itn/mjonApi/cmn/msg/MjonResponse.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.itn.mjonApi.cmn.msg;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* packageName : com.itn.mjonApi.cmn.msg
|
||||||
|
* fileName : mjonResponse
|
||||||
|
* author : hylee
|
||||||
|
* date : 2023-05-12
|
||||||
|
* description :
|
||||||
|
* ===========================================================
|
||||||
|
* DATE AUTHOR NOTE
|
||||||
|
* -----------------------------------------------------------
|
||||||
|
* 2023-05-12 hylee 최초 생성
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class MjonResponse {
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
private String result;
|
||||||
|
private String resultSts; // 수신거부 갯수
|
||||||
|
private String resultBlockSts; // 수신거부 갯수
|
||||||
|
private String afterCash;
|
||||||
|
|
||||||
|
}
|
||||||
@ -165,7 +165,7 @@ public class MjonMsgVO implements Serializable {
|
|||||||
private Float agentPrice;
|
private Float agentPrice;
|
||||||
|
|
||||||
private float smsPrice; // sms 단가
|
private float smsPrice; // sms 단가
|
||||||
private float mmsPrice; // mms 단가
|
// private float mmsPrice; // mms 단가
|
||||||
private float kakaoAtPrice; // 카카오 알림톡 단가
|
private float kakaoAtPrice; // 카카오 알림톡 단가
|
||||||
private float kakaoFtPrice; // 카카오 친구톡 단가
|
private float kakaoFtPrice; // 카카오 친구톡 단가
|
||||||
private float kakaoFtImgPrice;// 카카오 이미지 단가
|
private float kakaoFtImgPrice;// 카카오 이미지 단가
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.itn.mjonApi.mjon.api.send.service;
|
||||||
|
|
||||||
|
import com.itn.mjonApi.cmn.msg.MjonResponse;
|
||||||
|
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonMsgVO;
|
||||||
|
|
||||||
|
public interface SendService {
|
||||||
|
|
||||||
|
|
||||||
|
MjonResponse sendMsgData(MjonMsgVO mjonMsgVO) throws Exception;
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.itn.mjonApi.mjon.api.send.service.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.itn.mjonApi.cmn.msg.MjonResponse;
|
||||||
|
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonMsgVO;
|
||||||
|
import com.itn.mjonApi.mjon.api.send.service.SendService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class SendServiceImpl implements SendService {
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
public SendServiceImpl(RestTemplate restTemplate) {
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MjonResponse sendMsgData(MjonMsgVO mjonMsgVO) throws Exception {
|
||||||
|
|
||||||
|
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(
|
||||||
|
"/web/user/login/sendMsgDataAjax.do"
|
||||||
|
, mjonMsgVO
|
||||||
|
, String.class
|
||||||
|
);
|
||||||
|
MjonResponse mjonResponse = getMjonResponse(stringResponseEntity);
|
||||||
|
|
||||||
|
return mjonResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param stringResponseEntity
|
||||||
|
* @return ResponseEntity vo convert
|
||||||
|
* @throws JsonProcessingException
|
||||||
|
*/
|
||||||
|
private static MjonResponse getMjonResponse(ResponseEntity<String> stringResponseEntity) throws JsonProcessingException {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
MjonResponse mjonResponse = objectMapper.readValue(stringResponseEntity.getBody(), MjonResponse.class);
|
||||||
|
return mjonResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,19 @@
|
|||||||
package com.itn.mjonApi.mjon.api.send.web;
|
package com.itn.mjonApi.mjon.api.send.web;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.itn.mjonApi.cmn.msg.MjonResponse;
|
||||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonMsgVO;
|
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonMsgVO;
|
||||||
|
import com.itn.mjonApi.mjon.api.send.service.SendService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* packageName : com.itn.mjonApi.mjon.send.web
|
* packageName : com.itn.mjonApi.mjon.send.web
|
||||||
* fileName : SendRestController
|
* fileName : SendRestController
|
||||||
@ -20,6 +26,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
* 2023-02-15 hylee 최초 생성
|
* 2023-02-15 hylee 최초 생성
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// 치환문자가 있으면 , => §로 치환
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@ -31,6 +38,9 @@ public class SendRestController {
|
|||||||
this.restTemplate = restTemplate;
|
this.restTemplate = restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SendService sendService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -39,13 +49,11 @@ public class SendRestController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/sendTest")
|
@PostMapping("/api/sendTest")
|
||||||
public Object sendTest(MjonMsgVO mjonMsgVO){
|
public MjonResponse sendTest(MjonMsgVO mjonMsgVO) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
return sendService.sendMsgData(mjonMsgVO);
|
||||||
|
|
||||||
return restTemplate.postForEntity(
|
|
||||||
"/web/user/login/sendMsgDataAjax.do"
|
|
||||||
,mjonMsgVO
|
|
||||||
, Object.class
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -55,12 +63,31 @@ public class SendRestController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/api/selectSpamTxtChkAjax")
|
@PostMapping("/api/selectSpamTxtChkAjax")
|
||||||
public Object selectSpamTxtChkAjax(MjonMsgVO mjonMsgVO){
|
public Object selectSpamTxtChkAjax(MjonMsgVO mjonMsgVO){
|
||||||
log.info(" :: START/api/selectSpamTxtChkAjax");
|
log.info(" :: START/api/selectSpamTxtChkAjax smsTxt :: [{}]", mjonMsgVO.getSmsTxt());
|
||||||
return restTemplate.postForEntity(
|
|
||||||
"/web/user/login/selectSpamTxtChkAjax.do"
|
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(
|
||||||
,mjonMsgVO
|
"http://localhost:8080/web/user/login/selectSpamTxtChkAjax.do"
|
||||||
, Object.class
|
, mjonMsgVO
|
||||||
);
|
, String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
MjonResponse mjonResponse = new MjonResponse();
|
||||||
|
|
||||||
|
log.info("stringResponseEntity :: [{}]", stringResponseEntity.getBody());
|
||||||
|
log.info("stringResponseEntity :: [{}]", stringResponseEntity);
|
||||||
|
|
||||||
|
try {
|
||||||
|
mjonResponse = objectMapper.readValue(stringResponseEntity.getBody(), MjonResponse.class);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mjonResponse;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,13 +98,37 @@ public class SendRestController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/returnTest")
|
@PostMapping("/api/returnTest")
|
||||||
public Object returnTest(MjonMsgVO mjonMsgVO){
|
public Object returnTest(MjonMsgVO mjonMsgVO) throws IOException {
|
||||||
|
|
||||||
return restTemplate.postForEntity(
|
System.out.println("test !!!");
|
||||||
"/web/user/login/returnTest.do"
|
|
||||||
, mjonMsgVO
|
|
||||||
, Object.class
|
|
||||||
);
|
|
||||||
|
// API에 요청할 URL
|
||||||
|
String apiUrl = "http://localhost:8080/web/user/login/returnTest.do";
|
||||||
|
|
||||||
|
// RestTemplate 객체 생성
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
// API로부터 ResponseEntity<ModelAndView> 응답 받기
|
||||||
|
ResponseEntity<ModelAndView> response = restTemplate.getForEntity(apiUrl, ModelAndView.class);
|
||||||
|
|
||||||
|
// ModelAndView 추출 및 데이터 출력
|
||||||
|
ModelAndView modelAndView = response.getBody();
|
||||||
|
System.out.println("View Name: " + modelAndView.getViewName());
|
||||||
|
System.out.println("Model: " + modelAndView.getModel());
|
||||||
|
|
||||||
|
|
||||||
|
// ResponseEntity<Object> objectResponseEntity = restTemplate.postForEntity(
|
||||||
|
// "/web/user/login/returnTest.do"
|
||||||
|
// , mjonMsgVO
|
||||||
|
// , Object.class
|
||||||
|
// );
|
||||||
|
|
||||||
|
// System.out.println("objectResponseEntity :: " + objectResponseEntity);
|
||||||
|
|
||||||
|
return modelAndView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user