add swagger
This commit is contained in:
parent
b6bc983f08
commit
d8c1adf08b
@ -25,16 +25,32 @@ import { PaginateOptions } from '@/modules/database/types';
|
|||||||
|
|
||||||
import { CategoryEntity, PostEntity, TagEntity } from '../entities';
|
import { CategoryEntity, PostEntity, TagEntity } from '../entities';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章分页查询验证
|
||||||
|
*/
|
||||||
@DtoValidation({ type: 'query' })
|
@DtoValidation({ type: 'query' })
|
||||||
export class QueryPostDto implements PaginateOptions {
|
export class QueryPostDto implements PaginateOptions {
|
||||||
|
/**
|
||||||
|
* 是否查询已发布(全部文章:不填、只查询已发布的:true、只查询未发布的:false)
|
||||||
|
*/
|
||||||
@Transform(({ value }) => toBoolean(value))
|
@Transform(({ value }) => toBoolean(value))
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
isPublished?: boolean;
|
isPublished?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全文搜索
|
||||||
|
*/
|
||||||
|
@MaxLength(100, {
|
||||||
|
always: true,
|
||||||
|
message: '搜索字符串长度不得超过$constraint1',
|
||||||
|
})
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
search?: string;
|
search?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询结果排序,不填则综合排序
|
||||||
|
*/
|
||||||
@IsEnum(PostOrder, {
|
@IsEnum(PostOrder, {
|
||||||
message: `The sorting rule must be one of ${Object.values(PostOrder).join(',')}`,
|
message: `The sorting rule must be one of ${Object.values(PostOrder).join(',')}`,
|
||||||
})
|
})
|
||||||
@ -60,11 +76,17 @@ export class QueryPostDto implements PaginateOptions {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
trashed?: SelectTrashMode;
|
trashed?: SelectTrashMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类ID查询此分类及其后代分类下的文章
|
||||||
|
*/
|
||||||
@IsDataExist(CategoryEntity, { always: true, message: 'The category does not exist' })
|
@IsDataExist(CategoryEntity, { always: true, message: 'The category does not exist' })
|
||||||
@IsUUID(undefined, { message: 'The ID format is incorrect' })
|
@IsUUID(undefined, { message: 'The ID format is incorrect' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
category?: string;
|
category?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据标签ID查询
|
||||||
|
*/
|
||||||
@IsUUID(undefined, { message: 'The ID format is incorrect' })
|
@IsUUID(undefined, { message: 'The ID format is incorrect' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
tag?: string;
|
tag?: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user