Ansichten verbessert - 1. Teil

This commit is contained in:
2024-03-17 20:29:53 +01:00
parent 25b201a9c6
commit 2b27ab8ba5
24 changed files with 322 additions and 108 deletions

View File

@@ -0,0 +1,21 @@
import { Body, Controller, Delete, Get, Inject, Param, Post, Put } from '@nestjs/common';
import { FileService } from '../file/file.service.js';
import { convertStringToNullUndefined } from '../utils.js';
import { ListingsService } from './listings.service.js';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { UserService } from '../user/user.service.js';
@Controller('listings/professionals_brokers')
export class BrokerListingsController {
constructor(private readonly userService:UserService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {
}
@Post('search')
find(@Body() criteria: any): any {
return this.userService.findUser(criteria);
}
}

View File

@@ -5,7 +5,7 @@ import { ListingsService } from './listings.service.js';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
@Controller('business-listings')
@Controller('listings/business')
export class BusinessListingsController {
constructor(private readonly listingsService:ListingsService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {

View File

@@ -1,12 +1,14 @@
import { Body, Controller, Delete, Get, Inject, Param, Post } from '@nestjs/common';
import { Body, Controller, Delete, Get, Inject, Param, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
import { ListingsService } from './listings.service.js';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
import { FileInterceptor } from '@nestjs/platform-express';
import { FileService } from '../file/file.service.js';
@Controller('commercial-property-listings')
@Controller('listings/commercialProperty')
export class CommercialPropertyListingsController {
constructor(private readonly listingsService:ListingsService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {
constructor(private readonly listingsService:ListingsService,private fileService:FileService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {
}
@Get()
@@ -40,5 +42,15 @@ export class CommercialPropertyListingsController {
deleteById(@Param('id') id:string){
this.listingsService.deleteCommercialPropertyListing(id)
}
@Post('uploadPropertyPicture/:id')
@UseInterceptors(FileInterceptor('file'),)
uploadFile(@UploadedFile() file: Express.Multer.File,@Param('id') id:string) {
this.fileService.storePropertyPicture(file,id);
}
@Get('images/:id')
getPropertyImagesById(@Param('id') id:string): any {
return this.fileService.getPropertyImages(id);
}
}

View File

@@ -3,10 +3,15 @@ import { BusinessListingsController } from './business-listings.controller.js';
import { ListingsService } from './listings.service.js';
import { CommercialPropertyListingsController } from './commercial-property-listings.controller.js';
import { RedisModule } from '../redis/redis.module.js';
import { FileService } from '../file/file.service.js';
import { UnknownListingsController } from './unknown-listings.controller.js';
import { UserModule } from '../user/user.module.js';
import { BrokerListingsController } from './broker-listings.controller.js';
import { UserService } from '../user/user.service.js';
@Module({
imports: [RedisModule],
controllers: [BusinessListingsController, CommercialPropertyListingsController],
providers: [ListingsService]
controllers: [BusinessListingsController, CommercialPropertyListingsController,UnknownListingsController,BrokerListingsController],
providers: [ListingsService,FileService,UserService]
})
export class ListingsModule {}

View File

@@ -67,6 +67,7 @@ export class ListingsService {
async saveListing(listing: BusinessListing | CommercialPropertyListing) {
const repo=listing.listingsCategory==='business'?this.businessListingRepository:this.commercialPropertyListingRepository;
let result
listing.temporary=false;
if (listing.id){
result = await repo.save(listing.id,listing as any)
} else {

View File

@@ -0,0 +1,26 @@
import { Body, Controller, Delete, Get, Inject, Param, Post, Put } from '@nestjs/common';
import { FileService } from '../file/file.service.js';
import { convertStringToNullUndefined } from '../utils.js';
import { ListingsService } from './listings.service.js';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { Logger } from 'winston';
@Controller('listings/undefined')
export class UnknownListingsController {
constructor(private readonly listingsService:ListingsService,@Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger) {
}
@Get(':id')
async findById(@Param('id') id:string): Promise<any> {
const result = await this.listingsService.getBusinessListingById(id);
if (result.id){
return result
} else {
return await this.listingsService.getCommercialPropertyListingById(id);
}
}
}