--- pom.xml
+++ pom.xml
... | ... | @@ -144,11 +144,12 @@ |
| 144 | 144 |
<version>1.1.2</version> |
| 145 | 145 |
</dependency> |
| 146 | 146 |
|
| 147 |
- <dependency> |
|
| 148 |
- <groupId>cglib</groupId> |
|
| 149 |
- <artifactId>cglib</artifactId> |
|
| 150 |
- <version>3.1</version> |
|
| 151 |
- </dependency> |
|
| 147 |
+ <!-- https://mvnrepository.com/artifact/cglib/cglib --> |
|
| 148 |
+ <dependency> |
|
| 149 |
+ <groupId>cglib</groupId> |
|
| 150 |
+ <artifactId>cglib</artifactId> |
|
| 151 |
+ <version>3.3.0</version> |
|
| 152 |
+ </dependency> |
|
| 152 | 153 |
|
| 153 | 154 |
<dependency> |
| 154 | 155 |
<groupId>org.antlr</groupId> |
--- src/main/java/itn/let/kakao/user/kakaoAt/service/impl/KakaoAlimTalkServiceImpl.java
+++ src/main/java/itn/let/kakao/user/kakaoAt/service/impl/KakaoAlimTalkServiceImpl.java
... | ... | @@ -900,7 +900,8 @@ |
| 900 | 900 |
* @false : 알림 X |
| 901 | 901 |
* @true : 알림 O */ |
| 902 | 902 |
boolean isHolidayNotified = mjonCommon.handleSmishingAlert(); |
| 903 |
- |
|
| 903 |
+ |
|
| 904 |
+ |
|
| 904 | 905 |
/** @LETTNGNRLMBER 사용자 정보 -> 스미싱의심 여부 */ |
| 905 | 906 |
UserManageVO userManageVO = mjonCommon.getUserManageInfo(userId); |
| 906 | 907 |
kakaoVO.setAtSmishingYn(userManageVO.getAtSmishingYn()); |
... | ... | @@ -976,6 +977,12 @@ |
| 976 | 977 |
} |
| 977 | 978 |
|
| 978 | 979 |
|
| 980 |
+ if(isHolidayNotified |
|
| 981 |
+ && "Y".equals(kakaoVO.getAtSmishingYn())) {
|
|
| 982 |
+ |
|
| 983 |
+ } |
|
| 984 |
+ |
|
| 985 |
+ |
|
| 979 | 986 |
// 측정할 메소드 호출 후 시간 기록 |
| 980 | 987 |
Instant end = Instant.now(); |
| 981 | 988 |
|
--- src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
+++ src/main/java/itn/let/mjo/mjocommon/MjonCommon.java
... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 |
import org.apache.commons.httpclient.methods.PostMethod; |
| 17 | 17 |
import org.json.simple.JSONObject; |
| 18 | 18 |
import org.springframework.beans.factory.annotation.Value; |
| 19 |
+import org.springframework.stereotype.Component; |
|
| 19 | 20 |
import org.springframework.stereotype.Service; |
| 20 | 21 |
|
| 21 | 22 |
import com.mysql.jdbc.StringUtils; |
... | ... | @@ -40,7 +41,7 @@ |
| 40 | 41 |
import lombok.extern.slf4j.Slf4j; |
| 41 | 42 |
|
| 42 | 43 |
@Slf4j |
| 43 |
-@Service("MjonCommon")
|
|
| 44 |
+@Component |
|
| 44 | 45 |
public class MjonCommon {
|
| 45 | 46 |
|
| 46 | 47 |
|
... | ... | @@ -157,94 +158,76 @@ |
| 157 | 158 |
} |
| 158 | 159 |
} |
| 159 | 160 |
|
| 160 |
- /** |
|
| 161 |
- * @throws Exception |
|
| 162 |
- * @Method Name : getAdminSlackSand |
|
| 163 |
- * @작성일 : 2022. 12. 6. |
|
| 164 |
- * @작성자 : WYH |
|
| 165 |
- * @Method 설명 : slack 메시지 전송 |
|
| 166 |
- */ |
|
| 167 |
- /*public void getAdminMsgSandSlack(MjonMsgVO mjonMsgVO) {
|
|
| 168 |
- |
|
| 161 |
+ public void getAdminKakaoAtSandSlack(KakaoVO kakaoVO) {
|
|
| 169 | 162 |
HttpClient client = new HttpClient(); |
| 170 |
- PostMethod post = new PostMethod(url); |
|
| 171 |
- JSONObject json = new JSONObject(); |
|
| 163 |
+ PostMethod post = new PostMethod(SLACK_URL); |
|
| 164 |
+ |
|
| 172 | 165 |
try {
|
| 173 |
- |
|
| 174 |
- String reserveYn = mjonMsgVO.getReserveYn(); |
|
| 175 |
- String delayYn = mjonMsgVO.getDelayYn(); |
|
| 176 |
- String smsTxt = mjonMsgVO.getSmsTxt(); |
|
| 177 |
- String smishingYn = mjonMsgVO.getSmishingYn(); |
|
| 178 |
- String reservSmsTxt = ""; |
|
| 179 |
- String smisingSmsTxt = ""; |
|
| 180 |
- //예약문자를 발송하는 경우 문자 내용 앞에 "[예약]" 표시되도록 처리 |
|
| 181 |
- |
|
| 182 |
- if(reserveYn.equals("Y")) {
|
|
| 183 |
- |
|
| 184 |
- if(smishingYn.equals("Y") || delayYn.equals("Y")) {
|
|
| 185 |
- reservSmsTxt = "[스미싱의심][예약]" + smsTxt; |
|
| 186 |
- }else {
|
|
| 187 |
- reservSmsTxt = "[예약]" + smsTxt; |
|
| 188 |
- } |
|
| 189 |
- |
|
| 190 |
- smsTxt = reservSmsTxt; |
|
| 191 |
- System.out.println("smishingYn : "+ smishingYn);
|
|
| 192 |
- System.out.println("delayYn : "+ delayYn);
|
|
| 193 |
- }else if(smishingYn.equals("Y") || delayYn.equals("Y")) {
|
|
| 194 |
- |
|
| 195 |
- smisingSmsTxt = "[스미싱의심]" + smsTxt; |
|
| 196 |
- smsTxt = smisingSmsTxt; |
|
| 197 |
- } |
|
| 198 |
- |
|
| 199 |
- String sandName = mjonMsgVO.getCallFrom(); |
|
| 200 |
- String userId = mjonMsgVO.getUserId(); |
|
| 201 |
- String msgType = ""; |
|
| 202 |
- int fileCount = Integer.parseInt(mjonMsgVO.getFileCnt());//그림 이미지 갯수 |
|
| 203 |
- if(mjonMsgVO.getMsgType().equals("4")) { //단문 금액
|
|
| 204 |
- msgType = "[단문]"; |
|
| 205 |
- }else if(mjonMsgVO.getMsgType().equals("6")){
|
|
| 206 |
- if(fileCount == 0) {
|
|
| 207 |
- msgType = "[장문]"; |
|
| 208 |
- }else {
|
|
| 209 |
- msgType = "[그림]"; |
|
| 210 |
- // 2022.12.21 JSP => 텍스트없는 그림문자만 발송시 슬랙알림 안됨 |
|
| 211 |
- if (StringUtils.isNullOrEmpty(smsTxt)) {
|
|
| 212 |
- smsTxt = "그림문자 " + smsTxt; |
|
| 213 |
- } |
|
| 214 |
- } |
|
| 215 |
- } |
|
| 216 |
-// sandName = "[" + userId + "]" + "[" + sandName + "]" + msgType; |
|
| 217 |
- sandName = "[개발테스트]"+"[" + userId + "]" + "[" + sandName + "]" + msgType; |
|
| 218 |
- |
|
| 219 |
- json.put("channel", "mjon메시지");
|
|
| 166 |
+ // 메시지 내용 설정 |
|
| 167 |
+ String smsTxt = formatKakaoText(kakaoVO); |
|
| 168 |
+ String sandName = formatKakaoSandName(kakaoVO); |
|
| 169 |
+ |
|
| 170 |
+ // Slack 메시지 생성 |
|
| 171 |
+ JSONObject json = new JSONObject(); |
|
| 172 |
+ json.put("channel", SLACK_CHANNEL);
|
|
| 220 | 173 |
json.put("text", smsTxt);
|
| 221 | 174 |
json.put("username", sandName);
|
| 222 |
- |
|
| 223 |
- |
|
| 175 |
+ |
|
| 176 |
+ // Slack 요청 |
|
| 224 | 177 |
post.addParameter("payload", json.toString());
|
| 225 |
- // 처음에 utf-8로 content-type안넣어주니까 한글은 깨져서 content-type넣어줌 |
|
| 226 | 178 |
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
| 179 |
+ |
|
| 180 |
+ // Slack 응답 처리 |
|
| 227 | 181 |
int responseCode = client.executeMethod(post); |
| 228 |
- String response = post.getResponseBodyAsString(); |
|
| 229 |
- if (responseCode != HttpStatus.SC_OK) {
|
|
| 230 |
- System.out.println("Response: " + response);
|
|
| 182 |
+ if (responseCode != HttpStatus.SC_OK) {
|
|
| 183 |
+ log.warn("Slack 메시지 전송 실패. Response: {}", post.getResponseBodyAsString());
|
|
| 231 | 184 |
} |
| 185 |
+ |
|
| 232 | 186 |
} catch (IllegalArgumentException e) {
|
| 233 |
- System.out.println("IllegalArgumentException posting to Slack " + e);
|
|
| 234 |
- } |
|
| 235 |
- catch (IOException e) {
|
|
| 236 |
- System.out.println("IOException posting to Slack " + e);
|
|
| 237 |
- } |
|
| 238 |
- catch (Exception e) {
|
|
| 239 |
- System.out.println("Exception posting to Slack " + e);
|
|
| 240 |
- e.printStackTrace(); |
|
| 187 |
+ log.error("Slack 메시지 전송 중 IllegalArgumentException 발생", e);
|
|
| 188 |
+ } catch (IOException e) {
|
|
| 189 |
+ log.error("Slack 메시지 전송 중 IOException 발생", e);
|
|
| 190 |
+ } catch (Exception e) {
|
|
| 191 |
+ log.error("Slack 메시지 전송 중 Exception 발생", e);
|
|
| 241 | 192 |
} finally {
|
| 242 | 193 |
post.releaseConnection(); |
| 243 | 194 |
} |
| 195 |
+ } |
|
| 196 |
+ |
|
| 197 |
+ private String formatKakaoSandName(KakaoVO kakaoVO) {
|
|
| 198 |
+ // TODO Auto-generated method stub |
|
| 199 |
+ return null; |
|
| 200 |
+ } |
|
| 201 |
+ |
|
| 202 |
+ |
|
| 203 |
+ |
|
| 204 |
+ /** |
|
| 205 |
+ * 카카오톡 메시지 텍스트 포맷팅 |
|
| 206 |
+ */ |
|
| 207 |
+ public String formatKakaoText(KakaoVO kakaoVO) {
|
|
| 208 |
+ String smsTxt = kakaoVO.getTemplateContent(); |
|
| 209 |
+ String reserveYn = safeGetString(kakaoVO.getReserveYn()); |
|
| 210 |
+ String atDelayYn = safeGetString(kakaoVO.getAtDelayYn()); |
|
| 244 | 211 |
|
| 245 |
- }*/ |
|
| 246 |
- |
|
| 247 |
- |
|
| 212 |
+ // 공통 텍스트 포맷팅 로직 적용 |
|
| 213 |
+ return formatMessagePrefix(smsTxt, reserveYn, "Y".equals(atDelayYn)); |
|
| 214 |
+ } |
|
| 215 |
+ |
|
| 216 |
+ |
|
| 217 |
+ /** |
|
| 218 |
+ * 메시지 접두사 포맷팅 공통 로직 |
|
| 219 |
+ * (예약 및 스미싱 의심 접두사 처리) |
|
| 220 |
+ */ |
|
| 221 |
+ private static String formatMessagePrefix(String messageText, String reserveYn, boolean isSmishing) {
|
|
| 222 |
+ if ("Y".equals(reserveYn)) {
|
|
| 223 |
+ return isSmishing ? "[스미싱의심][예약]" + messageText : "[예약]" + messageText; |
|
| 224 |
+ } else if (isSmishing) {
|
|
| 225 |
+ return "[스미싱의심]" + messageText; |
|
| 226 |
+ } |
|
| 227 |
+ return messageText; |
|
| 228 |
+ } |
|
| 229 |
+ |
|
| 230 |
+ |
|
| 248 | 231 |
/** |
| 249 | 232 |
* @Method Name : sendSimpleSlackMsg |
| 250 | 233 |
* @작성일 : 2022. 12. 9 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?