Files
plates-server/src/users/dto/apple-login.dto.ts
2025-08-13 15:17:33 +08:00

113 lines
2.4 KiB
TypeScript

import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsNotEmpty, IsOptional } from 'class-validator';
import { ResponseCode } from 'src/base.dto';
export class AppleLoginDto {
@ApiProperty({
description: 'Apple Identity Token (JWT)',
example: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...',
})
@IsString()
@IsNotEmpty()
identityToken: string;
@ApiProperty({
description: '用户标识符(可选,首次登录时提供)',
example: 'user123',
required: false,
})
@IsString()
@IsOptional()
name?: string;
@ApiProperty({
description: '用户邮箱(可选,首次登录时提供)',
example: 'user@example.com',
required: false,
})
@IsString()
@IsOptional()
email?: string;
}
export class AppleLoginResponseDto {
@ApiProperty({
description: '响应代码',
example: ResponseCode.SUCCESS,
})
code: ResponseCode;
@ApiProperty({
description: '响应消息',
example: 'success',
})
message: string;
@ApiProperty({
description: '登录结果数据',
example: {
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
refreshToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
expiresIn: 2592000,
user: {
id: 'apple_000123.456789abcdef',
name: '张三',
email: 'user@example.com',
isNew: false,
isVip: true,
membershipExpiration: '2024-12-31T23:59:59.000Z'
}
},
})
data: {
accessToken: string;
refreshToken: string;
expiresIn: number;
user: {
id: string;
name: string;
email: string;
isNew: boolean;
isVip: boolean;
membershipExpiration?: Date;
[key: string]: any;
};
};
}
export class RefreshTokenDto {
@ApiProperty({
description: '刷新令牌',
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
})
@IsString()
@IsNotEmpty()
refreshToken: string;
}
export class RefreshTokenResponseDto {
@ApiProperty({
description: '响应代码',
example: ResponseCode.SUCCESS,
})
code: ResponseCode;
@ApiProperty({
description: '响应消息',
example: 'success',
})
message: string;
@ApiProperty({
description: '新的访问令牌数据',
example: {
accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
expiresIn: 2592000
},
})
data: {
accessToken: string;
expiresIn: number;
};
}