forked from VinokurovVE/tests
Remove @mui, move states into zustand store
This commit is contained in:
@ -61,11 +61,38 @@ router.get('/objects/list', async (req: Request, res: Response) => {
|
||||
|
||||
if (type) {
|
||||
const result = await tediousQuery(
|
||||
// `
|
||||
// SELECT
|
||||
// *
|
||||
// FROM
|
||||
// vObjects
|
||||
// WHERE
|
||||
// vObjects.id_city = ${city_id}
|
||||
// AND vObjects.year = ${year}
|
||||
// AND type = ${type}
|
||||
// AND
|
||||
// (
|
||||
// CASE
|
||||
// WHEN TRY_CAST(vObjects.planning AS BIT) IS NOT NULL THEN TRY_CAST(vObjects.planning AS BIT)
|
||||
// WHEN vObjects.planning = 'TRUE' THEN 1
|
||||
// WHEN vObjects.planning = 'FALSE' THEN 0
|
||||
// ELSE NULL
|
||||
// END
|
||||
// ) = ${planning};
|
||||
// `
|
||||
`
|
||||
SELECT
|
||||
*
|
||||
vObjects.*,
|
||||
CASE
|
||||
WHEN vObjects.boiler_id IS NOT NULL THEN vBoilers.name
|
||||
ELSE CAST(tValues.value AS varchar(max))
|
||||
END AS name
|
||||
FROM
|
||||
vObjects
|
||||
JOIN
|
||||
vBoilers ON vBoilers.id = vObjects.boiler_id
|
||||
JOIN
|
||||
tValues ON tValues.id_param = 4 AND tValues.id_object = vObjects.object_id
|
||||
WHERE
|
||||
vObjects.id_city = ${city_id}
|
||||
AND vObjects.year = ${year}
|
||||
|
24
ems/src/api/static/index.ts
Normal file
24
ems/src/api/static/index.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
const tileFolder = path.join(__dirname, '..', '..', '..', 'public', 'static')
|
||||
|
||||
router.get('/:city_id', async (req: Request, res: Response) => {
|
||||
const { city_id } = req.params
|
||||
|
||||
const tilePath1 = path.join(tileFolder, `${city_id}.jpg`)
|
||||
const tilePath2 = path.join(tileFolder, `${city_id}.png`)
|
||||
|
||||
if (fs.existsSync(tilePath1)) {
|
||||
return res.sendFile(tilePath1)
|
||||
} else if (fs.existsSync(tilePath2)) {
|
||||
return res.sendFile(tilePath2)
|
||||
} else {
|
||||
res.status(404).send('Tile is not generated or not provided')
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
@ -5,6 +5,7 @@ import generalRouter from './api/general'
|
||||
import gisRouter from './api/gis'
|
||||
import nodesRouter from './api/nodes'
|
||||
import tilesRouter from './api/tiles'
|
||||
import staticRouter from './api/static'
|
||||
|
||||
const app = express()
|
||||
const PORT = process.env.EMS_PORT || 5000
|
||||
@ -19,5 +20,6 @@ app.use('/general', generalRouter)
|
||||
app.use('/gis', gisRouter)
|
||||
app.use('/nodes', nodesRouter)
|
||||
app.use('/tiles', tilesRouter)
|
||||
app.use('/static', staticRouter)
|
||||
|
||||
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
|
Reference in New Issue
Block a user