261008_01_ENH: 알림톡 템플릿 관련내용 구현 및 발송 구현
This commit is contained in:
@@ -3,8 +3,7 @@ import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {FileResponse, PageRequest, PageResponse} from "@kri/common";
|
||||
import type {BulkSendInfo, SendResultSummaryRequest, SendResultSummaryResponse} from "@kri/common/noti-hub";
|
||||
import type {SendResultInfo} from "@/types/message";
|
||||
import type {BulkSendInfo, SendResultInfo, SendResultSummaryRequest, SendResultSummaryResponse} from "@kri/common/noti-hub";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
|
||||
@@ -2,9 +2,11 @@ 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 {MessageBulkSendResponse, SendSingleResponse} from "@/types/message";
|
||||
import type {BulkSendResult} from "@kri/common/noti-hub";
|
||||
import type {MessageSendChannel, SendSingleResponse} from "@/types/message";
|
||||
|
||||
const isChannel = (value: string): value is "sms" | "email" => value === "sms" || value === "email";
|
||||
const isChannel = (value: string): value is MessageSendChannel =>
|
||||
value === "sms" || value === "email" || value === "kko";
|
||||
|
||||
export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
@@ -27,7 +29,7 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
}
|
||||
|
||||
if (action === "bulk") {
|
||||
const result = await contactApi.post<MessageBulkSendResponse>(`/message-send/${channel}/bulk/${prjctIdx}`, body);
|
||||
const result = await contactApi.post<BulkSendResult>(`/message-send/${channel}/bulk/${prjctIdx}`, body);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,31 @@
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type { Template, TemplateSummary } from "@kri/common/noti-hub";
|
||||
import type { KkoTemplateDetail, KkoTemplateListResponse, Template, TemplateSummary } from "@kri/common/noti-hub";
|
||||
|
||||
// 외부 알림톡 템플릿 목록·상세 조회. JSON 본문을 contact-back에 그대로 전달한다.
|
||||
export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
try{
|
||||
const {slug = []} = await context.params;
|
||||
const [channel, action] = slug;
|
||||
if (channel !== "kko" || slug.length !== 2 || (action !== "list" && action !== "detail")) {
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body || typeof body !== "object") {
|
||||
return NextResponse.json({ message: "요청 바디가 없습니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const contactApi = await createContactApi();
|
||||
const result = action === "list"
|
||||
? await contactApi.post<KkoTemplateListResponse>(`/message-template/kko/list`, body)
|
||||
: await contactApi.post<KkoTemplateDetail>(`/message-template/kko/detail`, body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try{
|
||||
|
||||
Reference in New Issue
Block a user