feat: 문자 response 추가
This commit is contained in:
parent
770b338fb9
commit
6ce7aed1b1
@ -0,0 +1,61 @@
|
||||
package com.itn.mjonApi.cmn.msg;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonResponseVO;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SendFailRestResponse {
|
||||
|
||||
//private HttpStatus status;
|
||||
private String resultCode;
|
||||
|
||||
private String message;
|
||||
|
||||
private LocalDateTime localDateTime;
|
||||
|
||||
/*
|
||||
* 200-OK : 정상접속
|
||||
* 401-Unauthorized : 인증실패
|
||||
*
|
||||
* */
|
||||
|
||||
@Builder
|
||||
public SendFailRestResponse(String enumStr) {
|
||||
this.resultCode = StatMsg.valueOf(enumStr).getCode();
|
||||
this.message = StatMsg.valueOf(enumStr).getMsg();
|
||||
this.localDateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
|
||||
public static SendFailRestResponse convertMjonDataToApiResponse(MjonResponseVO mjonResponseVO) {
|
||||
String result = mjonResponseVO.getResult();
|
||||
String message = mjonResponseVO.getMessage();
|
||||
String enumStr = "";
|
||||
switch (result) {
|
||||
case "statusFail" : enumStr = "1070"; // 회원 정지
|
||||
break;
|
||||
case "smsLengFail" : enumStr = "1080"; // 문자 길이 초과
|
||||
break;
|
||||
case "fail" :
|
||||
if(message.indexOf("문자 치환 후 전송 문자 길이를 초과하였습니다.")>-1)
|
||||
enumStr = "1050"; // 치환 후 문자 길이 초과
|
||||
if(message.indexOf("치환문자 데이터가 없습니다")>-1)
|
||||
enumStr = "1040"; // 치환 데이터 오류
|
||||
if(message.indexOf("치환 후 전송 문자 길이를 초과")>-1)
|
||||
enumStr = "1050"; // 치환 데이터 오류
|
||||
break;
|
||||
default: enumStr = "1099"; // 기타 시스템 오류
|
||||
break;
|
||||
}
|
||||
|
||||
return SendFailRestResponse.builder()
|
||||
.enumStr("STAT_"+enumStr)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package com.itn.mjonApi.cmn.msg;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SendRestResponse {
|
||||
|
||||
//private HttpStatus status;
|
||||
private String resultCode;
|
||||
|
||||
private String message;
|
||||
|
||||
private LocalDateTime localDateTime;
|
||||
|
||||
/*
|
||||
* 200-OK : 정상접속
|
||||
* 401-Unauthorized : 인증실패
|
||||
*
|
||||
* */
|
||||
|
||||
@Builder
|
||||
public SendRestResponse(String resultStr) {
|
||||
this.resultCode = StatMsg.valueOf(resultStr).getCode();
|
||||
this.message = StatMsg.valueOf(resultStr).getMsg();
|
||||
this.localDateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.itn.mjonApi.cmn.msg;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonResponseVO;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class SendSuccessRestResponse {
|
||||
|
||||
//private HttpStatus status;
|
||||
private String resultCode; // 성공 코드
|
||||
|
||||
private String message; // 메세지
|
||||
|
||||
private String msgGroupId; // 문자 전송 그룹 아이디
|
||||
|
||||
private String successCnt; // 성공 건수
|
||||
|
||||
private String blockCnt; // 수신거부 건수
|
||||
|
||||
private String msgType; // 메세지 타입
|
||||
|
||||
private LocalDateTime localDateTime;
|
||||
|
||||
/*
|
||||
* 200-OK : 정상접속
|
||||
* 401-Unauthorized : 인증실패
|
||||
*
|
||||
* */
|
||||
|
||||
@Builder
|
||||
public SendSuccessRestResponse(String enumStr) {
|
||||
this.resultCode = StatMsg.valueOf(enumStr).getCode();
|
||||
this.message = StatMsg.valueOf(enumStr).getMsg();
|
||||
this.localDateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
|
||||
public static SendSuccessRestResponse convertMjonDataToApiResponse(MjonResponseVO mjonResponseVO) {
|
||||
|
||||
String enumStr = "STAT_200";
|
||||
|
||||
return SendSuccessRestResponse.builder()
|
||||
.resultCode(StatMsg.valueOf(enumStr).getCode()) // 성공 코드 200 - StatMsg 참고
|
||||
.message(StatMsg.valueOf(enumStr).getMsg()) // 성공은 message가 없음 - StatMsg 참고
|
||||
.msgGroupId(mjonResponseVO.getMsgGroupId()) // 전송 메세지 그룹 ID
|
||||
.successCnt(mjonResponseVO.getResultSts()) // 성공 건수
|
||||
.blockCnt(mjonResponseVO.getResultBlockSts()) // 수신거부 건수
|
||||
.build();
|
||||
// TODO 추가 예정
|
||||
// .msgType(mjonResponseVO.getMsgType())
|
||||
|
||||
}
|
||||
}
|
||||
@ -25,8 +25,18 @@ import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum StatMsg {
|
||||
STAT1010("1010","발신자 전화번호 사용 불가")
|
||||
,STAT1020("1020","수신자 전화번호 오류")
|
||||
STAT_200("200","")
|
||||
, STAT_1010("1010","발신자 전화번호 사용 불가")
|
||||
, STAT_1020("1020","수신자 전화번호 오류")
|
||||
, STAT_1030("1030","문자 내용 발송 불가")
|
||||
, STAT_1040("1040","치환 데이터 오류")
|
||||
, STAT_1050("1050","치환 후 문자 길이 초과")
|
||||
, STAT_1060("1060","발송 비용 부족")
|
||||
, STAT_1070("1070","서비스 이용 정지 회원")
|
||||
, STAT_1080("1080","문자 길이 초과")
|
||||
, STAT_1090("1090","요청 발송일시에 발송 불가")
|
||||
, STAT_1099("1099","기타 시스템 오류")
|
||||
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.itn.mjonApi.mjon.api.send.service;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.SendRestResponse;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
public interface SendService {
|
||||
|
||||
|
||||
SendRestResponse sendMsgData(MsgRequestVO msgRequestVO) throws Exception;
|
||||
ResponseEntity<?> sendMsgData(MsgRequestVO msgRequestVO) throws Exception;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
package com.itn.mjonApi.mjon.api.send.service.impl;
|
||||
|
||||
import com.itn.mjonApi.cmn.apiServer.ApiService;
|
||||
import com.itn.mjonApi.cmn.msg.SendRestResponse;
|
||||
import com.itn.mjonApi.cmn.msg.SendFailRestResponse;
|
||||
import com.itn.mjonApi.cmn.msg.SendSuccessRestResponse;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.SendMapper;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonResponseVO;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
|
||||
@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.connector.Response;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -34,7 +36,7 @@ public class SendServiceImpl implements SendService {
|
||||
private static final String replaseStrList = "[*이름*],[*1*],[*2*],[*3*],[*4*]";
|
||||
|
||||
@Override
|
||||
public SendRestResponse sendMsgData(MsgRequestVO msgRequestVO) throws Exception {
|
||||
public ResponseEntity<?> sendMsgData(MsgRequestVO msgRequestVO) throws Exception {
|
||||
|
||||
//sendMsg 문자 발송 전 체크 사항
|
||||
log.info(" :: sendMsgData ::");
|
||||
@ -42,14 +44,14 @@ public class SendServiceImpl implements SendService {
|
||||
//step1.발신자 전화번호 사용 가능 여부 체크(해당 사용자의 기 등록된 번호만 발송 가능)
|
||||
// 1010
|
||||
if(!sendMapper.findByCallFrom(msgRequestVO)){
|
||||
return _falseRetunDate("STAT1010");
|
||||
return ResponseEntity.ok().body(_falseRetunDate("STAT_1010"));
|
||||
}
|
||||
|
||||
//step2.수신자 전화번호 정상 여부 체크(정상 번호에 대해서만 발송 가능)
|
||||
// 1020
|
||||
// 폰번호 확인 - 빈 값 -> 유효성 정규식
|
||||
if(StringUtils.isNotEmpty(this.getCallToListChk(msgRequestVO))){
|
||||
return _falseRetunDate("STAT1020");
|
||||
return ResponseEntity.ok().body(_falseRetunDate("STAT_1020"));
|
||||
}
|
||||
|
||||
//step3.문자 내용 정상 여부 확인 - 스미싱 문구는 발송 30분 지연으로 처리됨
|
||||
@ -102,6 +104,12 @@ public class SendServiceImpl implements SendService {
|
||||
, String.class
|
||||
);
|
||||
log.info("munjaSendResponse : [{}]", munjaSendResponse.toString());
|
||||
|
||||
if(munjaSendResponse.getResult() != "fail"){ // 성공
|
||||
return ResponseEntity.ok().body(SendSuccessRestResponse.convertMjonDataToApiResponse(munjaSendResponse));
|
||||
}else{ // 실패
|
||||
return ResponseEntity.ok().body(SendFailRestResponse.convertMjonDataToApiResponse(munjaSendResponse));
|
||||
}
|
||||
//step5.발송일시 정상여부 확인
|
||||
// 1050
|
||||
|
||||
@ -109,18 +117,15 @@ public class SendServiceImpl implements SendService {
|
||||
// 1060
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
// return munjaSendResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 리턴 데이터 메소드
|
||||
* @return
|
||||
*/
|
||||
private static SendRestResponse _falseRetunDate(String ststCode) {
|
||||
return SendRestResponse.builder()
|
||||
.resultStr(ststCode)
|
||||
private static SendFailRestResponse _falseRetunDate(String ststCode) {
|
||||
return SendFailRestResponse.builder()
|
||||
.enumStr(ststCode)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.itn.mjonApi.mjon.api.send.web;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.SendRestResponse;
|
||||
import com.itn.mjonApi.cmn.msg.SendFailRestResponse;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
|
||||
import com.itn.mjonApi.mjon.api.send.service.SendService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -49,9 +49,10 @@ public class SendRestController {
|
||||
@CrossOrigin("*") // 모든 요청에 접근 허용
|
||||
@PostMapping("/api/send/sendMsg")
|
||||
@ApiOperation(value= "단문 문자 전송", notes = "같은 내용으로 여러명에게 보냄")
|
||||
public ResponseEntity<SendRestResponse> sendMsg(MsgRequestVO msgRequestVO) throws Exception {
|
||||
public ResponseEntity<?> sendMsg(MsgRequestVO msgRequestVO) throws Exception {
|
||||
|
||||
return ResponseEntity.ok().body(sendService.sendMsgData(msgRequestVO));
|
||||
// return ResponseEntity.ok().body();
|
||||
return sendService.sendMsgData(msgRequestVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user