260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋

This commit is contained in:
2026-07-14 10:59:07 +09:00
parent a8ce35f5bf
commit 192d47bdb1
180 changed files with 11942 additions and 6007 deletions

View File

@@ -1,10 +1,28 @@
"use client";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { nextApi } from "@/lib/http-client";
import { qk } from "@/query/key/keys";
import type { ChannelType, Template, TemplateSummary } from "@/types/messageTemplate";
import type {
BulkSendCreateRequest,
BulkSendInfo,
BulkSendResponse,
ChannelType,
SendRequestBulk,
SendResultSummaryRequest,
SendResultSummaryResponse,
Template,
TemplateSummary,
} from "@kri/common/noti-hub";
import type { FileResponse, PageRequest, PageResponse } from "@kri/common";
import type { ProjectMainTemplateUpdateRequest } from "@/types/project";
import type {
MessageBulkSendResponse,
MessageSendBulkRequest,
MessageSendChannel,
MessageSendSingleRequest,
SendResultInfo,
} from "@/types/message";
export function useTemplateListQuery(chnnlTy: ChannelType, itrntPrjctCd: string, enabled: boolean) {
return useQuery({
@@ -87,4 +105,123 @@ export function useUploadTemplateBodyImageMutation(itrntPrjctCd: string) {
return nextApi.putForm<string>(`/message-template/body-image/${itrntPrjctCd}`, formData);
},
});
}
}
/**
* 발송키 생성 (PUT /send-{sms,email}/create/bulk)
*/
export function useCreateBulkSendKeyMutation(channel: MessageSendChannel) {
return useMutation({
mutationFn: (req: BulkSendCreateRequest) =>
nextApi.put<string>(`/message-send/create-bulk/${channel}`, req),
});
}
/**
* bulkSendKey 기반 벌크 발송 (POST /send-{sms,email}/bulk)
*/
export function useSendBulkMutation(channel: MessageSendChannel) {
return useMutation({
mutationFn: (req: SendRequestBulk) =>
nextApi.post<BulkSendResponse>(`/message-send/bulk/${channel}`, req),
});
}
/**
* 대량발송 리스트 조회 (GET /report/bulk-list/{sendTy}/{reqstSvc}/{prjctCd})
*/
export function useBulkSendListQuery(sendTy: number, reqstSvc: string, prjctCd: string, enabled: boolean) {
return useQuery({
queryKey: qk.bulkSendList(sendTy, reqstSvc, prjctCd),
queryFn: () => nextApi.get<BulkSendInfo[]>(`/message-report/bulk-list/${sendTy}/${reqstSvc}/${prjctCd}`),
enabled: enabled && !!reqstSvc && !!prjctCd,
staleTime: 0,
refetchOnMount: "always",
meta: { ignoreGlobalLoading: true },
});
}
/**
* 대량발송 상세 결과 조회 (POST /report/bulk-detail/{bulkSendKey})
*/
export function useBulkSendDetailQuery(bulkSendKey: string, pageRequest: PageRequest, enabled: boolean) {
return useQuery({
queryKey: qk.bulkSendDetail(bulkSendKey, pageRequest),
queryFn: () => nextApi.post<PageResponse<SendResultInfo>>(`/message-report/bulk-detail/${bulkSendKey}`, pageRequest),
enabled: enabled && !!bulkSendKey,
staleTime: 0,
placeholderData: keepPreviousData,
meta: { ignoreGlobalLoading: true },
});
}
/**
* 대량발송 결과 엑셀 다운로드 (POST /report/bulk-detail/excel/{bulkSendKey})
*/
export function useBulkSendDetailExcelMutation() {
return useMutation({
mutationFn: (bulkSendKey: string) =>
nextApi.post<FileResponse>(`/message-report/bulk-detail-excel/${bulkSendKey}`, undefined),
});
}
/**
* 발송 결과 축약 조회 (POST /report/send-result-summary)
*/
export function useSendResultSummaryQuery(request: SendResultSummaryRequest, enabled: boolean) {
return useQuery({
queryKey: qk.sendResultSummary(request),
queryFn: () => nextApi.post<SendResultSummaryResponse[]>(`/message-report/send-result-summary`, request),
enabled,
staleTime: 0,
meta: { ignoreGlobalLoading: true },
});
}
/**
* 단건 발송 (POST /message/{channel}/single/{prjctIdx}, contactServer 경유)
*/
export function useSendSingleMessageMutation(channel: MessageSendChannel, prjctIdx: number) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (req: MessageSendSingleRequest) =>
nextApi.post<void>(`/message/${channel}/single/${prjctIdx}`, req),
onSuccess: (_data, req) => {
queryClient.invalidateQueries({ queryKey: ["message-report", "send-result", String(req.sid)] });
},
});
}
/**
* 대량 발송 (POST /message/{channel}/bulk/{prjctIdx}, contactServer 경유)
*/
export function useSendBulkMessageMutation(channel: MessageSendChannel, prjctIdx: number) {
return useMutation({
mutationFn: (req: MessageSendBulkRequest) =>
nextApi.post<MessageBulkSendResponse>(`/message/${channel}/bulk/${prjctIdx}`, req),
});
}
/**
* SID 단위 발송 결과 목록 조회 (GET /report/send-result/{sid}/{prjctCd}/{reqstSvc})
*/
export function useSendResultBySidQuery(
sid: string,
prjctCd: string,
reqstSvc: string,
channelTy: ChannelType | undefined,
enabled: boolean,
) {
return useQuery({
queryKey: qk.sendResultBySid(sid, prjctCd, reqstSvc, channelTy),
queryFn: () => {
const query = channelTy !== undefined ? `?channelTy=${channelTy}` : "";
return nextApi.get<SendResultInfo[]>(`/message-report/send-result/${sid}/${prjctCd}/${reqstSvc}${query}`);
},
enabled: enabled && !!sid && !!prjctCd && !!reqstSvc,
staleTime: 0,
refetchOnMount: "always",
meta: { ignoreGlobalLoading: true },
});
}