Merge pull request '260805_02_ENH: 외부 설문에서 리스트 관련 기능 사용시 prjctIdx가 아닌 prjctCd로 동작하게 변경' (#20) from develop into master

Reviewed-on: #20
This commit is contained in:
2026-08-05 16:19:43 +09:00
2 changed files with 19 additions and 19 deletions

View File

@@ -15,17 +15,17 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
} }
const { slug = [] } = await context.params; const { slug = [] } = await context.params;
const [action, prjctIdx, sid] = slug; const [action, prjctCd, sid] = slug;
const contactApi = await createContactApiWithApiKey(apiKey); const contactApi = await createContactApiWithApiKey(apiKey);
if (action === "header" && prjctIdx) { if (action === "header" && prjctCd) {
const result = await contactApi.get<string[]>(`/list-external/header/${prjctIdx}`); const result = await contactApi.get<string[]>(`/list-external/header/${encodeURIComponent(prjctCd)}`);
return NextResponse.json(result, { status: 200 }); return NextResponse.json(result, { status: 200 });
} }
if (action === "search" && prjctIdx && sid) { if (action === "search" && prjctCd && sid) {
const result = await contactApi.get<ListSearchExternal>( const result = await contactApi.get<ListSearchExternal>(
`/list-external/search/${prjctIdx}/${encodeURIComponent(sid)}`, `/list-external/search/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`,
); );
return NextResponse.json(result, { status: 200 }); return NextResponse.json(result, { status: 200 });
} }
@@ -45,13 +45,13 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
} }
const { slug = [] } = await context.params; const { slug = [] } = await context.params;
const [action, prjctIdx, sid] = slug; const [action, prjctCd, sid] = slug;
if (action === "update" && prjctIdx && sid) { if (action === "update" && prjctCd && sid) {
const body = await req.json().catch(() => null); const body = await req.json().catch(() => null);
const contactApi = await createContactApiWithApiKey(apiKey); const contactApi = await createContactApiWithApiKey(apiKey);
const result = await contactApi.patch<number>( const result = await contactApi.patch<number>(
`/list-external/update/${prjctIdx}/${encodeURIComponent(sid)}`, `/list-external/update/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`,
body, body,
); );
return NextResponse.json(result, { status: 200 }); return NextResponse.json(result, { status: 200 });
@@ -74,35 +74,35 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
const { slug = [] } = await context.params; const { slug = [] } = await context.params;
const [action] = slug; const [action] = slug;
const { searchParams } = req.nextUrl; const { searchParams } = req.nextUrl;
const prjctIdx = searchParams.get("prjctIdx"); const prjctCd = searchParams.get("prjctCd");
const sid = searchParams.get("sid"); const sid = searchParams.get("sid");
const contactApi = await createContactApiWithApiKey(apiKey); const contactApi = await createContactApiWithApiKey(apiKey);
if (action === "header") { if (action === "header") {
if (!prjctIdx) { if (!prjctCd) {
return NextResponse.json({ message: "prjctIdx는 필수입니다." }, { status: 400 }); return NextResponse.json({ message: "prjctCd는 필수입니다." }, { status: 400 });
} }
const result = await contactApi.get<string[]>(`/list-external/header/${prjctIdx}`); const result = await contactApi.get<string[]>(`/list-external/header/${encodeURIComponent(prjctCd)}`);
return NextResponse.json(result, { status: 200 }); return NextResponse.json(result, { status: 200 });
} }
if (action === "search") { if (action === "search") {
if (!prjctIdx || !sid) { if (!prjctCd || !sid) {
return NextResponse.json({ message: "prjctIdx, sid는 필수입니다." }, { status: 400 }); return NextResponse.json({ message: "prjctCd, sid는 필수입니다." }, { status: 400 });
} }
const result = await contactApi.get<ListSearchExternal>( const result = await contactApi.get<ListSearchExternal>(
`/list-external/search/${prjctIdx}/${encodeURIComponent(sid)}`, `/list-external/search/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`,
); );
return NextResponse.json(result, { status: 200 }); return NextResponse.json(result, { status: 200 });
} }
if (action === "update") { if (action === "update") {
if (!prjctIdx || !sid) { if (!prjctCd || !sid) {
return NextResponse.json({ message: "prjctIdx, sid는 필수입니다." }, { status: 400 }); return NextResponse.json({ message: "prjctCd, sid는 필수입니다." }, { status: 400 });
} }
const body = await req.json().catch(() => null); const body = await req.json().catch(() => null);
const result = await contactApi.patch<number>( const result = await contactApi.patch<number>(
`/list-external/update/${prjctIdx}/${encodeURIComponent(sid)}`, `/list-external/update/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`,
body, body,
); );
return NextResponse.json(result, { status: 200 }); return NextResponse.json(result, { status: 200 });

View File

@@ -369,7 +369,7 @@ export type ListSearchWithFullResult = ListSearchWithResult & {
}; };
export type ListSearchExternal = { export type ListSearchExternal = {
prjctIdx: number; prjctCd: string;
sid: string; sid: string;
itemList: Record<string, string>; itemList: Record<string, string>;
}; };