server: add POST bounds get method by list of ids
This commit is contained in:
@ -64,6 +64,50 @@ export class GisService {
|
||||
}
|
||||
}
|
||||
|
||||
async getBoundsByEntityTypeAndList(
|
||||
entity_type: 'region' | 'district' | 'city',
|
||||
list: number[],
|
||||
): Promise<any[]> {
|
||||
if (!list || list.length === 0) {
|
||||
throw new NotFoundException('No entity IDs provided');
|
||||
}
|
||||
|
||||
// Build placeholders (?, ?, ?) for SQLite IN clause
|
||||
const placeholders = list.map(() => '?').join(', ');
|
||||
|
||||
const result = await this.dataSource.query(
|
||||
`
|
||||
SELECT entity_id, entity_type, geometry
|
||||
FROM bounds
|
||||
WHERE entity_type = ?
|
||||
AND entity_id IN (${placeholders})
|
||||
`,
|
||||
[entity_type, ...list],
|
||||
);
|
||||
|
||||
if (!Array.isArray(result) || result.length === 0) {
|
||||
throw new NotFoundException('Not found');
|
||||
}
|
||||
|
||||
return result.map(
|
||||
(bound: {
|
||||
id: string;
|
||||
entity_id: number;
|
||||
entity_type: string;
|
||||
geometry: string;
|
||||
published_at: string;
|
||||
deleted_at: string | null;
|
||||
}) => ({
|
||||
...(JSON.parse(bound.geometry)),
|
||||
properties: {
|
||||
id: bound.id,
|
||||
entity_id: bound.entity_id,
|
||||
entity_type: bound.entity_type,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async getImages(offset: number, limit: number, city_id: number): Promise<any[]> {
|
||||
const result = await this.emsDataSource.query(`
|
||||
SELECT * FROM images
|
||||
|
Reference in New Issue
Block a user