261105_02_CLN: 미사용 동기 처리 메서드 및 관련 코드 정리
This commit is contained in:
@@ -16,10 +16,6 @@ public enum ChannelType implements CodeEnum<Short> {
|
|||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
ChannelType(CodeEnum<Short> source) {
|
|
||||||
this.code = source.getCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
public static ChannelType fromCode(Short code) {
|
public static ChannelType fromCode(Short code) {
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.kri.contact.server.dto.message;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Schema(description = "MessageFailedChunkDto")
|
|
||||||
public record MessageFailedChunkDto(
|
|
||||||
|
|
||||||
@Schema(description = "chunkIndex")
|
|
||||||
int chunkIndex,
|
|
||||||
|
|
||||||
@Schema(description = "from")
|
|
||||||
int from,
|
|
||||||
|
|
||||||
@Schema(description = "to")
|
|
||||||
int to,
|
|
||||||
|
|
||||||
@Schema(description = "targetCount")
|
|
||||||
int targetCount,
|
|
||||||
|
|
||||||
@Schema(description = "errorMessage")
|
|
||||||
String errorMessage
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.kri.contact.server.dto.message;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import lombok.Builder;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Schema(description = "MessageBulkSendResponseDto")
|
|
||||||
public record MessageSendBulkResponseDto(
|
|
||||||
|
|
||||||
@Schema(description = "bulkSendKey")
|
|
||||||
String bulkSendKey,
|
|
||||||
|
|
||||||
@Schema(description = "targetCount")
|
|
||||||
int targetCount,
|
|
||||||
|
|
||||||
@Schema(description = "requestCount")
|
|
||||||
int requestCount,
|
|
||||||
|
|
||||||
@Schema(description = "acceptCount")
|
|
||||||
int acceptCount,
|
|
||||||
|
|
||||||
@Schema(description = "failCount")
|
|
||||||
int failCount,
|
|
||||||
|
|
||||||
@Schema(description = "failedChunks")
|
|
||||||
List<MessageFailedChunkDto> failedChunks
|
|
||||||
) {
|
|
||||||
|
|
||||||
public static class MessageSendBulkResponseDtoBuilder {
|
|
||||||
private boolean failedChunksSet;
|
|
||||||
private List<MessageFailedChunkDto> failedChunks;
|
|
||||||
|
|
||||||
public MessageSendBulkResponseDtoBuilder failedChunks(List<MessageFailedChunkDto> failedChunks) {
|
|
||||||
this.failedChunks = failedChunks;
|
|
||||||
this.failedChunksSet = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageSendBulkResponseDto build() {
|
|
||||||
return new MessageSendBulkResponseDto(
|
|
||||||
bulkSendKey, targetCount, requestCount, acceptCount, failCount,
|
|
||||||
failedChunksSet ? failedChunks : new ArrayList<>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -220,20 +220,5 @@ public class ListResetJdbcSupport {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteCounts plus(DeleteCounts other) {
|
|
||||||
return new DeleteCounts(
|
|
||||||
fileCount + other.fileCount,
|
|
||||||
callHistCount + other.callHistCount,
|
|
||||||
eventHistCount + other.eventHistCount,
|
|
||||||
eventLatestCount + other.eventLatestCount,
|
|
||||||
updateHistCount + other.updateHistCount,
|
|
||||||
itemCount + other.itemCount,
|
|
||||||
listCount + other.listCount,
|
|
||||||
assignUserCount + other.assignUserCount,
|
|
||||||
assignCmpnCount + other.assignCmpnCount,
|
|
||||||
resveCount + other.resveCount
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,17 +21,6 @@ public class ListResetPersistenceSupport {
|
|||||||
private final ListDeleteSessionContext deleteSessionContext;
|
private final ListDeleteSessionContext deleteSessionContext;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public int resetWithAuditContext(
|
|
||||||
Long prjctIdx,
|
|
||||||
Collection<String> sids,
|
|
||||||
ListResetMode mode,
|
|
||||||
String listResetLogId,
|
|
||||||
String delUser,
|
|
||||||
int chunkSize
|
|
||||||
) {
|
|
||||||
return resetWithAuditContext(prjctIdx, sids, mode, listResetLogId, delUser, chunkSize, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int resetChunkWithAuditContext(Long projectId, Collection<String> sids, ListResetMode mode,
|
public int resetChunkWithAuditContext(Long projectId, Collection<String> sids, ListResetMode mode,
|
||||||
String logId, String user, int chunkSize) {
|
String logId, String user, int chunkSize) {
|
||||||
return resetWithAuditContext(projectId, sids, mode, logId, user, chunkSize, true);
|
return resetWithAuditContext(projectId, sids, mode, logId, user, chunkSize, true);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.kri.contact.server.persistence.repository.ProjectRepository;
|
|||||||
import com.kri.contact.server.persistence.repository.ProjectSurveyRepository;
|
import com.kri.contact.server.persistence.repository.ProjectSurveyRepository;
|
||||||
import com.kri.contact.server.persistence.repository.ResultCodeRepository;
|
import com.kri.contact.server.persistence.repository.ResultCodeRepository;
|
||||||
import com.kri.contact.server.service.file.ListItemFileService;
|
import com.kri.contact.server.service.file.ListItemFileService;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -112,18 +111,6 @@ public class ListDownloadService {
|
|||||||
default void beforeWrite() { checkCancelled(); }
|
default void beforeWrite() { checkCancelled(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final DownloadObserver NO_OBSERVER = new DownloadObserver() {};
|
|
||||||
|
|
||||||
public byte[] downloadList(
|
|
||||||
Long prjctIdx,
|
|
||||||
ListFilterDto listFilter,
|
|
||||||
boolean includeResult
|
|
||||||
) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeList(prjctIdx, listFilter, includeResult, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeList(
|
public void writeList(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
ListFilterDto listFilter,
|
ListFilterDto listFilter,
|
||||||
@@ -189,20 +176,6 @@ public class ListDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadListWithEventHist(
|
|
||||||
Long prjctIdx,
|
|
||||||
ListFilterDto listFilter,
|
|
||||||
Collection<ResultCodeType> resultCodeTypes,
|
|
||||||
ListEventHistoryBase searchBase,
|
|
||||||
DateRangeDto dateRange,
|
|
||||||
ListEventHistoryOrder historyOrder,
|
|
||||||
boolean includeResult
|
|
||||||
) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeListWithEventHist(prjctIdx, listFilter, resultCodeTypes, searchBase, dateRange, historyOrder, includeResult, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeListWithEventHist(
|
public void writeListWithEventHist(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
ListFilterDto listFilter,
|
ListFilterDto listFilter,
|
||||||
@@ -309,12 +282,6 @@ public class ListDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeSidWithUpdateHist(prjctIdx, listFilter, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
public void writeSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
||||||
observer.checkCancelled();
|
observer.checkCancelled();
|
||||||
int maxHistoryGroupCount = findMaxUpdateHistoryGroupCount(prjctIdx, listFilter, observer);
|
int maxHistoryGroupCount = findMaxUpdateHistoryGroupCount(prjctIdx, listFilter, observer);
|
||||||
@@ -367,12 +334,6 @@ public class ListDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadItemFile(Long prjctIdx, ListFilterDto listFilter) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeItemFile(prjctIdx, listFilter, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeItemFile(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
public void writeItemFile(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
||||||
observer.checkCancelled();
|
observer.checkCancelled();
|
||||||
List<ListHeaderDto> fileHeaders = getSortedHeaders(prjctIdx).stream()
|
List<ListHeaderDto> fileHeaders = getSortedHeaders(prjctIdx).stream()
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.kri.contact.server.service;
|
package com.kri.contact.server.service;
|
||||||
|
|
||||||
import static com.kri.contact.server.common.util.SidUtil.requireValidFilterConditions;
|
|
||||||
|
|
||||||
import com.kri.common.feature.web.BusinessException;
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import com.kri.contact.server.common.consts.ContactConstant;
|
import com.kri.contact.server.common.consts.ContactConstant;
|
||||||
import com.kri.contact.server.common.enums.ListResetMode;
|
import com.kri.contact.server.common.enums.ListResetMode;
|
||||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
|
||||||
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
||||||
import com.kri.contact.server.dto.list.ListResetScopeDto;
|
import com.kri.contact.server.dto.list.ListResetScopeDto;
|
||||||
import com.kri.contact.server.persistence.entity.TListResetLogEntity;
|
import com.kri.contact.server.persistence.entity.TListResetLogEntity;
|
||||||
@@ -26,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
public class ListResetService {
|
public class ListResetService {
|
||||||
|
|
||||||
private final ListResetLogRepository listResetLogRepository;
|
private final ListResetLogRepository listResetLogRepository;
|
||||||
private final ListSearchService listSearchService;
|
|
||||||
private final ListResetPersistenceSupport listResetPersistenceSupport;
|
private final ListResetPersistenceSupport listResetPersistenceSupport;
|
||||||
private final ProjectSurveyRepository projectSurveyRepository;
|
private final ProjectSurveyRepository projectSurveyRepository;
|
||||||
|
|
||||||
@@ -75,39 +72,6 @@ public class ListResetService {
|
|||||||
return BusinessException.badRequest("INVALID_LIST_RESET", message);
|
return BusinessException.badRequest("INVALID_LIST_RESET", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public int resetByFilter(
|
|
||||||
Long prjctIdx,
|
|
||||||
ListFilterDto filter,
|
|
||||||
ListResetMode mode,
|
|
||||||
String regUser,
|
|
||||||
LocalDateTime regDt
|
|
||||||
) {
|
|
||||||
requireValidFilterConditions(filter == null ? null : filter.getSidSet());
|
|
||||||
Set<String> sids = listSearchService.findTargetSids(prjctIdx, filter);
|
|
||||||
return resetBySids(prjctIdx, sids, mode, regUser, regDt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public int resetBySids(
|
|
||||||
Long prjctIdx,
|
|
||||||
Set<String> sids,
|
|
||||||
ListResetMode mode,
|
|
||||||
String regUser,
|
|
||||||
LocalDateTime regDt
|
|
||||||
) {
|
|
||||||
if (sids == null || sids.isEmpty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (mode == null) {
|
|
||||||
throw BusinessException.badRequest("EMPTY_MODE", "mode는 필수 입니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String listResetLogId = createResetLog(prjctIdx, mode, 0, regUser, regDt);
|
|
||||||
return listResetPersistenceSupport.resetWithAuditContext(
|
|
||||||
prjctIdx, sids, mode, listResetLogId, regUser, ContactConstant.INSERT_CHUNK_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public String createResetLog(
|
public String createResetLog(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ import com.kri.contact.server.common.enums.ListHeaderTypeSpecific;
|
|||||||
import com.kri.contact.server.common.enums.ListIsUse;
|
import com.kri.contact.server.common.enums.ListIsUse;
|
||||||
import com.kri.contact.server.common.enums.ListResetMode;
|
import com.kri.contact.server.common.enums.ListResetMode;
|
||||||
import com.kri.contact.server.common.enums.ListUploadMode;
|
import com.kri.contact.server.common.enums.ListUploadMode;
|
||||||
import com.kri.contact.server.common.util.ExcelUploadResultUtil;
|
|
||||||
import com.kri.contact.server.dto.excel.ExcelUploadResultDto;
|
|
||||||
import com.kri.contact.server.dto.excel.ListUploadErrorDto;
|
import com.kri.contact.server.dto.excel.ListUploadErrorDto;
|
||||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||||
@@ -196,124 +194,6 @@ public class ListUploadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public ExcelUploadResultDto uploadExcel(
|
|
||||||
Long prjctIdx,
|
|
||||||
MultipartFile file,
|
|
||||||
ListUploadRequestDto request,
|
|
||||||
String uploadUser,
|
|
||||||
LocalDateTime uploadDt
|
|
||||||
) {
|
|
||||||
Path listFilePath = listFileService.saveListFile(file, prjctIdx);
|
|
||||||
|
|
||||||
List<String> excelHeaders = ExcelMapper.readHeaderStreaming(listFilePath,
|
|
||||||
UPPER_CASE_HEADER_OPTIONS);
|
|
||||||
List<ListUploadErrorDto> headerErrorList = new ArrayList<>();
|
|
||||||
|
|
||||||
List<ListHeaderDto> resolvedHeaders = listHeaderService.resolveUploadHeaders(
|
|
||||||
prjctIdx,
|
|
||||||
excelHeaders,
|
|
||||||
request,
|
|
||||||
headerErrorList
|
|
||||||
);
|
|
||||||
if (!headerErrorList.isEmpty()) {
|
|
||||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, null);
|
|
||||||
return buildErrorResponse(0, headerErrorList, listFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ListHeaderDto> existingHeaders = listHeaderService.getHeader(prjctIdx).stream()
|
|
||||||
.map(ListHeaderDto.class::cast)
|
|
||||||
.toList();
|
|
||||||
List<ListHeaderDto> existingCommon = existingHeaders.stream()
|
|
||||||
.filter(h -> Objects.equals(h.getListHderGrad(), ListHeaderGrade.COMMON))
|
|
||||||
.sorted(Comparator.comparing(ListHeaderDto::getListHderOrder))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (!existingCommon.isEmpty() && !listHeaderService.isEqualHeader(existingHeaders, resolvedHeaders, true)) {
|
|
||||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, null);
|
|
||||||
headerErrorList.add(ListUploadErrorDto.of(1, "헤더", "기존 헤더와 업로드 헤더가 일치하지 않습니다."));
|
|
||||||
return buildErrorResponse(0, headerErrorList, listFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> prjctAssignList = assignService.getPrjctFieldworkAssign(prjctIdx);
|
|
||||||
List<String> prjctAssignCmpnList = assignService.getPrjctCmpnAssign(prjctIdx);
|
|
||||||
Map<String, Integer> userRoleByUserId = assignService.findActiveUserRoleMap(prjctAssignList);
|
|
||||||
Map<String, Short> assignRoleByHeaderName = createAssignRoleByHeaderName(resolvedHeaders);
|
|
||||||
Map<Short, Set<String>> allowedUserRolesByAssignRole =
|
|
||||||
assignService.findAllowedUserRolesByAssignRole(new LinkedHashSet<>(assignRoleByHeaderName.values()));
|
|
||||||
Map<String, TCmpnEntity> cmpnByUploadText = createCmpnByUploadText(resolvedHeaders, listFilePath);
|
|
||||||
|
|
||||||
TListUploadLogEntity uploadLog = createPendingLog(
|
|
||||||
prjctIdx,
|
|
||||||
listFilePath,
|
|
||||||
request,
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
|
|
||||||
ValidationSummary validation = validateFile(
|
|
||||||
prjctIdx,
|
|
||||||
listFilePath,
|
|
||||||
request,
|
|
||||||
resolvedHeaders,
|
|
||||||
prjctAssignList,
|
|
||||||
prjctAssignCmpnList,
|
|
||||||
userRoleByUserId,
|
|
||||||
assignRoleByHeaderName,
|
|
||||||
allowedUserRolesByAssignRole,
|
|
||||||
cmpnByUploadText,
|
|
||||||
uploadLog.getListUploadLogId()
|
|
||||||
);
|
|
||||||
|
|
||||||
markValidated(uploadLog, validation.totalCount());
|
|
||||||
|
|
||||||
if (!validation.errors().isEmpty()) {
|
|
||||||
listUploadJdbcSupport.deleteTemp(uploadLog.getListUploadLogId());
|
|
||||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, uploadLog);
|
|
||||||
return buildErrorResponse(validation.totalCount(), validation.errors(), listFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existingCommon.isEmpty()) {
|
|
||||||
listHeaderService.upsertHeader(prjctIdx, resolvedHeaders, uploadUser, uploadDt);
|
|
||||||
}
|
|
||||||
|
|
||||||
persistUpload(
|
|
||||||
prjctIdx,
|
|
||||||
listFilePath,
|
|
||||||
request,
|
|
||||||
resolvedHeaders,
|
|
||||||
cmpnByUploadText,
|
|
||||||
uploadLog.getListUploadLogId(),
|
|
||||||
validation.uploadedSids(),
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
|
|
||||||
markSuccess(uploadLog, validation.totalCount());
|
|
||||||
listUploadJdbcSupport.deleteTemp(uploadLog.getListUploadLogId());
|
|
||||||
|
|
||||||
//목록형 헤더의 값들 최신화
|
|
||||||
listContentItemService.refreshListContentItem(prjctIdx, resolvedHeaders);
|
|
||||||
|
|
||||||
return ExcelUploadResultDto.success(validation.totalCount(), validation.totalCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Path markUploadFailed(Long prjctIdx, Path listFilePath, TListUploadLogEntity uploadLog) {
|
|
||||||
Path failedFilePath = listFileService.renameFailedListFile(prjctIdx, listFilePath);
|
|
||||||
if (uploadLog != null) {
|
|
||||||
uploadLog.setFileNm(failedFilePath.getFileName().toString());
|
|
||||||
listUploadLogRepository.save(uploadLog);
|
|
||||||
}
|
|
||||||
return failedFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, TCmpnEntity> createCmpnByUploadText(
|
|
||||||
List<ListHeaderDto> resolvedHeaders,
|
|
||||||
Path listFilePath
|
|
||||||
) {
|
|
||||||
return createCmpnByUploadText(resolvedHeaders, listFilePath, () -> {});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, TCmpnEntity> createCmpnByUploadText(List<ListHeaderDto> resolvedHeaders,
|
private Map<String, TCmpnEntity> createCmpnByUploadText(List<ListHeaderDto> resolvedHeaders,
|
||||||
Path listFilePath, Runnable checkCancelled) {
|
Path listFilePath, Runnable checkCancelled) {
|
||||||
String outsourceHeaderName = findOptionalHeaderNameByType(resolvedHeaders, ListHeaderType.OUTSOURCE);
|
String outsourceHeaderName = findOptionalHeaderNameByType(resolvedHeaders, ListHeaderType.OUTSOURCE);
|
||||||
@@ -422,40 +302,6 @@ public class ListUploadService {
|
|||||||
listUploadLogRepository.save(uploadLog);
|
listUploadLogRepository.save(uploadLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistUpload(
|
|
||||||
Long prjctIdx,
|
|
||||||
Path listFilePath,
|
|
||||||
ListUploadRequestDto request,
|
|
||||||
List<ListHeaderDto> resolvedHeaders,
|
|
||||||
Map<String, TCmpnEntity> cmpnByUploadText,
|
|
||||||
String listUploadLogId,
|
|
||||||
Set<String> uploadedSids,
|
|
||||||
String uploadUser,
|
|
||||||
LocalDateTime uploadDt
|
|
||||||
) {
|
|
||||||
if (request.uploadMode() == ListUploadMode.RESET_AND_INSERT) {
|
|
||||||
listResetService.resetByFilter(
|
|
||||||
prjctIdx,
|
|
||||||
null,
|
|
||||||
ListResetMode.ALL,
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (request.uploadMode() == ListUploadMode.ADD_AND_CHANGE && !uploadedSids.isEmpty()) {
|
|
||||||
listResetService.resetBySids(
|
|
||||||
prjctIdx,
|
|
||||||
uploadedSids,
|
|
||||||
ListResetMode.LIST_UPLOAD,
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
readUploadChunks(prjctIdx, listFilePath, resolvedHeaders, cmpnByUploadText,
|
|
||||||
listUploadLogId, uploadUser, uploadDt, () -> {}, this::insertUploadChunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
public record UploadChunk(List<ListRowInsert> lists, List<ListItemRowInsert> items,
|
public record UploadChunk(List<ListRowInsert> lists, List<ListItemRowInsert> items,
|
||||||
List<ListAssignRowInsert> users, List<ListAssignCmpnRowInsert> companies) {
|
List<ListAssignRowInsert> users, List<ListAssignCmpnRowInsert> companies) {
|
||||||
public List<String> sids() { return lists.stream().map(ListRowInsert::sid).toList(); }
|
public List<String> sids() { return lists.stream().map(ListRowInsert::sid).toList(); }
|
||||||
@@ -677,24 +523,6 @@ public class ListUploadService {
|
|||||||
listUploadJdbcSupport.batchInsertListAssignCmpn(chunk.companies(), ContactConstant.INSERT_CHUNK_SIZE);
|
listUploadJdbcSupport.batchInsertListAssignCmpn(chunk.companies(), ContactConstant.INSERT_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValidationSummary validateFile(
|
|
||||||
Long prjctIdx,
|
|
||||||
Path listFilePath,
|
|
||||||
ListUploadRequestDto request,
|
|
||||||
List<ListHeaderDto> resolvedHeaders,
|
|
||||||
List<String> prjctAssignList,
|
|
||||||
List<String> prjctAssignCmpnList,
|
|
||||||
Map<String, Integer> userRoleByUserId,
|
|
||||||
Map<String, Short> assignRoleByHeaderName,
|
|
||||||
Map<Short, Set<String>> allowedUserRolesByAssignRole,
|
|
||||||
Map<String, TCmpnEntity> cmpnByUploadText,
|
|
||||||
String listUploadLogId
|
|
||||||
) {
|
|
||||||
return validateFile(prjctIdx, listFilePath, request, resolvedHeaders, prjctAssignList,
|
|
||||||
prjctAssignCmpnList, userRoleByUserId, assignRoleByHeaderName, allowedUserRolesByAssignRole,
|
|
||||||
cmpnByUploadText, listUploadLogId, () -> {}, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ValidationSummary validateFile(Long prjctIdx, Path listFilePath, ListUploadRequestDto request,
|
private ValidationSummary validateFile(Long prjctIdx, Path listFilePath, ListUploadRequestDto request,
|
||||||
List<ListHeaderDto> resolvedHeaders, List<String> prjctAssignList, List<String> prjctAssignCmpnList,
|
List<ListHeaderDto> resolvedHeaders, List<String> prjctAssignList, List<String> prjctAssignCmpnList,
|
||||||
Map<String, Integer> userRoleByUserId, Map<String, Short> assignRoleByHeaderName,
|
Map<String, Integer> userRoleByUserId, Map<String, Short> assignRoleByHeaderName,
|
||||||
@@ -900,31 +728,6 @@ public class ListUploadService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExcelUploadResultDto buildErrorResponse(
|
|
||||||
int totalCount,
|
|
||||||
List<ListUploadErrorDto> errorList,
|
|
||||||
Path sourceFile
|
|
||||||
) {
|
|
||||||
String origin = sourceFile.getFileName().toString();
|
|
||||||
String errorFileName = origin.endsWith(".xlsx")
|
|
||||||
? origin.substring(0, origin.length() - 5) + "_error.xlsx"
|
|
||||||
: origin + "_error.xlsx";
|
|
||||||
int failCount = errorList.stream()
|
|
||||||
.map(ListUploadErrorDto::getRowNumber)
|
|
||||||
.distinct()
|
|
||||||
.toList()
|
|
||||||
.size();
|
|
||||||
|
|
||||||
return ExcelUploadResultUtil.buildUploadResult(
|
|
||||||
totalCount,
|
|
||||||
0,
|
|
||||||
failCount,
|
|
||||||
errorList,
|
|
||||||
ListUploadErrorDto.class,
|
|
||||||
errorFileName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Integer, ListHeaderDto> toHeaderById(List<ListHeaderDto> headers) {
|
private Map<Integer, ListHeaderDto> toHeaderById(List<ListHeaderDto> headers) {
|
||||||
Map<Integer, ListHeaderDto> map = new LinkedHashMap<>();
|
Map<Integer, ListHeaderDto> map = new LinkedHashMap<>();
|
||||||
for (ListHeaderDto h : headers) {
|
for (ListHeaderDto h : headers) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.kri.contact.server.service;
|
|||||||
|
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.REQUEST_SERVICE;
|
import static com.kri.contact.server.common.consts.ContactConstant.REQUEST_SERVICE;
|
||||||
import static com.kri.contact.server.common.util.SidUtil.requireSid;
|
import static com.kri.contact.server.common.util.SidUtil.requireSid;
|
||||||
import static com.kri.contact.server.common.util.SidUtil.requireValidFilterConditions;
|
|
||||||
|
|
||||||
import com.kri.common.feature.web.BusinessException;
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import com.kri.common.feature.web.RequestUserContext;
|
import com.kri.common.feature.web.RequestUserContext;
|
||||||
@@ -18,8 +17,6 @@ import com.kri.contact.server.common.external.notihub.dto.NotiHubSendRequestSing
|
|||||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubSendSingleResponseDto;
|
import com.kri.contact.server.common.external.notihub.dto.NotiHubSendSingleResponseDto;
|
||||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDto;
|
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDto;
|
||||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||||
import com.kri.contact.server.dto.message.MessageSendBulkResponseDto;
|
|
||||||
import com.kri.contact.server.dto.message.MessageFailedChunkDto;
|
|
||||||
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
||||||
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
||||||
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
||||||
@@ -50,7 +47,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MessageSendService {
|
public class MessageSendService {
|
||||||
private static final int BULK_SEND_CHUNK_SIZE = 1_000;
|
|
||||||
private static final Pattern TEMPLATE_PARAM_PATTERN = Pattern.compile("(?:\\[\\$|#\\{)([^\\]}]+)(?:]|})");
|
private static final Pattern TEMPLATE_PARAM_PATTERN = Pattern.compile("(?:\\[\\$|#\\{)([^\\]}]+)(?:]|})");
|
||||||
|
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
@@ -92,16 +88,6 @@ public class MessageSendService {
|
|||||||
return sendSingle(prjctIdx, request, ctx, ChannelType.SMS);
|
return sendSingle(prjctIdx, request, ctx, ChannelType.SMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public MessageSendBulkResponseDto sendEmailBulk(Long prjctIdx, MessageSendBulkRequestDto request, RequestUserContext ctx) {
|
|
||||||
return sendBulk(prjctIdx, request, ctx, ChannelType.EMAIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public MessageSendBulkResponseDto sendSmsBulk(Long prjctIdx, MessageSendBulkRequestDto request, RequestUserContext ctx) {
|
|
||||||
return sendBulk(prjctIdx, request, ctx, ChannelType.SMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public MessageSendSingleResponseDto sendKkoSingle(
|
public MessageSendSingleResponseDto sendKkoSingle(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
@@ -111,15 +97,6 @@ public class MessageSendService {
|
|||||||
return sendSingle(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
return sendSingle(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public MessageSendBulkResponseDto sendKkoBulk(
|
|
||||||
Long prjctIdx,
|
|
||||||
MessageSendBulkRequestDto request,
|
|
||||||
RequestUserContext ctx
|
|
||||||
) {
|
|
||||||
return sendBulk(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MessageSendSingleResponseDto sendSingle(
|
private MessageSendSingleResponseDto sendSingle(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
MessageSendSingleRequestDto request,
|
MessageSendSingleRequestDto request,
|
||||||
@@ -172,101 +149,6 @@ public class MessageSendService {
|
|||||||
return MessageSendSingleResponseDto.from(response);
|
return MessageSendSingleResponseDto.from(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessageSendBulkResponseDto sendBulk(
|
|
||||||
Long prjctIdx,
|
|
||||||
MessageSendBulkRequestDto request,
|
|
||||||
RequestUserContext ctx,
|
|
||||||
ChannelType channelType
|
|
||||||
) {
|
|
||||||
validateDestinationHeaders(request.destHeaderIds());
|
|
||||||
requireValidFilterConditions(
|
|
||||||
request.listFilter() == null ? null : request.listFilter().getSidSet()
|
|
||||||
);
|
|
||||||
|
|
||||||
MessageContext messageContext = createMessageContext(prjctIdx, request.tmplatIdx(), request.destHeaderIds());
|
|
||||||
List<NotiHubDestInfoDto> destInfos = createAllDestInfos(
|
|
||||||
prjctIdx,
|
|
||||||
request,
|
|
||||||
messageContext,
|
|
||||||
channelType,
|
|
||||||
request.dedupe()
|
|
||||||
);
|
|
||||||
if (destInfos.isEmpty()) {
|
|
||||||
throw BusinessException.badRequest("NO_DESTINATION", "발송 대상 이메일 또는 전화번호가 없습니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String bulkSendKey = createBulkSendKey(request, ctx, messageContext, destInfos.size(), channelType);
|
|
||||||
int requestCount = 0;
|
|
||||||
int acceptCount = 0;
|
|
||||||
int failCount = 0;
|
|
||||||
List<MessageFailedChunkDto> failedChunks = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int start = 0, chunkIndex = 1; start < destInfos.size(); start += BULK_SEND_CHUNK_SIZE, chunkIndex++) {
|
|
||||||
int end = Math.min(start + BULK_SEND_CHUNK_SIZE, destInfos.size());
|
|
||||||
List<NotiHubDestInfoDto> chunk = destInfos.subList(start, end);
|
|
||||||
try {
|
|
||||||
NotiHubBulkSendResponseDto response = sendBulkChunk(bulkSendKey, chunk, channelType);
|
|
||||||
requestCount += defaultInt(response.requestCount());
|
|
||||||
acceptCount += defaultInt(response.acceptCount());
|
|
||||||
failCount += defaultInt(response.failCount());
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
requestCount += chunk.size();
|
|
||||||
failCount += chunk.size();
|
|
||||||
failedChunks.add(MessageFailedChunkDto.builder()
|
|
||||||
.chunkIndex(chunkIndex)
|
|
||||||
.from(start + 1)
|
|
||||||
.to(end)
|
|
||||||
.targetCount(chunk.size())
|
|
||||||
.errorMessage(e.getMessage())
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MessageSendBulkResponseDto.builder()
|
|
||||||
.bulkSendKey(bulkSendKey)
|
|
||||||
.targetCount(destInfos.size())
|
|
||||||
.requestCount(requestCount)
|
|
||||||
.acceptCount(acceptCount)
|
|
||||||
.failCount(failCount)
|
|
||||||
.failedChunks(failedChunks)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<NotiHubDestInfoDto> createAllDestInfos(
|
|
||||||
Long prjctIdx,
|
|
||||||
MessageSendBulkRequestDto request,
|
|
||||||
MessageContext messageContext,
|
|
||||||
ChannelType channelType,
|
|
||||||
boolean dedupe
|
|
||||||
) {
|
|
||||||
List<NotiHubDestInfoDto> destInfos = new ArrayList<>();
|
|
||||||
Set<String> dedupeKeys = new LinkedHashSet<>();
|
|
||||||
String lastSid = null;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
List<ListSearchService.DownloadListRow> rows = listSearchService.findDownloadListRows(
|
|
||||||
prjctIdx,
|
|
||||||
request.listFilter(),
|
|
||||||
lastSid
|
|
||||||
);
|
|
||||||
if (rows.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
destInfos.addAll(createDestInfos(
|
|
||||||
rows,
|
|
||||||
request.destHeaderIds(),
|
|
||||||
request.destNameHeaderId(),
|
|
||||||
messageContext,
|
|
||||||
channelType,
|
|
||||||
dedupeKeys,
|
|
||||||
dedupe
|
|
||||||
));
|
|
||||||
lastSid = rows.get(rows.size() - 1).sid();
|
|
||||||
}
|
|
||||||
return destInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<NotiHubDestInfoDto> createDestInfos(
|
private List<NotiHubDestInfoDto> createDestInfos(
|
||||||
Collection<ListSearchService.DownloadListRow> rows,
|
Collection<ListSearchService.DownloadListRow> rows,
|
||||||
List<Integer> destHeaderIds,
|
List<Integer> destHeaderIds,
|
||||||
@@ -537,10 +419,6 @@ public class MessageSendService {
|
|||||||
return trimmed.isEmpty() ? null : trimmed;
|
return trimmed.isEmpty() ? null : trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int defaultInt(Integer value) {
|
|
||||||
return value == null ? 0 : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public record MessageContext(
|
public record MessageContext(
|
||||||
ProjectInfoDto project,
|
ProjectInfoDto project,
|
||||||
NotiHubTemplateDto template,
|
NotiHubTemplateDto template,
|
||||||
|
|||||||
@@ -191,11 +191,6 @@ public class ListAsyncJobStore {
|
|||||||
finishLocked(lock(key), errorCode, null);
|
finishLocked(lock(key), errorCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
||||||
public void finish(String key, String errorCode, Integer failedChunkNo) {
|
|
||||||
finishLocked(lock(key), errorCode, failedChunkNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
public void finish(String key, String errorCode, Integer failedChunkNo,
|
public void finish(String key, String errorCode, Integer failedChunkNo,
|
||||||
Map<String, Object> failureDetail) {
|
Map<String, Object> failureDetail) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.kri.contact.server.service.file;
|
package com.kri.contact.server.service.file;
|
||||||
|
|
||||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
|
||||||
import com.kri.common.feature.util.CommonUtil;
|
import com.kri.common.feature.util.CommonUtil;
|
||||||
import com.kri.common.feature.web.BusinessException;
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -27,37 +26,11 @@ public abstract class AbstractFileService {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String extractBaseName(String originalFileName) {
|
|
||||||
if (originalFileName == null || originalFileName.isBlank()) {
|
|
||||||
return "file";
|
|
||||||
}
|
|
||||||
|
|
||||||
String fileName = java.nio.file.Paths.get(originalFileName).getFileName().toString();
|
|
||||||
int dot = fileName.lastIndexOf('.');
|
|
||||||
|
|
||||||
if (dot > 0) {
|
|
||||||
return fileName.substring(0, dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String buildFileName(MultipartFile file) {
|
protected String buildFileName(MultipartFile file) {
|
||||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
||||||
return CommonUtil.uuid32() + extractExtension(original);
|
return CommonUtil.uuid32() + extractExtension(original);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String buildFileNameWithTime(MultipartFile file, String prefix) {
|
|
||||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
|
||||||
String baseName = extractBaseName(original);
|
|
||||||
String ext = extractExtension(original);
|
|
||||||
|
|
||||||
String timestamp = DateTimeUtil.nowKstLocalDateTime()
|
|
||||||
.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
|
||||||
|
|
||||||
return prefix + "_" + timestamp + "_" + baseName + ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Path createDirectories(Path dir) throws IOException {
|
protected Path createDirectories(Path dir) throws IOException {
|
||||||
return Files.createDirectories(dir.toAbsolutePath().normalize());
|
return Files.createDirectories(dir.toAbsolutePath().normalize());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -26,19 +25,6 @@ public class ListFileService extends AbstractFileService {
|
|||||||
return Paths.get(properties.getListBaseDir()).toAbsolutePath().normalize();
|
return Paths.get(properties.getListBaseDir()).toAbsolutePath().normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path saveListFile(MultipartFile file, Long prjctIdx) {
|
|
||||||
String newFileName = buildFileNameWithTime(file, prjctIdx.toString());
|
|
||||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
|
||||||
Path savedPath = dir.resolve(newFileName).toAbsolutePath().normalize();
|
|
||||||
|
|
||||||
try {
|
|
||||||
saveFile(dir, file, newFileName);
|
|
||||||
return savedPath;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw BusinessException.internalError("FAIL_LIST_UPLOAD", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Path saveAsyncListFile(MultipartFile file, Long projectId) {
|
public Path saveAsyncListFile(MultipartFile file, Long projectId) {
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
||||||
@@ -95,33 +81,6 @@ public class ListFileService extends AbstractFileService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path renameFailedListFile(Long prjctIdx, Path sourceFilePath) {
|
|
||||||
String failPrefix = "uploadfail_";
|
|
||||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
|
||||||
Path source = sourceFilePath.toAbsolutePath().normalize();
|
|
||||||
|
|
||||||
if (!source.startsWith(dir)) {
|
|
||||||
throw BusinessException.badRequest("WRONG_FILE_PATH", "Wrong file path.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String sourceFileName = source.getFileName().toString();
|
|
||||||
if (sourceFileName.startsWith(failPrefix)) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path target = dir.resolve(failPrefix + sourceFileName).toAbsolutePath().normalize();
|
|
||||||
if (!target.startsWith(dir)) {
|
|
||||||
throw BusinessException.badRequest("WRONG_FILE_PATH", "Wrong file path.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
return target;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw BusinessException.internalError("FAIL_RENAME_LIST_UPLOAD_FILE", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] readListFile(Long prjctIdx, String fileName) {
|
public byte[] readListFile(Long prjctIdx, String fileName) {
|
||||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
||||||
Path filePath = dir.resolve(fileName).toAbsolutePath().normalize();
|
Path filePath = dir.resolve(fileName).toAbsolutePath().normalize();
|
||||||
|
|||||||
Reference in New Issue
Block a user