rwadurian/backend/services/identity-service/src/api/dto/request/auto-create-account.dto.ts

42 lines
1.4 KiB
TypeScript

import { IsString, IsOptional, IsNotEmpty, Matches, IsObject } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
/**
* 设备信息 - 接收任意 JSON 对象
* 前端可以传递完整的设备硬件信息,后端只提取需要的字段存储
*/
export interface DeviceNameDto {
model?: string; // 设备型号
platform?: string; // 平台: ios, android, web
osVersion?: string; // 系统版本
brand?: string; // 品牌
manufacturer?: string; // 厂商
device?: string; // 设备名
product?: string; // 产品名
hardware?: string; // 硬件名
sdkInt?: number; // SDK 版本 (Android)
isPhysicalDevice?: boolean; // 是否真机
[key: string]: unknown; // 允许其他字段
}
export class AutoCreateAccountDto {
@ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440000', description: '设备唯一标识' })
@IsString()
@IsNotEmpty()
deviceId: string;
@ApiPropertyOptional({
description: '设备信息 (JSON 对象)',
example: { model: 'iPhone 15 Pro', platform: 'ios', osVersion: '17.2' }
})
@IsOptional()
@IsObject()
deviceName?: DeviceNameDto;
@ApiPropertyOptional({ example: 'RWAABC1234', description: '邀请人推荐码 (6-20位大写字母和数字)' })
@IsOptional()
@IsString()
@Matches(/^[A-Z0-9]{6,20}$/, { message: '推荐码格式错误' })
inviterReferralCode?: string;
}