sjy-ecos/routes/api.js

45 lines
863 B
JavaScript

var express = require('express');
var router = express.Router();
var models_gis = require('../model/sjy_gis.js');
var models_eco = require('../model/sjy_eco.js');
router.get('/', function (req, res, next) {
res.status(200).send('sjy')
});
router.get('/eco/:tab_name', function (req, res, next) {
var tab_name = req.params.tab_name;
models_eco.getAll(tab_name)
.then(function (data) {
res.status(200)
.json({
status: 'success',
data: data
});
})
.catch(function (err) { res.status(500).send(err) });
});
router.get('/gis/:tab_name', function (req, res, next) {
var tab_name = req.params.tab_name;
models_gis.getAll(tab_name)
.then(function (data) {
res.status(200)
.json({
status: 'success',
data: data
});
})
.catch(function (err) { res.status(500).send(err) });
});
module.exports = router;