Paginator & SQL Querries where clauses & city search

This commit is contained in:
2024-07-18 19:02:32 +02:00
parent f88eebe8d3
commit abcde3991d
30 changed files with 850 additions and 421 deletions

View File

@@ -1,17 +1,16 @@
import { Body, Controller, Delete, Get, Inject, Param, Post, Put, Request, UseGuards } from '@nestjs/common';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { commercials } from '../drizzle/schema.js';
import { FileService } from '../file/file.service.js';
import { OptionalJwtAuthGuard } from '../jwt-auth/optional-jwt-auth.guard.js';
import { CommercialPropertyListing } from '../models/db.model';
import { CommercialPropertyListingCriteria, JwtUser } from '../models/main.model.js';
import { ListingsService } from './listings.service.js';
import { CommercialPropertyService } from './commercial-property.service.js';
@Controller('listings/commercialProperty')
export class CommercialPropertyListingsController {
constructor(
private readonly listingsService: ListingsService,
private readonly listingsService: CommercialPropertyService,
private fileService: FileService,
@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
) {}
@@ -30,16 +29,16 @@ export class CommercialPropertyListingsController {
@UseGuards(OptionalJwtAuthGuard)
@Post('find')
async find(@Request() req, @Body() criteria: CommercialPropertyListingCriteria): Promise<any> {
return await this.listingsService.findCommercialPropertyListings(criteria, req.user as JwtUser);
return await this.listingsService.searchCommercialProperties(criteria, req.user as JwtUser);
}
@Get('states/all')
getStates(): any {
return this.listingsService.getStates(commercials);
return this.listingsService.getStates();
}
@Post()
async create(@Body() listing: any) {
this.logger.info(`Save Listing`);
return await this.listingsService.createListing(listing, commercials);
return await this.listingsService.createListing(listing);
}
@Put()
async update(@Body() listing: any) {
@@ -48,7 +47,7 @@ export class CommercialPropertyListingsController {
}
@Delete(':id/:imagePath')
deleteById(@Param('id') id: string, @Param('imagePath') imagePath: string) {
this.listingsService.deleteListing(id, commercials);
this.listingsService.deleteListing(id);
this.fileService.deleteDirectoryIfExists(imagePath);
}
}