27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { Controller, Get, Inject, Param, Request, UseGuards } from '@nestjs/common';
|
|
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
|
|
import { Logger } from 'winston';
|
|
import { OptionalJwtAuthGuard } from '../jwt-auth/optional-jwt-auth.guard.js';
|
|
import { BusinessListingService } from './business-listing.service.js';
|
|
import { CommercialPropertyService } from './commercial-property.service.js';
|
|
|
|
@Controller('listings/undefined')
|
|
export class UnknownListingsController {
|
|
constructor(
|
|
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
|
|
private readonly businessListingsService: BusinessListingService,
|
|
private readonly propertyListingsService: CommercialPropertyService,
|
|
) {}
|
|
|
|
@UseGuards(OptionalJwtAuthGuard)
|
|
@Get(':id')
|
|
async findById(@Request() req, @Param('id') id: string): Promise<any> {
|
|
const result = await this.businessListingsService.findBusinessesById(id, req.user);
|
|
if (result) {
|
|
return result;
|
|
} else {
|
|
return await this.propertyListingsService.findCommercialPropertiesById(id, req.user);
|
|
}
|
|
}
|
|
}
|