手机登录/注册
X
登录
npm i -g @nestjs/cli
nest new project-name
modules文件下的user
nest g module user modules
nest g controller user modules
nest g service user modules
nest g resource navigation modules
新建文件src/swagger/index.ts
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
const swaggerOptions = new DocumentBuilder()
.setTitle('小白龙博客接口文档')
.setDescription('小白龙博客文档')
.setVersion('1.0.0')
.addBearerAuth()
.build();
export function createSwagger(app) {
const document = SwaggerModule.createDocument(app, swaggerOptions);
SwaggerModule.setup('swagger-doc', app, document);
}
import { LinksSetDto } from './dto/links.set.dto';
import { ApplyLinksService } from './apply-links.service';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { Controller, Get, Post, Query, Body } from '@nestjs/common';
@ApiTags('申请友链')
@Controller('apply-links')
export class ApplyLinksController {
constructor(private readonly applyLinksService: ApplyLinksService) {}
@Get('/set')
@ApiOperation({ summary: '创建申请友链' })
set(@Query() params: LinksSetDto) {
return this.applyLinksService.set(params);
}
@Get('/query')
@ApiOperation({ summary: '获取申请友链列表' })
query(@Query() params) {
return this.applyLinksService.query(params);
}
@Post('/del')
@ApiOperation({ summary: '删除{id}申请友链' })
del(@Body() params) {
return this.applyLinksService.del(params);
}
}