|
|
@@ -1,270 +0,0 @@
|
|
|
-import { z } from '@hono/zod-openapi';
|
|
|
-
|
|
|
-// 商品信息Schema
|
|
|
-export const GoodsSchema = z.object({
|
|
|
- id: z.number().int().positive().openapi({
|
|
|
- description: '商品ID',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- name: z.string().max(255).openapi({
|
|
|
- description: '商品名称',
|
|
|
- example: '精美商品'
|
|
|
- }),
|
|
|
- price: z.number().multipleOf(0.01).openapi({
|
|
|
- description: '售卖价',
|
|
|
- example: 99.99
|
|
|
- }),
|
|
|
- costPrice: z.number().multipleOf(0.01).openapi({
|
|
|
- description: '成本价',
|
|
|
- example: 50.00
|
|
|
- }),
|
|
|
- salesNum: z.number().int().min(0).openapi({
|
|
|
- description: '销售数量',
|
|
|
- example: 100
|
|
|
- }),
|
|
|
- clickNum: z.number().int().min(0).openapi({
|
|
|
- description: '点击次数',
|
|
|
- example: 1000
|
|
|
- }),
|
|
|
- categoryId1: z.number().int().min(0).openapi({
|
|
|
- description: '一级类别id',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- categoryId2: z.number().int().min(0).openapi({
|
|
|
- description: '二级类别id',
|
|
|
- example: 2
|
|
|
- }),
|
|
|
- categoryId3: z.number().int().min(0).openapi({
|
|
|
- description: '三级类别id',
|
|
|
- example: 3
|
|
|
- }),
|
|
|
- goodsType: z.number().int().min(1).max(2).openapi({
|
|
|
- description: '订单类型 1实物产品 2虚拟产品',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- supplierId: z.number().int().positive().nullable().openapi({
|
|
|
- description: '所属供应商id',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- image: z.string().max(255).nullable().openapi({
|
|
|
- description: '商品主图',
|
|
|
- example: 'https://example.com/image.jpg'
|
|
|
- }),
|
|
|
- slideImage: z.string().max(2000).nullable().openapi({
|
|
|
- description: '商品轮播图(多个用,隔开)',
|
|
|
- example: 'image1.jpg,image2.jpg,image3.jpg'
|
|
|
- }),
|
|
|
- detail: z.string().nullable().openapi({
|
|
|
- description: '商品详情',
|
|
|
- example: '<p>商品详细描述</p>'
|
|
|
- }),
|
|
|
- instructions: z.string().max(255).nullable().openapi({
|
|
|
- description: '简介',
|
|
|
- example: '优质商品,值得信赖'
|
|
|
- }),
|
|
|
- sort: z.number().int().min(0).openapi({
|
|
|
- description: '排序',
|
|
|
- example: 0
|
|
|
- }),
|
|
|
- state: z.number().int().min(1).max(2).openapi({
|
|
|
- description: '状态1可用2不可用',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- stock: z.number().int().min(0).openapi({
|
|
|
- description: '库存',
|
|
|
- example: 100
|
|
|
- }),
|
|
|
- spuId: z.number().int().min(0).openapi({
|
|
|
- description: '主商品ID',
|
|
|
- example: 0
|
|
|
- }),
|
|
|
- spuName: z.string().max(255).nullable().openapi({
|
|
|
- description: '主商品名称',
|
|
|
- example: null
|
|
|
- }),
|
|
|
- lowestBuy: z.number().int().min(1).openapi({
|
|
|
- description: '最小起购量',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- imageFileId: z.number().int().positive().nullable().openapi({
|
|
|
- description: '商品主图文件ID',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- imageFile: z.object({
|
|
|
- id: z.number().int().positive().openapi({ description: '文件ID' }),
|
|
|
- name: z.string().max(255).openapi({ description: '文件名', example: 'product.jpg' }),
|
|
|
- fullUrl: z.string().openapi({ description: '文件完整URL', example: 'https://example.com/product.jpg' }),
|
|
|
- type: z.string().nullable().openapi({ description: '文件类型', example: 'image/jpeg' }),
|
|
|
- size: z.number().nullable().openapi({ description: '文件大小(字节)', example: 102400 })
|
|
|
- }).nullable().optional().openapi({
|
|
|
- description: '商品主图文件信息'
|
|
|
- }),
|
|
|
- createdAt: z.date().openapi({
|
|
|
- description: '创建时间',
|
|
|
- example: '2024-01-01T00:00:00Z'
|
|
|
- }),
|
|
|
- updatedAt: z.date().openapi({
|
|
|
- description: '更新时间',
|
|
|
- example: '2024-01-01T00:00:00Z'
|
|
|
- })
|
|
|
-});
|
|
|
-
|
|
|
-// 创建商品DTO
|
|
|
-export const CreateGoodsDto = z.object({
|
|
|
- name: z.string().max(255).openapi({
|
|
|
- description: '商品名称',
|
|
|
- example: '精美商品'
|
|
|
- }),
|
|
|
- price: z.coerce.number().multipleOf(0.01).openapi({
|
|
|
- description: '售卖价',
|
|
|
- example: 99.99
|
|
|
- }),
|
|
|
- costPrice: z.coerce.number().multipleOf(0.01).openapi({
|
|
|
- description: '成本价',
|
|
|
- example: 50.00
|
|
|
- }),
|
|
|
- categoryId1: z.coerce.number().int().min(0).openapi({
|
|
|
- description: '一级类别id',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- categoryId2: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '二级类别id',
|
|
|
- example: 2
|
|
|
- }),
|
|
|
- categoryId3: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '三级类别id',
|
|
|
- example: 3
|
|
|
- }),
|
|
|
- goodsType: z.coerce.number().int().min(1).max(2).default(1).openapi({
|
|
|
- description: '订单类型 1实物产品 2虚拟产品',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- supplierId: z.coerce.number().int().positive().optional().openapi({
|
|
|
- description: '所属供应商id',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- image: z.string().max(255).optional().openapi({
|
|
|
- description: '商品主图',
|
|
|
- example: 'https://example.com/image.jpg'
|
|
|
- }),
|
|
|
- slideImage: z.string().max(2000).optional().openapi({
|
|
|
- description: '商品轮播图(多个用,隔开)',
|
|
|
- example: 'image1.jpg,image2.jpg,image3.jpg'
|
|
|
- }),
|
|
|
- detail: z.string().optional().openapi({
|
|
|
- description: '商品详情',
|
|
|
- example: '<p>商品详细描述</p>'
|
|
|
- }),
|
|
|
- instructions: z.string().max(255).optional().openapi({
|
|
|
- description: '简介',
|
|
|
- example: '优质商品,值得信赖'
|
|
|
- }),
|
|
|
- sort: z.coerce.number().int().min(0).default(0).openapi({
|
|
|
- description: '排序',
|
|
|
- example: 0
|
|
|
- }),
|
|
|
- state: z.coerce.number().int().min(1).max(2).default(1).openapi({
|
|
|
- description: '状态1可用2不可用',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- stock: z.coerce.number().int().min(0).default(0).openapi({
|
|
|
- description: '库存',
|
|
|
- example: 100
|
|
|
- }),
|
|
|
- spuId: z.coerce.number().int().min(0).default(0).openapi({
|
|
|
- description: '主商品ID',
|
|
|
- example: 0
|
|
|
- }),
|
|
|
- spuName: z.string().max(255).optional().openapi({
|
|
|
- description: '主商品名称',
|
|
|
- example: null
|
|
|
- }),
|
|
|
- lowestBuy: z.coerce.number().int().min(1).default(1).openapi({
|
|
|
- description: '最小起购量',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- imageFileId: z.coerce.number().int().positive().optional().openapi({
|
|
|
- description: '商品主图文件ID',
|
|
|
- example: 1
|
|
|
- })
|
|
|
-});
|
|
|
-
|
|
|
-// 更新商品DTO
|
|
|
-export const UpdateGoodsDto = z.object({
|
|
|
- name: z.string().max(255).optional().openapi({
|
|
|
- description: '商品名称',
|
|
|
- example: '精美商品'
|
|
|
- }),
|
|
|
- price: z.coerce.number().multipleOf(0.01).optional().openapi({
|
|
|
- description: '售卖价',
|
|
|
- example: 99.99
|
|
|
- }),
|
|
|
- costPrice: z.coerce.number().multipleOf(0.01).optional().openapi({
|
|
|
- description: '成本价',
|
|
|
- example: 50.00
|
|
|
- }),
|
|
|
- categoryId1: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '一级类别id',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- categoryId2: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '二级类别id',
|
|
|
- example: 2
|
|
|
- }),
|
|
|
- categoryId3: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '三级类别id',
|
|
|
- example: 3
|
|
|
- }),
|
|
|
- goodsType: z.coerce.number().int().min(1).max(2).optional().openapi({
|
|
|
- description: '订单类型 1实物产品 2虚拟产品',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- supplierId: z.coerce.number().int().positive().optional().openapi({
|
|
|
- description: '所属供应商id',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- image: z.string().max(255).optional().openapi({
|
|
|
- description: '商品主图',
|
|
|
- example: 'https://example.com/image.jpg'
|
|
|
- }),
|
|
|
- slideImage: z.string().max(2000).optional().openapi({
|
|
|
- description: '商品轮播图(多个用,隔开)',
|
|
|
- example: 'image1.jpg,image2.jpg,image3.jpg'
|
|
|
- }),
|
|
|
- detail: z.string().optional().openapi({
|
|
|
- description: '商品详情',
|
|
|
- example: '<p>商品详细描述</p>'
|
|
|
- }),
|
|
|
- instructions: z.string().max(255).optional().openapi({
|
|
|
- description: '简介',
|
|
|
- example: '优质商品,值得信赖'
|
|
|
- }),
|
|
|
- sort: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '排序',
|
|
|
- example: 0
|
|
|
- }),
|
|
|
- state: z.coerce.number().int().min(1).max(2).optional().openapi({
|
|
|
- description: '状态1可用2不可用',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- stock: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '库存',
|
|
|
- example: 100
|
|
|
- }),
|
|
|
- spuId: z.coerce.number().int().min(0).optional().openapi({
|
|
|
- description: '主商品ID',
|
|
|
- example: 0
|
|
|
- }),
|
|
|
- spuName: z.string().max(255).optional().openapi({
|
|
|
- description: '主商品名称',
|
|
|
- example: null
|
|
|
- }),
|
|
|
- lowestBuy: z.coerce.number().int().min(1).optional().openapi({
|
|
|
- description: '最小起购量',
|
|
|
- example: 1
|
|
|
- }),
|
|
|
- imageFileId: z.coerce.number().int().positive().optional().openapi({
|
|
|
- description: '商品主图文件ID',
|
|
|
- example: 1
|
|
|
- })
|
|
|
-});
|