feat: add isPrivate field to Product model and implement private product creation and retrieval
This commit is contained in:
@@ -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 } })
|
||||
|
||||
Reference in New Issue
Block a user