배치관리 쿼리수정
This commit is contained in:
parent
0a134d85c2
commit
2d8f5a184d
|
|
@ -61,23 +61,31 @@ export class BatchService {
|
||||||
|
|
||||||
// 배치 설정 조회 (매핑 포함 - 서브쿼리 사용)
|
// 배치 설정 조회 (매핑 포함 - 서브쿼리 사용)
|
||||||
const batchConfigs = await query<any>(
|
const batchConfigs = await query<any>(
|
||||||
`SELECT bc.*,
|
`SELECT bc.id, bc.batch_name, bc.description, bc.cron_schedule,
|
||||||
|
bc.is_active, bc.company_code, bc.created_date, bc.created_by,
|
||||||
|
bc.updated_date, bc.updated_by,
|
||||||
COALESCE(
|
COALESCE(
|
||||||
json_agg(
|
json_agg(
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'mapping_id', bm.mapping_id,
|
'id', bm.id,
|
||||||
'batch_id', bm.batch_id,
|
'batch_config_id', bm.batch_config_id,
|
||||||
'source_column', bm.source_column,
|
'from_connection_type', bm.from_connection_type,
|
||||||
'target_column', bm.target_column,
|
'from_connection_id', bm.from_connection_id,
|
||||||
'transformation_rule', bm.transformation_rule
|
'from_table_name', bm.from_table_name,
|
||||||
|
'from_column_name', bm.from_column_name,
|
||||||
|
'to_connection_type', bm.to_connection_type,
|
||||||
|
'to_connection_id', bm.to_connection_id,
|
||||||
|
'to_table_name', bm.to_table_name,
|
||||||
|
'to_column_name', bm.to_column_name,
|
||||||
|
'mapping_order', bm.mapping_order
|
||||||
)
|
)
|
||||||
) FILTER (WHERE bm.mapping_id IS NOT NULL),
|
) FILTER (WHERE bm.id IS NOT NULL),
|
||||||
'[]'
|
'[]'
|
||||||
) as batch_mappings
|
) as batch_mappings
|
||||||
FROM batch_configs bc
|
FROM batch_configs bc
|
||||||
LEFT JOIN batch_mappings bm ON bc.batch_id = bm.batch_id
|
LEFT JOIN batch_mappings bm ON bc.id = bm.batch_config_id
|
||||||
${whereClause}
|
${whereClause}
|
||||||
GROUP BY bc.batch_id
|
GROUP BY bc.id
|
||||||
ORDER BY bc.is_active DESC, bc.batch_name ASC
|
ORDER BY bc.is_active DESC, bc.batch_name ASC
|
||||||
LIMIT $${paramIndex} OFFSET $${paramIndex + 1}`,
|
LIMIT $${paramIndex} OFFSET $${paramIndex + 1}`,
|
||||||
[...values, limit, offset]
|
[...values, limit, offset]
|
||||||
|
|
@ -85,7 +93,7 @@ export class BatchService {
|
||||||
|
|
||||||
// 전체 개수 조회
|
// 전체 개수 조회
|
||||||
const countResult = await queryOne<{ count: string }>(
|
const countResult = await queryOne<{ count: string }>(
|
||||||
`SELECT COUNT(DISTINCT bc.batch_id) as count
|
`SELECT COUNT(DISTINCT bc.id) as count
|
||||||
FROM batch_configs bc
|
FROM batch_configs bc
|
||||||
${whereClause}`,
|
${whereClause}`,
|
||||||
values
|
values
|
||||||
|
|
@ -121,29 +129,34 @@ export class BatchService {
|
||||||
): Promise<ApiResponse<BatchConfig>> {
|
): Promise<ApiResponse<BatchConfig>> {
|
||||||
try {
|
try {
|
||||||
const batchConfig = await queryOne<any>(
|
const batchConfig = await queryOne<any>(
|
||||||
`SELECT bc.*,
|
`SELECT bc.id, bc.batch_name, bc.description, bc.cron_schedule,
|
||||||
|
bc.is_active, bc.company_code, bc.created_date, bc.created_by,
|
||||||
|
bc.updated_date, bc.updated_by,
|
||||||
COALESCE(
|
COALESCE(
|
||||||
json_agg(
|
json_agg(
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'mapping_id', bm.mapping_id,
|
'id', bm.id,
|
||||||
'batch_id', bm.batch_id,
|
'batch_config_id', bm.batch_config_id,
|
||||||
|
'from_connection_type', bm.from_connection_type,
|
||||||
|
'from_connection_id', bm.from_connection_id,
|
||||||
'from_table_name', bm.from_table_name,
|
'from_table_name', bm.from_table_name,
|
||||||
'from_column_name', bm.from_column_name,
|
'from_column_name', bm.from_column_name,
|
||||||
|
'from_column_type', bm.from_column_type,
|
||||||
|
'to_connection_type', bm.to_connection_type,
|
||||||
|
'to_connection_id', bm.to_connection_id,
|
||||||
'to_table_name', bm.to_table_name,
|
'to_table_name', bm.to_table_name,
|
||||||
'to_column_name', bm.to_column_name,
|
'to_column_name', bm.to_column_name,
|
||||||
'mapping_order', bm.mapping_order,
|
'to_column_type', bm.to_column_type,
|
||||||
'source_column', bm.source_column,
|
'mapping_order', bm.mapping_order
|
||||||
'target_column', bm.target_column,
|
|
||||||
'transformation_rule', bm.transformation_rule
|
|
||||||
)
|
)
|
||||||
ORDER BY bm.from_table_name ASC, bm.from_column_name ASC, bm.mapping_order ASC
|
ORDER BY bm.from_table_name ASC, bm.from_column_name ASC, bm.mapping_order ASC
|
||||||
) FILTER (WHERE bm.mapping_id IS NOT NULL),
|
) FILTER (WHERE bm.id IS NOT NULL),
|
||||||
'[]'
|
'[]'
|
||||||
) as batch_mappings
|
) as batch_mappings
|
||||||
FROM batch_configs bc
|
FROM batch_configs bc
|
||||||
LEFT JOIN batch_mappings bm ON bc.batch_id = bm.batch_id
|
LEFT JOIN batch_mappings bm ON bc.id = bm.batch_config_id
|
||||||
WHERE bc.id = $1
|
WHERE bc.id = $1
|
||||||
GROUP BY bc.batch_id`,
|
GROUP BY bc.id`,
|
||||||
[id]
|
[id]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -268,16 +281,16 @@ export class BatchService {
|
||||||
COALESCE(
|
COALESCE(
|
||||||
json_agg(
|
json_agg(
|
||||||
json_build_object(
|
json_build_object(
|
||||||
'mapping_id', bm.mapping_id,
|
'id', bm.id,
|
||||||
'batch_id', bm.batch_id
|
'batch_config_id', bm.batch_config_id
|
||||||
)
|
)
|
||||||
) FILTER (WHERE bm.mapping_id IS NOT NULL),
|
) FILTER (WHERE bm.id IS NOT NULL),
|
||||||
'[]'
|
'[]'
|
||||||
) as batch_mappings
|
) as batch_mappings
|
||||||
FROM batch_configs bc
|
FROM batch_configs bc
|
||||||
LEFT JOIN batch_mappings bm ON bc.batch_id = bm.batch_id
|
LEFT JOIN batch_mappings bm ON bc.id = bm.batch_config_id
|
||||||
WHERE bc.id = $1
|
WHERE bc.id = $1
|
||||||
GROUP BY bc.batch_id`,
|
GROUP BY bc.id`,
|
||||||
[id]
|
[id]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue