From 9f761849c2e98f650d089d00aed9df090497ada9 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 27 Oct 2025 03:12:26 +0000 Subject: (최겸) 공지사항 팝업기능 및 다시보지않기 기능 구현(로컬 스토리지 활용) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notice/repository.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'lib/notice/repository.ts') diff --git a/lib/notice/repository.ts b/lib/notice/repository.ts index fb941ac9..897eb5b0 100644 --- a/lib/notice/repository.ts +++ b/lib/notice/repository.ts @@ -2,8 +2,10 @@ import { desc, eq, and, sql } from "drizzle-orm" import db from "@/db/db" import { notice, users, type Notice, type NewNotice } from "@/db/schema" -// 페이지 경로별 공지사항 조회 (활성화된 것만, 작성자 정보 포함) +// 페이지 경로별 공지사항 조회 (활성화된 것만, 작성자 정보 포함, 유효기간 내 공지사항만) export async function getNoticesByPagePath(pagePath: string): Promise> { + const currentTime = new Date() + const result = await db .select({ id: notice.id, @@ -12,6 +14,10 @@ export async function getNoticesByPagePath(pagePath: string): Promise= ${currentTime})` )) .orderBy(desc(notice.createdAt)) @@ -32,7 +41,11 @@ export async function getNoticesByPagePath(pagePath: string): Promise { const result = await db .insert(notice) - .values(data) + .values({ + ...data, + createdAt: new Date(), + updatedAt: new Date() + }) .returning() return result[0] @@ -77,6 +90,10 @@ export async function getNoticeById(id: number): Promise<(Notice & { authorName: content: notice.content, authorId: notice.authorId, isActive: notice.isActive, + isPopup: notice.isPopup, + startAt: notice.startAt, + endAt: notice.endAt, + dontShowDuration: notice.dontShowDuration, createdAt: notice.createdAt, updatedAt: notice.updatedAt, authorName: users.name, -- cgit v1.2.3