diff --git a/src/main/java/uno/fastcampus/testdata/domain/constant/ExportFileType.java b/src/main/java/uno/fastcampus/testdata/domain/constant/ExportFileType.java new file mode 100644 index 0000000..f525fa9 --- /dev/null +++ b/src/main/java/uno/fastcampus/testdata/domain/constant/ExportFileType.java @@ -0,0 +1,5 @@ +package uno.fastcampus.testdata.domain.constant; + +public enum ExportFileType { + CSV, TSV, JSON, SQL_INSERT; +} diff --git a/src/main/java/uno/fastcampus/testdata/domain/constant/MockDataType.java b/src/main/java/uno/fastcampus/testdata/domain/constant/MockDataType.java index a8edf84..ac086c2 100644 --- a/src/main/java/uno/fastcampus/testdata/domain/constant/MockDataType.java +++ b/src/main/java/uno/fastcampus/testdata/domain/constant/MockDataType.java @@ -3,7 +3,10 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; +import java.util.Arrays; +import java.util.List; import java.util.Set; +import java.util.stream.Stream; @Getter @RequiredArgsConstructor @@ -27,6 +30,15 @@ public enum MockDataType { private final Set requiredOptions; private final MockDataType baseType; + private static final List objects = Stream.of(values()) + .map(MockDataType::toObject) + .toList(); + + + public static List toObjects() { + return objects; + } + public boolean isBaseType() { return baseType == null; } public MockDataTypeObject toObject() { @@ -37,6 +49,7 @@ public MockDataTypeObject toObject() { ); } + public record MockDataTypeObject( String name, Set requiredOptions, diff --git a/src/main/java/uno/fastcampus/testdata/dto/request/TableSchemaExportRequest.java b/src/main/java/uno/fastcampus/testdata/dto/request/TableSchemaExportRequest.java new file mode 100644 index 0000000..8748cd6 --- /dev/null +++ b/src/main/java/uno/fastcampus/testdata/dto/request/TableSchemaExportRequest.java @@ -0,0 +1,34 @@ +package uno.fastcampus.testdata.dto.request; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import uno.fastcampus.testdata.domain.constant.ExportFileType; +import uno.fastcampus.testdata.dto.TableSchemaDto; + +import java.util.List; +import java.util.stream.Collectors; + +// TODO: 스프링 부트 3.4를 쓸 수 있게 되면, record로 되돌리는 것을 검토하기 +@NoArgsConstructor +@AllArgsConstructor(staticName = "of") +@Data +public class TableSchemaExportRequest { + + private String schemaName; + private Integer rowCount; + private ExportFileType fileType; + private List schemaFields; + + public TableSchemaDto toDto(String userId) { + return TableSchemaDto.of( + schemaName, + userId, + null, + schemaFields.stream() + .map(SchemaFieldRequest::toDto) + .collect(Collectors.toUnmodifiableSet()) + ); + } + +}