feat: pms [#3176] 오류 수정
This commit is contained in:
parent
6039be3bcb
commit
65fe0128fb
7
pom.xml
7
pom.xml
@ -128,6 +128,13 @@
|
||||
<version>16.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</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>
|
||||
|
||||
<build>
|
||||
|
||||
@ -20,6 +20,8 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* packageName : com.itn.mjonApi.cmn.aop
|
||||
@ -96,34 +98,83 @@ public class LogAspect {
|
||||
|
||||
/**
|
||||
* @description 메소드 종료 후 return 값에 따른 로그 처리
|
||||
* - 매개변수 RestResponse는 메소드의 return 값과 일치해야 함
|
||||
* @param joinPoint
|
||||
* @param returnValue
|
||||
* @throws JsonProcessingException
|
||||
* @important 메소드의 매개변수 RestResponse는 메소드의 return 값과 일치해야 함
|
||||
*/
|
||||
@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 :: ");
|
||||
|
||||
String resutlCode = "";
|
||||
// HttpServletRequest 객체를 가져옴
|
||||
HttpServletRequest request = this.getHttpServletRequest();
|
||||
|
||||
// @Befer에서 저장한 logId를 가져옴
|
||||
String logId = (String) request.getAttribute("logId");
|
||||
|
||||
RestResponse restResponse = (RestResponse) returnValue;
|
||||
|
||||
// lettngnrlmber_access_log 응답값 Udpate
|
||||
LettnAccessLogVO lettnAccessLogVO = new LettnAccessLogVO()
|
||||
.builder()
|
||||
.logId(logId)
|
||||
.resCn(this.getJsonToString(restResponse))
|
||||
.resCn(this.mapToJson(this.getStringObjectMap(returnValue)))
|
||||
.resCode(resutlCode)
|
||||
.build();
|
||||
lettnAccessLogMapper.update(lettnAccessLogVO);
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> getStringObjectMap(Object returnValue) throws IllegalAccessException {
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||||
String val = "";
|
||||
|
||||
|
||||
// for(Field field : returnValue.getClass().getDeclaredFields()){
|
||||
// field.setAccessible(true);
|
||||
//
|
||||
// if("data".equals(field.getName()))
|
||||
// {
|
||||
// Object dataObj = field.get(returnValue);
|
||||
// for(Field dataF : dataObj.getClass().getDeclaredFields()){
|
||||
// dataF.setAccessible(true);
|
||||
// log.info("dataF.getName() :: [{}]", dataF.getName());
|
||||
// log.info("dataF.get(dataObj) :: [{}]", dataF.get(dataObj));
|
||||
// dataMap.put(dataF.getName(), this.getValChk(dataF.get(dataObj)));
|
||||
// }
|
||||
//
|
||||
// returnMap.put(field.getName(), dataMap);
|
||||
// continue;
|
||||
//
|
||||
// }
|
||||
// //field.get(returnValue) null check
|
||||
// returnMap.put(field.getName(), this.getValChk(field.get(returnValue)));
|
||||
// }
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : field.get(returnValue) null check
|
||||
* null 이면 nullPointException 발생
|
||||
* @param returnValue
|
||||
* @return
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
private static String getValChk(Object returnValue) {
|
||||
String val;
|
||||
if(returnValue == null) val = "";
|
||||
else val = returnValue.toString();
|
||||
return val;
|
||||
}
|
||||
|
||||
public String mapToJson(Map<String, Object> map) throws Exception
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.writeValueAsString(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : VO를 json으로 변환
|
||||
* @param restResponse
|
||||
|
||||
@ -264,6 +264,17 @@ public class SendServiceImpl implements SendService {
|
||||
.callFrom(callFrom)
|
||||
.callToList(new String[]{callTo})
|
||||
.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()
|
||||
);
|
||||
// 초기화
|
||||
|
||||
Loading…
Reference in New Issue
Block a user