This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: previous issues with notifications
- Loading branch information
1 parent
c275abc
commit 61eff0c
Showing
4 changed files
with
206 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
server/src/modules/notifications/dto/query-notification.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator'; | ||
import { plainToInstance, Transform, Type } from 'class-transformer'; | ||
export class SortNotificationDto { | ||
@ApiProperty() | ||
@IsString() | ||
orderBy: keyof Notification; | ||
|
||
@ApiProperty() | ||
@IsString() | ||
order: string; | ||
} | ||
|
||
export class FilterNotificationDto { | ||
@ApiProperty() | ||
@IsOptional() | ||
@IsNotEmpty() | ||
type?: string; | ||
|
||
@ApiProperty() | ||
@IsOptional() | ||
@IsNotEmpty() | ||
read?: string; | ||
} | ||
|
||
export class QueryNotificationDto { | ||
@ApiProperty({ | ||
required: false, | ||
}) | ||
@Transform(({ value }) => (value ? Number(value) : 1)) | ||
@IsNumber() | ||
@IsOptional() | ||
page: number; | ||
|
||
@ApiProperty({ | ||
required: false, | ||
}) | ||
@Transform(({ value }) => (value ? Number(value) : 10)) | ||
@IsNumber() | ||
@IsOptional() | ||
limit: number; | ||
|
||
@ApiProperty({ type: String, required: false }) | ||
@IsOptional() | ||
@Transform(({ value }) => | ||
value ? plainToInstance(FilterNotificationDto, JSON.parse(value)) : undefined | ||
) | ||
@ValidateNested() | ||
@Type(() => FilterNotificationDto) | ||
filters: FilterNotificationDto; | ||
|
||
@ApiProperty({ type: String, required: false }) | ||
@IsOptional() | ||
@Transform(({ value }) => { | ||
return value ? plainToInstance(SortNotificationDto, JSON.parse(value)) : undefined; | ||
}) | ||
@ValidateNested({ each: true }) | ||
@Type(() => SortNotificationDto) | ||
sort?: SortNotificationDto[] | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters