카카오발송 진행중
This commit is contained in:
parent
2bb22a522f
commit
69803afb35
11
pom.xml
11
pom.xml
@ -144,11 +144,12 @@
|
|||||||
<version>1.1.2</version>
|
<version>1.1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
|
||||||
<groupId>cglib</groupId>
|
<dependency>
|
||||||
<artifactId>cglib</artifactId>
|
<groupId>cglib</groupId>
|
||||||
<version>3.1</version>
|
<artifactId>cglib</artifactId>
|
||||||
</dependency>
|
<version>3.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.antlr</groupId>
|
<groupId>org.antlr</groupId>
|
||||||
|
|||||||
@ -900,7 +900,8 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
|
|||||||
* @false : 알림 X
|
* @false : 알림 X
|
||||||
* @true : 알림 O */
|
* @true : 알림 O */
|
||||||
boolean isHolidayNotified = mjonCommon.handleSmishingAlert();
|
boolean isHolidayNotified = mjonCommon.handleSmishingAlert();
|
||||||
|
|
||||||
|
|
||||||
/** @LETTNGNRLMBER 사용자 정보 -> 스미싱의심 여부 */
|
/** @LETTNGNRLMBER 사용자 정보 -> 스미싱의심 여부 */
|
||||||
UserManageVO userManageVO = mjonCommon.getUserManageInfo(userId);
|
UserManageVO userManageVO = mjonCommon.getUserManageInfo(userId);
|
||||||
kakaoVO.setAtSmishingYn(userManageVO.getAtSmishingYn());
|
kakaoVO.setAtSmishingYn(userManageVO.getAtSmishingYn());
|
||||||
@ -976,6 +977,12 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(isHolidayNotified
|
||||||
|
&& "Y".equals(kakaoVO.getAtSmishingYn())) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 측정할 메소드 호출 후 시간 기록
|
// 측정할 메소드 호출 후 시간 기록
|
||||||
Instant end = Instant.now();
|
Instant end = Instant.now();
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import org.apache.commons.httpclient.HttpStatus;
|
|||||||
import org.apache.commons.httpclient.methods.PostMethod;
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.mysql.jdbc.StringUtils;
|
import com.mysql.jdbc.StringUtils;
|
||||||
@ -40,7 +41,7 @@ import itn.let.uss.umt.service.UserManageVO;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("MjonCommon")
|
@Component
|
||||||
public class MjonCommon {
|
public class MjonCommon {
|
||||||
|
|
||||||
|
|
||||||
@ -157,94 +158,76 @@ public class MjonCommon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void getAdminKakaoAtSandSlack(KakaoVO kakaoVO) {
|
||||||
* @throws Exception
|
|
||||||
* @Method Name : getAdminSlackSand
|
|
||||||
* @작성일 : 2022. 12. 6.
|
|
||||||
* @작성자 : WYH
|
|
||||||
* @Method 설명 : slack 메시지 전송
|
|
||||||
*/
|
|
||||||
/*public void getAdminMsgSandSlack(MjonMsgVO mjonMsgVO) {
|
|
||||||
|
|
||||||
HttpClient client = new HttpClient();
|
HttpClient client = new HttpClient();
|
||||||
PostMethod post = new PostMethod(url);
|
PostMethod post = new PostMethod(SLACK_URL);
|
||||||
JSONObject json = new JSONObject();
|
|
||||||
try {
|
try {
|
||||||
|
// 메시지 내용 설정
|
||||||
String reserveYn = mjonMsgVO.getReserveYn();
|
String smsTxt = formatKakaoText(kakaoVO);
|
||||||
String delayYn = mjonMsgVO.getDelayYn();
|
String sandName = formatKakaoSandName(kakaoVO);
|
||||||
String smsTxt = mjonMsgVO.getSmsTxt();
|
|
||||||
String smishingYn = mjonMsgVO.getSmishingYn();
|
// Slack 메시지 생성
|
||||||
String reservSmsTxt = "";
|
JSONObject json = new JSONObject();
|
||||||
String smisingSmsTxt = "";
|
json.put("channel", SLACK_CHANNEL);
|
||||||
//예약문자를 발송하는 경우 문자 내용 앞에 "[예약]" 표시되도록 처리
|
|
||||||
|
|
||||||
if(reserveYn.equals("Y")) {
|
|
||||||
|
|
||||||
if(smishingYn.equals("Y") || delayYn.equals("Y")) {
|
|
||||||
reservSmsTxt = "[스미싱의심][예약]" + smsTxt;
|
|
||||||
}else {
|
|
||||||
reservSmsTxt = "[예약]" + smsTxt;
|
|
||||||
}
|
|
||||||
|
|
||||||
smsTxt = reservSmsTxt;
|
|
||||||
System.out.println("smishingYn : "+ smishingYn);
|
|
||||||
System.out.println("delayYn : "+ delayYn);
|
|
||||||
}else if(smishingYn.equals("Y") || delayYn.equals("Y")) {
|
|
||||||
|
|
||||||
smisingSmsTxt = "[스미싱의심]" + smsTxt;
|
|
||||||
smsTxt = smisingSmsTxt;
|
|
||||||
}
|
|
||||||
|
|
||||||
String sandName = mjonMsgVO.getCallFrom();
|
|
||||||
String userId = mjonMsgVO.getUserId();
|
|
||||||
String msgType = "";
|
|
||||||
int fileCount = Integer.parseInt(mjonMsgVO.getFileCnt());//그림 이미지 갯수
|
|
||||||
if(mjonMsgVO.getMsgType().equals("4")) { //단문 금액
|
|
||||||
msgType = "[단문]";
|
|
||||||
}else if(mjonMsgVO.getMsgType().equals("6")){
|
|
||||||
if(fileCount == 0) {
|
|
||||||
msgType = "[장문]";
|
|
||||||
}else {
|
|
||||||
msgType = "[그림]";
|
|
||||||
// 2022.12.21 JSP => 텍스트없는 그림문자만 발송시 슬랙알림 안됨
|
|
||||||
if (StringUtils.isNullOrEmpty(smsTxt)) {
|
|
||||||
smsTxt = "그림문자 " + smsTxt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// sandName = "[" + userId + "]" + "[" + sandName + "]" + msgType;
|
|
||||||
sandName = "[개발테스트]"+"[" + userId + "]" + "[" + sandName + "]" + msgType;
|
|
||||||
|
|
||||||
json.put("channel", "mjon메시지");
|
|
||||||
json.put("text", smsTxt);
|
json.put("text", smsTxt);
|
||||||
json.put("username", sandName);
|
json.put("username", sandName);
|
||||||
|
|
||||||
|
// Slack 요청
|
||||||
post.addParameter("payload", json.toString());
|
post.addParameter("payload", json.toString());
|
||||||
// 처음에 utf-8로 content-type안넣어주니까 한글은 깨져서 content-type넣어줌
|
|
||||||
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
|
||||||
|
// Slack 응답 처리
|
||||||
int responseCode = client.executeMethod(post);
|
int responseCode = client.executeMethod(post);
|
||||||
String response = post.getResponseBodyAsString();
|
if (responseCode != HttpStatus.SC_OK) {
|
||||||
if (responseCode != HttpStatus.SC_OK) {
|
log.warn("Slack 메시지 전송 실패. Response: {}", post.getResponseBodyAsString());
|
||||||
System.out.println("Response: " + response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
System.out.println("IllegalArgumentException posting to Slack " + e);
|
log.error("Slack 메시지 전송 중 IllegalArgumentException 발생", e);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e) {
|
log.error("Slack 메시지 전송 중 IOException 발생", e);
|
||||||
System.out.println("IOException posting to Slack " + e);
|
} catch (Exception e) {
|
||||||
}
|
log.error("Slack 메시지 전송 중 Exception 발생", e);
|
||||||
catch (Exception e) {
|
|
||||||
System.out.println("Exception posting to Slack " + e);
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
post.releaseConnection();
|
post.releaseConnection();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatKakaoSandName(KakaoVO kakaoVO) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 카카오톡 메시지 텍스트 포맷팅
|
||||||
|
*/
|
||||||
|
public String formatKakaoText(KakaoVO kakaoVO) {
|
||||||
|
String smsTxt = kakaoVO.getTemplateContent();
|
||||||
|
String reserveYn = safeGetString(kakaoVO.getReserveYn());
|
||||||
|
String atDelayYn = safeGetString(kakaoVO.getAtDelayYn());
|
||||||
|
|
||||||
}*/
|
// 공통 텍스트 포맷팅 로직 적용
|
||||||
|
return formatMessagePrefix(smsTxt, reserveYn, "Y".equals(atDelayYn));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 메시지 접두사 포맷팅 공통 로직
|
||||||
|
* (예약 및 스미싱 의심 접두사 처리)
|
||||||
|
*/
|
||||||
|
private static String formatMessagePrefix(String messageText, String reserveYn, boolean isSmishing) {
|
||||||
|
if ("Y".equals(reserveYn)) {
|
||||||
|
return isSmishing ? "[스미싱의심][예약]" + messageText : "[예약]" + messageText;
|
||||||
|
} else if (isSmishing) {
|
||||||
|
return "[스미싱의심]" + messageText;
|
||||||
|
}
|
||||||
|
return messageText;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Method Name : sendSimpleSlackMsg
|
* @Method Name : sendSimpleSlackMsg
|
||||||
* @작성일 : 2022. 12. 9
|
* @작성일 : 2022. 12. 9
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user