feat: add isPrivate field to Product model and implement private product creation and retrieval

This commit is contained in:
Nils-Johan Gynther
2026-05-01 02:29:38 +02:00
parent 1fd910b561
commit 9ee061d5f3
10 changed files with 215 additions and 18 deletions
@@ -94,12 +94,27 @@ export class ProductsController {
return this.productsService.findDeleted();
}
// Inloggad användares egna privata produkter (måste vara före :id)
@Get('mine')
findMine(@Request() req: { user: { id: number } }) {
return this.productsService.findByOwner(req.user.id);
}
// Tillgänglig för alla inloggade användare
@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) {
return this.productsService.findOne(id);
}
// Skapa en privat produkt för den inloggade användaren
@Post('private')
createPrivate(
@Body() body: CreateProductDto,
@Request() req: { user: { id: number } },
) {
return this.productsService.createPrivate(body, req.user.id);
}
@UseGuards(PremiumOrAdminGuard)
@Get(':id/suggest-category')
@Throttle({ default: { ttl: 60_000, limit: 20 } })