260929_01_ENH: 모니터링 평가양식에 classification추가

This commit is contained in:
2026-09-29 15:57:02 +09:00
parent cf99de9e14
commit 3c79665278
3 changed files with 45 additions and 18 deletions

View File

@@ -20,4 +20,6 @@ public class KmusicalConstant {
ISSUANCE_REQUEST_FORM_TYPE, "IssuanceRequestForm" ISSUANCE_REQUEST_FORM_TYPE, "IssuanceRequestForm"
); );
public static final Integer COMPLETE_STATUS = 10; public static final Integer COMPLETE_STATUS = 10;
public static final List<Integer> REVIEW_CLASSIFICATION = List.of(1, 2);
} }

View File

@@ -100,25 +100,28 @@ public class ReviewController {
@PostMapping(value = "/template/upload/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/template/upload/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public String uploadReviewTemplate( public String uploadReviewTemplate(
@PathVariable Integer reviewType, @PathVariable Integer reviewType,
@RequestParam(required = false) Integer classification,
@RequestParam("file") MultipartFile file @RequestParam("file") MultipartFile file
) { ) {
return reviewTemplateService.uploadReviewTemplate(reviewType, file); return reviewTemplateService.uploadReviewTemplate(reviewType, classification, file);
} }
@Operation(summary = "평가양식 다운로드") @Operation(summary = "평가양식 다운로드")
@GetMapping("/template/download/{reviewType}") @GetMapping("/template/download/{reviewType}")
public ResponseEntity<Resource> downloadReviewTemplate( public ResponseEntity<Resource> downloadReviewTemplate(
@PathVariable Integer reviewType @PathVariable Integer reviewType,
@RequestParam(required = false) Integer classification
) { ) {
return download(reviewTemplateService.getReviewTemplateResource(reviewType)); return download(reviewTemplateService.getReviewTemplateResource(reviewType, classification));
} }
@Operation(summary = "평가양식 pdf 다운로드") @Operation(summary = "평가양식 pdf 다운로드")
@GetMapping("/template/pdf/{reviewType}") @GetMapping("/template/pdf/{reviewType}")
public ResponseEntity<Resource> downloadReviewPdfTemplate( public ResponseEntity<Resource> downloadReviewPdfTemplate(
@PathVariable Integer reviewType @PathVariable Integer reviewType,
@RequestParam(required = false) Integer classification
) { ) {
return download(reviewTemplateService.getReviewTemplatePdfResource(reviewType)); return download(reviewTemplateService.getReviewTemplatePdfResource(reviewType, classification));
} }
private ResponseEntity<Resource> download(Resource resource) { private ResponseEntity<Resource> download(Resource resource) {

View File

@@ -1,5 +1,7 @@
package com.kri.kmusical.manage.back.service; package com.kri.kmusical.manage.back.service;
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.MONITORING_REVIEW_TYPE;
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.REVIEW_CLASSIFICATION;
import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.REVIEW_TYPE; import static com.kri.kmusical.manage.back.common.consts.KmusicalConstant.REVIEW_TYPE;
import com.kri.common.feature.util.StringUtil; import com.kri.common.feature.util.StringUtil;
@@ -35,14 +37,19 @@ public class ReviewTemplateService extends AbstractFileService {
.normalize(); .normalize();
} }
public String uploadReviewTemplate(Integer reviewType, MultipartFile file) { public String uploadReviewTemplate(Integer reviewType, Integer classification, MultipartFile file) {
validateReviewTemplateType(reviewType); validateReviewTemplateType(reviewType);
if(MONITORING_REVIEW_TYPE.equals(reviewType)){
validateReviewTemplateClassification(classification);
}
if (file == null || file.isEmpty()) { if (file == null || file.isEmpty()) {
throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다."); throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다.");
} }
String fileName = sanitizeFileName(file.getOriginalFilename()); String fileName = sanitizeFileName(file.getOriginalFilename());
Path dir = templateDir(reviewType); Path dir = templateDir(reviewType, classification);
try { try {
deleteExistingFiles(dir); deleteExistingFiles(dir);
@@ -55,20 +62,24 @@ public class ReviewTemplateService extends AbstractFileService {
} }
} }
public PathResource getReviewTemplateResource(Integer reviewType) { public PathResource getReviewTemplateResource(Integer reviewType, Integer classification) {
Path file = findReviewTemplateFile(reviewType, false); Path file = findReviewTemplateFile(reviewType, classification, false);
return new PathResource(file); return new PathResource(file);
} }
public PathResource getReviewTemplatePdfResource(Integer reviewType) { public PathResource getReviewTemplatePdfResource(Integer reviewType, Integer classification) {
Path file = findReviewTemplateFile(reviewType, true); Path file = findReviewTemplateFile(reviewType, classification, true);
return new PathResource(file); return new PathResource(file);
} }
private Path findReviewTemplateFile(Integer reviewType, boolean pdf) { private Path findReviewTemplateFile(Integer reviewType, Integer classification, boolean pdf) {
validateReviewTemplateType(reviewType); validateReviewTemplateType(reviewType);
Path dir = templateDir(reviewType); if(MONITORING_REVIEW_TYPE.equals(reviewType)){
validateReviewTemplateClassification(classification);
}
Path dir = templateDir(reviewType, classification);
if (!Files.isDirectory(dir)) { if (!Files.isDirectory(dir)) {
throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.") throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.")
.with("reviewType", reviewType); .with("reviewType", reviewType);
@@ -140,11 +151,15 @@ public class ReviewTemplateService extends AbstractFileService {
return ".pdf".equalsIgnoreCase(extractExtension(fileName)); return ".pdf".equalsIgnoreCase(extractExtension(fileName));
} }
private Path templateDir(Integer reviewType) { private Path templateDir(Integer reviewType, Integer classification) {
return getBaseDir() Path dir = getBaseDir()
.resolve(String.valueOf(reviewType)) .resolve(String.valueOf(reviewType));
.toAbsolutePath()
.normalize(); if (MONITORING_REVIEW_TYPE.equals(reviewType) && classification != null) {
dir = dir.resolve(String.valueOf(classification));
}
return dir.toAbsolutePath().normalize();
} }
private void validateReviewTemplateType(Integer reviewType) { private void validateReviewTemplateType(Integer reviewType) {
@@ -154,6 +169,13 @@ public class ReviewTemplateService extends AbstractFileService {
} }
} }
private void validateReviewTemplateClassification(Integer classification) {
if (!REVIEW_CLASSIFICATION.contains(classification)) {
throw BusinessException.badRequest("INVALID_REVIEW_TEMPLATE_CLASSIFICATION", "유효하지 않은 평가양식 분류입니다.")
.with("classification", classification);
}
}
private String sanitizeFileName(String originalFileName) { private String sanitizeFileName(String originalFileName) {
if (StringUtil.isNullOrBlank(originalFileName)) { if (StringUtil.isNullOrBlank(originalFileName)) {
return "review-template"; return "review-template";