import { Controller , Body , HttpStatus , Post , Get , Res , Param , } from '@nestjs/common' ; import { TypeService } from './type.service' ; import { ApiErrorCode } from '../../core/status/api-error-code.enum' ; import { CreateTypeDto } from './dto/create-type_dto' ; @ Controller ( 'type' ) export class TypeController { constructor ( private readonly typeService ) { } @ Get ( ':id' ) async findOne ( @ Param ( 'id' ) id , @ Res ( ) res ) { const data = await this . typeService . findOne ( id ) ; if ( data ) { res . status ( HttpStatus . OK ) . send ( { errorCode : ApiErrorCode . SUCCESS , errorMessage : '请求成功' , data , } ) ; } else { res . status ( HttpStatus . OK ) . send ( { errorCode : ApiErrorCode . SUCCESS , errorMessage : 'ID无效' , } ) ; } } @ Get ( ) async findAll ( @ Res ( ) res ) { return res . status ( HttpStatus . OK ) . send ( { errorCode : ApiErrorCode . SUCCESS , errorMessage : '请求成功' , data : await this . typeService . findAll ( ) , } ) ; } }