Skip to content

Commit

Permalink
#18 - 테이블 스키마 뷰에서 필요한 추가 enum 및 dto 구현
Browse files Browse the repository at this point in the history
테이블 스키마 뷰에서
프론트에 전달할 일부 데이터와
파일 출력 버튼을 고려한 데이터 구조를 추가함.
  • Loading branch information
mikonu committed Aug 5, 2024
1 parent 200ded9 commit 1a24500
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package uno.fastcampus.testdata.domain.constant;

public enum ExportFileType {
CSV, TSV, JSON, SQL_INSERT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,6 +30,15 @@ public enum MockDataType {
private final Set<String> requiredOptions;
private final MockDataType baseType;

private static final List<MockDataTypeObject> objects = Stream.of(values())
.map(MockDataType::toObject)
.toList();


public static List<MockDataTypeObject> toObjects() {
return objects;
}

public boolean isBaseType() { return baseType == null; }

public MockDataTypeObject toObject() {
Expand All @@ -37,6 +49,7 @@ public MockDataTypeObject toObject() {
);
}


public record MockDataTypeObject(
String name,
Set<String> requiredOptions,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SchemaFieldRequest> schemaFields;

public TableSchemaDto toDto(String userId) {
return TableSchemaDto.of(
schemaName,
userId,
null,
schemaFields.stream()
.map(SchemaFieldRequest::toDto)
.collect(Collectors.toUnmodifiableSet())
);
}

}

0 comments on commit 1a24500

Please sign in to comment.