앱/사용자 승인 및 거절 시 SMS 통지 로직 추가
eapim-admin CI / build (push) Has been cancelled

- 승인/거절 템플릿 변수 매핑 (APP_NAME, REASON 등)
- 법인 관리자 승인/거절 통지 로직 개선
This commit is contained in:
Rinjae
2026-06-24 19:43:30 +09:00
parent 7928a0c27b
commit 25a8e13752
2 changed files with 71 additions and 3 deletions
@@ -110,11 +110,13 @@ public class PortalAppApprovalListener implements ApprovalListener {
return;
}
MessageRecipient recipient = new MessageRecipient();
recipient.setUsername(requester.getUserName());
recipient.setPhone(requester.getMobileNumber());
recipient.setUserId(requester.getEmailAddr());
Map<String, String> params = new HashMap<>();
params.put("apiKey", appRequest.getClientName());
messageSendService.sendMessage(MessageCode.APP_REGISTER_APPROVED, recipient, params);
// DB 템플릿 APP_APPROVE SMS 변수(%APP_NAME%)에 매핑
params.put("APP_NAME", appRequest.getClientName());
messageSendService.sendMessage(MessageCode.APP_APPROVE, recipient, params);
}
private void syncTargetServer(AppRequestType action, CredentialUI credentialUI) throws ApprovalDeployException {
@@ -225,5 +227,36 @@ public class PortalAppApprovalListener implements ApprovalListener {
@Transactional
public void rollback(Approval approval) {
logger.info("Approval {} rollback", approval.getId());
// 앱 사용 거절 통지
Optional<AppRequest> optRequest = appRequestRepository.findAppRequestByApproval(approval);
if (!optRequest.isPresent()) {
return;
}
AppRequest appRequest = optRequest.get();
com.eactive.apim.portal.portaluser.entity.PortalUser requester = approval.getRequester();
if (requester == null) {
logger.warn("앱 거절 통지 생략 - 요청자 정보 없음. appRequestId: {}", appRequest.getId());
return;
}
MessageRecipient recipient = new MessageRecipient();
recipient.setUsername(requester.getUserName());
recipient.setPhone(requester.getMobileNumber());
recipient.setUserId(requester.getEmailAddr());
Map<String, String> params = new HashMap<>();
// DB 템플릿 APP_REJECTED SMS 변수(%APP_NAME%, %REASON%)에 매핑
params.put("APP_NAME", appRequest.getClientName());
params.put("REASON", extractRejectReason(approval));
messageSendService.sendMessage(MessageCode.APP_REJECTED, recipient, params);
}
private String extractRejectReason(Approval approval) {
if (approval.getApprovers() == null) {
return "";
}
return approval.getApprovers().stream()
.map(com.eactive.apim.portal.approval.entity.Approver::getApprovalMessage)
.filter(m -> m != null && !m.isEmpty())
.findFirst().orElse("");
}
}
@@ -94,10 +94,15 @@ public class PortalUserApprovalListener implements ApprovalListener {
private void sendApprovalResult(PortalUser portalUser) {
MessageRecipient recipient = new MessageRecipient();
recipient.setUsername(portalUser.getUserName());
recipient.setPhone(portalUser.getMobileNumber());
recipient.setUserId(portalUser.getEmailAddr());
Map<String, String> params = new HashMap<>();
// messageSendService.sendMessage(MessageCode.USER_REGISTRATION_APPROVED, recipient, params);
// DB 템플릿 MANAGER_WITH_ORG_REGISTER_APPROVED SMS 변수(%ORG_NAME%)에 매핑
PortalOrg org = portalUser.getPortalOrg();
if (org != null) {
params.put("ORG_NAME", org.getOrgName());
}
messageSendService.sendMessage(MessageCode.MANAGER_WITH_ORG_REGISTER_APPROVED, recipient, params);
}
@@ -155,6 +160,13 @@ public class PortalUserApprovalListener implements ApprovalListener {
PortalUser portalUser = portalUserService.findByUserId(userId);
PortalOrg portalOrg = portalUser.getPortalOrg();
// 거절 통지에 필요한 정보를 반려 처리(정보 마스킹) 이전에 캡처
String noticeName = portalUser.getUserName();
String noticePhone = portalUser.getMobileNumber();
String noticeEmail = portalUser.getEmailAddr();
String noticeOrgName = portalOrg != null ? portalOrg.getOrgName() : null;
String rejectReason = extractRejectReason(approval);
// 개인→법인 전환 요청 반려: approvalStatus가 PENDING이면 전환 신청이었으므로 개인 사용자로 복원
if (PortalUserEnums.ApprovalStatus.PENDING.equals(portalUser.getApprovalStatus())) {
logger.info("Approval {} is a personal-to-corporate conversion rejection. Reverting user {} to personal user.", approval.getId(), userId);
@@ -199,5 +211,28 @@ public class PortalUserApprovalListener implements ApprovalListener {
portalOrgService.save(portalOrg);
}
// 법인관리자/법인 등록 거절 통지 (정보 마스킹 이전 캡처값 사용)
MessageRecipient recipient = new MessageRecipient();
recipient.setUsername(noticeName);
recipient.setPhone(noticePhone);
recipient.setUserId(noticeEmail);
Map<String, String> params = new HashMap<>();
// DB 템플릿 MANAGER_WITH_ORG_REGISTER_REJECTED SMS 변수(%ORG_NAME%, %REASON%)에 매핑
if (noticeOrgName != null) {
params.put("ORG_NAME", noticeOrgName);
}
params.put("REASON", rejectReason);
messageSendService.sendMessage(MessageCode.MANAGER_WITH_ORG_REGISTER_REJECTED, recipient, params);
}
private String extractRejectReason(Approval approval) {
if (approval.getApprovers() == null) {
return "";
}
return approval.getApprovers().stream()
.map(com.eactive.apim.portal.approval.entity.Approver::getApprovalMessage)
.filter(m -> m != null && !m.isEmpty())
.findFirst().orElse("");
}
}