delete business
This commit is contained in:
@@ -116,11 +116,23 @@ export class BusinessImagesService {
|
||||
}
|
||||
}
|
||||
|
||||
async removeAllForBusiness(businessId: string): Promise<void> {
|
||||
const images = await this.imageRepo.find({ where: { businessId } });
|
||||
for (const image of images) {
|
||||
this.deleteFile(image.url);
|
||||
async listUrlsForBusiness(businessId: string): Promise<string[]> {
|
||||
const images = await this.imageRepo.find({
|
||||
where: { businessId },
|
||||
select: ['url'],
|
||||
});
|
||||
return images.map((image) => image.url);
|
||||
}
|
||||
|
||||
deleteFiles(urls: string[]): void {
|
||||
for (const url of urls) {
|
||||
this.deleteFile(url);
|
||||
}
|
||||
}
|
||||
|
||||
async removeAllForBusiness(businessId: string): Promise<void> {
|
||||
const urls = await this.listUrlsForBusiness(businessId);
|
||||
this.deleteFiles(urls);
|
||||
await this.imageRepo.delete({ businessId });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user