Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Dui123
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
王天宇
Dui123
Commits
aa36d917
Commit
aa36d917
authored
Nov 03, 2021
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上线test8
parent
ab684289
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
47 deletions
+28
-47
add.js
server/routes/add.js
+27
-45
query.js
server/routes/query.js
+1
-2
No files found.
server/routes/add.js
View file @
aa36d917
...
...
@@ -4,51 +4,33 @@ const getMysql = require('../SQLPool')
const
router
=
express
.
Router
()
const
query
=
require
(
'../lib/query'
)
getMysql
.
then
(
Mysql
=>
{
// router.get('/addToolBox', async (req, res) => {
// 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 SQL2 = 'INSERT INTO type_childtype_toolbox (toolbox_id,type_id,child_type_id) VALUES (?,?,?)'
// const SQL3 = 'SELECT * FROM toolbox'
// const addToolBox = await query(SQL1, [toolbox_name, toolbox_desc, toolbox_icon, toolbox_url, 0])
// const queryToolBox = await query(SQL3)
// const addRelation = await query(SQL2, [])
// Mysql.query(SQL, , (err, result) => {
// if (err) {
// res.send({
// success: false,
// err
// })
// return
// }
// request(domain + '/query/queryToolBox', {}, (error, response, body) => {
// if (error) {
// console.error(error)
// res.send({success: false,err : error})
// return
// }
// console.log(domain + '/query/queryToolBox')
// console.log('body:', body)
// 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
(
'/addToolBox'
,
async
(
req
,
res
)
=>
{
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
SQL2
=
'INSERT INTO type_childtype_toolbox (toolbox_id,type_id,child_type_id) VALUES (?,?,?)'
const
SQL3
=
'SELECT * FROM toolbox'
try
{
const
addToolBox
=
await
query
(
SQL1
,
[
toolbox_name
,
toolbox_desc
,
toolbox_icon
,
toolbox_url
,
0
])
if
(
!
addToolBox
)
throw
'addToolBox异常'
const
queryToolBox
=
await
query
(
SQL3
)
if
(
!
queryToolBox
)
throw
'没有toolbox信息'
const
lastToolBoxId
=
queryToolBox
[
queryToolBox
.
length
-
1
].
toolbox_id
const
params
=
[
lastToolBoxId
,
type_id
]
if
(
typeof
child_type_id
!==
'number'
)
params
.
push
(
null
)
else
params
.
push
(
child_type_id
)
const
addRelation
=
await
query
(
SQL2
,
params
)
if
(
addRelation
)
res
.
send
({
success
:
true
})
else
throw
'addRelation异常'
}
catch
(
e
){
console
.
error
(
e
)
res
.
send
({
success
:
false
,
err
:
e
})
}
})
router
.
get
(
'/addType'
,
(
req
,
res
)
=>
{
const
{
type_name
,
child_type_name
,
type_id
}
=
req
.
query
...
...
server/routes/query.js
View file @
aa36d917
...
...
@@ -66,8 +66,7 @@ getMysql.then(Mysql => {
res
.
send
({
success
:
true
,
data
:
{
result
,
toolbox_url
:
decodeURIComponent
(
result
[
'toolbox_url'
])
...
result
.
map
(
v
=>
({...
v
,
toolbox_url
:
v
[
'toolbox_url'
]})),
}
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment