server: use isGeneral
This commit is contained in:
BIN
server/ems.db
BIN
server/ems.db
Binary file not shown.
@ -6,22 +6,25 @@ import { DataSource } from 'typeorm';
|
||||
export class GeneralService {
|
||||
constructor(
|
||||
@InjectDataSource('emsConnection')
|
||||
private dataSource: DataSource
|
||||
private dataSource: DataSource,
|
||||
|
||||
@InjectDataSource('generalConnection')
|
||||
private generalDataSource: DataSource
|
||||
) { }
|
||||
|
||||
async getRegions(): Promise<any[]> {
|
||||
const generalDatabase = 'nGeneral'
|
||||
const generalDatabase = '_isGeneral'
|
||||
|
||||
const result = await this.dataSource.query(`
|
||||
const result = await this.generalDataSource.query(`
|
||||
SELECT * FROM ${generalDatabase}..vRegions;
|
||||
`)
|
||||
return result
|
||||
}
|
||||
|
||||
async getDistricts(region_id: number): Promise<any[]> {
|
||||
const generalDatabase = 'nGeneral'
|
||||
const generalDatabase = '_isGeneral'
|
||||
|
||||
const result = await this.dataSource.query(`
|
||||
const result = await this.generalDataSource.query(`
|
||||
SELECT c.*, d.name AS district_name
|
||||
FROM ${generalDatabase}..vCities c
|
||||
JOIN ${generalDatabase}..vDistricts d ON d.id_region = c.id_region AND d.id = c.id_district
|
||||
@ -31,9 +34,9 @@ export class GeneralService {
|
||||
}
|
||||
|
||||
async getCities(offset?: number, limit?: number, search?: string, id?: number): Promise<any[]> {
|
||||
const generalDatabase = 'nGeneral'
|
||||
const generalDatabase = '_isGeneral'
|
||||
|
||||
const result = await this.dataSource.query(`
|
||||
const result = await this.generalDataSource.query(`
|
||||
SELECT * FROM ${generalDatabase}..Cities
|
||||
${id ? `WHERE id = ${id}` : ''}
|
||||
${search ? `WHERE name LIKE '%${search || ''}%'` : ''}
|
||||
@ -45,19 +48,19 @@ export class GeneralService {
|
||||
}
|
||||
|
||||
async getTypes(): Promise<any[]> {
|
||||
const generalDatabase = 'nGeneral'
|
||||
const generalDatabase = '_isGeneral'
|
||||
|
||||
const result = await this.dataSource.query(`
|
||||
SELECT * FROM ${generalDatabase}..tTypes
|
||||
SELECT * FROM ${generalDatabase}..TTypes
|
||||
ORDER BY id
|
||||
`)
|
||||
return result
|
||||
}
|
||||
|
||||
async getObjects(offset?: number, limit?: number, city_id?: number): Promise<any[]> {
|
||||
const generalDatabase = 'nGeneral'
|
||||
const generalDatabase = '_isGeneral'
|
||||
|
||||
const result = await this.dataSource.query(`
|
||||
const result = await this.generalDataSource.query(`
|
||||
SELECT * FROM ${generalDatabase}..vObjects
|
||||
${city_id ? `WHERE id_city = ${Number(city_id)}` : ''}
|
||||
ORDER BY id_object
|
||||
|
||||
@ -22,7 +22,7 @@ export class GisService {
|
||||
|
||||
async getBoundsByEntityType(entity_type: 'region' | 'district' | 'city'): Promise<any[]> {
|
||||
const result = await this.dataSource.query(`
|
||||
SELECT entity_id, entity_type, geometry FROM bounds
|
||||
SELECT entity_id, entity_type, geometry FROM bounds_general
|
||||
WHERE entity_type = $1
|
||||
`, [entity_type])
|
||||
if (Array.isArray(result)) {
|
||||
@ -49,7 +49,7 @@ export class GisService {
|
||||
|
||||
async getBoundsByEntityTypeAndId(entity_type: 'region' | 'district' | 'city', entity_id: number): Promise<any[]> {
|
||||
const result = await this.dataSource.query(`
|
||||
SELECT entity_id, entity_type, geometry FROM bounds
|
||||
SELECT entity_id, entity_type, geometry FROM bounds_general
|
||||
WHERE entity_type = $1
|
||||
AND entity_id = $2
|
||||
`, [entity_type, entity_id])
|
||||
@ -78,7 +78,7 @@ export class GisService {
|
||||
const result = await this.dataSource.query(
|
||||
`
|
||||
SELECT entity_id, entity_type, geometry
|
||||
FROM bounds
|
||||
FROM bounds_general
|
||||
WHERE entity_type = ?
|
||||
AND entity_id IN (${placeholders})
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user