forked from datawhale/whale-town-end
feat: 重构业务模块架构
- 新增auth模块处理认证逻辑 - 新增security模块处理安全相关功能 - 新增user-mgmt模块管理用户相关操作 - 新增shared模块存放共享组件 - 重构admin模块,添加DTO和Guards - 为admin模块添加测试文件结构
This commit is contained in:
72
src/business/shared/dto/app-status.dto.ts
Normal file
72
src/business/shared/dto/app-status.dto.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 应用状态响应 DTO
|
||||
*
|
||||
* 功能描述:
|
||||
* - 定义应用状态接口的响应格式
|
||||
* - 提供 Swagger 文档生成支持
|
||||
*
|
||||
* @author angjustinl
|
||||
* @version 1.0.0
|
||||
* @since 2025-12-17
|
||||
*/
|
||||
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
/**
|
||||
* 应用状态响应 DTO
|
||||
*/
|
||||
export class AppStatusResponseDto {
|
||||
@ApiProperty({
|
||||
description: '服务名称',
|
||||
example: 'Pixel Game Server',
|
||||
type: String
|
||||
})
|
||||
service: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '服务版本',
|
||||
example: '1.0.0',
|
||||
type: String
|
||||
})
|
||||
version: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '运行状态',
|
||||
example: 'running',
|
||||
enum: ['running', 'starting', 'stopping', 'error'],
|
||||
type: String
|
||||
})
|
||||
status: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '当前时间戳',
|
||||
example: '2025-12-17T15:00:00.000Z',
|
||||
type: String,
|
||||
format: 'date-time'
|
||||
})
|
||||
timestamp: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '运行时间(秒)',
|
||||
example: 3600,
|
||||
type: Number,
|
||||
minimum: 0
|
||||
})
|
||||
uptime: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: '运行环境',
|
||||
example: 'development',
|
||||
enum: ['development', 'production', 'test'],
|
||||
type: String
|
||||
})
|
||||
environment: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: '存储模式',
|
||||
example: 'memory',
|
||||
enum: ['database', 'memory'],
|
||||
type: String
|
||||
})
|
||||
storage_mode: 'database' | 'memory';
|
||||
}
|
||||
56
src/business/shared/dto/error-response.dto.ts
Normal file
56
src/business/shared/dto/error-response.dto.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 通用错误响应 DTO
|
||||
*
|
||||
* 功能描述:
|
||||
* - 定义统一的错误响应格式
|
||||
* - 提供 Swagger 文档生成支持
|
||||
*
|
||||
* @author angjustinl
|
||||
* @version 1.0.0
|
||||
* @since 2025-12-17
|
||||
*/
|
||||
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
/**
|
||||
* 通用错误响应 DTO
|
||||
*/
|
||||
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;
|
||||
}
|
||||
17
src/business/shared/dto/index.ts
Normal file
17
src/business/shared/dto/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 共享 DTO 统一导出
|
||||
*
|
||||
* 功能描述:
|
||||
* - 导出所有共享的 DTO 类
|
||||
* - 提供统一的导入入口
|
||||
*
|
||||
* @author kiro-ai
|
||||
* @version 1.0.0
|
||||
* @since 2025-12-24
|
||||
*/
|
||||
|
||||
// 应用状态相关
|
||||
export * from './app-status.dto';
|
||||
|
||||
// 错误响应相关
|
||||
export * from './error-response.dto';
|
||||
Reference in New Issue
Block a user