테스트서버에서 로그인 인증번호 발송 시 테스트슬랙알림채널로 발송
This commit is contained in:
parent
9eb1057128
commit
fc75143262
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -158,7 +159,8 @@ public class CertPhoneController {
|
||||
|
||||
|
||||
@RequestMapping(value = {"/cert/phone/sendSysMsgDataAjax.do"})
|
||||
public ResponseEntity<StatusResponse> sendSysMsgDataAjax(MberCertPhoneVO mberCertPhoneVO) throws Exception {
|
||||
public ResponseEntity<StatusResponse> sendSysMsgDataAjax(MberCertPhoneVO mberCertPhoneVO,
|
||||
HttpServletRequest request) throws Exception {
|
||||
|
||||
|
||||
//로그인 권한정보 불러오기
|
||||
@ -178,7 +180,7 @@ public class CertPhoneController {
|
||||
|
||||
MjonMsgVO mjonMsgVO = new MjonMsgVO();
|
||||
mjonMsgVO.setCallTo(mberCertPhoneVO.getMbtlnum());
|
||||
MjonMsgReturnVO returnVO = mjonMsgDataService.sendSysMsgData(mjonMsgVO);
|
||||
MjonMsgReturnVO returnVO = mjonMsgDataService.sendSysMsgData(mjonMsgVO, request);
|
||||
|
||||
String resultSts = returnVO.getSendMsgCnt();
|
||||
String resultBlockSts = returnVO.getSendMsgBlockCnt();
|
||||
|
||||
@ -63,16 +63,57 @@ public class MjonCommon {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @methodName : getAdminSandSlack
|
||||
* @methodName : getAdminMsgSandSlack
|
||||
* @author : 이호영
|
||||
* @date : 2024.12.04
|
||||
* @description : 기존 메소드 리펙토링
|
||||
* @param mjonMsgVO
|
||||
*/
|
||||
public void getAdminSandSlack(MjonMsgVO mjonMsgVO) {
|
||||
public void getAdminSandSlack(String smsTxt, String sandName) {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
PostMethod post = new PostMethod(SLACK_URL);
|
||||
|
||||
try {
|
||||
// 메시지 내용 설정
|
||||
|
||||
// Slack 메시지 생성
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("channel", SLACK_CHANNEL);
|
||||
json.put("text", smsTxt);
|
||||
json.put("username", sandName);
|
||||
|
||||
// Slack 요청
|
||||
post.addParameter("payload", json.toString());
|
||||
post.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||
|
||||
// Slack 응답 처리
|
||||
int responseCode = client.executeMethod(post);
|
||||
if (responseCode != HttpStatus.SC_OK) {
|
||||
log.warn("Slack 메시지 전송 실패. Response: {}", post.getResponseBodyAsString());
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Slack 메시지 전송 중 IllegalArgumentException 발생", e);
|
||||
} catch (IOException e) {
|
||||
log.error("Slack 메시지 전송 중 IOException 발생", e);
|
||||
} catch (Exception e) {
|
||||
log.error("Slack 메시지 전송 중 Exception 발생", e);
|
||||
} finally {
|
||||
post.releaseConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @methodName : getAdminMsgSandSlack
|
||||
* @author : 이호영
|
||||
* @date : 2024.12.04
|
||||
* @description : 기존 메소드 리펙토링
|
||||
* @param mjonMsgVO
|
||||
*/
|
||||
public void getAdminMsgSandSlack(MjonMsgVO mjonMsgVO) {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
PostMethod post = new PostMethod(SLACK_URL);
|
||||
@ -116,7 +157,7 @@ public class MjonCommon {
|
||||
* @작성자 : WYH
|
||||
* @Method 설명 : slack 메시지 전송
|
||||
*/
|
||||
/*public void getAdminSandSlack(MjonMsgVO mjonMsgVO) {
|
||||
/*public void getAdminMsgSandSlack(MjonMsgVO mjonMsgVO) {
|
||||
|
||||
HttpClient client = new HttpClient();
|
||||
PostMethod post = new PostMethod(url);
|
||||
|
||||
@ -3289,7 +3289,7 @@ public class MjonMsgCampainDataController {
|
||||
if(!smishingAlarmPassSts) {//평일,주말, 공휴일 알림설정 시간에 포함되지 않는 경우 슬랙 알림 발송
|
||||
|
||||
MjonCommon comm = new MjonCommon();
|
||||
comm.getAdminSandSlack(mjonMsgVO);
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1140,7 +1140,7 @@ public class MjonMsgCampainHGDataController {
|
||||
if(!smishingAlarmPassSts) {//평일,주말, 공휴일 알림설정 시간에 포함되지 않는 경우 슬랙 알림 발송
|
||||
|
||||
MjonCommon comm = new MjonCommon();
|
||||
comm.getAdminSandSlack(mjonMsgVO);
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2124,7 +2124,7 @@ public class MjonMsgCampainTWDataController {
|
||||
if(!smishingAlarmPassSts) {//평일,주말, 공휴일 알림설정 시간에 포함되지 않는 경우 슬랙 알림 발송
|
||||
|
||||
MjonCommon comm = new MjonCommon();
|
||||
comm.getAdminSandSlack(mjonMsgVO);
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -188,7 +188,7 @@ public interface MjonMsgDataService {
|
||||
|
||||
public StatusResponse sendMsgData_advc(MjonMsgVO mjonMsgVO, HttpServletRequest request) throws Exception;
|
||||
|
||||
public MjonMsgReturnVO sendSysMsgData(MjonMsgVO mjonMsgVO) throws Exception;
|
||||
public MjonMsgReturnVO sendSysMsgData(MjonMsgVO mjonMsgVO, HttpServletRequest request) throws Exception;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package itn.let.mjo.msgdata.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URI;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -147,6 +148,7 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
|
||||
@Autowired
|
||||
private MjonCommon mjonCommon;
|
||||
|
||||
|
||||
public List<MjonMsgDataVO> selectCcmCmmCodeList() throws Exception {
|
||||
|
||||
@ -4172,7 +4174,7 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
|
||||
if (isNotified) {
|
||||
System.out.println("스미싱 알림이 처리되었습니다.");
|
||||
mjonCommon.getAdminSandSlack(mjonMsgVO);
|
||||
mjonCommon.getAdminMsgSandSlack(mjonMsgVO);
|
||||
} else if("Y".equalsIgnoreCase(mjonMsgVO.getSpamStatus())){
|
||||
System.out.println("==알림 예외 시간==");
|
||||
mjonMsgDAO.insertSpamPassMsgData(mjonMsgVO);
|
||||
@ -5022,7 +5024,7 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
}
|
||||
|
||||
@Override
|
||||
public MjonMsgReturnVO sendSysMsgData(MjonMsgVO mjonMsgVO) throws Exception {
|
||||
public MjonMsgReturnVO sendSysMsgData(MjonMsgVO mjonMsgVO,HttpServletRequest request) throws Exception {
|
||||
|
||||
|
||||
|
||||
@ -5099,6 +5101,22 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
|
||||
|
||||
mjonMsgDataService.insertSysMsgLog(sendLogVO);
|
||||
|
||||
|
||||
String fullUrl = request.getRequestURL().toString();
|
||||
try {
|
||||
URI uri = new URI(fullUrl);
|
||||
String domain = uri.getHost(); // www.munjaon.co.kr 반환
|
||||
|
||||
if(domain.indexOf("munjaon.co.kr") < 0) {
|
||||
mjonCommon.getAdminSandSlack(contents, mjonMsgVO.getCallTo());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return returnVO;
|
||||
}
|
||||
|
||||
|
||||
@ -3449,7 +3449,7 @@ public class MjonMsgDataController {
|
||||
if(!smishingAlarmPassSts) {//평일,주말, 공휴일 알림 예외설정 시간에 포함되지 않는 경우 슬랙 알림 발송
|
||||
|
||||
MjonCommon comm = new MjonCommon();
|
||||
comm.getAdminSandSlack(mjonMsgVO);
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2175,14 +2175,14 @@ public class TestController {
|
||||
if(!smishingAlarmPassSts) {//평일,주말, 공휴일 알림설정 시간에 포함되지 않는 경우 슬랙 알림 발송
|
||||
|
||||
MjonCommon comm = new MjonCommon();
|
||||
comm.getAdminSandSlack(mjonMsgVO);
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);
|
||||
|
||||
}
|
||||
|
||||
//Slack으로 메세지 전송 처리
|
||||
/*MjonCommon comm = new MjonCommon();
|
||||
System.out.println("slack noti");
|
||||
comm.getAdminSandSlack(mjonMsgVO);*/
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);*/
|
||||
}
|
||||
}
|
||||
/*else {//야간스미싱 알림 비활성화인 경우 - 알림일정에 포함되지 않으면 슬랙 발송 처리(알림일정에 포함되면 슬랙발송 X - 알림 비활성화이기 때문에 발송X)
|
||||
@ -2211,7 +2211,7 @@ public class TestController {
|
||||
if(!smishingAlarmPassSts) {//평일,주말, 공휴일 알림설정 시간에 포함되지 않는 경우 슬랙 알림 발송
|
||||
|
||||
MjonCommon comm = new MjonCommon();
|
||||
comm.getAdminSandSlack(mjonMsgVO);
|
||||
comm.getAdminMsgSandSlack(mjonMsgVO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3632,7 +3632,7 @@ public class EgovLoginController {
|
||||
*/
|
||||
@RequestMapping(value = { "/web/user/sendSysMsgDataAjax.do" })
|
||||
public ModelAndView sendSysMsgDataAjax(@ModelAttribute("searchVO") MjonMsgVO mjonMsgVO,
|
||||
RedirectAttributes redirectAttributes, ModelMap model) throws Exception {
|
||||
RedirectAttributes redirectAttributes, ModelMap model, HttpServletRequest request) throws Exception {
|
||||
|
||||
ModelAndView modelAndView = new ModelAndView();
|
||||
modelAndView.setViewName("jsonView");
|
||||
@ -3710,7 +3710,7 @@ public class EgovLoginController {
|
||||
|
||||
|
||||
|
||||
MjonMsgReturnVO returnVO = mjonMsgDataService.sendSysMsgData(mjonMsgVO);
|
||||
MjonMsgReturnVO returnVO = mjonMsgDataService.sendSysMsgData(mjonMsgVO, request);
|
||||
|
||||
resultSts = returnVO.getSendMsgCnt();
|
||||
resultBlockSts = returnVO.getSendMsgBlockCnt();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user