141 lines
2.2 KiB
TypeScript
141 lines
2.2 KiB
TypeScript
import { IsString, IsOptional, IsEnum, IsBoolean, IsDateString, IsInt, Min, Max } from 'class-validator';
|
|
import { NotificationType, NotificationPriority, TargetType } from '../../../domain/entities/notification.entity';
|
|
|
|
/**
|
|
* 创建通知请求
|
|
*/
|
|
export class CreateNotificationDto {
|
|
@IsString()
|
|
title: string;
|
|
|
|
@IsString()
|
|
content: string;
|
|
|
|
@IsEnum(NotificationType)
|
|
type: NotificationType;
|
|
|
|
@IsOptional()
|
|
@IsEnum(NotificationPriority)
|
|
priority?: NotificationPriority;
|
|
|
|
@IsOptional()
|
|
@IsEnum(TargetType)
|
|
targetType?: TargetType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
imageUrl?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
linkUrl?: string;
|
|
|
|
@IsOptional()
|
|
@IsDateString()
|
|
publishedAt?: string;
|
|
|
|
@IsOptional()
|
|
@IsDateString()
|
|
expiresAt?: string;
|
|
}
|
|
|
|
/**
|
|
* 更新通知请求
|
|
*/
|
|
export class UpdateNotificationDto {
|
|
@IsOptional()
|
|
@IsString()
|
|
title?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
content?: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(NotificationType)
|
|
type?: NotificationType;
|
|
|
|
@IsOptional()
|
|
@IsEnum(NotificationPriority)
|
|
priority?: NotificationPriority;
|
|
|
|
@IsOptional()
|
|
@IsEnum(TargetType)
|
|
targetType?: TargetType;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
imageUrl?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
linkUrl?: string;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isEnabled?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsDateString()
|
|
publishedAt?: string;
|
|
|
|
@IsOptional()
|
|
@IsDateString()
|
|
expiresAt?: string;
|
|
}
|
|
|
|
/**
|
|
* 查询通知列表请求
|
|
*/
|
|
export class ListNotificationsDto {
|
|
@IsOptional()
|
|
@IsEnum(NotificationType)
|
|
type?: NotificationType;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(100)
|
|
limit?: number;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(0)
|
|
offset?: number;
|
|
}
|
|
|
|
/**
|
|
* 用户查询通知请求(需要用户序列号)
|
|
*/
|
|
export class UserNotificationsDto {
|
|
@IsString()
|
|
userSerialNum: string;
|
|
|
|
@IsOptional()
|
|
@IsEnum(NotificationType)
|
|
type?: NotificationType;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(100)
|
|
limit?: number;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(0)
|
|
offset?: number;
|
|
}
|
|
|
|
/**
|
|
* 标记已读请求
|
|
*/
|
|
export class MarkReadDto {
|
|
@IsString()
|
|
userSerialNum: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
notificationId?: string; // 如果不传,则标记所有为已读
|
|
}
|