78 lines
1.8 KiB
TypeScript
78 lines
1.8 KiB
TypeScript
import { z } from "zod";
|
|
import {
|
|
type PageableList,
|
|
type PageableParams,
|
|
} from "@/shared/model/api-interface";
|
|
|
|
export interface PostParams extends PageableParams {
|
|
keywordType?: string;
|
|
keyword?: string;
|
|
bbsId?: number;
|
|
delYn?: string;
|
|
frDateYmd?: string;
|
|
toDateYmd?: string;
|
|
}
|
|
|
|
export interface Post {
|
|
bbsId: number;
|
|
pstNo: number;
|
|
pstTtl: string;
|
|
inqNocs: number;
|
|
rfrncUrl: string;
|
|
popupYn: string;
|
|
upndFixYn: string;
|
|
prdPstgYn: string;
|
|
rootPath: string;
|
|
pstPath: string;
|
|
ansPstn: number;
|
|
wrtrNm: string;
|
|
wrtrCplc: string;
|
|
atflCd: string;
|
|
regDt: string;
|
|
rgtrNm: string;
|
|
}
|
|
|
|
export interface PostInfo extends Post {
|
|
pstCn: string;
|
|
rgtr: string;
|
|
mdfcnDt: string;
|
|
mdfr: string;
|
|
}
|
|
|
|
export const postFormSchema = z.object({
|
|
bbsId: z.number(),
|
|
pstTtl: z.string(),
|
|
pstCn: z.string().nullish(),
|
|
rfrncUrl: z.string().nullish(),
|
|
popupYn: z.string().nullish(),
|
|
upndFixYn: z.string().nullish(),
|
|
prdPstgYn: z.string().nullish(),
|
|
pstPswd: z.string(),
|
|
wrtrNm: z.string().nullish(),
|
|
wrtrCplc: z.string().nullish(),
|
|
atflCd: z.string().nullish(),
|
|
parentPstNo: z.number().nullish(),
|
|
});
|
|
|
|
export const postUpdateFormSchema = postFormSchema.omit({
|
|
bbsId: true,
|
|
pstPswd: true,
|
|
parentPstNo: true,
|
|
});
|
|
|
|
export type PostList = PageableList<Post>;
|
|
export type PostFormData = z.infer<typeof postFormSchema>;
|
|
export type PostUpdateFormData = z.infer<typeof postUpdateFormSchema>;
|
|
|
|
export interface PostService {
|
|
getPostList(params: PostParams): Promise<PostList>;
|
|
getPostInfo(bbsId: string, pstNo: string): Promise<PostInfo>;
|
|
createPost(data: PostFormData): Promise<Post>;
|
|
updatePost(
|
|
bbsId: string,
|
|
pstNo: string,
|
|
data: PostUpdateFormData,
|
|
): Promise<Post>;
|
|
deletePost(bbsId: string, pstNo: string): Promise<void>;
|
|
}
|