refactor: 사용하지 않는 공통코드 조회 및 필터링 함수 삭제
This commit is contained in:
parent
870e3af597
commit
728dcfe928
@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { loggerWrapper } from '@/libs/api-wrapper'
|
||||
import { prisma } from '@/libs/prisma'
|
||||
import { CommonCode } from '@/types/Inquiry'
|
||||
import { CommCode } from '@/types/CommCode'
|
||||
|
||||
async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
||||
try {
|
||||
@ -32,6 +32,7 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
||||
CODE: true,
|
||||
CODE_JP: true,
|
||||
REF_CHR1: true,
|
||||
REF_NUM1: true,
|
||||
},
|
||||
orderBy: {
|
||||
CODE: 'asc',
|
||||
@ -43,68 +44,4 @@ async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
||||
return NextResponse.json({ error: '데이터 조회 중 오류가 발생했습니다' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
const getSaleOffice = async (headCode: string) => {
|
||||
// @ts-ignore
|
||||
const commCodeSaleOffice: CommCode[] = await prisma.BC_COMM_L.findMany({
|
||||
where: {
|
||||
HEAD_CD: headCode,
|
||||
REF_NUM1: 1,
|
||||
},
|
||||
select: {
|
||||
CODE: true,
|
||||
CODE_JP: true,
|
||||
REF_CHR1: true,
|
||||
REF_NUM1: true,
|
||||
},
|
||||
})
|
||||
return NextResponse.json(commCodeSaleOffice)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description QNA 공통 코드 조회
|
||||
* @returns {CommonCode[]} QNA 공통 코드 목록
|
||||
*/
|
||||
const getQnaCd = async () => {
|
||||
// @ts-ignore
|
||||
const headCdList: { HEAD_CD: string; HEAD_ID: string }[] = await prisma.BC_COMM_H.findMany({
|
||||
where: {
|
||||
OR: [{ HEAD_ID: { in: ['QNA_CLS_LRG_CD'] } }, { HEAD_ID: { in: ['QNA_CLS_MID_CD'] } }, { HEAD_ID: { in: ['QNA_CLS_SML_CD'] } }],
|
||||
},
|
||||
select: {
|
||||
HEAD_CD: true,
|
||||
HEAD_ID: true,
|
||||
},
|
||||
})
|
||||
const result: CommonCode[] = []
|
||||
// @ts-ignore
|
||||
const commCodeQna: CommCode[] = await prisma.BC_COMM_L.findMany({
|
||||
where: {
|
||||
HEAD_CD: {
|
||||
in: headCdList.map((item) => item.HEAD_CD).filter(Boolean),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
HEAD_CD: true,
|
||||
CODE: true,
|
||||
CODE_JP: true,
|
||||
REF_CHR1: true,
|
||||
},
|
||||
})
|
||||
commCodeQna.forEach((item) => {
|
||||
result.push({
|
||||
// @ts-ignore
|
||||
headCd: item.HEAD_CD,
|
||||
// @ts-ignore
|
||||
headId: headCdList.find((headCd) => headCd.HEAD_CD === item.HEAD_CD)?.HEAD_ID ?? '',
|
||||
// @ts-ignore
|
||||
code: item.CODE,
|
||||
// @ts-ignore
|
||||
name: item.CODE_JP,
|
||||
// @ts-ignore
|
||||
refChar1: item.REF_CHR1 ?? '',
|
||||
})
|
||||
})
|
||||
return NextResponse.json(result)
|
||||
}
|
||||
export const GET = loggerWrapper(getCommCode)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user