diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-22 02:12:15 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-22 02:12:15 +0000 |
| commit | 7dd2b9fc1856306652f311d19697d9880955bfab (patch) | |
| tree | 3144f14e2b6e9d66c25f10686ca9e94d61d9154e /lib/notice/validations.ts | |
| parent | 94082bfe915d3b0337f8929a2bb27828abb5d3c7 (diff) | |
(최겸) 공지사항, 인포메이션 기능 수정
Diffstat (limited to 'lib/notice/validations.ts')
| -rw-r--r-- | lib/notice/validations.ts | 57 |
1 files changed, 3 insertions, 54 deletions
diff --git a/lib/notice/validations.ts b/lib/notice/validations.ts index 05e84af9..146f8e09 100644 --- a/lib/notice/validations.ts +++ b/lib/notice/validations.ts @@ -1,14 +1,4 @@ import { z } from "zod"
-import {
- createSearchParamsCache,
- parseAsArrayOf,
- parseAsInteger,
- parseAsString,
- parseAsStringEnum,
- parseAsBoolean,
-} from "nuqs/server"
-import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers"
-import { Notice } from "@/db/schema/notice"
// 공지사항 생성 스키마
export const createNoticeSchema = z.object({
@@ -28,53 +18,12 @@ export const updateNoticeSchema = z.object({ isActive: z.boolean().default(true),
})
-// 현대적인 검색 파라미터 캐시
-export const searchParamsNoticeCache = createSearchParamsCache({
- flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault([]),
- page: parseAsInteger.withDefault(1),
- perPage: parseAsInteger.withDefault(10),
- sort: getSortingStateParser<Notice>().withDefault([
- { id: "createdAt", desc: true },
- ]),
-
- // 기본 검색 필드들
- pagePath: parseAsString.withDefault(""),
- title: parseAsString.withDefault(""),
- content: parseAsString.withDefault(""),
- authorId: parseAsInteger,
- isActive: parseAsBoolean,
-
- // 고급 필터
- filters: getFiltersStateParser().withDefault([]),
- joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
- search: parseAsString.withDefault(""),
-
- // 날짜 범위
- from: parseAsString.withDefault(""),
- to: parseAsString.withDefault(""),
-})
-
-// 타입 추출
-export type CreateNoticeSchema = z.infer<typeof createNoticeSchema>
-export type UpdateNoticeSchema = z.infer<typeof updateNoticeSchema>
-export type GetNoticeSchema = Awaited<ReturnType<typeof searchParamsNoticeCache.parse>>
-
-// 기존 스키마 (하위 호환성을 위해 유지)
-export const getNoticeSchema = z.object({
- page: z.coerce.number().default(1),
- per_page: z.coerce.number().default(10),
- sort: z.string().optional(),
- pagePath: z.string().optional(),
- title: z.string().optional(),
- authorId: z.coerce.number().optional(),
- isActive: z.coerce.boolean().optional(),
- from: z.string().optional(),
- to: z.string().optional(),
-})
-
// 페이지 경로별 공지사항 조회 스키마
export const getPageNoticeSchema = z.object({
pagePath: z.string().min(1, "페이지 경로를 입력해주세요"),
})
+// 타입 추출
+export type CreateNoticeSchema = z.infer<typeof createNoticeSchema>
+export type UpdateNoticeSchema = z.infer<typeof updateNoticeSchema>
export type GetPageNoticeSchema = z.infer<typeof getPageNoticeSchema>
\ No newline at end of file |
