import { CallHandler , ExecutionContext , Injectable , NestInterceptor , } from '@nestjs/common' ; import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; interface Response < T > { data : T ; } @ Injectable ( ) export class TransformInterceptor < T > implements NestInterceptor < T , Response < T > > { intercept ( context , next ) { return next . handle ( ) . pipe ( map ( rawData => { return { data : rawData , status : 0 , message : '请求成功' , } ; } ) ) ; } }