Fehler behebung

This commit is contained in:
Timo Knuth
2025-12-03 11:51:00 +01:00
parent d2953fd0d9
commit 30ecc292cd
20 changed files with 379 additions and 62 deletions

View File

@@ -218,15 +218,28 @@ export class BusinessListingService {
* Supports both slug (e.g., "restaurant-austin-tx-a3f7b2c1") and UUID
*/
async findBusinessBySlugOrId(slugOrId: string, user: JwtUser): Promise<BusinessListing> {
this.logger.debug(`findBusinessBySlugOrId called with: ${slugOrId}`);
let id = slugOrId;
// Check if it's a slug (contains multiple hyphens) vs UUID
if (isSlug(slugOrId)) {
this.logger.debug(`Detected as slug: ${slugOrId}`);
// Extract short ID from slug and find by slug field
const listing = await this.findBusinessBySlug(slugOrId);
if (listing) {
this.logger.debug(`Found listing by slug: ${slugOrId} -> ID: ${listing.id}`);
id = listing.id;
} else {
this.logger.warn(`Slug not found in database: ${slugOrId}`);
throw new NotFoundException(
`Business listing not found with slug: ${slugOrId}. ` +
`The listing may have been deleted or the URL may be incorrect.`
);
}
} else {
this.logger.debug(`Detected as UUID: ${slugOrId}`);
}
return this.findBusinessesById(id, user);