editar, modificar, ver y crear productos listo

This commit is contained in:
2025-08-27 14:52:47 -04:00
parent f050db4359
commit 2d596b93ad
20 changed files with 242 additions and 183 deletions

View File

@@ -47,7 +47,8 @@ export class UsersController {
@ApiResponse({ status: 200, description: 'Return the product.' })
@ApiResponse({ status: 404, description: 'product not found.' })
async findOne(@Param('id') id: string) {
const data = await this.inventoryService.findOne(id);
const productId = Number(id)
const data = await this.inventoryService.findOne(productId);
return { message: 'product fetched successfully', data };
}
@@ -60,7 +61,7 @@ export class UsersController {
@Req() req: Request,
@Body() createUserDto: CreateProductDto,
@UploadedFiles() files: Express.Multer.File[],
@Query('roleId') roleId?: string,
// @Query('roleId') roleId?: string,
) {
const id = Number(req['user'].id);
const data = await this.inventoryService.create(files,createUserDto,id)
@@ -79,18 +80,20 @@ export class UsersController {
@Body() body: any
) {
const id = Number(req['user'].id);
const result = await this.inventoryService.saveImages(files,body,id);
const result = await this.inventoryService.update(files,body,id);
return { data: result };
}
// @Delete(':id')
@Delete(':id')
// @Roles('admin')
// @ApiOperation({ summary: 'Delete a user' })
// @ApiResponse({ status: 200, description: 'User deleted successfully.' })
// @ApiResponse({ status: 404, description: 'User not found.' })
// async remove(@Param('id') id: string) {
// return await this.inventoryService.remove(id);
// }
@ApiOperation({ summary: 'Delete a Product' })
@ApiResponse({ status: 200, description: 'Product deleted successfully.' })
@ApiResponse({ status: 404, description: 'Product not found.' })
async remove(@Req() req: Request, @Param('id') id: string) {
const productId = Number(id);
const userId = Number(req['user'].id);
return await this.inventoryService.remove(productId,userId);
}
}