feat: 공통코드 조회 결과 내 ref_chr1 추가
This commit is contained in:
parent
a47b2fac79
commit
5a08c9067f
@ -7,9 +7,8 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
|||||||
try {
|
try {
|
||||||
const searchParams = request.nextUrl.searchParams
|
const searchParams = request.nextUrl.searchParams
|
||||||
const headId = searchParams.get('headId')
|
const headId = searchParams.get('headId')
|
||||||
if (headId === 'QNA_CD') {
|
|
||||||
return getQnaCd()
|
if (!headId) return NextResponse.json({ error: '필수 파라미터가 없습니다' }, { status: 400 })
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const commHeadData = await prisma.BC_COMM_H.findFirst({
|
const commHeadData = await prisma.BC_COMM_H.findFirst({
|
||||||
@ -21,15 +20,10 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!commHeadData) {
|
if (!commHeadData) return NextResponse.json({ error: `${headId}를 찾을 수 없습니다` }, { status: 404 })
|
||||||
return NextResponse.json({ error: `${headId}를 찾을 수 없습니다` }, { status: 404 })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (headId === 'SALES_OFFICE_CD') {
|
|
||||||
return getSaleOffice(commHeadData.HEAD_CD)
|
|
||||||
}
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const roofMaterials: CommCode[] = await prisma.BC_COMM_L.findMany({
|
const results: CommCode[] = await prisma.BC_COMM_L.findMany({
|
||||||
where: {
|
where: {
|
||||||
HEAD_CD: commHeadData.HEAD_CD,
|
HEAD_CD: commHeadData.HEAD_CD,
|
||||||
},
|
},
|
||||||
@ -37,12 +31,13 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
|||||||
HEAD_CD: true,
|
HEAD_CD: true,
|
||||||
CODE: true,
|
CODE: true,
|
||||||
CODE_JP: true,
|
CODE_JP: true,
|
||||||
|
REF_CHR1: true,
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
CODE: 'asc',
|
CODE: 'asc',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return NextResponse.json(roofMaterials)
|
return NextResponse.json(results)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ 데이터 조회 중 오류가 발생했습니다:', error)
|
console.error('❌ 데이터 조회 중 오류가 발생했습니다:', error)
|
||||||
return NextResponse.json({ error: '데이터 조회 중 오류가 발생했습니다' }, { status: 500 })
|
return NextResponse.json({ error: '데이터 조회 중 오류가 발생했습니다' }, { status: 500 })
|
||||||
|
|||||||
@ -2,4 +2,5 @@ export type CommCode = {
|
|||||||
headCd: string
|
headCd: string
|
||||||
code: string
|
code: string
|
||||||
codeJp: string
|
codeJp: string
|
||||||
|
refChr1: string
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user