Merge branch 'master' of http://yongjoon.cho@vcs.iten.co.kr:9999/hylee/mjon_api
This commit is contained in:
commit
d8956ac79f
7
pom.xml
7
pom.xml
@ -128,6 +128,13 @@
|
|||||||
<version>16.0.1</version>
|
<version>16.0.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-validation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.itn.mjonApi.cmn.idgen.service.IdgenService;
|
import com.itn.mjonApi.cmn.idgen.service.IdgenService;
|
||||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||||
|
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||||
import com.itn.mjonApi.mjon.log.service.mapper.LettnAccessLogMapper;
|
import com.itn.mjonApi.mjon.log.service.mapper.LettnAccessLogMapper;
|
||||||
import com.itn.mjonApi.mjon.log.service.mapper.domain.LettnAccessLogVO;
|
import com.itn.mjonApi.mjon.log.service.mapper.domain.LettnAccessLogVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -96,13 +97,13 @@ public class LogAspect {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 메소드 종료 후 return 값에 따른 로그 처리
|
* @description 메소드 종료 후 return 값에 따른 로그 처리
|
||||||
* - 매개변수 RestResponse는 메소드의 return 값과 일치해야 함
|
|
||||||
* @param joinPoint
|
* @param joinPoint
|
||||||
* @param returnValue
|
* @param returnValue
|
||||||
* @throws JsonProcessingException
|
* @throws JsonProcessingException
|
||||||
|
* @important 메소드의 매개변수 RestResponse는 메소드의 return 값과 일치해야 함
|
||||||
*/
|
*/
|
||||||
@AfterReturning(pointcut = "execution(* com.itn.mjonApi.mjon.api.*..*Impl.*(..))", returning = "returnValue")
|
@AfterReturning(pointcut = "execution(* com.itn.mjonApi.mjon.api.*..*Impl.*(..))", returning = "returnValue")
|
||||||
public void afterReturning(JoinPoint joinPoint, RestResponse returnValue) throws JsonProcessingException {
|
public void afterReturning(JoinPoint joinPoint, Object returnValue) throws Exception {
|
||||||
log.info(" :: AfterReturning :: ");
|
log.info(" :: AfterReturning :: ");
|
||||||
|
|
||||||
String resutlCode = "";
|
String resutlCode = "";
|
||||||
@ -111,30 +112,66 @@ public class LogAspect {
|
|||||||
// @Befer에서 저장한 logId를 가져옴
|
// @Befer에서 저장한 logId를 가져옴
|
||||||
String logId = (String) request.getAttribute("logId");
|
String logId = (String) request.getAttribute("logId");
|
||||||
|
|
||||||
RestResponse restResponse = (RestResponse) returnValue;
|
|
||||||
|
|
||||||
// lettngnrlmber_access_log 응답값 Udpate
|
// lettngnrlmber_access_log 응답값 Udpate
|
||||||
LettnAccessLogVO lettnAccessLogVO = new LettnAccessLogVO()
|
LettnAccessLogVO lettnAccessLogVO = new LettnAccessLogVO()
|
||||||
.builder()
|
.builder()
|
||||||
.logId(logId)
|
.logId(logId)
|
||||||
.resCn(this.getJsonToString(restResponse))
|
// .resCn(this.getJsonToString(returnValue))
|
||||||
|
.resCn(this.getJsonToString(returnValue))
|
||||||
.resCode(resutlCode)
|
.resCode(resutlCode)
|
||||||
.build();
|
.build();
|
||||||
lettnAccessLogMapper.update(lettnAccessLogVO);
|
lettnAccessLogMapper.update(lettnAccessLogVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description object의 맞는 Class를 찾아서 맵핑
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getJsonToString(Object returnValue) throws JsonProcessingException {
|
||||||
|
|
||||||
|
String classNmTemp = returnValue.getClass().getName();
|
||||||
|
String classNm = classNmTemp.substring(classNmTemp.lastIndexOf(".")+1, classNmTemp.length());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : return Class가 추가되면 여기에 추가
|
||||||
|
*/
|
||||||
|
if("AccessKeyVO".equals(classNm)){
|
||||||
|
AccessKeyVO accessKeyVO = (AccessKeyVO) returnValue;
|
||||||
|
return this.getAccessKeyVOToJsonString(accessKeyVO);
|
||||||
|
}else{
|
||||||
|
RestResponse restResponse = (RestResponse) returnValue;
|
||||||
|
return this.getRestResponseToJsonString(restResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : VO를 json으로 변환
|
* @description : VO를 json으로 변환
|
||||||
* @param restResponse
|
* @param restResponse
|
||||||
* @return String
|
* @return String
|
||||||
* @throws JsonProcessingException
|
* @throws JsonProcessingException
|
||||||
*/
|
*/
|
||||||
private static String getJsonToString(RestResponse restResponse) throws JsonProcessingException {
|
private static String getRestResponseToJsonString(RestResponse restResponse) throws JsonProcessingException {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// .registerModule(new JavaTimeModule()) : LocalDateTime을 json으로 변환하기 위함
|
// .registerModule(new JavaTimeModule()) : LocalDateTime을 json으로 변환하기 위함
|
||||||
return objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(restResponse);
|
return objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(restResponse);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @description : VO를 json으로 변환
|
||||||
|
* @param accessKeyVO
|
||||||
|
* @return String
|
||||||
|
* @throws JsonProcessingException
|
||||||
|
*/
|
||||||
|
private static String getAccessKeyVOToJsonString(AccessKeyVO accessKeyVO) throws JsonProcessingException {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
// .registerModule(new JavaTimeModule()) : LocalDateTime을 json으로 변환하기 위함
|
||||||
|
return objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(accessKeyVO);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : HttpServletRequest 객체를 가져옴
|
* @description : HttpServletRequest 객체를 가져옴
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package com.itn.mjonApi.cmn.config;
|
package com.itn.mjonApi.cmn.config;
|
||||||
|
|
||||||
import com.itn.mjonApi.cmn.interceptor.CertifInterceptor;
|
import com.itn.mjonApi.cmn.interceptor.CertifInterceptor;
|
||||||
import com.itn.mjonApi.cmn.interceptor.SendInterceptor;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
@ -26,10 +25,7 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
public CertifInterceptor certifInterceptor(){
|
public CertifInterceptor certifInterceptor(){
|
||||||
return new CertifInterceptor();
|
return new CertifInterceptor();
|
||||||
}
|
}
|
||||||
@Bean
|
|
||||||
public SendInterceptor sendInterceptor(){
|
|
||||||
return new SendInterceptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
|||||||
@ -1,129 +0,0 @@
|
|||||||
package com.itn.mjonApi.cmn.interceptor;
|
|
||||||
|
|
||||||
//import java.sql.Date;
|
|
||||||
|
|
||||||
import com.itn.mjonApi.cmn.idgen.service.IdgenService;
|
|
||||||
import com.itn.mjonApi.mjon.log.service.LettnAccessLogService;
|
|
||||||
import com.itn.mjonApi.mjon.log.service.mapper.domain.LettnAccessLogVO;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* packageName : com.itn.mjonApi.mjon.send.web
|
|
||||||
* fileName : SendRestController
|
|
||||||
* author : hylee
|
|
||||||
* date : 2023-02-15
|
|
||||||
* description :
|
|
||||||
* ===========================================================
|
|
||||||
* DATE AUTHOR NOTE
|
|
||||||
* -----------------------------------------------------------
|
|
||||||
* 2023-02-15 hylee 최초 생성
|
|
||||||
*/
|
|
||||||
//@Component
|
|
||||||
@Slf4j
|
|
||||||
public class SendInterceptor implements HandlerInterceptor{
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LettnAccessLogService lettnAccessLogService;
|
|
||||||
|
|
||||||
@Resource(name = "apiAccessLog")
|
|
||||||
private IdgenService idgenApiAccessLogId;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
|
||||||
throws Exception {
|
|
||||||
log.debug("=========== SendInterceptor preHandle()============");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
|
|
||||||
// TODO accessType 구분추가
|
|
||||||
LettnAccessLogVO lettnAccessLogVO = new LettnAccessLogVO()
|
|
||||||
.builder()
|
|
||||||
.logId(idgenApiAccessLogId.getNextStringId())
|
|
||||||
.accessType("K") // key : K , token : T
|
|
||||||
.accessKey(request.getParameter("accessKey"))
|
|
||||||
.reqUserId(request.getParameter("mberId"))
|
|
||||||
.reqCn("문자 전송")
|
|
||||||
.reqInfoRef(request.getParameter("Referer"))
|
|
||||||
.reqUrl(request.getRequestURI())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
//IP 컬럼 길이를 늘려서 비교 조건 제거함 2023-04-05
|
|
||||||
if (lettnAccessLogVO.getReqUrl().length() > 200) { //길이문제로 오류가 발생하는 경우도 처리하도록 수정
|
|
||||||
lettnAccessLogVO.setReqUrl(lettnAccessLogVO.getReqUrl().substring(0, 199));
|
|
||||||
}
|
|
||||||
|
|
||||||
lettnAccessLogService.insert(lettnAccessLogVO);
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
|
|
||||||
//내부 오류
|
|
||||||
this._jsonResult(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
|
||||||
ModelAndView modelAndView) throws Exception {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println("===== SendInterceptor postHandle apikey ==");
|
|
||||||
|
|
||||||
System.out.println("modelAndView.getModel() : "+ modelAndView);
|
|
||||||
|
|
||||||
|
|
||||||
// Get the request returned VO by the controller
|
|
||||||
if(modelAndView != null){
|
|
||||||
Object obj = modelAndView.getModel().get("mjonResponseVO");
|
|
||||||
System.out.println("obj : "+ obj);
|
|
||||||
}
|
|
||||||
// get response getHeaders value
|
|
||||||
System.out.println("response.getHeaderNames() : "+ response.getHeaderNames());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
|
||||||
throws Exception {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
System.out.println("===== SendInterceptor afterCompletion apikey ==");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void _jsonResult(
|
|
||||||
HttpServletResponse p_response
|
|
||||||
, HttpStatus p_HttpStatus
|
|
||||||
) throws Exception{
|
|
||||||
|
|
||||||
p_response.setContentType("application/json");
|
|
||||||
p_response.setCharacterEncoding("UTF-8");
|
|
||||||
p_response.getWriter().write("{\"resultCode\":\""+p_HttpStatus.value()+"\",\"message\":\""+p_HttpStatus.getReasonPhrase()+"\"}");
|
|
||||||
|
|
||||||
//return "{\"resultCode\":\""+p_HttpStatus.value()+"\",\"message\":\""+p_HttpStatus.getReasonPhrase()+"\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -265,6 +265,17 @@ public class SendServiceImpl implements SendService {
|
|||||||
.callFrom(callFrom)
|
.callFrom(callFrom)
|
||||||
.callToList(new String[]{callTo})
|
.callToList(new String[]{callTo})
|
||||||
.smsTxt(value.toString())
|
.smsTxt(value.toString())
|
||||||
|
.eachPrice("0") // 디폴트
|
||||||
|
.sPrice("0") // 디폴트
|
||||||
|
.totPrice("0") // 디폴트
|
||||||
|
.fileCnt("0") // 디폴트
|
||||||
|
.msgType("4") // 디폴트
|
||||||
|
.smsPrice(0) // 디폴트
|
||||||
|
.mmsPrice(0) // 디폴트
|
||||||
|
.imgFilePath(new String[0]) // 디폴트
|
||||||
|
.txtReplYn("N") // 디폴트
|
||||||
|
.reserveYn("N") // 디폴트
|
||||||
|
.msgKind("N") // 디폴트
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
// 초기화
|
// 초기화
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user