feat: api log 변경 처리 중
This commit is contained in:
parent
ecc7e0042f
commit
08d81992e3
@ -7,11 +7,14 @@ import com.itn.mjonApi.cmn.idgen.service.IdgenService;
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.cmn.msg.SendSucRestResponse;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgsRequestVO;
|
||||
import com.itn.mjonApi.mjon.log.service.mapper.LettnAccessLogMapper;
|
||||
import com.itn.mjonApi.mjon.log.service.mapper.LettnApiSendMsgLogMapper;
|
||||
import com.itn.mjonApi.mjon.log.service.mapper.domain.LettnAccessLogVO;
|
||||
import com.itn.mjonApi.mjon.log.service.mapper.domain.LettnApiSendMsgLogVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
@ -66,7 +69,7 @@ public class LogAspect {
|
||||
* - accessKey
|
||||
*/
|
||||
@Before(value = "execution(* com.itn.mjonApi.mjon.api.*..*Impl.*(..))" )
|
||||
public void before(JoinPoint joinPoint) throws IllegalAccessException {
|
||||
public void before(JoinPoint joinPoint) throws IllegalAccessException, JsonProcessingException {
|
||||
log.info(" :: AOP before :: ");
|
||||
|
||||
HttpServletRequest request = this.getHttpServletRequest();
|
||||
@ -81,12 +84,13 @@ public class LogAspect {
|
||||
// 필드명으로 구분하여 값을 가져옴
|
||||
String mberId = "";
|
||||
String accessKey = "";
|
||||
for(Field field : objectVO.getClass().getDeclaredFields()){
|
||||
for(Field field : objectVO.getClass().getDeclaredFields()){;
|
||||
field.setAccessible(true);
|
||||
if("mberId".equals(field.getName())){ mberId=field.get(objectVO).toString(); }
|
||||
if("accessKey".equals(field.getName())){ accessKey=field.get(objectVO).toString(); }
|
||||
}
|
||||
else if("accessKey".equals(field.getName())){ accessKey=field.get(objectVO).toString(); }
|
||||
|
||||
if(StringUtils.isNotEmpty(mberId) && StringUtils.isNotEmpty(accessKey)){ break; }
|
||||
}
|
||||
|
||||
String nextStringId = idgenApiAccessLogId.getNextStringId();
|
||||
LettnAccessLogVO lettnAccessLogVO = new LettnAccessLogVO()
|
||||
@ -95,8 +99,8 @@ public class LogAspect {
|
||||
.accessType("K") // key : K , token : T // TODO accessType 구분추가
|
||||
.accessKey(accessKey)
|
||||
.reqUserId(mberId)
|
||||
.reqCn(joinPoint.toString())
|
||||
.reqInfoRef(request.getHeader("Referer"))
|
||||
.reqCn(this.getJsonToString(objectVO))
|
||||
.reqInfoMeth(joinPoint.toString())
|
||||
.reqUrl(request.getRequestURI())
|
||||
.build();
|
||||
if (lettnAccessLogVO.getReqUrl().length() > 200) { //길이문제로 오류가 발생하는 경우도 처리하도록 수정
|
||||
@ -187,7 +191,7 @@ public class LogAspect {
|
||||
|
||||
return LettnApiSendMsgLogVO.builder()
|
||||
.logNo(idgenApiSendLogId.getNextStringId())
|
||||
.mberId(logId)
|
||||
.accessLogId(logId)
|
||||
.msgSendType(msgSendType)
|
||||
.msgGroupId(msgGroupId)
|
||||
.build();
|
||||
@ -243,10 +247,20 @@ public class LogAspect {
|
||||
if("AccessKeyVO".equals(classNm)) {
|
||||
AccessKeyVO accessKeyVO = (AccessKeyVO) returnValue;
|
||||
return this.getAccessKeyVOToJsonString(accessKeyVO);
|
||||
}else if("RestResponse".equals(classNm)){
|
||||
}
|
||||
else if("RestResponse".equals(classNm)){
|
||||
RestResponse restResponse = (RestResponse) returnValue;
|
||||
return this.getRestResponseToJsonString(restResponse);
|
||||
}else{
|
||||
}
|
||||
else if("MsgsRequestVO".equals(classNm)){
|
||||
MsgsRequestVO msgsRequestVO = (MsgsRequestVO) returnValue;
|
||||
return this.getMsgsRequestVOToJsonString(msgsRequestVO);
|
||||
}
|
||||
else if("MsgRequestVO".equals(classNm)){
|
||||
MsgRequestVO restResponse = (MsgRequestVO) returnValue;
|
||||
return this.getMsgRequestVOToJsonString(restResponse);
|
||||
}
|
||||
else{
|
||||
return "데이터를 추가해 주세요";
|
||||
}
|
||||
|
||||
@ -267,6 +281,16 @@ public class LogAspect {
|
||||
// .registerModule(new JavaTimeModule()) : LocalDateTime을 json으로 변환하기 위함
|
||||
return objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(restResponse);
|
||||
}
|
||||
private static String getMsgsRequestVOToJsonString(MsgsRequestVO msgsRequestVO) throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// .registerModule(new JavaTimeModule()) : LocalDateTime을 json으로 변환하기 위함
|
||||
return objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(msgsRequestVO);
|
||||
}
|
||||
private static String getMsgRequestVOToJsonString(MsgRequestVO msgRequestVO) throws JsonProcessingException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// .registerModule(new JavaTimeModule()) : LocalDateTime을 json으로 변환하기 위함
|
||||
return objectMapper.registerModule(new JavaTimeModule()).writeValueAsString(msgRequestVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : VO를 json으로 변환
|
||||
|
||||
@ -28,6 +28,8 @@ public class SendSucRestResponse {
|
||||
private String failCnt; // 실패 건수
|
||||
|
||||
private String msgType; // 메세지 타입
|
||||
|
||||
private List<String> msgTypeList; // 메세지 타입 리스트
|
||||
|
||||
private String test_yn; // 메세지 타입
|
||||
|
||||
@ -80,6 +82,10 @@ public class SendSucRestResponse {
|
||||
.map(s -> s.getMsgGroupId())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 성공한 메세지 그룹 아이디
|
||||
List<String> msgTypeList = mjonResponseVOList.stream()
|
||||
.map(s -> StatMsg.valueOf("msgType"+s.getMsgType()).getMsg())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
|
||||
@ -90,7 +96,7 @@ public class SendSucRestResponse {
|
||||
.successCnt(Integer.toString(successCnt)) // 성공 건수
|
||||
.blockCnt(Integer.toString(blockCnt)) // 수신거부 건수
|
||||
.failCnt(Integer.toString(failCnt)) // 수신거부 건수
|
||||
// .localDateTime(LocalDateTime.now()) // 현재 시간
|
||||
.msgTypeList(msgTypeList) // msgType List
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@ -131,6 +131,7 @@ public class SendServiceImpl implements SendService {
|
||||
.blockCnt("2") // 수신거부 건수
|
||||
.msgType("LMS")
|
||||
.failCnt("0")
|
||||
.test_yn("YS")
|
||||
.build()
|
||||
);
|
||||
}
|
||||
@ -151,12 +152,17 @@ public class SendServiceImpl implements SendService {
|
||||
gIdList.add("MSGGID_0000000000001");
|
||||
gIdList.add("MSGGID_0000000000002");
|
||||
|
||||
List<String> msgTypeList = new ArrayList<>();
|
||||
msgTypeList.add("SMS");
|
||||
msgTypeList.add("LMS");
|
||||
msgTypeList.add("LMS");
|
||||
return new RestResponse(
|
||||
SendSucRestResponse.builder()
|
||||
.resultCode("0")
|
||||
.msgGroupIdList(gIdList) // 전송 메세지 그룹 ID
|
||||
.successCnt("2") // 성공 건수
|
||||
.blockCnt("1") // 수신거부 건수
|
||||
.msgType("LMS")
|
||||
.msgTypeList(msgTypeList)
|
||||
.failCnt("0")
|
||||
.test_yn("YS")
|
||||
.build()
|
||||
|
||||
@ -29,7 +29,7 @@ public class LettnAccessLogVO implements Serializable {
|
||||
private String accessToken; //access_token 고유번호
|
||||
private String reqUserId; //호출자 USER_ID(요청 사이트의 로그인 ID)
|
||||
private String reqCn; //요청내용
|
||||
private String reqInfoRef; //요청 referer 값
|
||||
private String reqInfoMeth; //요청 메소드 정보
|
||||
private String reqUrl; //요청 URL
|
||||
private String resCn; //응답내용
|
||||
private String resCode; //응답코드
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
package com.itn.mjonApi.mjon.log.service.mapper.domain;
|
||||
/*
|
||||
table : mj_mymsg
|
||||
comment : '내문자 보관함';
|
||||
*/
|
||||
|
||||
/**
|
||||
* packageName : com.itn.mjonApi.mjon.log.service.mapper.domain
|
||||
* fileName : LettnApiSendMsgLogVO
|
||||
* author : hylee
|
||||
* date : 2023-06-15
|
||||
* description : lettngnrlmber_api_send_msg_log Table VO
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2023-05-09 hylee 최초 생성
|
||||
*/
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@ -18,7 +26,9 @@ public class LettnApiSendMsgLogVO implements Serializable {
|
||||
|
||||
|
||||
private String logNo; // access log 고유번호
|
||||
private String mberId; // 일반회원ID
|
||||
private String accessLogId; // 일반회원ID
|
||||
private String sendResultCode; // 메세지 정송 결과 코드
|
||||
private String testYn; // 테스트 여부 (실 발송 : "", 실패 테스트 : "YF", 성공 테스트 "YS")
|
||||
private String msgSendType; // 문자 : msg 대량문자 : msgs
|
||||
private String msgGroupId; // 문자 그룹 ID
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
, ACCESS_TOKEN
|
||||
, REQ_USER_ID
|
||||
, REQ_CN
|
||||
, REQ_INFO_REF
|
||||
, REQ_INFO_METH
|
||||
, REQ_URL
|
||||
, RES_CN
|
||||
, RES_CODE
|
||||
@ -49,7 +49,7 @@
|
||||
, #{accessToken }
|
||||
, #{reqUserId }
|
||||
, #{reqCn }
|
||||
, #{reqInfoRef }
|
||||
, #{reqInfoMeth }
|
||||
, #{reqUrl }
|
||||
, #{resCn }
|
||||
, #{resCode }
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<sql id="select_column_name">
|
||||
|
||||
LOG_NO
|
||||
, MBER_ID
|
||||
, ACCESS_LOG_ID
|
||||
, MSG_SEND_TYPE
|
||||
, MSG_GROUP_ID
|
||||
, REQ_REGIST_PNTTM
|
||||
@ -27,11 +27,10 @@
|
||||
<sql id="insert_column_name">
|
||||
|
||||
LOG_NO
|
||||
, MBER_ID
|
||||
, ACCESS_LOG_ID
|
||||
, MSG_SEND_TYPE
|
||||
, MSG_GROUP_ID
|
||||
, REQ_REGIST_PNTTM
|
||||
, REQ_REGISTER_ID
|
||||
|
||||
</sql>
|
||||
|
||||
@ -43,11 +42,10 @@
|
||||
)
|
||||
VALUE (
|
||||
#{logNo}
|
||||
, #{mberId}
|
||||
, #{accessLogId}
|
||||
, #{msgSendType}
|
||||
, #{msgGroupId}
|
||||
, now()
|
||||
, #{mberId}
|
||||
)
|
||||
|
||||
</insert>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user