Commit 2014702d authored by wty's avatar wty

更改后端代码

parent 5d3571d1
const express = require('express')
const request = require("request");
const Mysql = require("../SQLPool");
const getMysql = require('../SQLPool')
const router = express.Router()
router.get('/addToolBox', (req, res) => {
getMysql.then(Mysql => {
router.get('/addToolBox', (req, res) => {
const {toolbox_name, toolbox_icon, toolbox_desc, toolbox_url, type_id, child_type_id} = req.query
const SQL = 'INSERT INTO toolbox (toolbox_name, toolbox_icon, toolbox_desc, toolbox_url,sort_id) VALUES (?,?,?,?,?)'
......@@ -35,9 +35,9 @@ router.get('/addToolBox', (req, res) => {
})
})
})
})
})
router.get('/addType', (req, res) => {
router.get('/addType', (req, res) => {
const {type_name, child_type_name, type_id} = req.query
console.log(req.query)
let SQL = 'INSERT INTO type (type_name) VALUES (?)'
......@@ -67,7 +67,8 @@ router.get('/addType', (req, res) => {
} catch (e) {
console.error(e)
}
})
})
}).catch(e => console.error(e))
module.exports = router
const express = require('express')
const request = require('request')
const Mysql = require("../SQLPool");
const getMysql = require('../SQLPool')
const router = express.Router()
router.get('/deleteToolBoxById', (req, res) => {
getMysql.then(Mysql => {
router.get('/deleteToolBoxById', (req, res) => {
const {toolbox_id} = req.query
const SQL = 'DELETE FROM toolbox WHERE toolbox_id = ?'
try {
......@@ -24,6 +25,7 @@ router.get('/deleteToolBoxById', (req, res) => {
console.error(e)
}
})
})
}).catch(e => console.error(e))
module.exports = router
const express = require('express');
const Mysql = require('../SQLPool')
const getMysql = require('../SQLPool')
const fs = require("fs");
const request = require("request");
const path = require("path");
const router = express.Router();
router.post('/addPage', (req, res) => {
getMysql.then(Mysql => {
router.post('/addPage', (req, res) => {
const {page_name, code} = req.body
const SQL = `INSERT INTO page (page_name) VALUES (?)`
......@@ -49,10 +49,10 @@ router.post('/addPage', (req, res) => {
}
}
})
})
})
router.get('/queryPage', (req, res) => {
router.get('/queryPage', (req, res) => {
const SQL = 'SELECT * FROM page'
Mysql.query(SQL, [], (err, result) => {
if (err) {
......@@ -75,9 +75,9 @@ router.get('/queryPage', (req, res) => {
data: _result
})
})
})
})
router.post('/updatePage', (req, res) => {
router.post('/updatePage', (req, res) => {
const {page_id, page_name, code} = req.body
const SQL = 'UPDATE page SET page_name=? WHERE page_id = ?'
Mysql.query(SQL, [page_name, page_id], (err, result) => {
......@@ -102,6 +102,8 @@ router.post('/updatePage', (req, res) => {
}
})
})
})
}).catch(e => console.error(e))
module.exports = router
const express = require('express')
const request = require("request");
const Mysql = require('../SQLPool')
const getMysql = require('../SQLPool')
const router = express.Router()
router.get('/queryType', (req, res) => {
getMysql.then(Mysql => {
router.get('/queryType', (req, res) => {
const SQL = 'SELECT * FROM type'
Mysql.query(SQL, (err, result) => {
if (err) {
......@@ -18,9 +18,9 @@ router.get('/queryType', (req, res) => {
data: result
})
})
})
})
router.get('/queryChildType', (req, res) => {
router.get('/queryChildType', (req, res) => {
const SQL = 'SELECT * FROM child_type'
Mysql.query(SQL, (err, result) => {
if (err) {
......@@ -35,9 +35,9 @@ router.get('/queryChildType', (req, res) => {
data: result
})
})
})
})
router.get('/queryTypeForManage', (req, res) => {
router.get('/queryTypeForManage', (req, res) => {
const SQL = 'SELECT child_type.child_type_id, child_type.child_type_name, child_type.type_id, type.type_name FROM child_type INNER JOIN type ON child_type.type_id = type.type_id'
Mysql.query(SQL, [], (err, result) => {
const dataArr = []
......@@ -62,9 +62,9 @@ router.get('/queryTypeForManage', (req, res) => {
data: dataArr
})
})
})
})
router.get('/deleteChildType', ((req, res) => {
router.get('/deleteChildType', ((req, res) => {
const {child_type_id} = req.query
let SQL = 'DELETE FROM child_type WHERE child_type_id = ?;'
......@@ -85,9 +85,9 @@ router.get('/deleteChildType', ((req, res) => {
})
})
}))
}))
router.get('/updateType', (req, res) => {
router.get('/updateType', (req, res) => {
const {type_id, type_name, child_type_id, child_type_name} = req.query
let SQL
const values = []
......@@ -112,6 +112,8 @@ router.get('/updateType', (req, res) => {
success: true,
})
})
})
})
}).catch(e => console.error(e))
module.exports = router
const express = require('express')
const router = express.Router()
const Mysql = require('../SQLPool')
const getMysql = require('../SQLPool')
router.get('/updateToolBox', (req, res) => {
getMysql.then(Mysql => {
router.get('/updateToolBox', (req, res) => {
const {toolbox_name, toolbox_icon, toolbox_url, toolbox_desc, toolbox_id} = req.query
const SQL = 'UPDATE toolbox SET toolbox_name= ?, toolbox_icon=?, toolbox_url=?, toolbox_desc=? WHERE toolbox_id = ?'
......@@ -18,7 +20,7 @@ router.get('/updateToolBox', (req, res) => {
data: result
})
})
})
})
// router.get('/updateToolBoxSort',(req, res) => {
// const {sortArr} = req.query
......@@ -28,5 +30,7 @@ router.get('/updateToolBox', (req, res) => {
// data: sortArr
// })
// })
}).catch(e => console.error(e))
module.exports = router
......@@ -10,17 +10,18 @@ getMysql.then(Mysql => {
/* GET users listing. */
router.get('/getUser', function (req, res, next) {
let {uid} = req.cookies
if (!uid){
uid = req.query.uid
}
// if (!uid) {
// res.send({
// success: false,
// code: ErrorCode.USER_NOT_LOGIN,
// data: '用户尚未登录'
// })
// return
console.info(req.cookies)
// if (!uid){
// uid = req.query.uid
// }
if (!uid) {
res.send({
success: false,
code: ErrorCode.USER_NOT_LOGIN,
data: '用户尚未登录'
})
return
}
const SQL = 'SELECT * FROM `user` WHERE `user`.uid = ?'
Mysql.query(SQL, [uid], (err, result) => {
if (err || !result || !result.length) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment