플로우 위젝 라벨표시 및 , 배치관리 회사별 분리
This commit is contained in:
@@ -35,11 +35,11 @@ export interface BatchApiResponse<T = unknown> {
|
||||
|
||||
export class BatchManagementService {
|
||||
/**
|
||||
* 배치관리용 연결 목록 조회
|
||||
* 배치관리용 연결 목록 조회 (회사별)
|
||||
*/
|
||||
static async getAvailableConnections(): Promise<
|
||||
BatchApiResponse<BatchConnectionInfo[]>
|
||||
> {
|
||||
static async getAvailableConnections(
|
||||
userCompanyCode?: string
|
||||
): Promise<BatchApiResponse<BatchConnectionInfo[]>> {
|
||||
try {
|
||||
const connections: BatchConnectionInfo[] = [];
|
||||
|
||||
@@ -50,19 +50,27 @@ export class BatchManagementService {
|
||||
db_type: "postgresql",
|
||||
});
|
||||
|
||||
// 활성화된 외부 DB 연결 조회
|
||||
// 활성화된 외부 DB 연결 조회 (회사별 필터링)
|
||||
let query_sql = `SELECT id, connection_name, db_type, description
|
||||
FROM external_db_connections
|
||||
WHERE is_active = 'Y'`;
|
||||
|
||||
const params: any[] = [];
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
query_sql += ` AND company_code = $1`;
|
||||
params.push(userCompanyCode);
|
||||
}
|
||||
|
||||
query_sql += ` ORDER BY connection_name ASC`;
|
||||
|
||||
const externalConnections = await query<{
|
||||
id: number;
|
||||
connection_name: string;
|
||||
db_type: string;
|
||||
description: string;
|
||||
}>(
|
||||
`SELECT id, connection_name, db_type, description
|
||||
FROM external_db_connections
|
||||
WHERE is_active = 'Y'
|
||||
ORDER BY connection_name ASC`,
|
||||
[]
|
||||
);
|
||||
}>(query_sql, params);
|
||||
|
||||
// 외부 DB 연결 추가
|
||||
externalConnections.forEach((conn) => {
|
||||
@@ -90,11 +98,12 @@ export class BatchManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 배치관리용 테이블 목록 조회
|
||||
* 배치관리용 테이블 목록 조회 (회사별)
|
||||
*/
|
||||
static async getTablesFromConnection(
|
||||
connectionType: "internal" | "external",
|
||||
connectionId?: number
|
||||
connectionId?: number,
|
||||
userCompanyCode?: string
|
||||
): Promise<BatchApiResponse<BatchTableInfo[]>> {
|
||||
try {
|
||||
let tables: BatchTableInfo[] = [];
|
||||
@@ -115,8 +124,11 @@ export class BatchManagementService {
|
||||
columns: [],
|
||||
}));
|
||||
} else if (connectionType === "external" && connectionId) {
|
||||
// 외부 DB 테이블 조회
|
||||
const tablesResult = await this.getExternalTables(connectionId);
|
||||
// 외부 DB 테이블 조회 (회사별 필터링)
|
||||
const tablesResult = await this.getExternalTables(
|
||||
connectionId,
|
||||
userCompanyCode
|
||||
);
|
||||
if (tablesResult.success && tablesResult.data) {
|
||||
tables = tablesResult.data;
|
||||
}
|
||||
@@ -138,12 +150,13 @@ export class BatchManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 배치관리용 테이블 컬럼 정보 조회
|
||||
* 배치관리용 테이블 컬럼 정보 조회 (회사별)
|
||||
*/
|
||||
static async getTableColumns(
|
||||
connectionType: "internal" | "external",
|
||||
connectionId: number | undefined,
|
||||
tableName: string
|
||||
tableName: string,
|
||||
userCompanyCode?: string
|
||||
): Promise<BatchApiResponse<BatchColumnInfo[]>> {
|
||||
try {
|
||||
console.log(`[BatchManagementService] getTableColumns 호출:`, {
|
||||
@@ -189,14 +202,15 @@ export class BatchManagementService {
|
||||
column_default: row.column_default,
|
||||
}));
|
||||
} else if (connectionType === "external" && connectionId) {
|
||||
// 외부 DB 컬럼 조회
|
||||
// 외부 DB 컬럼 조회 (회사별 필터링)
|
||||
console.log(
|
||||
`[BatchManagementService] 외부 DB 컬럼 조회 시작: connectionId=${connectionId}, tableName=${tableName}`
|
||||
);
|
||||
|
||||
const columnsResult = await this.getExternalTableColumns(
|
||||
connectionId,
|
||||
tableName
|
||||
tableName,
|
||||
userCompanyCode
|
||||
);
|
||||
|
||||
console.log(
|
||||
@@ -226,22 +240,29 @@ export class BatchManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 외부 DB 테이블 목록 조회 (내부 구현)
|
||||
* 외부 DB 테이블 목록 조회 (내부 구현, 회사별)
|
||||
*/
|
||||
private static async getExternalTables(
|
||||
connectionId: number
|
||||
connectionId: number,
|
||||
userCompanyCode?: string
|
||||
): Promise<BatchApiResponse<BatchTableInfo[]>> {
|
||||
try {
|
||||
// 연결 정보 조회
|
||||
const connection = await queryOne<any>(
|
||||
`SELECT * FROM external_db_connections WHERE id = $1`,
|
||||
[connectionId]
|
||||
);
|
||||
// 연결 정보 조회 (회사별 필터링)
|
||||
let query_sql = `SELECT * FROM external_db_connections WHERE id = $1`;
|
||||
const params: any[] = [connectionId];
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
query_sql += ` AND company_code = $2`;
|
||||
params.push(userCompanyCode);
|
||||
}
|
||||
|
||||
const connection = await queryOne<any>(query_sql, params);
|
||||
|
||||
if (!connection) {
|
||||
return {
|
||||
success: false,
|
||||
message: "연결 정보를 찾을 수 없습니다.",
|
||||
message: "연결 정보를 찾을 수 없거나 권한이 없습니다.",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -299,26 +320,33 @@ export class BatchManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 외부 DB 테이블 컬럼 정보 조회 (내부 구현)
|
||||
* 외부 DB 테이블 컬럼 정보 조회 (내부 구현, 회사별)
|
||||
*/
|
||||
private static async getExternalTableColumns(
|
||||
connectionId: number,
|
||||
tableName: string
|
||||
tableName: string,
|
||||
userCompanyCode?: string
|
||||
): Promise<BatchApiResponse<BatchColumnInfo[]>> {
|
||||
try {
|
||||
console.log(
|
||||
`[BatchManagementService] getExternalTableColumns 호출: connectionId=${connectionId}, tableName=${tableName}`
|
||||
);
|
||||
|
||||
// 연결 정보 조회
|
||||
const connection = await queryOne<any>(
|
||||
`SELECT * FROM external_db_connections WHERE id = $1`,
|
||||
[connectionId]
|
||||
);
|
||||
// 연결 정보 조회 (회사별 필터링)
|
||||
let query_sql = `SELECT * FROM external_db_connections WHERE id = $1`;
|
||||
const params: any[] = [connectionId];
|
||||
|
||||
// 회사별 필터링 (최고 관리자가 아닌 경우)
|
||||
if (userCompanyCode && userCompanyCode !== "*") {
|
||||
query_sql += ` AND company_code = $2`;
|
||||
params.push(userCompanyCode);
|
||||
}
|
||||
|
||||
const connection = await queryOne<any>(query_sql, params);
|
||||
|
||||
if (!connection) {
|
||||
console.log(
|
||||
`[BatchManagementService] 연결 정보를 찾을 수 없음: connectionId=${connectionId}`
|
||||
`[BatchManagementService] 연결 정보를 찾을 수 없거나 권한이 없음: connectionId=${connectionId}`
|
||||
);
|
||||
return {
|
||||
success: false,
|
||||
|
||||
Reference in New Issue
Block a user