add swagger
This commit is contained in:
parent
03e70436c6
commit
b6bc983f08
@ -1,13 +1,34 @@
|
||||
export enum PostBodyType {
|
||||
/**
|
||||
* HTML格式
|
||||
*/
|
||||
HTML = 'html',
|
||||
/**
|
||||
* Markdown格式
|
||||
*/
|
||||
MD = 'markdown',
|
||||
}
|
||||
|
||||
export enum PostOrder {
|
||||
/**
|
||||
* 最新创建
|
||||
*/
|
||||
CREATED = 'createdAt',
|
||||
/**
|
||||
* 最新创建
|
||||
*/
|
||||
UPDATED = 'updatedAt',
|
||||
/**
|
||||
* 最新发布
|
||||
*/
|
||||
PUBLISHED = 'publishedAt',
|
||||
/**
|
||||
* 评论数量
|
||||
*/
|
||||
COMMENTCOUNT = 'commentCount',
|
||||
/**
|
||||
* 自定义排序
|
||||
*/
|
||||
CUSTOM = 'custom',
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,10 @@ import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { Depends } from '@/modules/restful/decorators/depend.decorator';
|
||||
|
||||
import { PaginateDto } from '@/modules/restful/dtos/paginate.dto';
|
||||
|
||||
import { ContentModule } from '../content.module';
|
||||
import { CreateCategoryDto, QueryCategoryDto, UpdateCategoryDto } from '../dtos/category.dto';
|
||||
import { CreateCategoryDto, UpdateCategoryDto } from '../dtos/category.dto';
|
||||
import { CategoryService } from '../services';
|
||||
|
||||
@ApiTags('Category Operate')
|
||||
@ -42,7 +44,7 @@ export class CategoryController {
|
||||
@SerializeOptions({ groups: ['category-list'] })
|
||||
async list(
|
||||
@Query()
|
||||
options: QueryCategoryDto,
|
||||
options: PaginateDto,
|
||||
) {
|
||||
return this.service.paginate(options);
|
||||
}
|
||||
|
@ -15,8 +15,10 @@ import { DeleteDto } from '@/modules/content/dtos/delete.dto';
|
||||
|
||||
import { Depends } from '@/modules/restful/decorators/depend.decorator';
|
||||
|
||||
import { PaginateDto } from '@/modules/restful/dtos/paginate.dto';
|
||||
|
||||
import { ContentModule } from '../content.module';
|
||||
import { CreateTagDto, QueryTagDto, UpdateTagDto } from '../dtos/tag.dto';
|
||||
import { CreateTagDto, UpdateTagDto } from '../dtos/tag.dto';
|
||||
import { TagService } from '../services';
|
||||
|
||||
@Depends(ContentModule)
|
||||
@ -28,7 +30,7 @@ export class TagController {
|
||||
@SerializeOptions({})
|
||||
async list(
|
||||
@Query()
|
||||
options: QueryTagDto,
|
||||
options: PaginateDto,
|
||||
) {
|
||||
return this.service.paginate(options);
|
||||
}
|
||||
|
@ -16,28 +16,9 @@ import { DtoValidation } from '@/modules/core/decorator/dto.validation.decorator
|
||||
import { IsDataExist } from '@/modules/database/constraints/data.exist.constraint';
|
||||
import { IsTreeUnique } from '@/modules/database/constraints/tree.unique.constraint';
|
||||
import { IsTreeUniqueExist } from '@/modules/database/constraints/tree.unique.exist.constraint';
|
||||
import { PaginateOptions } from '@/modules/database/types';
|
||||
|
||||
import { CategoryEntity } from '../entities';
|
||||
|
||||
@DtoValidation({ type: 'query' })
|
||||
export class QueryCategoryDto implements PaginateOptions {
|
||||
@Transform(({ value }) => toNumber(value))
|
||||
@Min(1, { always: true, message: 'The current page must be greater than 1.' })
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
page = 1;
|
||||
|
||||
@Transform(({ value }) => toNumber(value))
|
||||
@Min(1, {
|
||||
always: true,
|
||||
message: 'The number of data displayed per page must be greater than 1.',
|
||||
})
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
limit = 10;
|
||||
}
|
||||
|
||||
@DtoValidation({ groups: ['create'] })
|
||||
export class CreateCategoryDto {
|
||||
@IsTreeUnique(CategoryEntity, {
|
||||
|
@ -1,34 +1,13 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsDefined, IsInt, IsNotEmpty, IsOptional, IsUUID, MaxLength, Min } from 'class-validator';
|
||||
import { toNumber } from 'lodash';
|
||||
import { IsDefined, IsNotEmpty, IsOptional, IsUUID, MaxLength } from 'class-validator';
|
||||
|
||||
import { DtoValidation } from '@/modules/core/decorator/dto.validation.decorator';
|
||||
import { IsDataExist } from '@/modules/database/constraints';
|
||||
import { IsUnique } from '@/modules/database/constraints/unique.constraint';
|
||||
import { IsUniqueExist } from '@/modules/database/constraints/unique.exist.constraint';
|
||||
import { PaginateOptions } from '@/modules/database/types';
|
||||
|
||||
import { TagEntity } from '../entities';
|
||||
|
||||
@DtoValidation({ type: 'query' })
|
||||
export class QueryTagDto implements PaginateOptions {
|
||||
@Transform(({ value }) => toNumber(value))
|
||||
@Min(1, { always: true, message: 'The current page must be greater than 1.' })
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
page = 1;
|
||||
|
||||
@Transform(({ value }) => toNumber(value))
|
||||
@Min(1, {
|
||||
always: true,
|
||||
message: 'The number of data displayed per page must be greater than 1.',
|
||||
})
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
limit = 10;
|
||||
}
|
||||
|
||||
@DtoValidation({ groups: ['create'] })
|
||||
export class CreateTagDto {
|
||||
@IsUnique(TagEntity, { groups: ['create'], message: 'The label names are repeated' })
|
||||
|
@ -17,12 +17,27 @@ export enum SelectTrashMode {
|
||||
}
|
||||
|
||||
export enum OrderType {
|
||||
/**
|
||||
* 升序排序
|
||||
*/
|
||||
ASC = 'ASC',
|
||||
/**
|
||||
* 降序排序
|
||||
*/
|
||||
DESC = 'DESC',
|
||||
}
|
||||
|
||||
export enum TreeChildrenResolve {
|
||||
/**
|
||||
* 子信息删除
|
||||
*/
|
||||
DELETE = 'delete',
|
||||
/**
|
||||
* 子信息上升层级
|
||||
*/
|
||||
UP = 'up',
|
||||
/**
|
||||
* 子信息上升到顶层
|
||||
*/
|
||||
ROOT = 'root',
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user