Nest
CURD 增删改查
/*
* @Description: Nest CRUD
* @Version:
* @Autor: ZX
* @Date: 2021-09-17 14:15:05
* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-09-17 16:01:56
*/
import { Body, Controller, Get, Post,Param, Delete,Patch, Query } from '@nestjs/common';
import { TestService } from './test.service';
import { ApiTags, ApiParam, ApiQuery, ApiHeader } from '@nestjs/swagger';
@Controller('test')
export class TestController {
constructor(private readonly testService: TestService) {}
/**
* @description: 获取所有数据
* @param {*}
* @return {*}
*/
@ApiTags('获取所有数据')
@Get()
getAllListData(){
return this.testService.getAllListData();
}
/**
* @description: 添加数据
* @param {*}
* @return {*}
*/
@ApiTags('添加数据')
@Post()
addListData(@Body() obj ){
return this.testService.addListData(obj);
}
/**
* @description: 查询数据
* @param {*}
* @return {*}
*/
@ApiTags('查询数据')
@ApiParam({
name: 'id',
description: '传递数据id值',
})
@Get(':id')
getQueryData(@Param() {id}){
return this.testService.getQueryData(id);
}
/**
* @description: 删除数据
* @param {*}
* @return {*}
*/
@ApiTags('删除数据')
@Delete()
deleteListData(@Query() {id}){
return this.testService.deleteListData(id);
}
/**
* @description: 更新数据
* @param {*}
* @return {*}
*/
@ApiTags('更新数据')
@Post()
updateListData(@Body() obj){
return this.testService.updateListData(obj);
}
}