101 lines
2.6 KiB
TypeScript
101 lines
2.6 KiB
TypeScript
import { z } from "zod";
|
|
import type { PageableList, PageableParams } from "@/shared/model";
|
|
|
|
export const CONTENTS_APPROVE_STATUS = {
|
|
DRAFT: "01",
|
|
REQUESTED: "02",
|
|
APPROVED: "99",
|
|
} as const;
|
|
|
|
export type ContentsApproveStatus =
|
|
(typeof CONTENTS_APPROVE_STATUS)[keyof typeof CONTENTS_APPROVE_STATUS];
|
|
|
|
export interface ContentsParams extends PageableParams {
|
|
contsTtl?: string;
|
|
aprvContsVer?: number;
|
|
useYn?: string;
|
|
}
|
|
|
|
export interface ContentsVersionParams extends PageableParams {
|
|
contsSn?: number;
|
|
contsCn?: string;
|
|
aprvCd?: ContentsApproveStatus;
|
|
cclCd?: string;
|
|
koglCd?: string;
|
|
tag?: string;
|
|
useYn?: string;
|
|
}
|
|
|
|
export interface ContentsVersion {
|
|
contsSn: number;
|
|
contsVer: number;
|
|
contsCn: string;
|
|
useYn: string;
|
|
}
|
|
|
|
export const contentsSchema = z.object({
|
|
contsSn: z.number(),
|
|
contsTtl: z.string(),
|
|
aprvContsVer: z.number(),
|
|
useYn: z.string(),
|
|
mdfcnDt: z.string(),
|
|
mdfr: z.string(),
|
|
mdfrNm: z.string(),
|
|
aprvDt: z.string(),
|
|
autzrNm: z.string(),
|
|
workAprvCd: z.string(),
|
|
workAprvNm: z.string(),
|
|
workContsVer: z.number(),
|
|
});
|
|
|
|
export const contentsDetailSchema = z.object({
|
|
contsSn: z.number(),
|
|
contsVer: z.number(),
|
|
contsTtl: z.string(),
|
|
contsCn: z.string(),
|
|
contsRmrk: z.string().nullish(),
|
|
aprvCd: z.enum([
|
|
CONTENTS_APPROVE_STATUS.DRAFT,
|
|
CONTENTS_APPROVE_STATUS.REQUESTED,
|
|
CONTENTS_APPROVE_STATUS.APPROVED,
|
|
]),
|
|
cclCd: z.string().nullish(),
|
|
koglCd: z.string().nullish(),
|
|
tag: z.string().nullish(),
|
|
aprvDt: z.string(),
|
|
autzr: z.string(),
|
|
useYn: z.string(),
|
|
});
|
|
|
|
export const contentsFormSchema = contentsDetailSchema.omit({
|
|
contsVer: true,
|
|
aprvDt: true,
|
|
autzr: true,
|
|
});
|
|
|
|
export type Contents = z.infer<typeof contentsSchema>;
|
|
export type ContentsDetail = z.infer<typeof contentsDetailSchema>;
|
|
export type ContentsFormData = z.infer<typeof contentsFormSchema>;
|
|
export type ContentsList = PageableList<Contents>;
|
|
export type ContentsVersionList = PageableList<ContentsVersion>;
|
|
|
|
export interface ContentsService {
|
|
getContentsList(params: ContentsParams): Promise<ContentsList>;
|
|
getContentsVersionList(
|
|
params: ContentsVersionParams,
|
|
): Promise<ContentsVersionList>;
|
|
getLatestContentsInfo(
|
|
contsSn: number,
|
|
contsVer: number,
|
|
): Promise<ContentsDetail>;
|
|
createContents(data: ContentsFormData): Promise<void>;
|
|
updateContents(
|
|
contsSn: number,
|
|
contsVer: number,
|
|
data: ContentsFormData,
|
|
): Promise<void>;
|
|
deleteContents(contsSn: number, contsVer: number): Promise<void>;
|
|
requestApprove(contsSn: number, contsVer: number): Promise<void>;
|
|
approveContents(contsSn: number, contsVer: number): Promise<void>;
|
|
}
|