Commit aa36d917 authored by wty's avatar wty

上线test8

parent ab684289
...@@ -4,51 +4,33 @@ const getMysql = require('../SQLPool') ...@@ -4,51 +4,33 @@ const getMysql = require('../SQLPool')
const router = express.Router() const router = express.Router()
const query = require('../lib/query') const query = require('../lib/query')
getMysql.then(Mysql => { getMysql.then(Mysql => {
// router.get('/addToolBox', async (req, res) => { router.get('/addToolBox', async (req, res) => {
// const {toolbox_name, toolbox_icon, toolbox_desc, toolbox_url, type_id, child_type_id} = req.query const {toolbox_name, toolbox_icon, toolbox_desc, toolbox_url, type_id, child_type_id} = req.query
// const SQL1 = 'INSERT INTO toolbox (toolbox_name, toolbox_icon, toolbox_desc, toolbox_url,sort_id) VALUES (?,?,?,?,?)' const SQL1 = 'INSERT INTO toolbox (toolbox_name, toolbox_icon, toolbox_desc, toolbox_url,sort_id) VALUES (?,?,?,?,?)'
// const SQL2 = 'INSERT INTO type_childtype_toolbox (toolbox_id,type_id,child_type_id) VALUES (?,?,?)' const SQL2 = 'INSERT INTO type_childtype_toolbox (toolbox_id,type_id,child_type_id) VALUES (?,?,?)'
// const SQL3 = 'SELECT * FROM toolbox' const SQL3 = 'SELECT * FROM toolbox'
// const addToolBox = await query(SQL1, [toolbox_name, toolbox_desc, toolbox_icon, toolbox_url, 0]) try{
// const queryToolBox = await query(SQL3) const addToolBox = await query(SQL1, [toolbox_name, toolbox_desc, toolbox_icon, toolbox_url, 0])
// const addRelation = await query(SQL2, []) if (!addToolBox) throw 'addToolBox异常'
// Mysql.query(SQL, , (err, result) => {
// if (err) { const queryToolBox = await query(SQL3)
// res.send({ if (!queryToolBox) throw '没有toolbox信息'
// success: false,
// err const lastToolBoxId = queryToolBox[queryToolBox.length - 1].toolbox_id
// }) const params = [lastToolBoxId, type_id]
// return if (typeof child_type_id !== 'number') params.push(null)
// } else params.push(child_type_id)
// request(domain + '/query/queryToolBox', {}, (error, response, body) => { const addRelation = await query(SQL2, params)
// if (error) { if (addRelation) res.send({success: true})
// console.error(error) else throw 'addRelation异常'
// res.send({success: false,err : error}) }catch (e){
// return console.error(e)
// } res.send({
// console.log(domain + '/query/queryToolBox') success: false,
// console.log('body:', body) err: e
// const data = JSON.parse(body).data })
// const lastToolBoxId = data[data.length - 1].toolbox_id }
// })
// const params = [lastToolBoxId, type_id]
// if (typeof child_type_id !== 'number') params.push(null)
// else params.push(child_type_id)
// Mysql.query(SQL, params, (err, result) => {
// if (err) {
// res.send({
// success: false,
// err
// })
// return
// }
// res.send({
// success: true
// })
// })
// })
// })
// })
router.get('/addType', (req, res) => { router.get('/addType', (req, res) => {
const {type_name, child_type_name, type_id} = req.query const {type_name, child_type_name, type_id} = req.query
......
...@@ -66,8 +66,7 @@ getMysql.then(Mysql => { ...@@ -66,8 +66,7 @@ getMysql.then(Mysql => {
res.send({ res.send({
success: true, success: true,
data: { data: {
result, ...result.map(v => ({...v,toolbox_url : v['toolbox_url']})),
toolbox_url: decodeURIComponent(result['toolbox_url'])
} }
}) })
}) })
......
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