261019_01_ENH: 리스트 대량 작업 비동기 처리 및 프로젝트별 동시 실행 제어 적용, 미사용 코드 정
This commit is contained in:
@@ -4,8 +4,6 @@ import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.assign.ProjectCompanyAssignSummaryDto;
|
||||
import com.kri.contact.server.dto.assign.ProjectFieldworkAssignSummaryDto;
|
||||
import com.kri.contact.server.dto.list.ListAssignRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListAssignResetRequestDto;
|
||||
import com.kri.contact.server.service.AssignService;
|
||||
import com.kri.contact.server.service.common.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -14,7 +12,6 @@ import jakarta.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
@@ -95,33 +92,4 @@ public class AssignController {
|
||||
systemEventLogService.writeAssignCmpnProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx,
|
||||
assignCmpnIdList);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 배정")
|
||||
@PutMapping("/list/{prjctIdx}/{assignId}")
|
||||
public Integer upsertListAssign(
|
||||
@PathVariable Long prjctIdx,
|
||||
@PathVariable String assignId,
|
||||
@Valid @RequestBody ListAssignRequestDto req,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
Integer assignCnt = assignService.upsertListAssign(prjctIdx, assignId, req, ctx.getUserId(), now);
|
||||
systemEventLogService.writeAssignList(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req);
|
||||
|
||||
return assignCnt;
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 배정 초기화")
|
||||
@DeleteMapping("/list/reset/{prjctIdx}")
|
||||
public Integer resetListAssign(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListAssignResetRequestDto req,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
Integer resetCnt = assignService.resetListAssign(prjctIdx, req);
|
||||
systemEventLogService.writeAssignListReset(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, req);
|
||||
|
||||
return resetCnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.list.ListEventHistDownloadRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncJobAcceptedDto;
|
||||
import com.kri.contact.server.service.async.ListAsyncDownloadService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/list/jobs/{prjctIdx}/downloads")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "ListAsyncDownload", description = "리스트 비동기 다운로드 API")
|
||||
public class ListAsyncDownloadController {
|
||||
private final ListAsyncDownloadService downloads;
|
||||
|
||||
@Operation(summary = "리스트 Excel 생성 접수")
|
||||
@PostMapping("/list")
|
||||
public ListAsyncJobAcceptedDto list(@PathVariable Long prjctIdx,
|
||||
@RequestParam(defaultValue = "true") boolean includeResult,
|
||||
@Valid @RequestBody(required = false) ListFilterDto filter, RequestUserContext user) {
|
||||
return downloads.list(prjctIdx, filter, includeResult, user);
|
||||
}
|
||||
|
||||
@Operation(summary = "컨택 이력 Excel 생성 접수")
|
||||
@PostMapping("/event-history")
|
||||
public ListAsyncJobAcceptedDto eventHistory(@PathVariable Long prjctIdx,
|
||||
@RequestParam(defaultValue = "true") boolean includeResult,
|
||||
@Valid @RequestBody ListEventHistDownloadRequestDto request, RequestUserContext user) {
|
||||
return downloads.eventHistory(prjctIdx, request, includeResult, user);
|
||||
}
|
||||
|
||||
@Operation(summary = "수정 이력 Excel 생성 접수")
|
||||
@PostMapping("/update-history")
|
||||
public ListAsyncJobAcceptedDto updateHistory(@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody(required = false) ListFilterDto filter, RequestUserContext user) {
|
||||
return downloads.updateHistory(prjctIdx, filter, user);
|
||||
}
|
||||
|
||||
@Operation(summary = "다중 첨부 ZIP 생성 접수")
|
||||
@PostMapping("/item-files")
|
||||
public ListAsyncJobAcceptedDto itemFiles(@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody(required = false) ListFilterDto filter, RequestUserContext user) {
|
||||
return downloads.itemFiles(prjctIdx, filter, user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.common.enums.ListAsyncJobType;
|
||||
import com.kri.contact.server.common.enums.ListAsyncAssignOperation;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncAvailabilityDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncActiveJobsDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncJobStatusDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncResultFileDto;
|
||||
import com.kri.contact.server.dto.list.async.ListUploadResetActiveDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncSidFailuresDto;
|
||||
import com.kri.contact.server.persistence.entity.TListAsyncJobEntity;
|
||||
import com.kri.contact.server.service.async.ListAsyncJobAccess;
|
||||
import com.kri.contact.server.service.async.ListAsyncJobExecutor;
|
||||
import com.kri.contact.server.service.async.ListAsyncJobStore;
|
||||
import com.kri.contact.server.service.file.ListAsyncResultFileService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/list/jobs/{prjctIdx}")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "ListAsyncJob", description = "리스트 비동기 작업 관리 API")
|
||||
public class ListAsyncJobController {
|
||||
private final ListAsyncJobAccess access;
|
||||
private final ListAsyncJobExecutor executor;
|
||||
private final ListAsyncResultFileService files;
|
||||
|
||||
@GetMapping("/availability")
|
||||
public ResponseEntity<ListAsyncAvailabilityDto> availability(
|
||||
@PathVariable Long prjctIdx,
|
||||
@RequestParam ListAsyncJobType jobType, RequestUserContext user) {
|
||||
access.requireProject(prjctIdx, user);
|
||||
return ResponseEntity.ok().cacheControl(CacheControl.noStore())
|
||||
.body(executor.availability(prjctIdx, user.getUserId(), jobType));
|
||||
}
|
||||
|
||||
@GetMapping("/upload-reset-active")
|
||||
public ResponseEntity<ListUploadResetActiveDto> uploadResetActive(@PathVariable Long prjctIdx,
|
||||
RequestUserContext user) {
|
||||
var view = access.activeUploadReset(prjctIdx, user).map(job -> {
|
||||
boolean mine = user.getUserId().equals(job.getRequestUser());
|
||||
return new ListUploadResetActiveDto.Job(job.getJobType(), job.getJobStatus(), job.getJobStage(),
|
||||
job.getTotalSidCnt(), processedSidCount(job), mine, mine ? job.getJobKey() : null);
|
||||
});
|
||||
return ResponseEntity.ok().cacheControl(CacheControl.noStore())
|
||||
.body(new ListUploadResetActiveDto(view.isPresent(), view.orElse(null)));
|
||||
}
|
||||
|
||||
@GetMapping("/my-active")
|
||||
public ResponseEntity<ListAsyncActiveJobsDto> myActive(@PathVariable Long prjctIdx, RequestUserContext user) {
|
||||
return ResponseEntity.ok().cacheControl(CacheControl.noStore())
|
||||
.body(new ListAsyncActiveJobsDto(access.myActive(prjctIdx, user).stream().map(this::toStatus).toList()));
|
||||
}
|
||||
|
||||
@GetMapping("/{jobKey}")
|
||||
public ListAsyncJobStatusDto status(@PathVariable Long prjctIdx, @PathVariable String jobKey,
|
||||
RequestUserContext user) {
|
||||
return toStatus(access.require(prjctIdx, jobKey, user));
|
||||
}
|
||||
|
||||
@PostMapping("/{jobKey}/cancel")
|
||||
public ListAsyncJobStatusDto cancel(@PathVariable Long prjctIdx, @PathVariable String jobKey,
|
||||
RequestUserContext user) {
|
||||
access.require(prjctIdx, jobKey, user);
|
||||
executor.cancel(jobKey, user.getUserId());
|
||||
return toStatus(access.require(prjctIdx, jobKey, user));
|
||||
}
|
||||
|
||||
@GetMapping("/{jobKey}/sid-failures")
|
||||
public ListAsyncSidFailuresDto sidFailures(
|
||||
@PathVariable Long prjctIdx, @PathVariable String jobKey,
|
||||
@RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "100") int limit,
|
||||
RequestUserContext user) {
|
||||
var job = access.require(prjctIdx, jobKey, user);
|
||||
if (offset < 0 || limit < 1 || limit > 1000) {
|
||||
throw BusinessException.badRequest("INVALID_FAILURE_PAGE", "offset은 0 이상, limit은 1~1000이어야 합니다.");
|
||||
}
|
||||
return ListAsyncSidFailuresDto.from(job, offset, limit);
|
||||
}
|
||||
|
||||
@GetMapping("/{jobKey}/range-failures")
|
||||
public java.util.Map<String,Object> rangeFailures(@PathVariable Long prjctIdx, @PathVariable String jobKey,
|
||||
@RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "100") int limit, RequestUserContext user) {
|
||||
return failurePage(prjctIdx, jobKey, offset, limit, user, "rangeFailures");
|
||||
}
|
||||
|
||||
@GetMapping("/{jobKey}/validation-errors")
|
||||
public java.util.Map<String,Object> validationErrors(@PathVariable Long prjctIdx, @PathVariable String jobKey,
|
||||
@RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "100") int limit, RequestUserContext user) {
|
||||
return failurePage(prjctIdx, jobKey, offset, limit, user, "validationErrors");
|
||||
}
|
||||
|
||||
private java.util.Map<String,Object> failurePage(Long prjctIdx, String jobKey, int offset, int limit, RequestUserContext user, String field) {
|
||||
var job = access.require(prjctIdx, jobKey, user);
|
||||
if (offset < 0 || limit < 1 || limit > 1000) throw BusinessException.badRequest("INVALID_FAILURE_PAGE", "조회 범위가 올바르지 않습니다.");
|
||||
var detail = job.getErrorDetailJson();
|
||||
var failures = detail != null && detail.get(field) instanceof List<?> values ? values : List.of();
|
||||
int start = Math.min(offset, failures.size());
|
||||
return java.util.Map.of("total", failures.size(), "offset", offset,
|
||||
"items", failures.subList(start, (int) Math.min(failures.size(), (long) start + limit)));
|
||||
}
|
||||
|
||||
@GetMapping("/{jobKey}/files/{index}")
|
||||
public void download(@PathVariable Long prjctIdx, @PathVariable String jobKey,
|
||||
@PathVariable int index, RequestUserContext user, HttpServletResponse response) throws IOException {
|
||||
TListAsyncJobEntity job = access.require(prjctIdx, jobKey, user);
|
||||
List<ListAsyncResultFileDto> results = job.getResultFilesJson();
|
||||
if (results == null || index < 0 || index >= results.size() || !results.get(index).ready()) {
|
||||
throw BusinessException.notFound("LIST_RESULT_FILE_NOT_FOUND", "결과 파일을 찾을 수 없습니다.");
|
||||
}
|
||||
ListAsyncResultFileDto result = results.get(index);
|
||||
files.download(result.fileRef(), path -> {
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader(HttpHeaders.CACHE_CONTROL, "no-store");
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION,
|
||||
ContentDisposition.attachment().filename(result.fileName(), StandardCharsets.UTF_8).build().toString());
|
||||
response.setContentLengthLong(Files.size(path));
|
||||
Files.copy(path, response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
});
|
||||
}
|
||||
|
||||
private ListAsyncJobStatusDto toStatus(TListAsyncJobEntity job) {
|
||||
var results = job.getResultFilesJson() == null
|
||||
? List.<ListAsyncResultFileDto>of() : job.getResultFilesJson();
|
||||
var resultViews = IntStream.range(0, results.size()).mapToObj(index -> {
|
||||
var file = results.get(index);
|
||||
return new ListAsyncJobStatusDto.ResultFile(index, file.type(), file.fileName(),
|
||||
file.sizeBytes(), file.ready() && files.exists(file.fileRef()));
|
||||
}).toList();
|
||||
long failed = ListAsyncJobStore.failedSidCount(job);
|
||||
long processed = processedSidCount(job);
|
||||
Long remaining = job.getTotalSidCnt() == null ? null : Math.max(0L, job.getTotalSidCnt() - processed);
|
||||
return new ListAsyncJobStatusDto(job.getJobKey(), job.getJobType(),
|
||||
ListAsyncAssignOperation.fromRequest(job.getJobType(), job.getRequestJson()), job.getJobStatus(),
|
||||
job.getJobStage(), job.getTotalSidCnt(), job.getCompletedSidCnt(), job.getCompletedChunkCnt(),
|
||||
failed, processed, remaining,
|
||||
job.getProgressJson(), job.getFailedChunkNo(), job.getErrorCode(), job.getErrorMessage(),
|
||||
job.getCancelReason(), job.getRegDt(), job.getStartedDt(), job.getFinishedDt(), resultViews);
|
||||
}
|
||||
|
||||
private static long processedSidCount(TListAsyncJobEntity job) {
|
||||
return Math.addExact(job.getCompletedSidCnt(), ListAsyncJobStore.failedSidCount(job));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.common.enums.ListAsyncJobType;
|
||||
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListUploadRequestDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncJobAcceptedDto;
|
||||
import com.kri.contact.server.service.async.ListAsyncJobAccess;
|
||||
import com.kri.contact.server.service.async.ListAsyncMaintenanceService;
|
||||
import com.kri.contact.server.service.file.ListFileService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/list/jobs/{prjctIdx}")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "ListAsyncMaintenance", description = "리스트 비동기 업로드 및 초기화 API")
|
||||
public class ListAsyncMaintenanceController {
|
||||
private final ListAsyncMaintenanceService maintenance;
|
||||
private final ListAsyncJobAccess access;
|
||||
private final ListFileService sources;
|
||||
|
||||
@PostMapping("/reset")
|
||||
public ListAsyncJobAcceptedDto reset(@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListResetRequestDto request, RequestUserContext user) {
|
||||
return maintenance.reset(prjctIdx, request, user);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ListAsyncJobAcceptedDto upload(@PathVariable Long prjctIdx, @RequestParam("file") MultipartFile file,
|
||||
@Valid @RequestPart("request") ListUploadRequestDto request, RequestUserContext user) {
|
||||
return maintenance.upload(prjctIdx, file, request, user);
|
||||
}
|
||||
|
||||
@GetMapping("/{jobKey}/source-file")
|
||||
public void source(@PathVariable Long prjctIdx, @PathVariable String jobKey, RequestUserContext user,
|
||||
HttpServletResponse response) throws IOException {
|
||||
var job = access.require(prjctIdx, jobKey, user);
|
||||
if (job.getJobType() != ListAsyncJobType.LIST_UPLOAD || job.getInputFileRef() == null) {
|
||||
throw BusinessException.notFound("LIST_UPLOAD_FILE_NOT_FOUND", "원본 파일을 찾을 수 없습니다.");
|
||||
}
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader(HttpHeaders.CACHE_CONTROL, "no-store");
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, ContentDisposition.attachment()
|
||||
.filename("upload_source.xlsx", StandardCharsets.UTF_8).build().toString());
|
||||
sources.copyListFile(prjctIdx, job.getInputFileRef(), response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.common.enums.ChannelType;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncJobAcceptedDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
||||
import com.kri.contact.server.service.async.ListAsyncJobAccess;
|
||||
import com.kri.contact.server.service.async.ListAsyncMessageService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/list/jobs/{prjctIdx}")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "ListAsyncMessage", description = "리스트 비동기 메시지 발송 API")
|
||||
public class ListAsyncMessageController {
|
||||
private final ListAsyncMessageService messages;
|
||||
private final ListAsyncJobAccess access;
|
||||
|
||||
@PostMapping("/messages/email")
|
||||
public ListAsyncJobAcceptedDto email(@PathVariable Long prjctIdx, @Valid @RequestBody MessageSendBulkRequestDto request, RequestUserContext user) {
|
||||
return messages.submit(prjctIdx, ChannelType.EMAIL, request, user);
|
||||
}
|
||||
@PostMapping("/messages/sms")
|
||||
public ListAsyncJobAcceptedDto sms(@PathVariable Long prjctIdx, @Valid @RequestBody MessageSendBulkRequestDto request, RequestUserContext user) {
|
||||
return messages.submit(prjctIdx, ChannelType.SMS, request, user);
|
||||
}
|
||||
@PostMapping("/messages/kko")
|
||||
public ListAsyncJobAcceptedDto kko(@PathVariable Long prjctIdx, @Valid @RequestBody MessageSendBulkRequestDto request, RequestUserContext user) {
|
||||
return messages.submit(prjctIdx, ChannelType.KKO_AT, request, user);
|
||||
}
|
||||
public record ReportPage(int total, int offset, List<?> items) {}
|
||||
|
||||
@GetMapping("/{jobKey}/message-report/{section}")
|
||||
public ReportPage report(@PathVariable Long prjctIdx, @PathVariable String jobKey, @PathVariable String section,
|
||||
@RequestParam(defaultValue = "0") int offset, @RequestParam(defaultValue = "100") int limit, RequestUserContext user) {
|
||||
var job = access.require(prjctIdx, jobKey, user);
|
||||
String field = switch (section) {
|
||||
case "batches" -> "messageBatches";
|
||||
case "preparation-failures" -> "preparationFailures";
|
||||
default -> throw BusinessException.badRequest("INVALID_REPORT_SECTION", "조회 항목이 올바르지 않습니다.");
|
||||
};
|
||||
if (offset < 0 || limit < 1 || limit > 1000) throw BusinessException.badRequest("INVALID_REPORT_PAGE", "조회 범위가 올바르지 않습니다.");
|
||||
var detail = job.getErrorDetailJson() == null ? Map.<String,Object>of() : job.getErrorDetailJson();
|
||||
List<?> items = detail.get(field) instanceof List<?> values ? values : List.of();
|
||||
int start = Math.min(offset, items.size());
|
||||
return new ReportPage(items.size(), offset, items.subList(start, (int) Math.min(items.size(), (long) start + limit)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.list.ListAssignRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListAssignResetRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListUpdateRequestDto;
|
||||
import com.kri.contact.server.dto.list.async.ListAsyncJobAcceptedDto;
|
||||
import com.kri.contact.server.service.async.ListAsyncMutationService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/list/jobs/{prjctIdx}/mutations")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "ListAsyncMutation", description = "리스트 비동기 수정 및 배정 API")
|
||||
public class ListAsyncMutationController {
|
||||
private final ListAsyncMutationService mutations;
|
||||
|
||||
@PostMapping("/update")
|
||||
public ListAsyncJobAcceptedDto update(@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListUpdateRequestDto request, RequestUserContext user) {
|
||||
return mutations.update(prjctIdx, request, user);
|
||||
}
|
||||
|
||||
@PostMapping("/assign/{assignId}")
|
||||
public ListAsyncJobAcceptedDto assign(@PathVariable Long prjctIdx, @PathVariable String assignId,
|
||||
@Valid @RequestBody ListAssignRequestDto request, RequestUserContext user) {
|
||||
return mutations.assign(prjctIdx, assignId, request, user);
|
||||
}
|
||||
|
||||
@PostMapping("/assign-reset")
|
||||
public ListAsyncJobAcceptedDto resetAssignments(@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListAssignResetRequestDto request, RequestUserContext user) {
|
||||
return mutations.resetAssignments(prjctIdx, request, user);
|
||||
}
|
||||
}
|
||||
@@ -7,19 +7,14 @@ import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.common.feature.web.page.PageResponseDto;
|
||||
import com.kri.contact.server.common.enums.ListSearchResponseType;
|
||||
import com.kri.contact.server.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchWithFullResultDto;
|
||||
import com.kri.contact.server.dto.list.ListUpdateRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListUploadFileInfoDto;
|
||||
import com.kri.contact.server.dto.list.ListUploadHistoryDto;
|
||||
import com.kri.contact.server.dto.list.ListUploadRequestDto;
|
||||
import com.kri.contact.server.dto.project.ProjectInfoDto;
|
||||
import com.kri.contact.server.dto.systemlog.UploadContentDto;
|
||||
import com.kri.contact.server.service.ListDownloadService;
|
||||
import com.kri.contact.server.service.ListResetService;
|
||||
import com.kri.contact.server.service.ListSearchService;
|
||||
import com.kri.contact.server.service.ListUpdateService;
|
||||
import com.kri.contact.server.service.ListUploadService;
|
||||
@@ -38,7 +33,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -46,7 +40,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -61,7 +54,6 @@ public class ListController {
|
||||
private final ListSearchService listSearchService;
|
||||
private final ListUploadService listUploadService;
|
||||
private final ListUpdateService listUpdateService;
|
||||
private final ListResetService listResetService;
|
||||
private final SystemEventLogService systemEventLogService;
|
||||
|
||||
@Operation(summary = "리스트 정보 조회 With Sid")
|
||||
@@ -112,49 +104,6 @@ public class ListController {
|
||||
return buildExcelResponse(uploadFile.getFileName(), uploadFile.getBytes());
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 다운로드")
|
||||
@PostMapping("/excel/download/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadList(
|
||||
@PathVariable Long prjctIdx,
|
||||
@RequestParam(defaultValue = "true") boolean includeResult,
|
||||
@Valid @RequestBody(required = false) ListFilterDto listFilter
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadList(
|
||||
prjctIdx,
|
||||
listFilter,
|
||||
includeResult
|
||||
);
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " list.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 수정 이력 다운로드")
|
||||
@PostMapping("/excel/download/update/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadListUpdateHistory(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody(required = false) ListFilterDto listFilter
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadSidWithUpdateHist(prjctIdx, listFilter);
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " 수정 이력.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 파일 업로드")
|
||||
@PostMapping(value = "/excel/upload/{prjctIdx}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ExcelUploadResultDto uploadExcel(
|
||||
@PathVariable Long prjctIdx,
|
||||
@RequestParam("file") MultipartFile file,
|
||||
@Valid @RequestPart("request") ListUploadRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
getProjectOrThrow(prjctIdx);
|
||||
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
ExcelUploadResultDto result = listUploadService.uploadExcel(prjctIdx, file, request, ctx.getUserId(), now);
|
||||
systemEventLogService.writeUploadList(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, UploadContentDto.from(file));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 수정")
|
||||
@PatchMapping("/update/{prjctIdx}")
|
||||
public int updateList(
|
||||
@@ -189,17 +138,6 @@ public class ListController {
|
||||
systemEventLogService.writeUploadListItemFiles(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, contents);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 별 업로드 파일 다운로드")
|
||||
@PostMapping("/item-file/download/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadItemFile(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody(required = false) ListFilterDto listFilter
|
||||
){
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadItemFile(prjctIdx, listFilter);
|
||||
return buildZipResponse(projectInfoDto.getPrjctName() + " item_files.zip", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 단건 파일 다운로드")
|
||||
@GetMapping("/item-file/download/{prjctIdx}/{sid}/{listHderId}")
|
||||
public ResponseEntity<byte[]> downloadOneItemFile(
|
||||
@@ -212,25 +150,6 @@ public class ListController {
|
||||
return buildFileResponse(file.getFileName(), file.getBytes());
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 초기화")
|
||||
@DeleteMapping("/{prjctIdx}")
|
||||
public int resetList(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListResetRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
int resetCount = listResetService.resetByFilter(
|
||||
prjctIdx,
|
||||
request.getListFilter(),
|
||||
request.getResetMode(),
|
||||
ctx.getUserId(),
|
||||
now
|
||||
);
|
||||
systemEventLogService.writeResetList(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, request);
|
||||
return resetCount;
|
||||
}
|
||||
|
||||
private ProjectInfoDto getProjectOrThrow(Long prjctIdx) {
|
||||
ProjectInfoDto projectInfoDto = projectService.getProject(prjctIdx);
|
||||
if (projectInfoDto == null) {
|
||||
@@ -239,16 +158,6 @@ public class ListController {
|
||||
return projectInfoDto;
|
||||
}
|
||||
|
||||
private ResponseEntity<byte[]> buildZipResponse(String fileName, byte[] bytes) {
|
||||
String contentDisposition = "attachment; filename*=UTF-8''" +
|
||||
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
|
||||
.contentType(MediaType.parseMediaType("application/zip"))
|
||||
.body(bytes);
|
||||
}
|
||||
|
||||
private ResponseEntity<byte[]> buildFileResponse(String fileName, byte[] bytes) {
|
||||
String contentDisposition = "attachment; filename*=UTF-8''" +
|
||||
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import static com.kri.contact.server.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.list.ListEventHistDownloadRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListEventHistFromSurveyDto;
|
||||
import com.kri.contact.server.dto.list.ListEventHistInsertRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListEventHistSurveyMetaDto;
|
||||
import com.kri.contact.server.dto.list.ListEventHistoryDto;
|
||||
import com.kri.contact.server.dto.list.ListUpdateHistoryDto;
|
||||
import com.kri.contact.server.dto.project.ProjectInfoDto;
|
||||
import com.kri.contact.server.service.ListDownloadService;
|
||||
import com.kri.contact.server.service.ListHistoryQueryService;
|
||||
import com.kri.contact.server.service.ListUpdateService;
|
||||
import com.kri.contact.server.service.ProjectService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -30,7 +23,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@@ -39,8 +31,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Tag(name = "ListHistory", description = "리스트 이력 API")
|
||||
public class ListHistoryController {
|
||||
|
||||
private final ProjectService projectService;
|
||||
private final ListDownloadService listDownloadService;
|
||||
private final ListHistoryQueryService listHistoryQueryService;
|
||||
private final ListUpdateService listUpdateService;
|
||||
|
||||
@@ -62,26 +52,6 @@ public class ListHistoryController {
|
||||
return listHistoryQueryService.findUpdateHistories(prjctIdx, sid);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 이벤트 이력 다운로드")
|
||||
@PostMapping("/excel/download/event/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadListWithEventHistory(
|
||||
@PathVariable Long prjctIdx,
|
||||
@RequestParam(defaultValue = "true") boolean includeResult,
|
||||
@Valid @RequestBody ListEventHistDownloadRequestDto request
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadListWithEventHist(
|
||||
prjctIdx,
|
||||
request.getListFilter(),
|
||||
request.getResultCodeTypes(),
|
||||
request.getSearchBase(),
|
||||
request.getDateRange(),
|
||||
request.getHistoryOrder(),
|
||||
includeResult
|
||||
);
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " 컨택 이력.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(description = "설문 상태 추가")
|
||||
@PostMapping("/survey")
|
||||
public void putSurveyHistory(
|
||||
@@ -139,12 +109,4 @@ public class ListHistoryController {
|
||||
}
|
||||
return "SYSTEM";
|
||||
}
|
||||
|
||||
private ProjectInfoDto getProjectOrThrow(Long prjctIdx) {
|
||||
ProjectInfoDto projectInfoDto = projectService.getProject(prjctIdx);
|
||||
if (projectInfoDto == null) {
|
||||
throw BusinessException.internalError("프로젝트가 없습니다.");
|
||||
}
|
||||
return projectInfoDto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.contact.server.dto.message.MessageSendBulkResponseDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
||||
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
||||
import com.kri.contact.server.service.MessageSendService;
|
||||
@@ -34,16 +32,6 @@ public class MessageSendController {
|
||||
return messageSendService.sendEmailSingle(prjctIdx, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "Email bulk send")
|
||||
@PostMapping("/email/bulk/{prjctIdx}")
|
||||
public MessageSendBulkResponseDto sendEmailBulk(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody MessageSendBulkRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageSendService.sendEmailBulk(prjctIdx, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "Kakao Alimtalk single send")
|
||||
@PostMapping("/kko/single/{prjctIdx}")
|
||||
public MessageSendSingleResponseDto sendKkoSingle(
|
||||
@@ -54,16 +42,6 @@ public class MessageSendController {
|
||||
return messageSendService.sendKkoSingle(prjctIdx, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "Kakao Alimtalk bulk send")
|
||||
@PostMapping("/kko/bulk/{prjctIdx}")
|
||||
public MessageSendBulkResponseDto sendKkoBulk(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody MessageSendBulkRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageSendService.sendKkoBulk(prjctIdx, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "SMS single send")
|
||||
@PostMapping("/sms/single/{prjctIdx}")
|
||||
public MessageSendSingleResponseDto sendSmsSingle(
|
||||
@@ -73,14 +51,4 @@ public class MessageSendController {
|
||||
) {
|
||||
return messageSendService.sendSmsSingle(prjctIdx, request, ctx);
|
||||
}
|
||||
|
||||
@Operation(summary = "SMS bulk send")
|
||||
@PostMapping("/sms/bulk/{prjctIdx}")
|
||||
public MessageSendBulkResponseDto sendSmsBulk(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody MessageSendBulkRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return messageSendService.sendSmsBulk(prjctIdx, request, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user