delete business

This commit is contained in:
2026-05-31 17:02:41 +03:30
parent a4e9761825
commit 9afd54b522
4 changed files with 34 additions and 17 deletions
@@ -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 });
}