server: add POST bounds get method by list of ids

This commit is contained in:
2025-09-24 11:12:59 +09:00
parent 83b94126fc
commit bf3638f1d5
2 changed files with 56 additions and 1 deletions

View File

@ -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