Merge branch 'master' of http://yongjoon.cho@vcs.iten.co.kr:9999/hylee/mjon_api
This commit is contained in:
commit
ccbd49a2c4
8
pom.xml
8
pom.xml
@ -104,6 +104,14 @@
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.log.service.mapper.domain.LettnLoginLogVO;
|
||||
import com.itn.mjonApi.cmn.idgen.service.IdgenService;
|
||||
import com.itn.mjonApi.mjon.api.access.service.AccessKeyService;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service.mapper;
|
||||
package com.itn.mjonApi.mjon.api.access.mapper;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -1,6 +1,6 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service.mapper;
|
||||
package com.itn.mjonApi.mjon.api.access.mapper;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.cmn.idgen.mapper.domain.IdgenVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service.mapper.domain;
|
||||
package com.itn.mjonApi.mjon.api.access.mapper.domain;
|
||||
/*
|
||||
table : mj_mymsg
|
||||
comment : '내문자 보관함';
|
||||
@ -1,4 +1,4 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service.mapper.domain;
|
||||
package com.itn.mjonApi.mjon.api.access.mapper.domain;
|
||||
/*
|
||||
table : mj_mymsg
|
||||
comment : '내문자 보관함';
|
||||
@ -1,6 +1,6 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
|
||||
public interface AccessKeyService {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
|
||||
public interface AccessTokenService {
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
package com.itn.mjonApi.mjon.api.access.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.AccessKeyMapper;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.service.AccessKeyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.api.access.service.AccessKeyService;
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.AccessKeyMapper;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccessKeyServiceImpl implements AccessKeyService {
|
||||
|
||||
@ -7,11 +7,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO;
|
||||
import com.itn.mjonApi.cmn.idgen.mapper.domain.IdgenVO;
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.api.access.service.AccessTokenService;
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.AccessTokenMapper;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.AccessTokenMapper;
|
||||
|
||||
@Service
|
||||
public class AccessTokenServiceImpl implements AccessTokenService {
|
||||
|
||||
@ -1,23 +1,17 @@
|
||||
package com.itn.mjonApi.mjon.api.access.web;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.access.service.mapper.domain.SendMsgVO;
|
||||
import com.itn.mjonApi.cmn.msg.PlainResponse;
|
||||
import com.itn.mjonApi.cmn.msg.RestResponse;
|
||||
import com.itn.mjonApi.mjon.api.access.service.AccessKeyService;
|
||||
import com.itn.mjonApi.mjon.api.access.service.AccessTokenService;
|
||||
import com.itn.mjonApi.mjon.api.access.mapper.domain.SendMsgVO;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author User
|
||||
@ -98,24 +92,7 @@ public class AccessKeyRestController {
|
||||
//System.out.println(p_name_1);
|
||||
//System.out.println(p_name_2);
|
||||
|
||||
//sendMsg 문자 발송 전 체크 사항
|
||||
//step1.발신자 전화번호 사용 가능 여부 체크(해당 사용자의 기 등록된 번호만 발송 가능)
|
||||
// 1010
|
||||
|
||||
//step2.수신자 전화번호 정상 여부 체크(정상 번호에 대해서만 발송 가능)
|
||||
// 1020
|
||||
|
||||
//step3.문자 내용 정상 여부 확인 - 스미싱 문구는 발송 안됨
|
||||
// 1030
|
||||
|
||||
//step4.치환명 정상 여부 확인
|
||||
// 1040
|
||||
|
||||
//step5.발송일시 정상여부 확인
|
||||
// 1050
|
||||
|
||||
//step6.문자 타입에 따른 비용 처리 가능 여부 확인
|
||||
// 1060
|
||||
|
||||
|
||||
return ResponseEntity.ok(
|
||||
new RestResponse(
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package com.itn.mjonApi.mjon.api.inqry.service.mapper;
|
||||
package com.itn.mjonApi.mjon.api.inqry.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @packageName : com.itn.mjonApi.mjon.api.inqry.service.mapper
|
||||
* @packageName : com.itn.mjonApi.mjon.api.inqry.service
|
||||
* @fileName : PriceMapper.java
|
||||
* @author : JunHo Lee
|
||||
* @date : 2023.05.15
|
||||
@ -0,0 +1,22 @@
|
||||
package com.itn.mjonApi.mjon.api.send.mapper;
|
||||
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* packageName : com.itn.mjonApi.mjon.api.send.mapper.domain
|
||||
* fileName : SendMapper
|
||||
* author : hylee
|
||||
* date : 2023-05-19
|
||||
* description :
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2023-05-19 hylee 최초 생성
|
||||
*/
|
||||
@Mapper
|
||||
public interface SendMapper {
|
||||
|
||||
Boolean findByCallFrom(MsgRequestVO msgRequestVO);
|
||||
|
||||
}
|
||||
@ -2,8 +2,7 @@ package com.itn.mjonApi.mjon.api.send.mapper.domain;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.*;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
/**
|
||||
@ -19,10 +18,13 @@ import org.springframework.http.ResponseEntity;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MjonResponseVO {
|
||||
|
||||
private String message;
|
||||
private String result;
|
||||
private String message;
|
||||
private String resultSts; // 전송결과 갯수
|
||||
private String resultBlockSts; // 수신거부 갯수
|
||||
private String msgGroupId;
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.itn.mjonApi.mjon.api.send.mapper.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -22,6 +24,7 @@ import java.io.Serializable;
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(description = "문자 발송에 필요한 값들을 받는 vo")
|
||||
public class MsgRequestVO implements Serializable {
|
||||
|
||||
/**
|
||||
@ -31,39 +34,83 @@ public class MsgRequestVO implements Serializable {
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String smsTxt; // 'SMS용 메시지본문',
|
||||
private String[] callToList; // '수신번호리스트',
|
||||
private String callFrom; // '발신번호 (하이픈 등의 문자를 제외한 12byte이하의 숫자로 입력한다.)',
|
||||
@ApiModelProperty(value = "사용자 ID", example = "goodgkdus", required = true)
|
||||
private String mberId;
|
||||
|
||||
private String eachPrice="0"; // 전송문자 개별가격
|
||||
private String totPrice="0"; // 전송문자 토탈가격
|
||||
@ApiModelProperty(value = "Api Key", example = "0367a25ec370d1141898a0b9767103", required = true)
|
||||
private String accessKey;
|
||||
|
||||
private String fileCnt="0"; // 첨부파일 갯수
|
||||
@ApiModelProperty(value = "SMS용 메시지본문", example = "문자 메세지 본문", required = true)
|
||||
private String smsTxt;
|
||||
|
||||
@ApiModelProperty(value = "수신번호리스트", dataType = "[Ljava.lang.String;", example = "01011112222,01022223333", required = true)
|
||||
private String[] callToList;
|
||||
|
||||
@ApiModelProperty(value = "발신번호 :: 정책이 필요함", example = "01011112222", required = true)
|
||||
private String callFrom;
|
||||
|
||||
@ApiModelProperty(value = "전송문자 개별가격", example = "0", hidden = true)
|
||||
private String eachPrice="0";
|
||||
|
||||
@ApiModelProperty(value = "전송문자 토탈가격", example = "0", hidden = true)
|
||||
private String totPrice="0";
|
||||
|
||||
@ApiModelProperty(value = "첨부파일 갯수", example = "0", hidden = true)
|
||||
private String fileCnt="0";
|
||||
|
||||
@ApiModelProperty(value = "메시지의 (4: SMS 전송, 5: URL 전송, 6: MMS전송, 7: BARCODE전송, 8: 카카오 알림톡 전송)", example = "4", hidden = true)
|
||||
private String msgType="4";
|
||||
|
||||
private String msgType="4"; // '메시지의 (4: SMS 전송, 5: URL 전송, 6: MMS전송, 7: BARCODE전송, 8: 카카오 알림톡 전송)',
|
||||
// ==== 단가 ====
|
||||
private float smsPrice=0; // sms 단가 null 이면 에러
|
||||
private float mmsPrice=0; // mms 단가 null 이면 에러
|
||||
@ApiModelProperty(value = "sms 단가 null 이면 에러", example = "0", hidden = true)
|
||||
private float smsPrice=0;
|
||||
@ApiModelProperty(value = "mms 단가 null 이면 에러", example = "0", hidden = true)
|
||||
private float mmsPrice=0;
|
||||
// private float kakaoAtPrice; // 카카오 알림톡 단가
|
||||
// private float kakaoFtPrice; // 카카오 친구톡 단가
|
||||
// private float kakaoFtImgPrice;// 카카오 이미지 단가
|
||||
// private float kakaoFtWideImgPrice; // 카카오 와이드 이미지 단가
|
||||
|
||||
private String[] imgFilePath = new String[0]; // 그림 이미지 경로
|
||||
@ApiModelProperty(value = "그림 이미지 경로", example = "new String[0]", hidden = true)
|
||||
private String[] imgFilePath = new String[0];
|
||||
|
||||
|
||||
private String spamStatus; // 스팸문자 유무 (Y/N)
|
||||
@ApiModelProperty(value = "스팸문자 유무 (Y/N) - 서비스단에서 처리 함", example = "", hidden = true)
|
||||
private String spamStatus;
|
||||
|
||||
private String txtReplYn="N"; // 변환문자 유무 (Y/N)
|
||||
@ApiModelProperty(value = "변환문자 유무 (Y/N) - 서비스단에서 처리 함", example = "N", hidden = true)
|
||||
private String txtReplYn="N";
|
||||
|
||||
private String[] nameList; // '치환 이름 리스트'
|
||||
private String[] rep1List; // '치환 문자1 리스트'
|
||||
private String[] rep2List; // '치환 문자2 리스트'
|
||||
private String[] rep3List; // '치환 문자3 리스트'
|
||||
private String[] rep4List; // '치환 문자4 리스트'
|
||||
@ApiModelProperty(value = "치환 이름 리스트 |로 구분", example = "홍길동1|홍길동2|홍길동3")
|
||||
private String nameStr;
|
||||
@ApiModelProperty(value = "치환 문자1 리스트 |로 구분", example = "")
|
||||
private String rep1Str;
|
||||
@ApiModelProperty(value = "치환 문자2 리스트 |로 구분", example = "")
|
||||
private String rep2Str;
|
||||
@ApiModelProperty(value = "치환 문자3 리스트 |로 구분", example = "")
|
||||
private String rep3Str;
|
||||
@ApiModelProperty(value = "치환 문자4 리스트 |로 구분", example = "")
|
||||
private String rep4Str;
|
||||
|
||||
@ApiModelProperty(value = "nameStr 을 |로 split 후 담는 변수", example = "", hidden = true)
|
||||
private String[] nameList;
|
||||
@ApiModelProperty(value = "rep1Str 을 |로 split 후 담는 변수", example = "", hidden = true)
|
||||
private String[] rep1List;
|
||||
@ApiModelProperty(value = "rep2Str 을 |로 split 후 담는 변수", example = "", hidden = true)
|
||||
private String[] rep2List;
|
||||
@ApiModelProperty(value = "rep3Str 을 |로 split 후 담는 변수", example = "", hidden = true)
|
||||
private String[] rep3List;
|
||||
@ApiModelProperty(value = "rep4Str 을 |로 split 후 담는 변수", example = "", hidden = true)
|
||||
private String[] rep4List;
|
||||
|
||||
@ApiModelProperty(value = "예약 유무 (Y/N)", example = "N", hidden = true)
|
||||
private String reserveYn="N"; // 예약문자 여부 default N
|
||||
|
||||
// 치환 있을 경우 사용
|
||||
@ApiModelProperty(value = "치환 후 단문 건수", example = "", hidden = true)
|
||||
private String shortMsgCnt;
|
||||
@ApiModelProperty(value = "치환 후 장문 건수", example = "", hidden = true)
|
||||
private String longMsgCnt;
|
||||
|
||||
// private String msgId ;// '문자ID',
|
||||
// private String userId ; // '문자온 일반회원ID',
|
||||
|
||||
@ -1,14 +1,21 @@
|
||||
package com.itn.mjonApi.mjon.api.send.service.impl;
|
||||
|
||||
import com.itn.mjonApi.cmn.apiServer.ApiService;
|
||||
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;
|
||||
import com.itn.mjonApi.mjon.api.send.service.SendService;
|
||||
import com.itn.mjonApi.util.MunjaUtil;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -16,16 +23,93 @@ public class SendServiceImpl implements SendService {
|
||||
|
||||
private ApiService<Response> apiService;
|
||||
|
||||
@Autowired
|
||||
SendMapper sendMapper;
|
||||
@Autowired
|
||||
public SendServiceImpl(ApiService<Response> apiService) {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
private static final String replaseStrList = "[*이름*],[*1*],[*2*],[*3*],[*4*]";
|
||||
|
||||
@Override
|
||||
public MjonResponseVO sendMsgData(MsgRequestVO msgRequestVO) throws Exception {
|
||||
|
||||
log.info("msgRequestVO.getReserveYn() :: [{}]",msgRequestVO.getReserveYn());
|
||||
log.info(" :: sendMsgData ::");
|
||||
|
||||
Boolean byCallFrom = sendMapper.findByCallFrom(msgRequestVO);
|
||||
log.info(" :: byCallFrom ::" + byCallFrom);
|
||||
if(byCallFrom){
|
||||
|
||||
}
|
||||
/*
|
||||
발신번호 체크
|
||||
SELECT PHONE_NUMBER
|
||||
FROM MJ_PHONE_MEMBER
|
||||
WHERE 1=1
|
||||
AND USER_ID = 'goodgkdus'
|
||||
AND AUTH_YN = 'Y'
|
||||
AND PHM_TYPE = '01'
|
||||
ORDER BY BASE_YN DESC
|
||||
* */
|
||||
|
||||
//sendMsg 문자 발송 전 체크 사항
|
||||
//step1.발신자 전화번호 사용 가능 여부 체크(해당 사용자의 기 등록된 번호만 발송 가능)
|
||||
// 1010
|
||||
|
||||
|
||||
|
||||
//step2.수신자 전화번호 정상 여부 체크(정상 번호에 대해서만 발송 가능)
|
||||
// 1020
|
||||
|
||||
//step3.문자 내용 정상 여부 확인 - 스미싱 문구는 발송 안됨
|
||||
// 1030
|
||||
|
||||
//step4.치환명 정상 여부 확인
|
||||
// 1040
|
||||
|
||||
//step5.발송일시 정상여부 확인
|
||||
// 1050
|
||||
|
||||
//step6.문자 타입에 따른 비용 처리 가능 여부 확인
|
||||
// 1060
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
String message = "";
|
||||
// 폰번호 확인 - 빈 값 -> 유효성 정규식
|
||||
message = this.getCallToListChk(msgRequestVO);
|
||||
if(StringUtils.isNotEmpty(message)){
|
||||
return MjonResponseVO.builder()
|
||||
.result("fail")
|
||||
.message(message)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
// 치환데이터 여부 확인
|
||||
msgRequestVO.setTxtReplYn(this.getTxtReplYn(msgRequestVO));
|
||||
|
||||
if("Y".equals(msgRequestVO.getTxtReplYn())){
|
||||
|
||||
//일괄변환 문자에 콤마(,)가 들어가있으면 배열로 넘길때 문제가 발생하여 특수문자(§)로 치환하여 넘겨주도록 한다.
|
||||
msgRequestVO = this.getReplaceCommaToStrSymbol(msgRequestVO);
|
||||
|
||||
// 치환 후 단문 장문 개수 구하기
|
||||
msgRequestVO = getLengthOfShortAndLongMsg(msgRequestVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 스팸체크 하는 부분
|
||||
MjonResponseVO spamChkEntity = apiService.postForEntity(
|
||||
"/web/user/login/selectSpamTxtChkAjax.do"
|
||||
@ -37,6 +121,8 @@ public class SendServiceImpl implements SendService {
|
||||
msgRequestVO.setSpamStatus("Y");
|
||||
};
|
||||
|
||||
log.info("msgRequestVO.getSpamStatus() :: [[}]",msgRequestVO.getSpamStatus());
|
||||
|
||||
// 문자 전송하는 부분
|
||||
MjonResponseVO munjaSendResponse = apiService.postForEntity(
|
||||
"/web/user/login/sendMsgDataAjax.do"
|
||||
@ -44,10 +130,190 @@ public class SendServiceImpl implements SendService {
|
||||
, String.class
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
return munjaSendResponse;
|
||||
// return spamChkEntity;
|
||||
return null;
|
||||
// return munjaSendResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 치환 후 단문 장문 msg 개수 구하기
|
||||
* @param msgRequestVO
|
||||
* @return msgRequestVO
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private static MsgRequestVO getLengthOfShortAndLongMsg(MsgRequestVO msgRequestVO) throws UnsupportedEncodingException {
|
||||
String charset = "euc-kr";
|
||||
int totListCnt = msgRequestVO.getCallToList().length;
|
||||
|
||||
int shortMsgCnt=0; // 치환 후 단문 개수
|
||||
int longMsgCnt=0; // 치환 후 장문 개수
|
||||
for(int i=0; i < totListCnt; i ++) {
|
||||
String smsTxt = msgRequestVO.getSmsTxt().replaceAll(String.valueOf((char)13), ""); //발송 문자 내용
|
||||
|
||||
String[] nameList = msgRequestVO.getNameList(); //치환 이름 리스트
|
||||
String[] phone = msgRequestVO.getCallToList(); //수신자 휴대폰 번호
|
||||
String[] rep1 = msgRequestVO.getRep1List(); //치환 문자1 리스트
|
||||
String[] rep2 = msgRequestVO.getRep2List(); //치환 문자2 리스트
|
||||
String[] rep3 = msgRequestVO.getRep3List(); //치환 문자3 리스트
|
||||
String[] rep4 = msgRequestVO.getRep4List(); //치환 문자4 리스트
|
||||
|
||||
if (smsTxt.indexOf("[*이름*]") > -1) {
|
||||
if(nameList.length > i && StringUtils.isNotEmpty(nameList[i])) {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", MunjaUtil.getString(nameList[i].replaceAll("§", ",")));
|
||||
}else {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*이름\\*\\]", "");
|
||||
}
|
||||
}
|
||||
if (smsTxt.indexOf("[*1*]") > -1) {
|
||||
if(rep1.length > i && StringUtils.isNotEmpty(rep1[i])) {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", MunjaUtil.getString(rep1[i].replaceAll("§", ",")));
|
||||
}else {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*1\\*\\]", "");
|
||||
}
|
||||
}
|
||||
if (smsTxt.indexOf("[*2*]") > -1) {
|
||||
if(rep2.length > i && StringUtils.isNotEmpty(rep2[i])) {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", MunjaUtil.getString(rep2[i].replaceAll("§", ",")));
|
||||
}else {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*2\\*\\]", "");
|
||||
}
|
||||
}
|
||||
if (smsTxt.indexOf("[*3*]") > -1) {
|
||||
if(rep3.length > i && StringUtils.isNotEmpty(rep3[i])) {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", MunjaUtil.getString(rep3[i].replaceAll("§", ",")));
|
||||
}else {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*3\\*\\]", "");
|
||||
}
|
||||
}
|
||||
if (smsTxt.indexOf("[*4*]") > -1) {
|
||||
if(rep4.length > i && StringUtils.isNotEmpty(rep4[i])) {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", MunjaUtil.getString(rep4[i].replaceAll("§", ",")));
|
||||
}else {
|
||||
smsTxt = smsTxt.replaceAll("\\[\\*4\\*\\]", "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int bytes = smsTxt.getBytes(charset).length;
|
||||
|
||||
if(bytes > 90) {//장문문자 리스트 만들기
|
||||
longMsgCnt++;
|
||||
}else {//단문문자 리스트 만들기
|
||||
shortMsgCnt++;
|
||||
}
|
||||
}
|
||||
msgRequestVO.setLongMsgCnt(Integer.toString(longMsgCnt));
|
||||
msgRequestVO.setShortMsgCnt(Integer.toString(shortMsgCnt));
|
||||
|
||||
return msgRequestVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 치환문자가 있으면 , => §로 치환
|
||||
* @param msgRequestVO
|
||||
* @return
|
||||
*/
|
||||
private static MsgRequestVO getReplaceCommaToStrSymbol(MsgRequestVO msgRequestVO) {
|
||||
|
||||
AtomicInteger index = new AtomicInteger();
|
||||
|
||||
// 이름 배열
|
||||
if(StringUtils.isNotEmpty(msgRequestVO.getNameStr()))
|
||||
{
|
||||
msgRequestVO.setNameList(msgRequestVO.getNameStr().split("\\|"));
|
||||
String[] nameList = new String[msgRequestVO.getNameList().length];
|
||||
Arrays.stream(msgRequestVO.getNameList()).forEach(name -> {
|
||||
nameList[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(name);
|
||||
});
|
||||
msgRequestVO.setNameList(nameList);
|
||||
}
|
||||
|
||||
// Rep1 배열
|
||||
if(StringUtils.isNotEmpty(msgRequestVO.getRep1Str()))
|
||||
{
|
||||
index.set(0);
|
||||
msgRequestVO.setRep1List(msgRequestVO.getRep1Str().split("\\|"));
|
||||
String[] rep1List = new String[msgRequestVO.getRep1List().length];
|
||||
Arrays.stream(msgRequestVO.getRep1List()).forEach(str -> {
|
||||
rep1List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str);
|
||||
});
|
||||
msgRequestVO.setRep1List(rep1List);
|
||||
|
||||
}
|
||||
|
||||
// Rep2 배열
|
||||
if(StringUtils.isNotEmpty(msgRequestVO.getRep2Str()))
|
||||
{
|
||||
index.set(0);
|
||||
msgRequestVO.setRep2List(msgRequestVO.getRep2Str().split("\\|"));
|
||||
String[] rep2List = new String[msgRequestVO.getRep2List().length];
|
||||
Arrays.stream(msgRequestVO.getRep2List()).forEach(str -> {
|
||||
rep2List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str);
|
||||
});
|
||||
msgRequestVO.setRep2List(rep2List);
|
||||
}
|
||||
|
||||
// Rep3 배열
|
||||
if(StringUtils.isNotEmpty(msgRequestVO.getRep3Str()))
|
||||
{
|
||||
index.set(0);
|
||||
msgRequestVO.setRep3List(msgRequestVO.getRep3Str().split("\\|"));
|
||||
String[] rep3List = new String[msgRequestVO.getRep3List().length];
|
||||
Arrays.stream(msgRequestVO.getRep3List()).forEach(str -> {
|
||||
rep3List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str);
|
||||
});
|
||||
msgRequestVO.setRep3List(rep3List);
|
||||
}
|
||||
|
||||
// Rep4 배열
|
||||
if(StringUtils.isNotEmpty(msgRequestVO.getRep4Str()))
|
||||
{
|
||||
index.set(0);
|
||||
msgRequestVO.setRep4List(msgRequestVO.getRep4Str().split("\\|"));
|
||||
String[] rep4List = new String[msgRequestVO.getRep4List().length];
|
||||
Arrays.stream(msgRequestVO.getRep4List()).forEach(str -> {
|
||||
rep4List[index.getAndIncrement()] = MunjaUtil.replaceCommaToStrSymbol(str);
|
||||
});
|
||||
msgRequestVO.setRep4List(rep4List);
|
||||
}
|
||||
return msgRequestVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 치환 문자 여부 확인
|
||||
* @param msgRequestVO
|
||||
* @return
|
||||
*/
|
||||
private static String getTxtReplYn(MsgRequestVO msgRequestVO) {
|
||||
|
||||
int callLen = msgRequestVO.getCallToList().length;
|
||||
// 치환 데이터 확인
|
||||
Arrays.stream(replaseStrList.split(",")).forEach(
|
||||
str -> {
|
||||
if(msgRequestVO.getSmsTxt().indexOf(str) > -1){
|
||||
msgRequestVO.setTxtReplYn("Y");
|
||||
}
|
||||
}
|
||||
);
|
||||
return msgRequestVO.getTxtReplYn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 수신자 목록 번호 검증
|
||||
* @param msgRequestVO
|
||||
* @return
|
||||
*/
|
||||
private static String getCallToListChk(MsgRequestVO msgRequestVO) {
|
||||
String message = "";
|
||||
for(String callTo : msgRequestVO.getCallToList()){
|
||||
if(!MunjaUtil.checkPhoneNumberEmpty(callTo)){
|
||||
message = "수신 목록에 핸드폰 번호가 없는 항목이 있습니다."; break;};
|
||||
if(!MunjaUtil.validatePNumWithRegex(callTo)){
|
||||
message = "휴대폰 번호가 올바르지 않습니다. : " + callTo; break;};
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,8 +3,10 @@ package com.itn.mjonApi.mjon.api.send.web;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MjonResponseVO;
|
||||
import com.itn.mjonApi.mjon.api.send.mapper.domain.MsgRequestVO;
|
||||
import com.itn.mjonApi.mjon.api.send.service.SendService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@ -43,7 +45,9 @@ public class SendRestController {
|
||||
* @Discription 문자 발송 테스트
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/send/sendTest")
|
||||
@CrossOrigin("*") // 모든 요청에 접근 허용
|
||||
@PostMapping("/api/send/sendMsg")
|
||||
@ApiOperation(value= "단문 문자 전송", notes = "같은 내용으로 여러명에게 보냄")
|
||||
public MjonResponseVO sendTest(MsgRequestVO msgRequestVO) throws Exception {
|
||||
|
||||
return sendService.sendMsgData(msgRequestVO);
|
||||
|
||||
60
src/main/java/com/itn/mjonApi/util/MunjaUtil.java
Normal file
60
src/main/java/com/itn/mjonApi/util/MunjaUtil.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.itn.mjonApi.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* packageName : com.itn.mjonApi.util
|
||||
* fileName : SendUtil
|
||||
* author : hylee
|
||||
* date : 2023-05-17
|
||||
* description :
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 2023-05-17 hylee 최초 생성
|
||||
*/
|
||||
public class MunjaUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 폰번호 유효성 검사
|
||||
* @param callTo
|
||||
* @return
|
||||
*/
|
||||
public static Boolean validatePNumWithRegex(String callTo){
|
||||
// 핸드폰 정규식
|
||||
String regex = "^01(?:0|1|[6-9])(?:\\d{3}|\\d{4})\\d{4}$";
|
||||
return callTo.matches(regex) ? true : false;
|
||||
}
|
||||
/**
|
||||
* 폰번호 빈값 검사
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static Boolean checkPhoneNumberEmpty(String str){
|
||||
return StringUtils.isEmpty(str) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
public static String replaceCommaToStrSymbol(String name) {
|
||||
return name.replaceAll(",", "§");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 파라미터를 String 타입으로 가져옵니다.<br>
|
||||
* - null일 경우 빈 문자열을 가져옵니다.<br>
|
||||
* Get String(if object is null, return empty string).
|
||||
* @param Object
|
||||
* @return String
|
||||
*/
|
||||
public static String getString(Object obj) {
|
||||
if (obj == null)
|
||||
return "";
|
||||
else
|
||||
return String.valueOf(obj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
src/main/resources/mapper/Send/SendMapper.xml
Normal file
20
src/main/resources/mapper/Send/SendMapper.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.itn.mjonApi.mjon.api.send.mapper.SendMapper">
|
||||
|
||||
<select id="findByCallFrom" resultType="boolean">
|
||||
SELECT IF(COUNT(*), 1, 0)
|
||||
FROM MJ_PHONE_MEMBER
|
||||
WHERE 1=1
|
||||
AND USER_ID = #{mberId}
|
||||
AND AUTH_YN = 'Y'
|
||||
AND PHM_TYPE = '01'
|
||||
AND PHONE_NUMBER = #{callFrom}
|
||||
ORDER BY BASE_YN DESC
|
||||
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -3,9 +3,9 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.itn.mjonApi.mjon.api.access.service.mapper.AccessKeyMapper">
|
||||
<mapper namespace="com.itn.mjonApi.mjon.api.access.mapper.AccessKeyMapper">
|
||||
|
||||
<select id="findAll" resultType="com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO">
|
||||
<select id="findAll" resultType="com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO">
|
||||
SELECT
|
||||
*
|
||||
FROM lettngnrlmber_access_key
|
||||
@ -74,7 +74,7 @@
|
||||
<!-- access_key 정보 R -->
|
||||
<!-- <include refid="AccessKeyDAO.select_column_name"/> -->
|
||||
<!-- <include refid="AccessKeyDAO.table_name"/> a -->
|
||||
<select id="selectR" resultType="com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO">
|
||||
<select id="selectR" resultType="com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO">
|
||||
SELECT
|
||||
<include refid="select_column_name"/>
|
||||
FROM
|
||||
@ -84,7 +84,7 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectRKey" resultType="com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO">
|
||||
<select id="selectRKey" resultType="com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO">
|
||||
SELECT
|
||||
<include refid="select_column_name"/>
|
||||
FROM
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.itn.mjonApi.mjon.api.access.service.mapper.AccessTokenMapper">
|
||||
<mapper namespace="com.itn.mjonApi.mjon.api.access.mapper.AccessTokenMapper">
|
||||
|
||||
<select id="findAll" resultType="com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO">
|
||||
<select id="findAll" resultType="com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO">
|
||||
SELECT
|
||||
*
|
||||
FROM lettngnrlmber_access_token
|
||||
@ -74,7 +74,7 @@
|
||||
<!-- access_key 정보 R -->
|
||||
<!-- <include refid="AccessKeyDAO.select_column_name"/> -->
|
||||
<!-- <include refid="AccessKeyDAO.table_name"/> a -->
|
||||
<select id="selectR" resultType="com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO">
|
||||
<select id="selectR" resultType="com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO">
|
||||
SELECT
|
||||
<include refid="select_column_name"/>
|
||||
FROM
|
||||
@ -85,7 +85,7 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectRToken" resultType="com.itn.mjonApi.mjon.api.access.service.mapper.domain.AccessKeyVO">
|
||||
<select id="selectRToken" resultType="com.itn.mjonApi.mjon.api.access.mapper.domain.AccessKeyVO">
|
||||
SELECT
|
||||
<include refid="select_column_name"/>
|
||||
FROM
|
||||
|
||||
Loading…
Reference in New Issue
Block a user