| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import { z } from '@hono/zod-openapi';
- import { FileSchema } from '@/server/modules/files/file.schema';
- export const GoodsCategorySchema = z.object({
- id: z.number().int().positive().openapi({ description: '类别ID' }),
- name: z.string().min(1, '类别名称不能为空').max(255, '类别名称最多255个字符').openapi({
- description: '类别名称',
- example: '电子产品'
- }),
- parentId: z.number().int().nonnegative('上级ID必须为非负数').default(0).openapi({
- description: '上级分类ID',
- example: 0
- }),
- imageFileId: z.number().int().positive().nullable().openapi({
- description: '分类图片文件ID',
- example: 1
- }),
- level: z.number().int().nonnegative('层级必须为非负数').default(0).openapi({
- description: '分类层级',
- example: 1
- }),
- state: z.number().int().min(1).max(2).default(1).openapi({
- description: '状态 1可用 2不可用',
- example: 1
- }),
- imageFile: FileSchema.nullable().optional().openapi({
- description: '分类图片信息'
- }),
- createdAt: z.coerce.date().openapi({
- description: '创建时间',
- example: '2024-01-01T12:00:00Z'
- }),
- updatedAt: z.coerce.date().openapi({
- description: '更新时间',
- example: '2024-01-01T12:00:00Z'
- }),
- createdBy: z.number().int().positive().nullable().openapi({
- description: '创建用户ID',
- example: 1
- }),
- updatedBy: z.number().int().positive().nullable().openapi({
- description: '更新用户ID',
- example: 1
- })
- });
- export const CreateGoodsCategoryDto = z.object({
- name: z.string().min(1, '类别名称不能为空').max(255, '类别名称最多255个字符').openapi({
- description: '类别名称',
- example: '电子产品'
- }),
- parentId: z.number().int().nonnegative('上级ID必须为非负数').default(0).openapi({
- description: '上级分类ID',
- example: 0
- }),
- imageFileId: z.number().int().positive().nullable().optional().openapi({
- description: '分类图片文件ID',
- example: 1
- }),
- level: z.number().int().nonnegative('层级必须为非负数').default(0).openapi({
- description: '分类层级',
- example: 1
- }),
- state: z.number().int().min(1).max(2).default(1).openapi({
- description: '状态 1可用 2不可用',
- example: 1
- })
- });
- export const UpdateGoodsCategoryDto = z.object({
- name: z.string().min(1, '类别名称不能为空').max(255, '类别名称最多255个字符').optional().openapi({
- description: '类别名称',
- example: '电子产品'
- }),
- parentId: z.number().int().nonnegative('上级ID必须为非负数').optional().openapi({
- description: '上级分类ID',
- example: 0
- }),
- imageFileId: z.number().int().positive().nullable().optional().openapi({
- description: '分类图片文件ID',
- example: 1
- }),
- level: z.number().int().nonnegative('层级必须为非负数').optional().openapi({
- description: '分类层级',
- example: 1
- }),
- state: z.number().int().min(1).max(2).optional().openapi({
- description: '状态 1可用 2不可用',
- example: 1
- })
- });
|