添加新的API端点用于更新设备推送令牌绑定的用户ID,包括: - 新增UpdateTokenUserIdDto和UpdateTokenUserIdResponseDto - 在控制器中添加updateTokenUserId端点 - 在服务层实现updateTokenUserId方法 - 在push-token服务中添加底层更新逻辑 - 优化推送测试服务,仅在主进程中执行
107 lines
2.3 KiB
TypeScript
107 lines
2.3 KiB
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
import { ResponseCode } from '../../base.dto';
|
|
|
|
export class PushResult {
|
|
@ApiProperty({ description: '用户ID' })
|
|
userId: string;
|
|
|
|
@ApiProperty({ description: '设备令牌' })
|
|
deviceToken: string;
|
|
|
|
@ApiProperty({ description: '是否成功' })
|
|
success: boolean;
|
|
|
|
@ApiProperty({ description: '错误信息', required: false })
|
|
error?: string;
|
|
|
|
@ApiProperty({ description: 'APNs响应', required: false })
|
|
apnsResponse?: any;
|
|
}
|
|
|
|
export class PushResponseDto {
|
|
@ApiProperty({ description: '响应代码' })
|
|
code: ResponseCode;
|
|
|
|
@ApiProperty({ description: '响应消息' })
|
|
message: string;
|
|
|
|
@ApiProperty({ description: '推送结果' })
|
|
data: {
|
|
success: boolean;
|
|
sentCount: number;
|
|
failedCount: number;
|
|
results: PushResult[];
|
|
};
|
|
}
|
|
|
|
export class BatchPushResponseDto {
|
|
@ApiProperty({ description: '响应代码' })
|
|
code: ResponseCode;
|
|
|
|
@ApiProperty({ description: '响应消息' })
|
|
message: string;
|
|
|
|
@ApiProperty({ description: '批量推送结果' })
|
|
data: {
|
|
totalUsers: number;
|
|
totalTokens: number;
|
|
successCount: number;
|
|
failedCount: number;
|
|
results: PushResult[];
|
|
};
|
|
}
|
|
|
|
export class RegisterTokenResponseDto {
|
|
@ApiProperty({ description: '响应代码' })
|
|
code: ResponseCode;
|
|
|
|
@ApiProperty({ description: '响应消息' })
|
|
message: string;
|
|
|
|
@ApiProperty({ description: '注册结果' })
|
|
data: {
|
|
success: boolean;
|
|
tokenId: string;
|
|
};
|
|
}
|
|
|
|
export class UpdateTokenResponseDto {
|
|
@ApiProperty({ description: '响应代码' })
|
|
code: ResponseCode;
|
|
|
|
@ApiProperty({ description: '响应消息' })
|
|
message: string;
|
|
|
|
@ApiProperty({ description: '更新结果' })
|
|
data: {
|
|
success: boolean;
|
|
tokenId: string;
|
|
};
|
|
}
|
|
|
|
export class UnregisterTokenResponseDto {
|
|
@ApiProperty({ description: '响应代码' })
|
|
code: ResponseCode;
|
|
|
|
@ApiProperty({ description: '响应消息' })
|
|
message: string;
|
|
|
|
@ApiProperty({ description: '注销结果' })
|
|
data: {
|
|
success: boolean;
|
|
};
|
|
}
|
|
|
|
export class UpdateTokenUserIdResponseDto {
|
|
@ApiProperty({ description: '响应代码' })
|
|
code: ResponseCode;
|
|
|
|
@ApiProperty({ description: '响应消息' })
|
|
message: string;
|
|
|
|
@ApiProperty({ description: '更新结果' })
|
|
data: {
|
|
success: boolean;
|
|
tokenId: string;
|
|
};
|
|
} |