refactor:重构业务层服务架构
- 重构共享模块,移除冗余DTO定义 - 优化Zulip服务模块,重新组织控制器结构 - 更新用户管理和认证服务 - 移除过时的登录服务测试文件
This commit is contained in:
82
src/business/shared/error_response.dto.ts
Normal file
82
src/business/shared/error_response.dto.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 通用错误响应 DTO
|
||||
*
|
||||
* 功能描述:
|
||||
* - 定义统一的错误响应格式
|
||||
* - 提供 Swagger 文档生成支持
|
||||
* - 标准化全局异常处理响应结构
|
||||
*
|
||||
* 职责分离:
|
||||
* - 错误数据结构:定义统一的错误响应格式
|
||||
* - 文档生成:提供Swagger错误响应文档
|
||||
*
|
||||
* 最近修改:
|
||||
* - 2026-01-08: 文件夹扁平化 - 从dto/子文件夹移动到上级目录 (修改者: moyin)
|
||||
* - 2026-01-07: 代码规范优化 - 更新注释规范和作者信息
|
||||
*
|
||||
* @author moyin
|
||||
* @version 1.0.2
|
||||
* @since 2025-12-17
|
||||
* @lastModified 2026-01-08
|
||||
*/
|
||||
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
/**
|
||||
* 通用错误响应 DTO
|
||||
*
|
||||
* 职责:
|
||||
* - 定义全局异常处理的统一响应格式
|
||||
* - 提供完整的错误信息结构
|
||||
*
|
||||
* 主要属性:
|
||||
* - statusCode - HTTP状态码
|
||||
* - message - 错误描述信息
|
||||
* - timestamp - 错误发生时间
|
||||
* - path - 请求路径(可选)
|
||||
* - error - 错误代码(可选)
|
||||
*
|
||||
* 使用场景:
|
||||
* - 全局异常过滤器响应
|
||||
* - API错误信息标准化
|
||||
* - 客户端错误处理
|
||||
*/
|
||||
export class ErrorResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'HTTP 状态码',
|
||||
example: 500,
|
||||
type: Number
|
||||
})
|
||||
statusCode: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: '错误消息',
|
||||
example: 'Internal server error',
|
||||
type: String
|
||||
})
|
||||
message: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '错误发生时间',
|
||||
example: '2025-12-17T15:00:00.000Z',
|
||||
type: String,
|
||||
format: 'date-time'
|
||||
})
|
||||
timestamp: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '请求路径',
|
||||
example: '/api/status',
|
||||
type: String,
|
||||
required: false
|
||||
})
|
||||
path?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '错误代码',
|
||||
example: 'INTERNAL_ERROR',
|
||||
type: String,
|
||||
required: false
|
||||
})
|
||||
error?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user