Files
whale-town-end/src/business/admin/admin_response.dto.ts
moyin 6924416bbd feat:实现管理员系统核心功能
- 添加管理员数据库管理控制器和服务
- 实现管理员操作日志记录系统
- 添加数据库异常处理过滤器
- 完善管理员权限验证和响应格式
- 添加全面的属性测试覆盖
2026-01-08 23:05:34 +08:00

166 lines
4.1 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.
/**
* 管理员响应 DTO
*
* 功能描述:
* - 定义管理员相关接口的响应格式
* - 提供统一的API响应结构
* - 支持Swagger文档自动生成
*
* 职责分离:
* - 响应数据结构定义
* - API文档生成支持
* - 类型安全保障
*
* 最近修改:
* - 2026-01-08: 注释规范优化 - 为所有DTO类添加类注释完善文档说明 (修改者: moyin)
* - 2026-01-08: 文件夹扁平化 - 从dto/子文件夹移动到上级目录 (修改者: moyin)
* - 2026-01-07: 代码规范优化 - 修正文件命名规范,更新作者信息和修改记录
*
* @author moyin
* @version 1.0.3
* @since 2025-12-19
* @lastModified 2026-01-08
*/
import { ApiProperty } from '@nestjs/swagger';
/**
* 管理员登录响应DTO
*
* 功能描述:
* 定义管理员登录接口的响应数据结构
*
* 使用场景:
* - POST /admin/auth/login 接口的响应体
* - 包含登录状态、Token和管理员基本信息
*/
export class AdminLoginResponseDto {
@ApiProperty({ description: '是否成功', example: true })
success: boolean;
@ApiProperty({ description: '消息', example: '登录成功' })
message: string;
@ApiProperty({ description: 'JWT Token', example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' })
token?: string;
@ApiProperty({ description: '管理员信息', required: false })
admin?: {
id: string;
username: string;
email: string;
role: number;
};
}
/**
* 管理员用户列表响应DTO
*
* 功能描述:
* 定义获取用户列表接口的响应数据结构
*
* 使用场景:
* - GET /admin/users 接口的响应体
* - 包含用户列表和分页信息
*/
export class AdminUsersResponseDto {
@ApiProperty({ description: '是否成功', example: true })
success: boolean;
@ApiProperty({ description: '消息', example: '获取用户列表成功' })
message: string;
@ApiProperty({ description: '用户列表', type: 'array' })
users?: Array<{
id: string;
username: string;
email: string;
phone: string;
role: number;
status: string;
created_at: string;
updated_at: string;
}>;
@ApiProperty({ description: '总数', example: 100 })
total?: number;
@ApiProperty({ description: '偏移量', example: 0 })
offset?: number;
@ApiProperty({ description: '限制数量', example: 100 })
limit?: number;
}
/**
* 管理员用户详情响应DTO
*
* 功能描述:
* 定义获取单个用户详情接口的响应数据结构
*
* 使用场景:
* - GET /admin/users/:id 接口的响应体
* - 包含用户的详细信息
*/
export class AdminUserResponseDto {
@ApiProperty({ description: '是否成功', example: true })
success: boolean;
@ApiProperty({ description: '消息', example: '获取用户详情成功' })
message: string;
@ApiProperty({ description: '用户信息', required: false })
user?: {
id: string;
username: string;
email: string;
phone: string;
role: number;
status: string;
created_at: string;
updated_at: string;
last_login_at?: string;
};
}
/**
* 管理员通用响应DTO
*
* 功能描述:
* 定义管理员操作的通用响应数据结构
*
* 使用场景:
* - 各种管理员操作接口的通用响应体
* - 包含操作状态和消息信息
*/
export class AdminCommonResponseDto {
@ApiProperty({ description: '是否成功', example: true })
success: boolean;
@ApiProperty({ description: '消息', example: '操作成功' })
message: string;
}
/**
* 管理员运行日志响应DTO
*
* 功能描述:
* 定义获取系统运行日志接口的响应数据结构
*
* 使用场景:
* - GET /admin/logs/runtime 接口的响应体
* - 包含系统运行日志内容
*/
export class AdminRuntimeLogsResponseDto {
@ApiProperty({ description: '是否成功', example: true })
success: boolean;
@ApiProperty({ description: '消息', example: '获取日志成功' })
message: string;
@ApiProperty({ description: '日志内容', type: 'array', items: { type: 'string' } })
logs?: string[];
@ApiProperty({ description: '返回行数', example: 200 })
lines?: number;
}