diff options
Diffstat (limited to 'lib/oracle-db')
| -rw-r--r-- | lib/oracle-db/nonsap/services/creditService.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/oracle-db/nonsap/services/creditService.ts b/lib/oracle-db/nonsap/services/creditService.ts index 60e4f287..0b83e192 100644 --- a/lib/oracle-db/nonsap/services/creditService.ts +++ b/lib/oracle-db/nonsap/services/creditService.ts @@ -4,6 +4,7 @@ import { oracleKnex, getOracleConnection } from "@/lib/oracle-db/db"; import { readFileSync } from "fs"; import { join } from "path"; import creditServiceMapping from "./creditServiceMapping.json"; +import { getTaxIdByVendorId } from "@/lib/vendors/repository"; // SQL 파일 읽기 const getCreditQuerySQL = () => { @@ -31,23 +32,19 @@ const convertCreditGbToCode = (creditGb: string): string => { // 방법 1: knex.raw() 사용 (네임드 바인드 변수) // reno: 사업자번호, credit_gb: 신용평가사 코드 -export const getCreditInfo = async (reno: string, credit_gb: string) => { +export const getCreditInfo = async (id: string, credit_gb: string) => { const query = getCreditQuerySQL(); - const creditGbCode = convertCreditGbToCode(credit_gb); + const bindParameters = { + reno: await getTaxIdByVendorId(id), + credit_gb: convertCreditGbToCode(credit_gb) + } - const result = await oracleKnex.raw(query, { - reno: reno, - credit_gb: creditGbCode - }); + const result = await oracleKnex.raw(query, bindParameters); // Oracle knex raw 결과에서 실제 rows 추출 const rows = Array.isArray(result) ? result : result.rows || []; return rows; - - // UI 테스트용 목업 데이터 (필요시 주석 해제) - // const mockData = getMockCreditData(reno, credit_gb); - // return [mockData]; }; // 방법 2: oracledb 직접 사용 (네임드 바인드 변수) |
