93 lines
2.8 KiB
Java
93 lines
2.8 KiB
Java
package com.kri.notihub.server.service;
|
|
|
|
import com.kri.common.util.CommonUtil;
|
|
import com.kri.notihub.server.common.consts.NotihubConst;
|
|
import com.kri.notihub.server.common.enums.SendStatusType;
|
|
import com.kri.notihub.server.common.enums.SendType;
|
|
import com.kri.notihub.server.dto.send.DestInfoDto;
|
|
import com.kri.notihub.server.dto.send.SendInternalResultDto;
|
|
import com.kri.notihub.server.persistence.entity.BizMsgEntity;
|
|
import com.kri.notihub.server.persistence.entity.TSendEntity;
|
|
import com.kri.notihub.server.persistence.repository.BizMsgRepository;
|
|
import com.kri.notihub.server.persistence.repository.BulkSendRepository;
|
|
import com.kri.notihub.server.persistence.repository.SendRepository;
|
|
import com.kri.notihub.server.persistence.repository.TemplateRepository;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@Service
|
|
public class SendSmsService extends SendService {
|
|
|
|
private final BizMsgRepository bizMsgRepository;
|
|
|
|
public SendSmsService(
|
|
BizMsgRepository bizMsgRepository,
|
|
TemplateRepository templateRepository,
|
|
BulkSendRepository bulkSendRepository,
|
|
SendRepository sendRepository,
|
|
TemplateService templateService
|
|
) {
|
|
super(templateRepository, bulkSendRepository, sendRepository, templateService);
|
|
this.bizMsgRepository = bizMsgRepository;
|
|
}
|
|
|
|
@Override
|
|
protected SendType getSendType() {
|
|
//일단 SMS로 내보내고 발송시에 Template의 SendType 또는 MessageBody, 제목여부로 강화 필요
|
|
return SendType.SMS; // 프로젝트 enum 기준
|
|
}
|
|
|
|
@Override
|
|
protected SendInternalResultDto doSendInternal(
|
|
Boolean isResve,
|
|
String bulkSendKey,
|
|
SendType sendType,
|
|
String sendTel,
|
|
String sendNm,
|
|
String msgTitle,
|
|
String msgBody,
|
|
DestInfoDto dest
|
|
) {
|
|
//문자는 비즈 뿌리오가 발송을 해주기 때문에 예약도 따로 처리할 필요 없음
|
|
|
|
String cmid = CommonUtil.uuid32();
|
|
SendStatusType sendStatus = SendStatusType.STANDBY;
|
|
short resultCode =
|
|
sendType == SendType.LMS_MMS ? NotihubConst.LMS_MMS_STANDBY : NotihubConst.SMS_STANDBY;
|
|
|
|
return SendInternalResultDto.of(
|
|
cmid,
|
|
sendStatus,
|
|
resultCode
|
|
);
|
|
}
|
|
|
|
@Override
|
|
public void afterPersistSendEntities(List<TSendEntity> persisted) {
|
|
if (persisted == null || persisted.isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
List<BizMsgEntity> msgList = new ArrayList<>(persisted.size());
|
|
|
|
for (TSendEntity s : persisted) {
|
|
if (s == null) {
|
|
continue;
|
|
}
|
|
|
|
if (NotihubConst.MOBILE_TYPE_LIST.contains(s.getSendTy())) {
|
|
continue;
|
|
}
|
|
|
|
BizMsgEntity m = BizMsgEntity.fromSend(s);
|
|
msgList.add(m);
|
|
}
|
|
|
|
if (!msgList.isEmpty()) {
|
|
bizMsgRepository.saveAll(msgList);
|
|
bizMsgRepository.flush();
|
|
}
|
|
}
|
|
}
|