Commit e571b425 authored by wty's avatar wty

上线test9

parent aa36d917
...@@ -39,15 +39,21 @@ getMysql.then(Mysql => { ...@@ -39,15 +39,21 @@ getMysql.then(Mysql => {
}) })
router.get('/queryTypeForManage', async (req, res) => { router.get('/queryTypeForManage', async (req, res) => {
const SQL1 = 'SELECT * FROM type' try {
const SQL2 = 'SELECT * FROM child_type' const SQL1 = 'SELECT * FROM type'
const typeArr = await query(SQL1) const SQL2 = 'SELECT * FROM child_type'
const childTypeArr = await query(SQL2) const typeArr = await query(SQL1)
const data = typeArr.map(v =>({...v, children: childTypeArr.filter(_v => _v.type_id === v.type_id)})) const childTypeArr = await query(SQL2)
res.send({ const data = typeArr.map(v => ({...v, children: childTypeArr.filter(_v => _v.type_id === v.type_id)}))
success: true, res.send({
data: data success: true,
}) data: data
})
} catch (e) {
console.error(e)
res.send({success: false, err: e})
}
}) })
......
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