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