fix: brand api
This commit is contained in:
@@ -4,7 +4,6 @@ const { createFileUploadDb } = require('../db/file_uploads.db');
|
||||
const {
|
||||
insertBrandSchema,
|
||||
updateBrandSchema,
|
||||
uploadSolutionSchema
|
||||
} = require('../validate/brand.schema');
|
||||
|
||||
class BrandController {
|
||||
@@ -23,6 +22,9 @@ class BrandController {
|
||||
const { id } = req.params;
|
||||
|
||||
const results = await BrandService.getBrandById(id);
|
||||
|
||||
// console.log('Brand response structure:', JSON.stringify(results, null, 2));
|
||||
|
||||
const response = await setResponse(results, 'Brand found');
|
||||
|
||||
res.status(response.statusCode).json(response);
|
||||
@@ -98,14 +100,8 @@ class BrandController {
|
||||
// Soft delete brand by ID
|
||||
static async delete(req, res) {
|
||||
const { id } = req.params;
|
||||
// Get brand by ID first to get name for deletion
|
||||
const brand = await BrandService.getBrandById(id);
|
||||
if (!brand) {
|
||||
const response = await setResponse([], 'Brand not found', 404);
|
||||
return res.status(response.statusCode).json(response);
|
||||
}
|
||||
|
||||
const results = await BrandService.deleteBrand(brand.brand_name, req.user.user_id);
|
||||
const results = await BrandService.deleteBrand(id, req.user.user_id);
|
||||
const response = await setResponse(results, 'Brand deleted successfully');
|
||||
|
||||
res.status(response.statusCode).json(response);
|
||||
|
||||
Reference in New Issue
Block a user