Recipe-app main
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { CreateProductDto } from './dto/create-product.dto';
|
||||
import { UpdateProductDto } from './dto/update-product.dto';
|
||||
import { ProductsService } from './products.service';
|
||||
import { MergeProductsDto } from './dto/merge-products.dto';
|
||||
import { UpdateCanonicalNameDto } from './dto/update-canonical-name.dto';
|
||||
|
||||
@Controller('products')
|
||||
export class ProductsController {
|
||||
constructor(private readonly productsService: ProductsService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.productsService.findAll();
|
||||
}
|
||||
|
||||
@Get('duplicates')
|
||||
findDuplicates() {
|
||||
return this.productsService.findDuplicateCandidates();
|
||||
}
|
||||
|
||||
@Get('merge-preview')
|
||||
previewMerge(
|
||||
@Query('sourceProductId', ParseIntPipe) sourceProductId: number,
|
||||
@Query('targetProductId', ParseIntPipe) targetProductId: number,
|
||||
) {
|
||||
return this.productsService.previewMerge(sourceProductId, targetProductId);
|
||||
}
|
||||
|
||||
@Post('backfill-canonical')
|
||||
backfillCanonical() {
|
||||
return this.productsService.backfillCanonicalNames();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.productsService.findOne(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() body: CreateProductDto) {
|
||||
return this.productsService.create(body);
|
||||
}
|
||||
|
||||
@Post('merge')
|
||||
merge(@Body() body: MergeProductsDto) {
|
||||
return this.productsService.merge(body.sourceProductId, body.targetProductId);
|
||||
}
|
||||
|
||||
@Patch(':id/canonical-name')
|
||||
updateCanonicalName(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() body: UpdateCanonicalNameDto,
|
||||
) {
|
||||
return this.productsService.updateCanonicalName(id, body.canonicalName);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() body: UpdateProductDto,
|
||||
) {
|
||||
return this.productsService.update(id, body);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.productsService.remove(id);
|
||||
}
|
||||
|
||||
@Post(':id/restore')
|
||||
restore(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.productsService.restore(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user