From 3c796652789c188e862b218d9e32d427c0d63326 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 29 Sep 2026 15:57:02 +0900 Subject: [PATCH] =?UTF-8?q?260929=5F01=5FENH:=20=EB=AA=A8=EB=8B=88?= =?UTF-8?q?=ED=84=B0=EB=A7=81=20=ED=8F=89=EA=B0=80=EC=96=91=EC=8B=9D?= =?UTF-8?q?=EC=97=90=20classification=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/common/consts/KmusicalConstant.java | 2 + .../back/controller/ReviewController.java | 13 +++-- .../back/service/ReviewTemplateService.java | 48 ++++++++++++++----- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/kri/kmusical/manage/back/common/consts/KmusicalConstant.java b/src/main/java/com/kri/kmusical/manage/back/common/consts/KmusicalConstant.java index 4910550..180c683 100644 --- a/src/main/java/com/kri/kmusical/manage/back/common/consts/KmusicalConstant.java +++ b/src/main/java/com/kri/kmusical/manage/back/common/consts/KmusicalConstant.java @@ -20,4 +20,6 @@ public class KmusicalConstant { ISSUANCE_REQUEST_FORM_TYPE, "IssuanceRequestForm" ); public static final Integer COMPLETE_STATUS = 10; + + public static final List REVIEW_CLASSIFICATION = List.of(1, 2); } diff --git a/src/main/java/com/kri/kmusical/manage/back/controller/ReviewController.java b/src/main/java/com/kri/kmusical/manage/back/controller/ReviewController.java index 244a9d9..6714b8e 100644 --- a/src/main/java/com/kri/kmusical/manage/back/controller/ReviewController.java +++ b/src/main/java/com/kri/kmusical/manage/back/controller/ReviewController.java @@ -100,25 +100,28 @@ public class ReviewController { @PostMapping(value = "/template/upload/{reviewType}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public String uploadReviewTemplate( @PathVariable Integer reviewType, + @RequestParam(required = false) Integer classification, @RequestParam("file") MultipartFile file ) { - return reviewTemplateService.uploadReviewTemplate(reviewType, file); + return reviewTemplateService.uploadReviewTemplate(reviewType, classification, file); } @Operation(summary = "평가양식 다운로드") @GetMapping("/template/download/{reviewType}") public ResponseEntity 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 다운로드") @GetMapping("/template/pdf/{reviewType}") public ResponseEntity 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 download(Resource resource) { diff --git a/src/main/java/com/kri/kmusical/manage/back/service/ReviewTemplateService.java b/src/main/java/com/kri/kmusical/manage/back/service/ReviewTemplateService.java index 329f13a..c19eb10 100644 --- a/src/main/java/com/kri/kmusical/manage/back/service/ReviewTemplateService.java +++ b/src/main/java/com/kri/kmusical/manage/back/service/ReviewTemplateService.java @@ -1,5 +1,7 @@ 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 com.kri.common.feature.util.StringUtil; @@ -35,14 +37,19 @@ public class ReviewTemplateService extends AbstractFileService { .normalize(); } - public String uploadReviewTemplate(Integer reviewType, MultipartFile file) { + public String uploadReviewTemplate(Integer reviewType, Integer classification, MultipartFile file) { validateReviewTemplateType(reviewType); + + if(MONITORING_REVIEW_TYPE.equals(reviewType)){ + validateReviewTemplateClassification(classification); + } + if (file == null || file.isEmpty()) { throw BusinessException.badRequest("EMPTY_FILE", "업로드된 파일이 없습니다."); } String fileName = sanitizeFileName(file.getOriginalFilename()); - Path dir = templateDir(reviewType); + Path dir = templateDir(reviewType, classification); try { deleteExistingFiles(dir); @@ -55,20 +62,24 @@ public class ReviewTemplateService extends AbstractFileService { } } - public PathResource getReviewTemplateResource(Integer reviewType) { - Path file = findReviewTemplateFile(reviewType, false); + public PathResource getReviewTemplateResource(Integer reviewType, Integer classification) { + Path file = findReviewTemplateFile(reviewType, classification, false); return new PathResource(file); } - public PathResource getReviewTemplatePdfResource(Integer reviewType) { - Path file = findReviewTemplateFile(reviewType, true); + public PathResource getReviewTemplatePdfResource(Integer reviewType, Integer classification) { + Path file = findReviewTemplateFile(reviewType, classification, true); return new PathResource(file); } - private Path findReviewTemplateFile(Integer reviewType, boolean pdf) { + private Path findReviewTemplateFile(Integer reviewType, Integer classification, boolean pdf) { validateReviewTemplateType(reviewType); - Path dir = templateDir(reviewType); + if(MONITORING_REVIEW_TYPE.equals(reviewType)){ + validateReviewTemplateClassification(classification); + } + + Path dir = templateDir(reviewType, classification); if (!Files.isDirectory(dir)) { throw BusinessException.notFound("REVIEW_TEMPLATE_NOT_FOUND", "평가양식 파일이 없습니다.") .with("reviewType", reviewType); @@ -140,11 +151,15 @@ public class ReviewTemplateService extends AbstractFileService { return ".pdf".equalsIgnoreCase(extractExtension(fileName)); } - private Path templateDir(Integer reviewType) { - return getBaseDir() - .resolve(String.valueOf(reviewType)) - .toAbsolutePath() - .normalize(); + private Path templateDir(Integer reviewType, Integer classification) { + Path dir = getBaseDir() + .resolve(String.valueOf(reviewType)); + + if (MONITORING_REVIEW_TYPE.equals(reviewType) && classification != null) { + dir = dir.resolve(String.valueOf(classification)); + } + + return dir.toAbsolutePath().normalize(); } 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) { if (StringUtil.isNullOrBlank(originalFileName)) { return "review-template";