Some checks failed
Deploy / deploy (push) Has been cancelled
Full-stack web application for Telegram management - Frontend: Vue 3 + Vben Admin - Backend: NestJS - Features: User management, group broadcast, statistics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
243 lines
5.6 KiB
TypeScript
243 lines
5.6 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import {
|
|
IsString,
|
|
IsOptional,
|
|
IsEnum,
|
|
IsDateString,
|
|
IsNumber,
|
|
Min,
|
|
IsArray,
|
|
ArrayNotEmpty
|
|
} from 'class-validator';
|
|
|
|
export class AnalyticsQueryDto {
|
|
@ApiProperty({
|
|
description: '指标类型',
|
|
example: 'user_activity'
|
|
})
|
|
@IsString({ message: '指标类型必须是字符串' })
|
|
metricType: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '实体类型',
|
|
example: 'tg_account'
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: '实体类型必须是字符串' })
|
|
entityType?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '实体ID',
|
|
example: 1
|
|
})
|
|
@IsOptional()
|
|
@IsNumber({}, { message: '实体ID必须是数字' })
|
|
entityId?: number;
|
|
|
|
@ApiProperty({
|
|
description: '开始日期',
|
|
example: '2023-12-01'
|
|
})
|
|
@IsDateString({}, { message: '开始日期格式不正确' })
|
|
startDate: string;
|
|
|
|
@ApiProperty({
|
|
description: '结束日期',
|
|
example: '2023-12-31'
|
|
})
|
|
@IsDateString({}, { message: '结束日期格式不正确' })
|
|
endDate: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '时间周期',
|
|
enum: ['hour', 'day', 'week', 'month', 'year'],
|
|
example: 'day'
|
|
})
|
|
@IsOptional()
|
|
@IsEnum(['hour', 'day', 'week', 'month', 'year'], {
|
|
message: '时间周期必须是有效的枚举值'
|
|
})
|
|
period?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '分组维度',
|
|
example: ['status', 'type']
|
|
})
|
|
@IsOptional()
|
|
@IsArray({ message: '分组维度必须是数组' })
|
|
groupBy?: string[];
|
|
|
|
@ApiPropertyOptional({
|
|
description: '聚合函数',
|
|
enum: ['count', 'sum', 'avg', 'min', 'max'],
|
|
example: 'count'
|
|
})
|
|
@IsOptional()
|
|
@IsEnum(['count', 'sum', 'avg', 'min', 'max'], {
|
|
message: '聚合函数必须是有效的枚举值'
|
|
})
|
|
aggregation?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '限制结果数量',
|
|
example: 100
|
|
})
|
|
@IsOptional()
|
|
@IsNumber({}, { message: '限制数量必须是数字' })
|
|
@Min(1, { message: '限制数量不能小于1' })
|
|
limit?: number;
|
|
}
|
|
|
|
export class CreateAnalyticsRecordDto {
|
|
@ApiProperty({
|
|
description: '事件类型',
|
|
enum: ['user_action', 'system_event', 'business_metric', 'performance_metric', 'error_event', 'custom'],
|
|
example: 'user_action'
|
|
})
|
|
@IsEnum(['user_action', 'system_event', 'business_metric', 'performance_metric', 'error_event', 'custom'], {
|
|
message: '事件类型必须是有效的枚举值'
|
|
})
|
|
eventType: string;
|
|
|
|
@ApiProperty({
|
|
description: '事件名称',
|
|
example: 'login'
|
|
})
|
|
@IsString({ message: '事件名称必须是字符串' })
|
|
eventName: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '实体类型',
|
|
example: 'user'
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: '实体类型必须是字符串' })
|
|
entityType?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '实体ID',
|
|
example: 1
|
|
})
|
|
@IsOptional()
|
|
@IsNumber({}, { message: '实体ID必须是数字' })
|
|
entityId?: number;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '用户ID',
|
|
example: 1
|
|
})
|
|
@IsOptional()
|
|
@IsNumber({}, { message: '用户ID必须是数字' })
|
|
userId?: number;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '事件数据',
|
|
example: { action: 'click', target: 'button' }
|
|
})
|
|
@IsOptional()
|
|
eventData?: any;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '上下文信息',
|
|
example: { page: 'dashboard', source: 'mobile' }
|
|
})
|
|
@IsOptional()
|
|
context?: any;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '数值指标',
|
|
example: 100.5
|
|
})
|
|
@IsOptional()
|
|
@IsNumber({}, { message: '数值指标必须是数字' })
|
|
value?: number;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '数值单位',
|
|
example: 'ms'
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: '数值单位必须是字符串' })
|
|
unit?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '标签',
|
|
example: { category: 'performance', severity: 'high' }
|
|
})
|
|
@IsOptional()
|
|
tags?: any;
|
|
}
|
|
|
|
export class BatchAnalyticsQueryDto {
|
|
@ApiProperty({
|
|
description: '查询列表',
|
|
type: [AnalyticsQueryDto]
|
|
})
|
|
@IsArray({ message: '查询列表必须是数组' })
|
|
@ArrayNotEmpty({ message: '查询列表不能为空' })
|
|
queries: AnalyticsQueryDto[];
|
|
}
|
|
|
|
export class UserActivityQueryDto {
|
|
@ApiProperty({
|
|
description: '开始日期',
|
|
example: '2023-12-01'
|
|
})
|
|
@IsDateString({}, { message: '开始日期格式不正确' })
|
|
startDate: string;
|
|
|
|
@ApiProperty({
|
|
description: '结束日期',
|
|
example: '2023-12-31'
|
|
})
|
|
@IsDateString({}, { message: '结束日期格式不正确' })
|
|
endDate: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '用户ID',
|
|
example: 1
|
|
})
|
|
@IsOptional()
|
|
@IsNumber({}, { message: '用户ID必须是数字' })
|
|
userId?: number;
|
|
}
|
|
|
|
export class PerformanceQueryDto {
|
|
@ApiProperty({
|
|
description: '开始日期',
|
|
example: '2023-12-01'
|
|
})
|
|
@IsDateString({}, { message: '开始日期格式不正确' })
|
|
startDate: string;
|
|
|
|
@ApiProperty({
|
|
description: '结束日期',
|
|
example: '2023-12-31'
|
|
})
|
|
@IsDateString({}, { message: '结束日期格式不正确' })
|
|
endDate: string;
|
|
|
|
@ApiPropertyOptional({
|
|
description: '指标名称',
|
|
example: 'response_time'
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: '指标名称必须是字符串' })
|
|
metricName?: string;
|
|
}
|
|
|
|
export class ErrorAnalyticsQueryDto {
|
|
@ApiProperty({
|
|
description: '开始日期',
|
|
example: '2023-12-01'
|
|
})
|
|
@IsDateString({}, { message: '开始日期格式不正确' })
|
|
startDate: string;
|
|
|
|
@ApiProperty({
|
|
description: '结束日期',
|
|
example: '2023-12-31'
|
|
})
|
|
@IsDateString({}, { message: '结束日期格式不正确' })
|
|
endDate: string;
|
|
} |