add content

This commit is contained in:
liuyi 2025-05-20 09:29:44 +08:00
parent 7fd3bd83f8
commit db5802d8e6
2 changed files with 6 additions and 4 deletions

View File

@ -26,18 +26,20 @@ export class QueryPostDto implements PaginateOptions {
@IsOptional() @IsOptional()
isPublished?: boolean; isPublished?: boolean;
@IsEnum(PostOrder, { message: `` }) @IsEnum(PostOrder, {
message: `The sorting rule must be one of ${Object.values(PostOrder).join(',')}`,
})
@IsOptional() @IsOptional()
orderBy: PostOrder; orderBy: PostOrder;
@Transform(({ value }) => toNumber(value)) @Transform(({ value }) => toNumber(value))
@Min(1, { message: '' }) @Min(1, { message: 'The current page must be greater than 1.' })
@IsNumber() @IsNumber()
@IsOptional() @IsOptional()
page = 1; page = 1;
@Transform(({ value }) => toNumber(value)) @Transform(({ value }) => toNumber(value))
@Min(1, { message: '' }) @Min(1, { message: 'The number of data displayed per page must be greater than 1.' })
@IsNumber() @IsNumber()
@IsOptional() @IsOptional()
limit = 10; limit = 10;

View File

@ -65,7 +65,7 @@ export class PostService {
const { orderBy, isPublished } = options; const { orderBy, isPublished } = options;
if (typeof isPublished === 'boolean') { if (typeof isPublished === 'boolean') {
isPublished isPublished
? qb.where({ publishedAt: Not(IsNull) }) ? qb.where({ publishedAt: Not(IsNull()) })
: qb.where({ publishedAt: IsNull() }); : qb.where({ publishedAt: IsNull() });
} }
this.queryOrderBy(qb, orderBy); this.queryOrderBy(qb, orderBy);