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')
...
@@ -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
...
...
server/routes/query.js
View file @
aa36d917
...
@@ -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'
])
}
}
})
})
})
})
...
...
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