|
|
|
@ -3,7 +3,6 @@ package kr.re.etri.autoflow.controllers;
|
|
|
|
import io.minio.*;
|
|
|
|
import io.minio.*;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
|
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import kr.re.etri.autoflow.entity.MinioAttachmentEntity;
|
|
|
|
import kr.re.etri.autoflow.entity.MinioAttachmentEntity;
|
|
|
|
import kr.re.etri.autoflow.payload.request.BaseSearchRequest;
|
|
|
|
import kr.re.etri.autoflow.payload.request.BaseSearchRequest;
|
|
|
|
@ -12,7 +11,6 @@ import kr.re.etri.autoflow.service.MinioAttachmentService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
@ -96,4 +94,33 @@ public class AttachmentController {
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "파일 업데이트", description = "파일을 새 버전으로 업로드합니다. 기존 파일은 그대로 보존되고, 버전은 +1 증가합니다.")
|
|
|
|
|
|
|
|
@PutMapping(value = "/{id}/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
|
|
|
|
public ResponseEntity<Map<String, Object>> updateFile(
|
|
|
|
|
|
|
|
@Parameter(description = "기존 첨부파일 ID", required = true)
|
|
|
|
|
|
|
|
@PathVariable("id") Long id,
|
|
|
|
|
|
|
|
@Parameter(description = "새 파일") @RequestPart("file") MultipartFile file,
|
|
|
|
|
|
|
|
@RequestPart(value = "path", required = false) String path,
|
|
|
|
|
|
|
|
@RequestParam(value = "title", required = false) String title,
|
|
|
|
|
|
|
|
@RequestParam(value = "description", required = false) String description,
|
|
|
|
|
|
|
|
@RequestParam(value = "regUserId") String regUserId
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MinioAttachmentEntity updated = minioAttachmentService.updateFile(
|
|
|
|
|
|
|
|
id, file, path, title, description, regUserId
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> response = new HashMap<>();
|
|
|
|
|
|
|
|
response.put("attachment", updated);
|
|
|
|
|
|
|
|
response.put("minioUrl", minioAttachmentService.getFileUrl(updated.getStoragePath()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(response);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("파일 업데이트 실패", e);
|
|
|
|
|
|
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|