const express = require('express')
const router = express.Router()
const Mysql = require('../SQLPool')

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 = ?'

    Mysql.query(SQL, [toolbox_name, toolbox_icon, toolbox_url, toolbox_desc, toolbox_id], (err, result) => {
        if (err) {
            res.send({
                success: false,
                err
            })
        }
        res.send({
            success: true,
            data: result
        })
    })
})

// router.get('/updateToolBoxSort',(req, res) => {
//     const {sortArr} = req.query
//     console.log(sortArr)
//     res.send({
//         success: true,
//         data: sortArr
//     })
// })

module.exports = router
