| 1 | import { createPaginationVo, createZodDto, UserType } from '@yikart/common' |
| 2 | import { z } from 'zod' |
| 3 | import { AiLogChannel, AiLogStatus, AiLogType } from '../enums' |
| 4 | |
| 5 | // 日志基本信息 |
| 6 | const logItemSchema = z.object({ |
| 7 | id: z.string().describe('日志ID'), |
| 8 | userId: z.string().describe('用户ID'), |
| 9 | userType: z.enum(UserType).describe('用户类型'), |
| 10 | taskId: z.string().optional().describe('任务ID'), |
| 11 | type: z.enum(AiLogType).describe('日志类型'), |
| 12 | model: z.string().describe('模型'), |
| 13 | channel: z.enum(AiLogChannel).describe('渠道'), |
| 14 | action: z.string().optional().describe('操作'), |
| 15 | status: z.enum(AiLogStatus).describe('日志状态'), |
| 16 | startedAt: z.coerce.date().describe('开始时间'), |
| 17 | duration: z.number().optional().describe('持续时间'), |
| 18 | createdAt: z.coerce.date().describe('创建时间'), |
| 19 | updatedAt: z.coerce.date().describe('更新时间'), |
| 20 | }) |
| 21 | |
| 22 | export class LogItemVo extends createZodDto(logItemSchema) {} |
| 23 | |
| 24 | // 日志列表响应 |
| 25 | export class LogsListResponseVo extends createPaginationVo(logItemSchema, 'LogsListResponseVo') {} |
| 26 | |
| 27 | // 日志详情响应 |
| 28 | const logDetailResponseSchema = z.object({ |
| 29 | ...logItemSchema.shape, |
| 30 | request: z.record(z.string(), z.unknown()).describe('请求参数'), |
| 31 | response: z.record(z.string(), z.unknown()).optional().describe('响应结果'), |
| 32 | errorMessage: z.string().optional().describe('错误信息'), |
| 33 | }) |
| 34 | |
| 35 | export class LogDetailResponseVo extends createZodDto(logDetailResponseSchema) {} |
| 36 |