feat: file_store 테이블 생성
This commit is contained in:
@@ -40,11 +40,9 @@ public class BookVersion extends BaseEntity {
|
||||
@Enumerated(EnumType.STRING)
|
||||
private LengthPreset lengthPreset;
|
||||
|
||||
@Column(name = "book_s3_key")
|
||||
private String bookS3Key;
|
||||
private Long bookFileId;
|
||||
|
||||
@Column(name = "audio_s3_key")
|
||||
private String audioS3Key;
|
||||
private Long audioFileId;
|
||||
|
||||
private String language = "en-Us";
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.audio.core.storage.domain.entity;
|
||||
|
||||
import com.audio.common.entity.BaseEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Entity
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
public class FileStore extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String objectKey;
|
||||
|
||||
private String originalFileName;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private Long sizeBytes;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.audio.core.storage.domain.repository;
|
||||
|
||||
import com.audio.core.storage.domain.entity.FileStore;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface FileStoreRepository extends JpaRepository<FileStore, Long> {
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.audio.core.storage.domain.service;
|
||||
|
||||
import com.audio.core.storage.domain.entity.FileStore;
|
||||
import com.audio.core.storage.domain.repository.FileStoreRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class FileStoreService {
|
||||
|
||||
private final FileStoreRepository fileStoreRepository;
|
||||
|
||||
public record SaveFileStoreRequest(String objectKey, String fileName, String contentType, Long sizeBytes) {}
|
||||
|
||||
@Transactional
|
||||
public void save(SaveFileStoreRequest request) {
|
||||
FileStore fileStore = FileStore.builder()
|
||||
.objectKey(request.objectKey())
|
||||
.originalFileName(request.fileName)
|
||||
.contentType(request.contentType)
|
||||
.sizeBytes(request.sizeBytes)
|
||||
.build();
|
||||
|
||||
fileStoreRepository.save(fileStore);
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,6 @@ databaseChangeLog:
|
||||
- includeAll:
|
||||
path: db/sql/book/251215
|
||||
- includeAll:
|
||||
path: db/sql/filestore/251221
|
||||
path: db/sql/filestore/251221
|
||||
- includeAll:
|
||||
path: db/sql/book/251222
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
-- liquibase formatted sql
|
||||
-- changeset ijeongmin:1_update_book_version.sql
|
||||
alter table book_version
|
||||
change column book_s3_key book_file_id bigint null,
|
||||
change column audio_s3_key audio_file_id bigint null,
|
||||
|
||||
add index idx_book_version_book_file_id (book_file_id),
|
||||
add index idx_book_version_audio_file_id (audio_file_id);
|
||||
Reference in New Issue
Block a user