2024-03-20 19:32:04 +01:00
|
|
|
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
|
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
2024-03-20 23:53:07 +01:00
|
|
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
|
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
|
|
import { PersonResponseDto } from 'src/dtos/person.dto';
|
2023-10-10 16:34:25 +02:00
|
|
|
import {
|
2024-02-13 02:50:47 +01:00
|
|
|
MetadataSearchDto,
|
2024-02-24 01:42:37 +01:00
|
|
|
PlacesResponseDto,
|
2023-10-10 16:34:25 +02:00
|
|
|
SearchDto,
|
2024-03-20 23:53:07 +01:00
|
|
|
SearchExploreResponseDto,
|
2023-10-10 16:34:25 +02:00
|
|
|
SearchPeopleDto,
|
2024-02-24 01:42:37 +01:00
|
|
|
SearchPlacesDto,
|
2024-03-20 23:53:07 +01:00
|
|
|
SearchResponseDto,
|
|
|
|
SearchSuggestionRequestDto,
|
2024-02-13 02:50:47 +01:00
|
|
|
SmartSearchDto,
|
2024-03-20 23:53:07 +01:00
|
|
|
} from 'src/dtos/search.dto';
|
2024-03-20 21:15:01 +01:00
|
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { SearchService } from 'src/services/search.service';
|
2023-03-03 03:47:08 +01:00
|
|
|
|
|
|
|
@ApiTags('Search')
|
|
|
|
@Controller('search')
|
2023-03-24 05:53:56 +01:00
|
|
|
@Authenticated()
|
2023-03-03 03:47:08 +01:00
|
|
|
export class SearchController {
|
2023-03-24 05:53:56 +01:00
|
|
|
constructor(private service: SearchService) {}
|
2023-03-03 03:47:08 +01:00
|
|
|
|
2024-03-08 17:20:54 +01:00
|
|
|
@Get()
|
|
|
|
@ApiOperation({ deprecated: true })
|
|
|
|
search(@Auth() auth: AuthDto, @Query() dto: SearchDto): Promise<SearchResponseDto> {
|
|
|
|
return this.service.search(auth, dto);
|
|
|
|
}
|
|
|
|
|
2024-02-17 18:00:55 +01:00
|
|
|
@Post('metadata')
|
2024-03-08 17:20:54 +01:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2024-02-17 18:00:55 +01:00
|
|
|
searchMetadata(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
|
2024-02-13 02:50:47 +01:00
|
|
|
return this.service.searchMetadata(auth, dto);
|
|
|
|
}
|
|
|
|
|
2024-02-17 18:00:55 +01:00
|
|
|
@Post('smart')
|
2024-03-08 17:20:54 +01:00
|
|
|
@HttpCode(HttpStatus.OK)
|
2024-02-17 18:00:55 +01:00
|
|
|
searchSmart(@Auth() auth: AuthDto, @Body() dto: SmartSearchDto): Promise<SearchResponseDto> {
|
2024-02-13 02:50:47 +01:00
|
|
|
return this.service.searchSmart(auth, dto);
|
|
|
|
}
|
|
|
|
|
2023-03-05 21:44:31 +01:00
|
|
|
@Get('explore')
|
2023-12-10 05:34:12 +01:00
|
|
|
getExploreData(@Auth() auth: AuthDto): Promise<SearchExploreResponseDto[]> {
|
|
|
|
return this.service.getExploreData(auth) as Promise<SearchExploreResponseDto[]>;
|
2023-03-05 21:44:31 +01:00
|
|
|
}
|
2023-11-25 16:46:20 +01:00
|
|
|
|
|
|
|
@Get('person')
|
2023-12-10 05:34:12 +01:00
|
|
|
searchPerson(@Auth() auth: AuthDto, @Query() dto: SearchPeopleDto): Promise<PersonResponseDto[]> {
|
|
|
|
return this.service.searchPerson(auth, dto);
|
2023-11-25 16:46:20 +01:00
|
|
|
}
|
2024-02-13 20:54:58 +01:00
|
|
|
|
2024-02-24 01:42:37 +01:00
|
|
|
@Get('places')
|
|
|
|
searchPlaces(@Query() dto: SearchPlacesDto): Promise<PlacesResponseDto[]> {
|
|
|
|
return this.service.searchPlaces(dto);
|
|
|
|
}
|
|
|
|
|
2024-03-20 04:23:57 +01:00
|
|
|
@Get('cities')
|
|
|
|
getAssetsByCity(@Auth() auth: AuthDto): Promise<AssetResponseDto[]> {
|
|
|
|
return this.service.getAssetsByCity(auth);
|
|
|
|
}
|
|
|
|
|
2024-02-13 20:54:58 +01:00
|
|
|
@Get('suggestions')
|
|
|
|
getSearchSuggestions(@Auth() auth: AuthDto, @Query() dto: SearchSuggestionRequestDto): Promise<string[]> {
|
|
|
|
return this.service.getSearchSuggestions(auth, dto);
|
|
|
|
}
|
2023-03-03 03:47:08 +01:00
|
|
|
}
|