You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB
TypeScript

import { Logger, Get, Query, Delete, Post, Body, Param, UseGuards } from "@nestjs/common";
import { AuthGuard } from "@nestjs/passport";
import { AuthModule } from "src/auth/auth.module";
import { FindManyOptions } from "typeorm";
import { PcdTransactionService } from "./pcd-transaction.service";
export class PcdTransactionController<T> {
private logger = new Logger('PcdTransactionController'); // for logging
constructor(
private service: PcdTransactionService<T>
) { }
@UseGuards(AuthGuard())
@Get()
async findList(@Query() filter: FindManyOptions, ): Promise<T[]> {
return await this.service.findList(filter);
}
@Get('/:id')
async findOne(@Query() filter: FindManyOptions,@Param('id') id: string , ): Promise<T> {
return await this.service.findOne(filter, id);
}
@Post()
async createOne(@Body() body: T, ): Promise<T> {
return await this.service.createOne(body,);
}
@Delete('/:id')
async delete(@Query() filter: FindManyOptions,@Param('id') id: string , ): Promise<any> {
return await this.service.deleteOne(filter,id, );
}
}