테이블 관계 저장 구현
This commit is contained in:
@@ -46,11 +46,38 @@ export interface TableRelationship {
|
||||
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>;
|
||||
settings?: Record<string, unknown>;
|
||||
companyCode: string;
|
||||
isActive?: string;
|
||||
}
|
||||
|
||||
// 데이터 연결 중계 테이블 타입
|
||||
export interface DataBridge {
|
||||
bridgeId: number;
|
||||
relationshipId: number;
|
||||
fromTableName: string;
|
||||
fromColumnName: string;
|
||||
fromKeyValue: string;
|
||||
fromRecordId?: string;
|
||||
toTableName: string;
|
||||
toColumnName: string;
|
||||
toKeyValue: string;
|
||||
toRecordId?: string;
|
||||
connectionType: string;
|
||||
companyCode: string;
|
||||
createdAt: string;
|
||||
createdBy?: string;
|
||||
updatedAt: string;
|
||||
updatedBy?: string;
|
||||
isActive: string;
|
||||
bridgeData?: Record<string, unknown>;
|
||||
relationship?: {
|
||||
relationshipName: string;
|
||||
relationshipType: string;
|
||||
connectionType: string;
|
||||
};
|
||||
}
|
||||
|
||||
// 테이블 간 데이터 관계 설정 API 클래스
|
||||
export class DataFlowAPI {
|
||||
/**
|
||||
@@ -113,7 +140,10 @@ export class DataFlowAPI {
|
||||
*/
|
||||
static async createRelationship(relationship: Omit<TableRelationship, "relationshipId">): Promise<TableRelationship> {
|
||||
try {
|
||||
const response = await apiClient.post<ApiResponse<TableRelationship>>("/table-relationships", relationship);
|
||||
const response = await apiClient.post<ApiResponse<TableRelationship>>(
|
||||
"/dataflow/table-relationships",
|
||||
relationship,
|
||||
);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "관계 생성에 실패했습니다.");
|
||||
@@ -131,7 +161,7 @@ export class DataFlowAPI {
|
||||
*/
|
||||
static async getRelationshipsByCompany(companyCode: string): Promise<TableRelationship[]> {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<TableRelationship[]>>("/table-relationships", {
|
||||
const response = await apiClient.get<ApiResponse<TableRelationship[]>>("/dataflow/table-relationships", {
|
||||
params: { companyCode },
|
||||
});
|
||||
|
||||
@@ -155,7 +185,7 @@ export class DataFlowAPI {
|
||||
): Promise<TableRelationship> {
|
||||
try {
|
||||
const response = await apiClient.put<ApiResponse<TableRelationship>>(
|
||||
`/table-relationships/${relationshipId}`,
|
||||
`/dataflow/table-relationships/${relationshipId}`,
|
||||
relationship,
|
||||
);
|
||||
|
||||
@@ -175,7 +205,7 @@ export class DataFlowAPI {
|
||||
*/
|
||||
static async deleteRelationship(relationshipId: number): Promise<void> {
|
||||
try {
|
||||
const response = await apiClient.delete<ApiResponse<null>>(`/table-relationships/${relationshipId}`);
|
||||
const response = await apiClient.delete<ApiResponse<null>>(`/dataflow/table-relationships/${relationshipId}`);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "관계 삭제에 실패했습니다.");
|
||||
@@ -185,4 +215,72 @@ export class DataFlowAPI {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 데이터 연결 관리 API ====================
|
||||
|
||||
/**
|
||||
* 데이터 연결 생성
|
||||
*/
|
||||
static async createDataLink(linkData: {
|
||||
relationshipId: number;
|
||||
fromTableName: string;
|
||||
fromColumnName: string;
|
||||
fromKeyValue: string;
|
||||
fromRecordId?: string;
|
||||
toTableName: string;
|
||||
toColumnName: string;
|
||||
toKeyValue: string;
|
||||
toRecordId?: string;
|
||||
connectionType: string;
|
||||
bridgeData?: Record<string, unknown>;
|
||||
}): Promise<DataBridge> {
|
||||
try {
|
||||
const response = await apiClient.post<ApiResponse<DataBridge>>("/dataflow/data-links", linkData);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "데이터 연결 생성에 실패했습니다.");
|
||||
}
|
||||
|
||||
return response.data.data as DataBridge;
|
||||
} catch (error) {
|
||||
console.error("데이터 연결 생성 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 관계별 연결된 데이터 조회
|
||||
*/
|
||||
static async getLinkedDataByRelationship(relationshipId: number): Promise<DataBridge[]> {
|
||||
try {
|
||||
const response = await apiClient.get<ApiResponse<DataBridge[]>>(
|
||||
`/dataflow/data-links/relationship/${relationshipId}`,
|
||||
);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "연결된 데이터 조회에 실패했습니다.");
|
||||
}
|
||||
|
||||
return response.data.data as DataBridge[];
|
||||
} catch (error) {
|
||||
console.error("연결된 데이터 조회 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터 연결 삭제
|
||||
*/
|
||||
static async deleteDataLink(bridgeId: number): Promise<void> {
|
||||
try {
|
||||
const response = await apiClient.delete<ApiResponse<null>>(`/dataflow/data-links/${bridgeId}`);
|
||||
|
||||
if (!response.data.success) {
|
||||
throw new Error(response.data.message || "데이터 연결 삭제에 실패했습니다.");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("데이터 연결 삭제 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user