feat: 공통코드 조회 결과 내 ref_chr1 추가

This commit is contained in:
Daseul Kim 2025-08-06 16:59:47 +09:00
parent a47b2fac79
commit 5a08c9067f
2 changed files with 7 additions and 11 deletions

View File

@ -7,9 +7,8 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
try {
const searchParams = request.nextUrl.searchParams
const headId = searchParams.get('headId')
if (headId === 'QNA_CD') {
return getQnaCd()
}
if (!headId) return NextResponse.json({ error: '필수 파라미터가 없습니다' }, { status: 400 })
// @ts-ignore
const commHeadData = await prisma.BC_COMM_H.findFirst({
@ -21,15 +20,10 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
},
})
if (!commHeadData) {
return NextResponse.json({ error: `${headId}를 찾을 수 없습니다` }, { status: 404 })
}
if (!commHeadData) return NextResponse.json({ error: `${headId}를 찾을 수 없습니다` }, { status: 404 })
if (headId === 'SALES_OFFICE_CD') {
return getSaleOffice(commHeadData.HEAD_CD)
}
// @ts-ignore
const roofMaterials: CommCode[] = await prisma.BC_COMM_L.findMany({
const results: CommCode[] = await prisma.BC_COMM_L.findMany({
where: {
HEAD_CD: commHeadData.HEAD_CD,
},
@ -37,12 +31,13 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
HEAD_CD: true,
CODE: true,
CODE_JP: true,
REF_CHR1: true,
},
orderBy: {
CODE: 'asc',
},
})
return NextResponse.json(roofMaterials)
return NextResponse.json(results)
} catch (error) {
console.error('❌ 데이터 조회 중 오류가 발생했습니다:', error)
return NextResponse.json({ error: '데이터 조회 중 오류가 발생했습니다' }, { status: 500 })

View File

@ -2,4 +2,5 @@ export type CommCode = {
headCd: string
code: string
codeJp: string
refChr1: string
}