[BO] 수정사항 반영 (1)
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package app.module.core.usecase.file.createFile.ports.application;
|
||||
|
||||
import app.module.core.config.application.enums.FileUploadType;
|
||||
import app.module.core.usecase.file.createFile.ports.CreateFilePortIn;
|
||||
import app.module.core.usecase.file.createFile.ports.CreateFilePortOut;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFile;
|
||||
import app.module.core.usecase.file.createFile.ports.application.domain.CreateFileCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class CreateFileService implements CreateFilePortIn {
|
||||
@@ -16,6 +19,24 @@ class CreateFileService implements CreateFilePortIn {
|
||||
|
||||
@Override
|
||||
public Optional<CreateFile> operate(CreateFileCmd command) {
|
||||
validateFileSize(command);
|
||||
return portOut.operate(command);
|
||||
}
|
||||
|
||||
private void validateFileSize(CreateFileCmd command) {
|
||||
// 공지사항 파일 업로드 형식 파일당 최대 5MB
|
||||
if(FileUploadType.NOTICE.equals(command.getType())) {
|
||||
long NOTICE_MAX_FILE_SIZE = 5 * 1024 * 1024;
|
||||
|
||||
if (command.getFileLength() != null && command.getFileLength() > NOTICE_MAX_FILE_SIZE) {
|
||||
log.info(String.format(
|
||||
"파일 크기는 5MB 이하만 업로드 가능합니다: %s (크기: %.2fMB)",
|
||||
command.getOriginName(),
|
||||
command.getFileLength() / (1024.0 * 1024.0)
|
||||
));
|
||||
|
||||
throw new IllegalArgumentException("파일 크기는 5MB 이하만 업로드 가능합니다");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user