Files
chat-one-service/src/apps/client-app/chat/dto/chat-session-response.dto.ts
alboped 32303d099a feat(client): 新增会话管理与消息落库能力
补齐客户端会话生命周期接口(创建、列表、消息分页、改名、删除),并在流式 chat 中强制绑定 sessionId 与落库消息,确保会话标题和历史可追踪,同时统一 Swagger 文档为 DTO 驱动以减少重复维护。

Made-with: Cursor
2026-04-22 23:32:10 +08:00

81 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class ChatSessionRowDto {
@ApiProperty({ type: String, example: '1', description: '会话 ID数字字符串' })
id!: string;
@ApiProperty({ type: String, example: '1', description: '用户 ID数字字符串' })
userId!: string;
@ApiProperty({
type: String,
description: '标题(可能为空字符串)',
example: '你好',
})
title!: string;
@ApiProperty({ type: String, description: '创建时间 ISO8601' })
createdAt!: string;
@ApiProperty({ type: String, description: '更新时间 ISO8601' })
updatedAt!: string;
}
export class ChatSessionListResponseDto {
@ApiProperty({ type: () => ChatSessionRowDto, isArray: true })
items!: ChatSessionRowDto[];
@ApiProperty({ type: Number })
total!: number;
@ApiProperty({ type: Number })
limit!: number;
@ApiProperty({ type: Number })
offset!: number;
}
export class ChatMessageRowDto {
@ApiProperty({ type: String, example: '1', description: '消息 ID数字字符串' })
id!: string;
@ApiProperty({ type: String, example: 'user' })
role!: string;
@ApiProperty({ type: String })
content!: string;
@ApiProperty({
type: Number,
description: 'completion token 数(用户消息为 0',
})
tokenCount!: number;
@ApiPropertyOptional({
type: String,
nullable: true,
description: '大模型渠道(用户消息一般为 null',
})
provider?: string | null;
@ApiProperty({ type: String, description: '创建时间 ISO8601' })
createdAt!: string;
}
export class ChatMessageListResponseDto {
@ApiProperty({ type: String, example: '1' })
sessionId!: string;
@ApiProperty({ type: () => ChatMessageRowDto, isArray: true })
items!: ChatMessageRowDto[];
@ApiProperty({ type: Number })
total!: number;
@ApiProperty({ type: Number })
limit!: number;
@ApiProperty({ type: Number })
offset!: number;
}