menu.js 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var express = require('express');
  2. var config = require('../conf/config.inc');
  3. var mysql = require('mysql');
  4. var conn = mysql.createConnection(config['dbInfo']['default']);
  5. conn.connect();
  6. var selectSQL = 'select * from cUser';
  7. function getcUser(cb) {
  8. conn.query(selectSQL, function(err, res) {
  9. if(err) {
  10. console.log(err);
  11. } else {
  12. cb && cb(res);
  13. }
  14. });
  15. }
  16. var router = express.Router();
  17. /* GET menu page. */
  18. router.get('/', function(req, res, next) {
  19. getcUser(function(cUser) {
  20. var pageData = {
  21. title : '偶家后台 - 菜单权限管理',
  22. cUser : cUser
  23. }
  24. res.render('menu', pageData);
  25. });
  26. });
  27. router.get('/getcUser', function(req, res, next) {
  28. // var seachSQL = 'select * from cUser where userName like 1';
  29. // if(req.body.username=='...'&&req.body.password=='...'){
  30. // res.json({success:1});
  31. // }
  32. res.json({success:1})
  33. });
  34. module.exports = router;