summaryrefslogtreecommitdiff
path: root/lib/notice/service.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-08-21 06:57:36 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-08-21 06:57:36 +0000
commit02b1cf005cf3e1df64183d20ba42930eb2767a9f (patch)
treee932c54d5260b0e6fda2b46be2a6ba1c3ee30434 /lib/notice/service.ts
parentd78378ecd7ceede1429359f8058c7a99ac34b1b7 (diff)
(대표님, 최겸) 설계메뉴추가, 작업사항 업데이트
설계메뉴 - 문서관리 설계메뉴 - 벤더 데이터 gtc 메뉴 업데이트 정보시스템 - 메뉴리스트 및 정보 업데이트 파일 라우트 업데이트 엑셀임포트 개선 기본계약 개선 벤더 가입과정 변경 및 개선 벤더 기본정보 - pq 돌체 오류 수정 및 개선 벤더 로그인 과정 이메일 오류 수정
Diffstat (limited to 'lib/notice/service.ts')
-rw-r--r--lib/notice/service.ts45
1 files changed, 44 insertions, 1 deletions
diff --git a/lib/notice/service.ts b/lib/notice/service.ts
index 24b03fe9..c261cd2e 100644
--- a/lib/notice/service.ts
+++ b/lib/notice/service.ts
@@ -6,7 +6,7 @@ import { unstable_cache } from "@/lib/unstable-cache"
import { filterColumns } from "@/lib/filter-columns"
import { asc, desc, ilike, and, or, eq } from "drizzle-orm"
import db from "@/db/db"
-import { notice, pageInformation } from "@/db/schema"
+import { notice, pageInformation, menuAssignments } from "@/db/schema"
import type {
CreateNoticeSchema,
@@ -321,4 +321,47 @@ export async function getPagePathList(): Promise<Array<{ pagePath: string; pageN
console.error("Failed to get page path list:", error)
return []
}
+}
+
+// menu_assignments 기반으로 notice 페이지 경로 동기화
+export async function syncNoticeFromMenuAssignments() {
+ try {
+ // menu_assignments에서 모든 메뉴 가져오기
+ const menuItems = await db.select().from(menuAssignments);
+
+ // 기존 notice 페이지 경로들 가져오기 (중복 제거)
+ const existingNotices = await db.select({
+ pagePath: notice.pagePath
+ }).from(notice);
+ const existingPaths = new Set(existingNotices.map(item => item.pagePath));
+
+ let processedCount = 0;
+ const missingPaths = [];
+
+ // 각 메뉴 항목에 대해 확인
+ for (const menu of menuItems) {
+ if (!existingPaths.has(menu.menuPath)) {
+ missingPaths.push({
+ pagePath: menu.menuPath,
+ pageName: menu.menuTitle
+ });
+ }
+ processedCount++;
+ }
+
+ revalidateTag("notice");
+
+ return {
+ success: true,
+ message: `공지사항 경로 동기화 확인 완료: ${processedCount}개 확인, ${missingPaths.length}개 누락`,
+ missingPaths: missingPaths
+ };
+ } catch (error) {
+ console.error("Notice 동기화 오류:", error);
+ return {
+ success: false,
+ message: "공지사항 경로 동기화 중 오류가 발생했습니다.",
+ missingPaths: []
+ };
+ }
} \ No newline at end of file