refactor: 지붕재 적합성 main만 있고 detial은 없는 경우 방어처리
This commit is contained in:
parent
b7188cf5bc
commit
c27608ea71
@ -37,7 +37,7 @@ async function createSuitablePdf(request: NextRequest): Promise<NextResponse> {
|
|||||||
const fileTitle = formData.get('fileTitle') as string
|
const fileTitle = formData.get('fileTitle') as string
|
||||||
|
|
||||||
/* 파라미터 체크 */
|
/* 파라미터 체크 */
|
||||||
if (ids === '' || detailIds === '' || fileTitle === '') {
|
if (ids === '' || fileTitle === '') {
|
||||||
return NextResponse.json({ error: '필수 파라미터가 누락되었습니다' }, { status: HttpStatusCode.BadRequest })
|
return NextResponse.json({ error: '필수 파라미터가 누락되었습니다' }, { status: HttpStatusCode.BadRequest })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ async function createSuitablePdf(request: NextRequest): Promise<NextResponse> {
|
|||||||
, msd_json.memo
|
, msd_json.memo
|
||||||
FROM ms_suitable_detail msd_json
|
FROM ms_suitable_detail msd_json
|
||||||
WHERE msd.main_id = msd_json.main_id
|
WHERE msd.main_id = msd_json.main_id
|
||||||
AND msd_json.id IN (:detailIds)
|
--detailIds AND msd_json.id IN (:detailIds)
|
||||||
FOR JSON PATH
|
FOR JSON PATH
|
||||||
) AS detail
|
) AS detail
|
||||||
FROM ms_suitable_detail msd
|
FROM ms_suitable_detail msd
|
||||||
@ -85,7 +85,10 @@ async function createSuitablePdf(request: NextRequest): Promise<NextResponse> {
|
|||||||
|
|
||||||
/* 검색 조건 설정 */
|
/* 검색 조건 설정 */
|
||||||
query = query.replaceAll(':mainIds', ids)
|
query = query.replaceAll(':mainIds', ids)
|
||||||
query = query.replaceAll(':detailIds', detailIds)
|
if (detailIds) {
|
||||||
|
query = query.replace('--detailIds', '')
|
||||||
|
query = query.replace(':detailIds', detailIds)
|
||||||
|
}
|
||||||
|
|
||||||
/* 데이터 조회 */
|
/* 데이터 조회 */
|
||||||
const suitable: Suitable[] = await prisma.$queryRawUnsafe(query)
|
const suitable: Suitable[] = await prisma.$queryRawUnsafe(query)
|
||||||
|
|||||||
@ -310,7 +310,7 @@ export function useSuitable() {
|
|||||||
inputFileTitle.value = fileTitle
|
inputFileTitle.value = fileTitle
|
||||||
|
|
||||||
form.appendChild(inputIds)
|
form.appendChild(inputIds)
|
||||||
form.appendChild(inputDetailIds)
|
if (detailIds) form.appendChild(inputDetailIds)
|
||||||
form.appendChild(inputFileTitle)
|
form.appendChild(inputFileTitle)
|
||||||
document.body.appendChild(form)
|
document.body.appendChild(form)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user