Skip to content

Commit

Permalink
feat: 데이터베이스에 inputFileName도 저장 (#49)
Browse files Browse the repository at this point in the history
* refactor: 불필요한 의존성 제거

* feat: 데이터베이스에 원본 파일 이름 저장
  • Loading branch information
gitchannn authored Feb 22, 2024
1 parent e6cd367 commit ca66d37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import org.springframework.web.multipart.MultipartFile;
import sunflower.server.application.dto.TranslationStatusDto;
import sunflower.server.application.event.OcrRegisterEvent;
import sunflower.server.client.OcrDownloadClient;
import sunflower.server.client.OcrRegisterClient;
import sunflower.server.client.OcrStatusClient;
import sunflower.server.entity.Translations;
import sunflower.server.repository.TranslationsRepository;

Expand All @@ -29,16 +26,14 @@ public class TranslationService {

private final TranslationsRepository translationsRepository;
private final ResourceLoader resourceLoader;
private final OcrRegisterClient ocrRegisterClient;
private final OcrStatusClient ocrStatusClient;
private final OcrDownloadClient ocrDownloadClient;
private final ApplicationEventPublisher eventPublisher;

@Transactional
public Long register(final MultipartFile file) {
final String pdfURI = saveFile(file).replace("file:", "");
log.info("Saved pdf File in Server. File URI: {}", pdfURI);
final Translations translations = translationsRepository.save(Translations.of(pdfURI));

final Translations translations = translationsRepository.save(Translations.of(pdfURI, file.getOriginalFilename()));

eventPublisher.publishEvent(new OcrRegisterEvent(this, translations));
log.info("pdf file 저장 이벤트를 발행했습니다!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Translations {
@GeneratedValue(strategy = IDENTITY)
private Long id;

private String fileName;
private String inputFileName;
private String pdfURI;
private String ocrPdfId;

Expand All @@ -36,16 +36,21 @@ public class Translations {
private Integer translationPercentDone;
private String brfFileURI;

public static Translations of(final String pdfURI) {
public static Translations of(final String pdfURI, final String inputFileName) {
final Translations translations = new Translations();
translations.changePdfURI(pdfURI);
translations.changeInputFileName(inputFileName);
return translations;
}

private void changePdfURI(final String pdfURI) {
this.pdfURI = pdfURI;
}

private void changeInputFileName(final String inputFileName) {
this.inputFileName = inputFileName;
}

public void startOcr() {
this.ocrPercentDone = 0;
this.ocrStatus = OcrStatus.SPLIT;
Expand Down

0 comments on commit ca66d37

Please sign in to comment.