260722_01_ENH: 버그 수정 및 개선 사항 수정
This commit is contained in:
14
src/app/api/external/[[...slug]]/route.ts
vendored
14
src/app/api/external/[[...slug]]/route.ts
vendored
@@ -36,7 +36,7 @@ const toRequiredNumber = (value: string): number | null => {
|
||||
const buildExternalEventBody = (
|
||||
req: NextRequest,
|
||||
action: ExternalAction,
|
||||
prjctIdx: number,
|
||||
prjctSurveyIdx: number,
|
||||
sid: number,
|
||||
): ExternalEventBody => {
|
||||
const pathname = req.nextUrl.pathname;
|
||||
@@ -45,12 +45,12 @@ const buildExternalEventBody = (
|
||||
|
||||
return {
|
||||
action: actionCode,
|
||||
prjctIdx,
|
||||
prjctSurveyIdx,
|
||||
sid,
|
||||
meta: {
|
||||
entryType: getEntryTypeCode(h),
|
||||
action: actionCode,
|
||||
pid: String(prjctIdx),
|
||||
psidx: String(prjctSurveyIdx),
|
||||
sid: String(sid),
|
||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||
uri: getHeader(h, "x-orig-uri") || pathname,
|
||||
@@ -74,14 +74,14 @@ const handleExternalEvent = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const prjctIdx = toRequiredNumber((searchParams.get("pid") ?? "").trim());
|
||||
const prjctSurveyIdx = toRequiredNumber((searchParams.get("psidx") ?? "").trim());
|
||||
const sid = toRequiredNumber((searchParams.get("sid") ?? "").trim());
|
||||
|
||||
if (!prjctIdx || !sid) {
|
||||
return NextResponse.json({ message: "pid와 sid는 필수입니다." }, { status: 400 });
|
||||
if (!prjctSurveyIdx || !sid) {
|
||||
return NextResponse.json({ message: "psidx, sid는 필수입니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const body = buildExternalEventBody(req, action, prjctIdx, sid);
|
||||
const body = buildExternalEventBody(req, action, prjctSurveyIdx, sid);
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
await contactApi.post(`/list-hist/survey`, body);
|
||||
|
||||
@@ -3,7 +3,7 @@ import {RouteContext} from "@/types/common";
|
||||
import {createIntranetApi} from "@/lib/http-server";
|
||||
import {CallerTelNumInfo, IntranetProjectSearchResponse} from "@/types/project";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
import {GroupCodeInfo, ItrntUserInfo} from "@/types/user";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
@@ -34,6 +34,12 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "group-code-list"){
|
||||
const result = await itrntApi.get<GroupCodeInfo[]>(`/user/group-code-list`);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -2,6 +2,25 @@ import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {ListCallHistSession} from "@/types/list";
|
||||
|
||||
export const GET = async (_req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action, agentSessionId] = slug;
|
||||
if (action !== "session" || !agentSessionId) {
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const contactApi = await createContactApi();
|
||||
const result = await contactApi.get<ListCallHistSession>(
|
||||
`/list-call-hist/session/${encodeURIComponent(agentSessionId)}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
|
||||
@@ -32,6 +32,17 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "item-file-download" && slug.length === 4) {
|
||||
const result = await contactApi.get<ArrayBuffer>(
|
||||
`/list/item-file/download/${slug[1]}/${slug[2]}/${slug[3]}`,
|
||||
{ expectBinary: true },
|
||||
);
|
||||
return new NextResponse(result, {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/octet-stream" },
|
||||
});
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
Reference in New Issue
Block a user