feat: 지붕재적합성 검색조건 그룹코드로 변경

This commit is contained in:
Daseul Kim 2025-05-26 17:06:33 +09:00
parent 8bcffd43bb
commit 94ce738a73
2 changed files with 8 additions and 4 deletions

View File

@ -50,7 +50,7 @@ export async function GET(request: NextRequest) {
// 검색 조건 설정 // 검색 조건 설정
if (category) { if (category) {
let roofMtQuery = ` const roofMtQuery = `
SELECT roof_mt_cd SELECT roof_mt_cd
FROM ms_suitable_roof_material_group FROM ms_suitable_roof_material_group
WHERE roof_matl_grp_cd = ':roofMtGrpCd' WHERE roof_matl_grp_cd = ':roofMtGrpCd'

View File

@ -1,6 +1,5 @@
import { NextRequest, NextResponse } from 'next/server' import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/libs/prisma' import { prisma } from '@/libs/prisma'
import { type Suitable } from '@/types/Suitable'
export async function GET(request: NextRequest) { export async function GET(request: NextRequest) {
try { try {
@ -22,15 +21,20 @@ export async function GET(request: NextRequest) {
) AS details ) AS details
ON msm.id = details.main_id ON msm.id = details.main_id
WHERE 1=1 WHERE 1=1
--roofMtCd AND msm.roof_mt_cd = ':roofMtCd' --roofMtCd AND msm.roof_mt_cd IN (:roofMtCd)
--productName AND msm.product_name LIKE '%:productName%' --productName AND msm.product_name LIKE '%:productName%'
; ;
` `
// 검색 조건 설정 // 검색 조건 설정
if (category) { if (category) {
const roofMtQuery = `
SELECT roof_mt_cd
FROM ms_suitable_roof_material_group
WHERE roof_matl_grp_cd = ':roofMtGrpCd'
`
query = query.replace('--roofMtCd ', '') query = query.replace('--roofMtCd ', '')
query = query.replace(':roofMtCd', category) query = query.replace(':roofMtCd', roofMtQuery.replace(':roofMtGrpCd', category))
} }
if (keyword) { if (keyword) {
query = query.replace('--productName ', '') query = query.replace('--productName ', '')