Merge branch 'mhkim-node' of https://g.wace.me/jskim/vexplor_dev into jskim-node
This commit is contained in:
29
backend-node/src/utils/categoryUtils.ts
Normal file
29
backend-node/src/utils/categoryUtils.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { PoolClient } from "pg";
|
||||
|
||||
/**
|
||||
* value_label 로 category_values 를 조회해 value_code 를 반환한다.
|
||||
* 매칭되는 카테고리가 없으면 입력 label 을 그대로 돌려준다.
|
||||
*
|
||||
* company_code 조건은 걸지 않는다 — 같은 label 은 전사에서 동일한 value_code 로
|
||||
* 관리되는 것을 전제로, 업체 간 데이터 복사 시에도 값이 깨지지 않게 하기 위함.
|
||||
*/
|
||||
export async function resolveCategoryCode(
|
||||
client: PoolClient,
|
||||
tableName: string,
|
||||
columnName: string,
|
||||
label: string | null | undefined,
|
||||
): Promise<string | null> {
|
||||
if (!label) return label ?? null;
|
||||
|
||||
const result = await client.query(
|
||||
`SELECT DISTINCT value_code FROM category_values
|
||||
WHERE table_name = $1
|
||||
AND column_name = $2
|
||||
AND value_label = $3
|
||||
AND is_active = true
|
||||
LIMIT 1`,
|
||||
[tableName, columnName, label],
|
||||
);
|
||||
|
||||
return result.rows[0]?.value_code ?? label;
|
||||
}
|
||||
@@ -19,6 +19,11 @@ function getAiAssistantDir(): string {
|
||||
* AI 어시스턴트 서비스 기동 (있으면 띄움, 실패해도 backend는 계속 동작)
|
||||
*/
|
||||
export function startAiAssistant(): void {
|
||||
if (process.env.DISABLE_AI_ASSISTANT === "1") {
|
||||
logger.info("⏭️ AI 어시스턴트 스킵 (DISABLE_AI_ASSISTANT=1)");
|
||||
return;
|
||||
}
|
||||
|
||||
const aiDir = getAiAssistantDir();
|
||||
const appPath = path.join(aiDir, "src", "app.js");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user