deleting abstract product image on its deletion
This commit is contained in:
parent
2be40b6f34
commit
eb0c8ac99d
|
@ -16,7 +16,8 @@ services:
|
||||||
|
|
||||||
# ports:
|
# ports:
|
||||||
# - 5432:5432
|
# - 5432:5432
|
||||||
|
volumes:
|
||||||
|
- ./data/db:/var/lib/postgresql
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_USER: bsfe
|
POSTGRES_USER: bsfe
|
||||||
POSTGRES_PASSWORD: Ch@NgEME!
|
POSTGRES_PASSWORD: Ch@NgEME!
|
||||||
|
|
|
@ -93,6 +93,10 @@ class AbstractProductController {
|
||||||
async delete(req, res) {
|
async delete(req, res) {
|
||||||
let { localId, groupId } = req.params;
|
let { localId, groupId } = req.params;
|
||||||
|
|
||||||
|
let imageFilename = (await AbstractProductService.getByLocalId(groupId, localId)).image_filename
|
||||||
|
let imagePath = path.join(path.resolve(path.dirname('')), `/uploads/${imageFilename}.png`);
|
||||||
|
fs.unlinkSync(imagePath)
|
||||||
|
|
||||||
await AbstractProductService.delete(groupId, localId)
|
await AbstractProductService.delete(groupId, localId)
|
||||||
|
|
||||||
notify(req.headers.authorization.split(' ')[1], groupId, 'delete', 'abstractproduct', { local_id: localId });
|
notify(req.headers.authorization.split(' ')[1], groupId, 'delete', 'abstractproduct', { local_id: localId });
|
||||||
|
|
Loading…
Reference in New Issue