feat: add updateCategoryMine endpoint to manage product category updates
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
- Implemented a new PATCH endpoint in ProductsController to update the category of a user's product. - Added corresponding service method in ProductsService to handle business logic and validation. - Created UpdateCategoryMineDto for request validation. - Enhanced error handling for forbidden actions and not found resources. - Updated API error mapping in Flutter to handle specific forbidden messages. - Modified ProductPickerField to allow product creation directly from the picker. - Added tests for the new endpoint and service method to ensure proper functionality and error handling.
This commit is contained in:
@@ -25,6 +25,7 @@ import { UpsertNutritionDto } from './dto/upsert-nutrition.dto';
|
||||
import { BulkUpdateProductsDto } from './dto/bulk-update-products.dto';
|
||||
import { AiCategorizeBulkDto } from './dto/ai-categorize-bulk.dto';
|
||||
import { SetProductStatusDto } from './dto/set-product-status.dto';
|
||||
import { UpdateCategoryMineDto } from './dto/update-category-mine.dto';
|
||||
import { Roles } from '../auth/decorators/roles.decorator';
|
||||
import { AiService } from '../ai/ai.service';
|
||||
import { CategoriesService } from '../categories/categories.service';
|
||||
@@ -166,6 +167,15 @@ export class ProductsController {
|
||||
return this.productsService.mergePrivate(req.user.id, body.sourceProductId, body.targetProductId);
|
||||
}
|
||||
|
||||
@Patch('mine/:id/category')
|
||||
updateCategoryMine(
|
||||
@Param('id', ParseIntPipe) id: number,
|
||||
@Body() body: UpdateCategoryMineDto,
|
||||
@Request() req: { user: { id: number } },
|
||||
) {
|
||||
return this.productsService.updateCategoryMine(req.user.id, id, body.categoryId);
|
||||
}
|
||||
|
||||
@Roles('admin')
|
||||
@Post('merge')
|
||||
merge(@Body() body: MergeProductsDto) {
|
||||
|
||||
Reference in New Issue
Block a user