|
|
@@ -0,0 +1,106 @@
|
|
|
+import { z } from '@hono/zod-openapi';
|
|
|
+import { FileSchema } from '@/server/modules/files/file.schema';
|
|
|
+import { DeleteStatus, DisabledStatus } from '@/share/types';
|
|
|
+
|
|
|
+// 模板实体完整Schema
|
|
|
+export const TemplateSchema = z.object({
|
|
|
+ id: z.number().int('必须是整数').positive('必须是正整数').openapi({
|
|
|
+ description: '模板ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ title: z.string().min(1, '模板标题不能为空').max(255, '模板标题最多255个字符').openapi({
|
|
|
+ description: '模板标题',
|
|
|
+ example: '项目计划书模板'
|
|
|
+ }),
|
|
|
+ description: z.string().nullable().openapi({
|
|
|
+ description: '模板描述',
|
|
|
+ example: '适用于各类项目管理的标准计划书模板'
|
|
|
+ }),
|
|
|
+ fileId: z.number().int('必须是整数').positive('必须是正整数').openapi({
|
|
|
+ description: '关联文件ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ file: FileSchema.openapi({
|
|
|
+ description: '关联文件信息'
|
|
|
+ }),
|
|
|
+ category: z.string().min(1, '模板分类不能为空').max(100, '模板分类最多100个字符').openapi({
|
|
|
+ description: '模板分类',
|
|
|
+ example: '项目管理'
|
|
|
+ }),
|
|
|
+ isFree: z.number().int('必须是整数').min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').openapi({
|
|
|
+ description: '是否免费:0-收费,1-免费',
|
|
|
+ example: 0
|
|
|
+ }),
|
|
|
+ downloadCount: z.number().int('必须是整数').min(0, '下载次数不能为负数').openapi({
|
|
|
+ description: '下载次数',
|
|
|
+ example: 100
|
|
|
+ }),
|
|
|
+ isDisabled: z.number().int('必须是整数').min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').default(DisabledStatus.ENABLED).openapi({
|
|
|
+ description: '是否禁用:0-启用,1-禁用',
|
|
|
+ example: DisabledStatus.ENABLED
|
|
|
+ }),
|
|
|
+ isDeleted: z.number().int('必须是整数').min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').default(DeleteStatus.NOT_DELETED).openapi({
|
|
|
+ description: '是否删除:0-未删除,1-已删除',
|
|
|
+ example: DeleteStatus.NOT_DELETED
|
|
|
+ }),
|
|
|
+ createdAt: z.coerce.date('创建时间格式不正确').openapi({
|
|
|
+ description: '创建时间',
|
|
|
+ example: '2024-01-15T10:30:00Z'
|
|
|
+ }),
|
|
|
+ updatedAt: z.coerce.date('更新时间格式不正确').openapi({
|
|
|
+ description: '更新时间',
|
|
|
+ example: '2024-01-16T14:20:00Z'
|
|
|
+ })
|
|
|
+});
|
|
|
+
|
|
|
+// 创建模板请求Schema
|
|
|
+export const CreateTemplateDto = z.object({
|
|
|
+ title: z.string().min(1, '模板标题不能为空').max(255, '模板标题最多255个字符').openapi({
|
|
|
+ description: '模板标题',
|
|
|
+ example: '项目计划书模板'
|
|
|
+ }),
|
|
|
+ description: z.string().nullable().optional().openapi({
|
|
|
+ description: '模板描述',
|
|
|
+ example: '适用于各类项目管理的标准计划书模板'
|
|
|
+ }),
|
|
|
+ fileId: z.coerce.number().int('必须是整数').positive('必须是正整数').openapi({
|
|
|
+ description: '关联文件ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ category: z.string().min(1, '模板分类不能为空').max(100, '模板分类最多100个字符').openapi({
|
|
|
+ description: '模板分类',
|
|
|
+ example: '项目管理'
|
|
|
+ }),
|
|
|
+ isFree: z.coerce.number().int('必须是整数').min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').default(0).openapi({
|
|
|
+ description: '是否免费:0-收费,1-免费',
|
|
|
+ example: 0
|
|
|
+ })
|
|
|
+});
|
|
|
+
|
|
|
+// 更新模板请求Schema
|
|
|
+export const UpdateTemplateDto = z.object({
|
|
|
+ title: z.string().min(1, '模板标题不能为空').max(255, '模板标题最多255个字符').optional().openapi({
|
|
|
+ description: '模板标题',
|
|
|
+ example: '项目计划书模板(更新版)'
|
|
|
+ }),
|
|
|
+ description: z.string().nullable().optional().openapi({
|
|
|
+ description: '模板描述',
|
|
|
+ example: '适用于各类项目管理的标准计划书模板(修订版)'
|
|
|
+ }),
|
|
|
+ fileId: z.coerce.number().int('必须是整数').positive('必须是正整数').optional().openapi({
|
|
|
+ description: '关联文件ID',
|
|
|
+ example: 2
|
|
|
+ }),
|
|
|
+ category: z.string().min(1, '模板分类不能为空').max(100, '模板分类最多100个字符').optional().openapi({
|
|
|
+ description: '模板分类',
|
|
|
+ example: '项目管理'
|
|
|
+ }),
|
|
|
+ isFree: z.coerce.number().int('必须是整数').min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').optional().openapi({
|
|
|
+ description: '是否免费:0-收费,1-免费',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ isDisabled: z.coerce.number().int('必须是整数').min(0, '状态值只能是0或1').max(1, '状态值只能是0或1').optional().openapi({
|
|
|
+ description: '是否禁用:0-启用,1-禁用',
|
|
|
+ example: DisabledStatus.ENABLED
|
|
|
+ })
|
|
|
+});
|