diff --git a/pom.xml b/pom.xml
index 5878c03c..7a7f5633 100644
--- a/pom.xml
+++ b/pom.xml
@@ -144,11 +144,12 @@
1.1.2
-
- cglib
- cglib
- 3.1
-
+
+
+ cglib
+ cglib
+ 3.3.0
+
org.antlr
diff --git a/src/main/java/itn/let/kakao/user/kakaoAt/service/impl/KakaoAlimTalkServiceImpl.java b/src/main/java/itn/let/kakao/user/kakaoAt/service/impl/KakaoAlimTalkServiceImpl.java
index bd4176fc..1093c97f 100644
--- a/src/main/java/itn/let/kakao/user/kakaoAt/service/impl/KakaoAlimTalkServiceImpl.java
+++ b/src/main/java/itn/let/kakao/user/kakaoAt/service/impl/KakaoAlimTalkServiceImpl.java
@@ -900,7 +900,8 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
* @false : 알림 X
* @true : 알림 O */
boolean isHolidayNotified = mjonCommon.handleSmishingAlert();
-
+
+
/** @LETTNGNRLMBER 사용자 정보 -> 스미싱의심 여부 */
UserManageVO userManageVO = mjonCommon.getUserManageInfo(userId);
kakaoVO.setAtSmishingYn(userManageVO.getAtSmishingYn());
@@ -976,6 +977,12 @@ public class KakaoAlimTalkServiceImpl extends EgovAbstractServiceImpl implements
}
+ if(isHolidayNotified
+ && "Y".equals(kakaoVO.getAtSmishingYn())) {
+
+ }
+
+
// 측정할 메소드 호출 후 시간 기록
Instant end = Instant.now();
diff --git a/src/main/java/itn/let/mjo/mjocommon/MjonCommon.java b/src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
index dcbaf78f..1dd3af64 100644
--- a/src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
+++ b/src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
@@ -16,6 +16,7 @@ import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.mysql.jdbc.StringUtils;
@@ -40,7 +41,7 @@ import itn.let.uss.umt.service.UserManageVO;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-@Service("MjonCommon")
+@Component
public class MjonCommon {
@@ -157,94 +158,76 @@ public class MjonCommon {
}
}
- /**
- * @throws Exception
- * @Method Name : getAdminSlackSand
- * @작성일 : 2022. 12. 6.
- * @작성자 : WYH
- * @Method 설명 : slack 메시지 전송
- */
- /*public void getAdminMsgSandSlack(MjonMsgVO mjonMsgVO) {
-
+ public void getAdminKakaoAtSandSlack(KakaoVO kakaoVO) {
HttpClient client = new HttpClient();
- PostMethod post = new PostMethod(url);
- JSONObject json = new JSONObject();
+ PostMethod post = new PostMethod(SLACK_URL);
+
try {
-
- String reserveYn = mjonMsgVO.getReserveYn();
- String delayYn = mjonMsgVO.getDelayYn();
- String smsTxt = mjonMsgVO.getSmsTxt();
- String smishingYn = mjonMsgVO.getSmishingYn();
- String reservSmsTxt = "";
- String smisingSmsTxt = "";
- //예약문자를 발송하는 경우 문자 내용 앞에 "[예약]" 표시되도록 처리
-
- 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메시지");
+ // 메시지 내용 설정
+ String smsTxt = formatKakaoText(kakaoVO);
+ String sandName = formatKakaoSandName(kakaoVO);
+
+ // Slack 메시지 생성
+ JSONObject json = new JSONObject();
+ json.put("channel", SLACK_CHANNEL);
json.put("text", smsTxt);
json.put("username", sandName);
-
-
+
+ // Slack 요청
post.addParameter("payload", json.toString());
- // 처음에 utf-8로 content-type안넣어주니까 한글은 깨져서 content-type넣어줌
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
+
+ // Slack 응답 처리
int responseCode = client.executeMethod(post);
- String response = post.getResponseBodyAsString();
- if (responseCode != HttpStatus.SC_OK) {
- System.out.println("Response: " + response);
+ if (responseCode != HttpStatus.SC_OK) {
+ log.warn("Slack 메시지 전송 실패. Response: {}", post.getResponseBodyAsString());
}
+
} catch (IllegalArgumentException e) {
- System.out.println("IllegalArgumentException posting to Slack " + e);
- }
- catch (IOException e) {
- System.out.println("IOException posting to Slack " + e);
- }
- catch (Exception e) {
- System.out.println("Exception posting to Slack " + e);
- e.printStackTrace();
+ log.error("Slack 메시지 전송 중 IllegalArgumentException 발생", e);
+ } catch (IOException e) {
+ log.error("Slack 메시지 전송 중 IOException 발생", e);
+ } catch (Exception e) {
+ log.error("Slack 메시지 전송 중 Exception 발생", e);
} finally {
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
* @작성일 : 2022. 12. 9