forked from VinokurovVE/tests
Map
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { tediousQuery } from '../../utils/tedious';
|
||||
import { GeneralDB, GisDB } from '../../constants/db';
|
||||
const router = express.Router()
|
||||
|
||||
router.get('/images/all', async (req: Request, res: Response) => {
|
||||
@ -8,7 +9,7 @@ router.get('/images/all', async (req: Request, res: Response) => {
|
||||
|
||||
const result = await tediousQuery(
|
||||
`
|
||||
SELECT * FROM New_Gis..images
|
||||
SELECT * FROM ${GisDB}..images
|
||||
${city_id ? `WHERE city_id = ${city_id}` : ''}
|
||||
ORDER BY city_id
|
||||
OFFSET ${Number(offset) || 0} ROWS
|
||||
@ -29,8 +30,8 @@ router.get('/figures/all', async (req: Request, res: Response) => {
|
||||
|
||||
const result = await tediousQuery(
|
||||
`
|
||||
SELECT * FROM New_Gis..figures f
|
||||
JOIN nGeneral..vObjects o ON f.object_id = o.object_id WHERE o.id_city = ${city_id} AND f.year = ${year}
|
||||
SELECT * FROM ${GisDB}..figures f
|
||||
JOIN ${GeneralDB}..vObjects o ON f.object_id = o.object_id WHERE o.id_city = ${city_id} AND f.year = ${year}
|
||||
ORDER BY f.year
|
||||
OFFSET ${Number(offset) || 0} ROWS
|
||||
FETCH NEXT ${Number(limit) || 10} ROWS ONLY;
|
||||
@ -49,8 +50,8 @@ router.get('/lines/all', async (req: Request, res: Response) => {
|
||||
|
||||
const result = await tediousQuery(
|
||||
`
|
||||
SELECT * FROM New_Gis..lines l
|
||||
JOIN nGeneral..vObjects o ON l.object_id = o.object_id WHERE o.id_city = ${city_id} AND l.year = ${year}
|
||||
SELECT * FROM ${GisDB}..lines l
|
||||
JOIN ${GeneralDB}..vObjects o ON l.object_id = o.object_id WHERE o.id_city = ${city_id} AND l.year = ${year}
|
||||
ORDER BY l.year
|
||||
OFFSET ${Number(offset) || 0} ROWS
|
||||
FETCH NEXT ${Number(limit) || 10} ROWS ONLY;
|
||||
@ -62,4 +63,16 @@ router.get('/lines/all', async (req: Request, res: Response) => {
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/regions/borders', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const result = await tediousQuery(
|
||||
`
|
||||
SELECT * FROM ${GisDB}..visual_regions`
|
||||
)
|
||||
res.status(200).json(result)
|
||||
} catch (err) {
|
||||
res.status(500)
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
Reference in New Issue
Block a user