import { Controller , Post , Body , Res , HttpStatus , Get , Param , } from '@nestjs/common' ; import { GoodsService } from './goods.service' ; import { CreateGoodDto } from './dto/create-good_dto' ; import { ApiErrorCode } from '../../core/status/api-error-code.enum' ; @ Controller ( 'goods' ) export class GoodsController { constructor ( private readonly goodsService ) { } @ Get ( ) async findAll ( @ Res ( ) res ) { const data = await this . goodsService . findAll ( ) ; if ( data ) { return res . status ( HttpStatus . OK ) . send ( { errorCode : ApiErrorCode . SUCCESS , errorMessage : '请求成功' , data , } ) ; } else { return res . status ( HttpStatus . OK ) . send ( { errorCode : ApiErrorCode . SUCCESS , errorMessage : '无效typeid' , } ) ; } } @ Post ( 'search' ) async serach ( @ Body ( ) params , @ Res ( ) res ) { return res . status ( HttpStatus . OK ) . send ( { errorCode : ApiErrorCode . SUCCESS , errorMessage : '请求成功' , data : await this . goodsService . searchGood ( params . title ) , } ) ; } }