|
|
@@ -0,0 +1,145 @@
|
|
|
+import { z } from '@hono/zod-openapi';
|
|
|
+
|
|
|
+// 广告实体Schema
|
|
|
+export const AdvertisementSchema = z.object({
|
|
|
+ id: z.number().int().positive().openapi({
|
|
|
+ description: '广告ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ title: z.string().max(30).nullable().openapi({
|
|
|
+ description: '标题',
|
|
|
+ example: '首页轮播图'
|
|
|
+ }),
|
|
|
+ typeId: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '广告类型',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ code: z.string().max(20).nullable().openapi({
|
|
|
+ description: '调用别名',
|
|
|
+ example: 'home_banner'
|
|
|
+ }),
|
|
|
+ url: z.string().max(255).nullable().openapi({
|
|
|
+ description: '跳转URL',
|
|
|
+ example: 'https://example.com'
|
|
|
+ }),
|
|
|
+ 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: 'banner.jpg' }),
|
|
|
+ fullUrl: z.string().openapi({ description: '文件完整URL', example: 'https://example.com/banner.jpg' }),
|
|
|
+ type: z.string().nullable().openapi({ description: '文件类型', example: 'image/jpeg' }),
|
|
|
+ size: z.number().nullable().openapi({ description: '文件大小(字节)', example: 102400 })
|
|
|
+ }).nullable().optional().openapi({
|
|
|
+ description: '图片文件信息'
|
|
|
+ }),
|
|
|
+ advertisementType: z.object({
|
|
|
+ id: z.number().int().positive().openapi({ description: '广告类型ID' }),
|
|
|
+ name: z.string().max(50).openapi({ description: '类型名称', example: '首页轮播' }),
|
|
|
+ code: z.string().max(20).openapi({ description: '类型编码', example: 'home_banner' })
|
|
|
+ }).nullable().optional().openapi({
|
|
|
+ description: '广告类型信息'
|
|
|
+ }),
|
|
|
+ sort: z.number().int().default(0).openapi({
|
|
|
+ description: '排序值',
|
|
|
+ example: 10
|
|
|
+ }),
|
|
|
+ createdAt: z.coerce.date().openapi({
|
|
|
+ description: '创建时间',
|
|
|
+ example: '2024-01-01T00:00:00Z'
|
|
|
+ }),
|
|
|
+ updatedAt: z.coerce.date().openapi({
|
|
|
+ description: '更新时间',
|
|
|
+ example: '2024-01-01T00:00:00Z'
|
|
|
+ }),
|
|
|
+ createdBy: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '创建用户ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ updatedBy: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '更新用户ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ status: z.number().int().min(0).max(1).default(0).openapi({
|
|
|
+ description: '状态 0禁用 1启用',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ actionType: z.number().int().min(0).max(2).default(1).openapi({
|
|
|
+ description: '跳转类型 0不跳转 1webview 2小程序页面',
|
|
|
+ example: 1
|
|
|
+ })
|
|
|
+});
|
|
|
+
|
|
|
+// 创建广告DTO
|
|
|
+export const CreateAdvertisementDto = z.object({
|
|
|
+ title: z.string().min(1).max(30).openapi({
|
|
|
+ description: '标题',
|
|
|
+ example: '首页轮播图'
|
|
|
+ }),
|
|
|
+ typeId: z.coerce.number<number>().int().positive().openapi({
|
|
|
+ description: '广告类型',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ code: z.string().min(1).max(20).openapi({
|
|
|
+ description: '调用别名',
|
|
|
+ example: 'home_banner'
|
|
|
+ }),
|
|
|
+ url: z.string().max(255).nullable().optional().openapi({
|
|
|
+ description: '跳转URL',
|
|
|
+ example: 'https://example.com'
|
|
|
+ }),
|
|
|
+ imageFileId: z.coerce.number<number>().int().positive().optional().openapi({
|
|
|
+ description: '图片文件ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ sort: z.coerce.number<number>().int().default(0).optional().openapi({
|
|
|
+ description: '排序值',
|
|
|
+ example: 10
|
|
|
+ }),
|
|
|
+ status: z.coerce.number<number>().int().min(0).max(1).default(0).optional().openapi({
|
|
|
+ description: '状态 0禁用 1启用',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ actionType: z.coerce.number<number>().int().min(0).max(2).default(1).optional().openapi({
|
|
|
+ description: '跳转类型 0不跳转 1webview 2小程序页面',
|
|
|
+ example: 1
|
|
|
+ })
|
|
|
+});
|
|
|
+
|
|
|
+// 更新广告DTO
|
|
|
+export const UpdateAdvertisementDto = z.object({
|
|
|
+ title: z.string().min(1).max(30).optional().openapi({
|
|
|
+ description: '标题',
|
|
|
+ example: '首页轮播图'
|
|
|
+ }),
|
|
|
+ typeId: z.coerce.number<number>().int().positive().optional().openapi({
|
|
|
+ description: '广告类型',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ code: z.string().min(1).max(20).optional().openapi({
|
|
|
+ description: '调用别名',
|
|
|
+ example: 'home_banner'
|
|
|
+ }),
|
|
|
+ url: z.string().max(255).nullable().optional().openapi({
|
|
|
+ description: '跳转URL',
|
|
|
+ example: 'https://example.com'
|
|
|
+ }),
|
|
|
+ imageFileId: z.coerce.number<number>().int().positive().optional().openapi({
|
|
|
+ description: '图片文件ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ sort: z.coerce.number<number>().int().optional().openapi({
|
|
|
+ description: '排序值',
|
|
|
+ example: 10
|
|
|
+ }),
|
|
|
+ status: z.coerce.number<number>().int().min(0).max(1).optional().openapi({
|
|
|
+ description: '状态 0禁用 1启用',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ actionType: z.coerce.number<number>().int().min(0).max(2).optional().openapi({
|
|
|
+ description: '跳转类型 0不跳转 1webview 2小程序页面',
|
|
|
+ example: 1
|
|
|
+ })
|
|
|
+});
|