This commit is contained in:
myname 2023-05-24 17:28:47 +09:00
commit 4bac396dba
8 changed files with 87 additions and 31 deletions

View File

@ -112,6 +112,10 @@
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -2,7 +2,9 @@ package com.itn.mjonApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@EnableAspectJAutoProxy // AOP를 사용하기 위한 어노테이션
@SpringBootApplication
public class MjonApiApplication {

View File

@ -0,0 +1,57 @@
package com.itn.mjonApi.cmn.aop;
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
/**
* packageName : com.itn.mjonApi.cmn.aop
* fileName : SendAspect
* author : hylee
* date : 2023-05-24
* description : send package 관련 AOP
* ===========================================================
* DATE AUTHOR NOTE
* -----------------------------------------------------------
* 2023-05-24 hylee 최초 생성
*/
@Slf4j
@Aspect
@Component
public class SendAspect {
@Before(value = "execution(* com.itn.mjonApi.mjon.api.send.service.impl.SendServiceImpl.sendMsgData(..))" )
public void before(JoinPoint joinPoint){
log.info(" :: SendAspect before :: ");
//메서드에 들어가는 매개변수 배열을 읽어옴
Object[] args = joinPoint.getArgs();
log.info("args[0] : [{}]", args[0]);
MsgRequestVO msgRequestVO = (MsgRequestVO) args[0];
log.info("msgRequestVO : [{}]", msgRequestVO.getSmsTxt());
}
@AfterReturning(pointcut = "execution(* com.itn.mjonApi.mjon.api.send.service.impl.SendServiceImpl.sendMsgData(..))", returning = "returnValue")
public void afterReturning(JoinPoint joinPoint, ResponseEntity<?> returnValue){
log.info(" :: AfterReturning :: ");
String bodyClassName = returnValue.getBody().toString();
log.info("bodyClassName : [{}]", bodyClassName);
// body에 담긴 calss가 SendSuccessRestResponse이면
if(bodyClassName.indexOf("SendSuccessRestResponse") > -1){
}
}
}

View File

@ -47,15 +47,6 @@ public class WebConfig implements WebMvcConfigurer {
.order(0)
;
/**
* 2023-05-16
* send에 대한 interceptor 설정 - lettngnrlmber_access_log Insert
* 진행중
*/
registry.addInterceptor(sendInterceptor())
.addPathPatterns("/api/send/**")
.order(1)
;
//.excludePathPatterns("/css/**", "/images/**", "/js/**");
}

View File

@ -34,7 +34,6 @@ public class RestResponse{
public RestResponse(HttpStatus status, String message, LocalDateTime timestamp, Object object) {
this.resultCode = status.value();
checkMessage(status, message);
this.object= object;
this.localDateTime = timestamp;
}

View File

@ -56,9 +56,8 @@ public class SendSuccessRestResponse {
.successCnt(mjonResponseVO.getResultSts()) // 성공 건수
.blockCnt(mjonResponseVO.getResultBlockSts()) // 수신거부 건수
.localDateTime(LocalDateTime.now()) // 현재 시간
.msgType(StatMsg.valueOf("msgType"+mjonResponseVO.getMsgType()).getMsg())
.build();
// TODO 추가 예정
// .msgType(mjonResponseVO.getMsgType())
}

View File

@ -7,7 +7,7 @@ import lombok.Getter;
* fileName : statMsg
* author : hylee
* date : 2023-05-19
* description :
* description : CODE, MSG 관리 class
* ===========================================================
* DATE AUTHOR NOTE
* -----------------------------------------------------------
@ -25,6 +25,7 @@ import lombok.Getter;
@Getter
public enum StatMsg {
// 문자보내기 ======================================================================
STAT_200("200","")
, STAT_1010("1010","발신자 전화번호 사용 불가")
, STAT_1020("1020","수신자 전화번호 오류")
@ -37,6 +38,14 @@ public enum StatMsg {
, STAT_1090("1090","요청 발송일시에 발송 불가")
, STAT_1099("1099","기타 시스템 오류")
//======================================================================
, msgType4("단문","SMS")
, msgType6("장문","LMS")
;
private final String code;

View File

@ -99,7 +99,7 @@ public class SendServiceImpl implements SendService {
msgRequestVO = getLengthOfShortAndLongMsg(msgRequestVO);
}
/*
// 문자 전송하는 부분
// apiService.postForEntity => restTemplate.postForEntity 호출 MjonResponseVO에 맞게 데이터 정제하는 메소드
MjonResponseVO munjaSendResponse = apiService.postForEntity(
@ -115,6 +115,11 @@ public class SendServiceImpl implements SendService {
}else{ // 실패
return ResponseEntity.ok().body(FailRestResponse.convertMjonDataToApiResponse(munjaSendResponse));
}
*/
SendSuccessRestResponse sendSuccessRestResponse = new SendSuccessRestResponse();
sendSuccessRestResponse.setMsgGroupId("1234567890");
return ResponseEntity.ok().body(sendSuccessRestResponse);
// return ResponseEntity.ok().body(new RestResponse(sendSuccessRestResponse));
//step5.발송일시 정상여부 확인
// 1050
//step6.문자 타입에 따른 비용 처리 가능 여부 확인
@ -126,9 +131,9 @@ public class SendServiceImpl implements SendService {
@Override
public ResponseEntity<?> sendMsgsData(MsgsRequestVO msgsRequestVO) throws Exception {
// msgsVO -> msgVO List로 변환
List<MsgRequestVO> msgRequestVOList = this.getDataCleaning(msgsRequestVO);
log.info("msgRequestVOList.size() :: [{}]", msgRequestVOList.size());
msgRequestVOList.forEach(msgRequestVO -> {
log.info("msgRequestVO getCallToList() :: [{}]", msgRequestVO.getCallToList());
log.info("msgRequestVO getSmsTxt() :: [{}]", msgRequestVO.getSmsTxt());
@ -185,7 +190,7 @@ public class SendServiceImpl implements SendService {
}
/**
* @description
* @description 최대 1~100개의 수신번호와 메세지를 MsgRequestVO로 정재하는 메소드.
* @param msgsRequestVO
* @return
*/
@ -218,8 +223,10 @@ public class SendServiceImpl implements SendService {
// nullPointException 방지
if(value != null)
{
log.info(field.getName());
/**
* 필드 이름으로 분기하여
* 각각에 맞는 위치에 값을 넣어준다.
*/
if("mberId".equals(field.getName())){ // 사용자 ID
mberId = value.toString();
}else if("accessKey".equals(field.getName())){ // accessKey
@ -232,19 +239,10 @@ public class SendServiceImpl implements SendService {
// 값이 비여 있으면 다음 반복문으로 넘어간다.
if(StringUtils.isEmpty(value.toString())){
callTo = "";
continue;
}
// MsgRequestVO msgRequestVO = new MsgRequestVO();
// msgRequestVO.setMberId(mberId);
// msgRequestVO.setAccessKey(accessKey);
// msgRequestVO.setCallFrom(callFrom);
// msgRequestVO.setCallToList(new String[]{callTo});
// msgRequestVO.setSmsTxt(value.toString());
msgRequestVOList.add(
MsgRequestVO.builder()
.mberId(mberId)
@ -254,11 +252,8 @@ public class SendServiceImpl implements SendService {
.smsTxt(value.toString())
.build()
);
// 초기화
callTo = "";
}