var express = require('express'); var config = require('../conf/config.inc'); var mysql = require('mysql'); var conn = mysql.createConnection(config['dbInfo']['default']); conn.connect(); var selectSQL = 'select * from cUser'; function getcUser(cb) { conn.query(selectSQL, function(err, res) { if(err) { console.log(err); } else { cb && cb(res); } }); } var router = express.Router(); /* GET menu page. */ router.get('/', function(req, res, next) { getcUser(function(cUser) { var pageData = { title : '偶家后台 - 菜单权限管理', cUser : cUser } res.render('menu', pageData); }); }); router.get('/getcUser', function(req, res, next) { // var seachSQL = 'select * from cUser where userName like 1'; // if(req.body.username=='...'&&req.body.password=='...'){ // res.json({success:1}); // } res.json({success:1}) }); module.exports = router;