diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-12 09:50:35 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-12 09:50:35 +0000 |
| commit | 58dd81f6208199791e7451a1cb239f23bcd0a20f (patch) | |
| tree | 365d6e0f15a5df9be09bda8061af1d3118c84c77 /lib/approval-line/service.ts | |
| parent | bcd462d6e60871b86008e072f4b914138fc5c328 (diff) | |
(김준회) 결재 템플릿 및 결재선 관리 revalidate 처리, 결재선 관리 카테고리 처리
Diffstat (limited to 'lib/approval-line/service.ts')
| -rw-r--r-- | lib/approval-line/service.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/approval-line/service.ts b/lib/approval-line/service.ts index 3000e25f..f3c3fb95 100644 --- a/lib/approval-line/service.ts +++ b/lib/approval-line/service.ts @@ -1,6 +1,7 @@ 'use server'; import db from '@/db/db'; +import { revalidateI18nPaths } from '@/lib/revalidate'; import { and, asc, @@ -21,6 +22,14 @@ import { filterColumns } from '@/lib/filter-columns'; // --------------------------------------------- export type ApprovalLine = typeof approvalLines.$inferSelect; +// --------------------------------------------- +// Revalidation helpers +// --------------------------------------------- + +async function revalidateApprovalLinesPaths() { + await revalidateI18nPaths('/evcp/approval/line'); +} + export interface ApprovalLineWithUsage extends ApprovalLine { templateCount: number; // 사용 중인 템플릿 수 @@ -193,6 +202,7 @@ export async function getApprovalLine(id: string): Promise<ApprovalLine | null> interface CreateInput { name: string; description?: string; + category?: string | null; // eslint-disable-next-line @typescript-eslint/no-explicit-any aplns: any[]; // 결재선 구성 (JSON) createdBy: number; @@ -215,12 +225,14 @@ export async function createApprovalLine(data: CreateInput): Promise<ApprovalLin .values({ name: data.name, description: data.description, + category: data.category ?? null, // eslint-disable-next-line @typescript-eslint/no-explicit-any aplns: data.aplns as any, createdBy: data.createdBy, }) .returning(); + await revalidateApprovalLinesPaths(); return newLine; } @@ -230,6 +242,7 @@ export async function createApprovalLine(data: CreateInput): Promise<ApprovalLin interface UpdateInput { name?: string; description?: string; + category?: string | null; // eslint-disable-next-line @typescript-eslint/no-explicit-any aplns?: any[]; // 결재선 구성 (JSON) updatedBy: number; @@ -263,6 +276,7 @@ export async function updateApprovalLine(id: string, data: UpdateInput): Promise .set({ name: data.name ?? existing.name, description: data.description ?? existing.description, + category: data.category ?? existing.category, // eslint-disable-next-line @typescript-eslint/no-explicit-any aplns: (data.aplns as any) ?? (existing.aplns as any), updatedAt: new Date(), @@ -271,6 +285,7 @@ export async function updateApprovalLine(id: string, data: UpdateInput): Promise const result = await getApprovalLine(id); if (!result) throw new Error('업데이트된 결재선을 조회할 수 없습니다.'); + await revalidateApprovalLinesPaths(); return result; } @@ -305,6 +320,7 @@ export async function duplicateApprovalLine( const duplicated = await createApprovalLine({ name: newName, description: existing.description ? `${existing.description} (복사본)` : undefined, + category: existing.category ?? null, // eslint-disable-next-line @typescript-eslint/no-explicit-any aplns: existing.aplns as any, createdBy, @@ -322,6 +338,7 @@ export async function duplicateApprovalLine( export async function deleteApprovalLine(id: string): Promise<{ success: boolean; error?: string }> { try { await db.delete(approvalLines).where(eq(approvalLines.id, id)); + await revalidateApprovalLinesPaths(); return { success: true }; } catch (error) { return { |
