Compare commits
2 Commits
85adbbcdb3
...
0a6321deb0
Author | SHA1 | Date | |
---|---|---|---|
0a6321deb0 | |||
a811a2ece2 |
@ -6,7 +6,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
const DbHandler = new MysqlService.Handler('BrandService')
|
const DbHandler = new MysqlService.Handler('BrandService')
|
||||||
const logger = new Logger({name: 'BrandService'})
|
const logger = new Logger({name: 'BrandService'})
|
||||||
|
|
||||||
//SEC Blob validation
|
//SEC todo Blob validation
|
||||||
/**
|
/**
|
||||||
* Creates a brand in the database with the given data.
|
* Creates a brand in the database with the given data.
|
||||||
*
|
*
|
||||||
@ -34,6 +34,7 @@ async function createBrand(data: IDbBrand): Promise<unknown> {
|
|||||||
return { error: 'failed' };
|
return { error: 'failed' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SEC todo Blob validation
|
||||||
/**
|
/**
|
||||||
* Updates a brand in the database.
|
* Updates a brand in the database.
|
||||||
*
|
*
|
||||||
@ -98,7 +99,6 @@ async function getBySlugBrand(brandSlug: string): Promise<IDbBrand | false> {
|
|||||||
return brand;
|
return brand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a brand from the database based on the provided brand ID.
|
* Retrieves a brand from the database based on the provided brand ID.
|
||||||
*
|
*
|
||||||
|
@ -118,6 +118,8 @@ async function getById(id: string):Promise<IDbCategory | null> {
|
|||||||
* @return {Promise} - A Promise that resolves to the deleted category if successful, or null if an error occurs.
|
* @return {Promise} - A Promise that resolves to the deleted category if successful, or null if an error occurs.
|
||||||
*/
|
*/
|
||||||
async function deleteCategory(id:string): Promise<unknown> {
|
async function deleteCategory(id:string): Promise<unknown> {
|
||||||
|
//TODO Verify if exist
|
||||||
|
//TODO Verify if element linked to category
|
||||||
try {
|
try {
|
||||||
logger.info(`Deleting category... (${id})`);
|
logger.info(`Deleting category... (${id})`);
|
||||||
return await MysqlService.Category.delete(DbHandler, id);
|
return await MysqlService.Category.delete(DbHandler, id);
|
||||||
|
@ -407,6 +407,7 @@ const MySqlService = {
|
|||||||
* @throws {Error} If the brandId is undefined or invalid.
|
* @throws {Error} If the brandId is undefined or invalid.
|
||||||
*/
|
*/
|
||||||
delete(handler: MysqlHandler, brandId: string): Promise<unknown> {
|
delete(handler: MysqlHandler, brandId: string): Promise<unknown> {
|
||||||
|
//TODO check if has models linked before actions
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!brandId) return reject('Id is undefined');
|
if (!brandId) return reject('Id is undefined');
|
||||||
if (brandId.length !== 36) return reject('Id invalid');
|
if (brandId.length !== 36) return reject('Id invalid');
|
||||||
@ -419,6 +420,8 @@ const MySqlService = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Get models of the brand
|
||||||
},
|
},
|
||||||
Model: {
|
Model: {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user