251216_01_ENH : 프로젝트에 FW User 배정 구현 및 테스트 완료

This commit is contained in:
2025-12-16 16:57:03 +09:00
parent d9775c8a1d
commit bfbf4635b3
19 changed files with 813 additions and 107 deletions

View File

@@ -10,11 +10,41 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
const [action] = slug;
const contactApi = await createContactApi();
if (action === "prjct-outsource") {
if (action === "prjct-outsource" && slug.length === 2) {
const result = await contactApi.get<string[]>(`/assign/prjct-outsource/${slug[1]}`);
return NextResponse.json(result, { status: 200 });
}
if (action === "prjct-fieldwork" && slug.length === 2) {
const result = await contactApi.get<string[]>(`/assign/prjct-fieldwork/${slug[1]}`);
return NextResponse.json(result, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
}
};
export const PUT = async (req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
if (action === "prjct-fieldwork" && slug.length === 2) {
const body = await req.json().catch(() => null);
if (!body) {
return NextResponse.json(
{ message: "요청 바디가 없습니다." },
{ status: 400 }
);
}
await contactApi.put(`/assign/prjct-fieldwork/${slug[1]}`, body);
return new NextResponse(null, { status: 204 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);

View File

@@ -35,6 +35,11 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json(result, { status: 200 });
}
if(action === "fieldwork"){
const result = await contactApi.get<UserInfo[]>("/user/fieldwork");
return NextResponse.json(result, { status: 200 });
}
if (slug.length === 1) {
const userId = action;
const result = await contactApi.get<UserInfo>(`/user/${encodeURIComponent(userId)}`);