Final Refinement: Native Labels, Interactive Management UI, and Visual Polishing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Post, Body, Query, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Delete, Body, Query, UseGuards, HttpException, HttpStatus } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiQuery } from '@nestjs/swagger';
|
||||
import { GeocodingService } from './geocoding.service';
|
||||
import { ApiKeyGuard } from '../common/guards/api-key.guard';
|
||||
@@ -15,13 +15,15 @@ export class GeocodingController {
|
||||
@ApiQuery({ name: 'lat', required: false, type: Number })
|
||||
@ApiQuery({ name: 'lng', required: false, type: Number })
|
||||
@ApiQuery({ name: 'radius', required: false, type: Number })
|
||||
@ApiQuery({ name: 'country', required: false, enum: ['jordan', 'syria', 'egypt'] })
|
||||
async search(
|
||||
@Query('q') query: string,
|
||||
@Query('lat') lat?: number,
|
||||
@Query('lng') lng?: number,
|
||||
@Query('radius') radius?: number,
|
||||
@Query('country') country?: string,
|
||||
) {
|
||||
return this.geocodingService.searchPlaces(query, lat, lng, radius);
|
||||
return this.geocodingService.searchPlaces(query, lat, lng, radius, country);
|
||||
}
|
||||
|
||||
@Get('reverse')
|
||||
@@ -38,6 +40,25 @@ export class GeocodingController {
|
||||
return this.geocodingService.addPlace(placeData);
|
||||
}
|
||||
|
||||
@Delete('places')
|
||||
@ApiOperation({ summary: 'Delete a place by name or ID' })
|
||||
@ApiQuery({ name: 'name', required: false })
|
||||
@ApiQuery({ name: 'id', required: false, type: Number })
|
||||
@ApiQuery({ name: 'country', required: true, enum: ['jordan', 'syria', 'egypt'] })
|
||||
async deletePlace(
|
||||
@Query('country') country: string,
|
||||
@Query('name') name?: string,
|
||||
@Query('id') id?: number,
|
||||
) {
|
||||
if (id) {
|
||||
return this.geocodingService.deletePlaceById(Number(id), country);
|
||||
}
|
||||
if (name) {
|
||||
return this.geocodingService.deletePlacesByName(name, country);
|
||||
}
|
||||
throw new HttpException('Name or ID required', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Post('upsert-place')
|
||||
@ApiOperation({ summary: 'Add or Update a location (Automated Scraper)' })
|
||||
async upsertPlace(@Body() placeData: any) {
|
||||
@@ -55,4 +76,10 @@ export class GeocodingController {
|
||||
async getPlaces(@Query('limit') limit?: number) {
|
||||
return this.geocodingService.getRecentPlaces(limit);
|
||||
}
|
||||
|
||||
@Get('geojson')
|
||||
@ApiOperation({ summary: 'Get all user submitted places as GeoJSON for Map Style' })
|
||||
async getGeoJSON() {
|
||||
return this.geocodingService.getAllPlacesGeoJSON();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user