테이블 기반 방식으로 변경
This commit is contained in:
@@ -1,19 +1,6 @@
|
||||
import { apiClient, ApiResponse } from "./client";
|
||||
|
||||
// 데이터 흐름 관리 관련 타입 정의
|
||||
export interface ScreenDefinition {
|
||||
screenId: number;
|
||||
screenName: string;
|
||||
screenCode: string;
|
||||
tableName: string;
|
||||
companyCode: string;
|
||||
description?: string;
|
||||
isActive: string;
|
||||
createdDate: string;
|
||||
createdBy?: string;
|
||||
updatedDate: string;
|
||||
updatedBy?: string;
|
||||
}
|
||||
// 테이블 간 데이터 관계 설정 관련 타입 정의
|
||||
|
||||
export interface ColumnInfo {
|
||||
columnName: string;
|
||||
@@ -36,17 +23,27 @@ export interface ColumnInfo {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface ScreenWithFields extends ScreenDefinition {
|
||||
fields: ColumnInfo[];
|
||||
export interface TableDefinition {
|
||||
tableName: string;
|
||||
displayName?: string;
|
||||
description?: string;
|
||||
columns: ColumnInfo[];
|
||||
}
|
||||
|
||||
export interface ScreenRelationship {
|
||||
export interface TableInfo {
|
||||
tableName: string;
|
||||
displayName: string;
|
||||
description: string;
|
||||
columnCount: number;
|
||||
}
|
||||
|
||||
export interface TableRelationship {
|
||||
relationshipId?: number;
|
||||
relationshipName: string;
|
||||
fromScreenId: number;
|
||||
fromFieldName: string;
|
||||
toScreenId: number;
|
||||
toFieldName: string;
|
||||
fromTableName: string;
|
||||
fromColumnName: string;
|
||||
toTableName: string;
|
||||
toColumnName: string;
|
||||
relationshipType: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many";
|
||||
connectionType: "simple-key" | "data-save" | "external-call";
|
||||
settings?: Record<string, any>;
|
||||
@@ -54,24 +51,22 @@ export interface ScreenRelationship {
|
||||
isActive?: string;
|
||||
}
|
||||
|
||||
// 데이터 흐름 관리 API 클래스
|
||||
// 테이블 간 데이터 관계 설정 API 클래스
|
||||
export class DataFlowAPI {
|
||||
/**
|
||||
* 회사별 화면 목록 조회
|
||||
* 테이블 목록 조회
|
||||
*/
|
||||
static async getScreensByCompany(companyCode: string): Promise<ScreenDefinition[]> {
|
||||
static async getTables(): Promise<TableInfo[]> {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<ScreenDefinition[]>>("/screen-management/screens", {
|
||||
params: { companyCode },
|
||||
});
|
||||
const response = await apiClient.get<ApiResponse<TableInfo[]>>("/table-management/tables");
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "화면 목록 조회에 실패했습니다.");
|
||||
throw new Error(response.data.message || "테이블 목록 조회에 실패했습니다.");
|
||||
}
|
||||
|
||||
return response.data.data || [];
|
||||
} catch (error) {
|
||||
console.error("화면 목록 조회 오류:", error);
|
||||
console.error("테이블 목록 조회 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -95,39 +90,30 @@ export class DataFlowAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면과 필드 정보를 함께 조회
|
||||
* 테이블 정보와 컬럼 정보를 함께 조회
|
||||
*/
|
||||
static async getScreenWithFields(screenId: number, tableName: string): Promise<ScreenWithFields | null> {
|
||||
static async getTableWithColumns(tableName: string): Promise<TableDefinition | null> {
|
||||
try {
|
||||
// 화면 정보와 컬럼 정보를 병렬로 조회
|
||||
const [screensResponse, columnsResponse] = await Promise.all([
|
||||
this.getScreensByCompany("*"), // 전체 화면 목록에서 해당 화면 찾기
|
||||
this.getTableColumns(tableName),
|
||||
]);
|
||||
|
||||
const screen = screensResponse.find((s) => s.screenId === screenId);
|
||||
if (!screen) {
|
||||
return null;
|
||||
}
|
||||
const columns = await this.getTableColumns(tableName);
|
||||
|
||||
return {
|
||||
...screen,
|
||||
fields: columnsResponse,
|
||||
tableName,
|
||||
displayName: tableName,
|
||||
description: `${tableName} 테이블`,
|
||||
columns,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("화면 및 필드 정보 조회 오류:", error);
|
||||
console.error("테이블 및 컬럼 정보 조회 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면 관계 생성
|
||||
* 테이블 관계 생성
|
||||
*/
|
||||
static async createRelationship(
|
||||
relationship: Omit<ScreenRelationship, "relationshipId">,
|
||||
): Promise<ScreenRelationship> {
|
||||
static async createRelationship(relationship: Omit<TableRelationship, "relationshipId">): Promise<TableRelationship> {
|
||||
try {
|
||||
const response = await apiClient.post<ApiResponse<ScreenRelationship>>("/dataflow/relationships", relationship);
|
||||
const response = await apiClient.post<ApiResponse<TableRelationship>>("/table-relationships", relationship);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "관계 생성에 실패했습니다.");
|
||||
@@ -141,11 +127,11 @@ export class DataFlowAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* 회사별 화면 관계 목록 조회
|
||||
* 회사별 테이블 관계 목록 조회
|
||||
*/
|
||||
static async getRelationshipsByCompany(companyCode: string): Promise<ScreenRelationship[]> {
|
||||
static async getRelationshipsByCompany(companyCode: string): Promise<TableRelationship[]> {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<ScreenRelationship[]>>("/dataflow/relationships", {
|
||||
const response = await apiClient.get<ApiResponse<TableRelationship[]>>("/table-relationships", {
|
||||
params: { companyCode },
|
||||
});
|
||||
|
||||
@@ -161,15 +147,15 @@ export class DataFlowAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면 관계 수정
|
||||
* 테이블 관계 수정
|
||||
*/
|
||||
static async updateRelationship(
|
||||
relationshipId: number,
|
||||
relationship: Partial<ScreenRelationship>,
|
||||
): Promise<ScreenRelationship> {
|
||||
relationship: Partial<TableRelationship>,
|
||||
): Promise<TableRelationship> {
|
||||
try {
|
||||
const response = await apiClient.put<ApiResponse<ScreenRelationship>>(
|
||||
`/dataflow/relationships/${relationshipId}`,
|
||||
const response = await apiClient.put<ApiResponse<TableRelationship>>(
|
||||
`/table-relationships/${relationshipId}`,
|
||||
relationship,
|
||||
);
|
||||
|
||||
@@ -185,11 +171,11 @@ export class DataFlowAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면 관계 삭제
|
||||
* 테이블 관계 삭제
|
||||
*/
|
||||
static async deleteRelationship(relationshipId: number): Promise<void> {
|
||||
try {
|
||||
const response = await apiClient.delete<ApiResponse<null>>(`/dataflow/relationships/${relationshipId}`);
|
||||
const response = await apiClient.delete<ApiResponse<null>>(`/table-relationships/${relationshipId}`);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "관계 삭제에 실패했습니다.");
|
||||
|
||||
Reference in New Issue
Block a user