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
2014702d
Commit
2014702d
authored
Oct 22, 2021
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改后端代码
parent
5d3571d1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
275 additions
and
263 deletions
+275
-263
add.js
server/routes/add.js
+55
-54
delete.js
server/routes/delete.js
+21
-19
page.js
server/routes/page.js
+82
-80
typeManage.js
server/routes/typeManage.js
+89
-87
update.js
server/routes/update.js
+17
-13
users.js
server/routes/users.js
+11
-10
No files found.
server/routes/add.js
View file @
2014702d
const
express
=
require
(
'express'
)
const
request
=
require
(
"request"
);
const
Mysql
=
require
(
"../SQLPool"
);
const
getMysql
=
require
(
'../SQLPool'
)
const
router
=
express
.
Router
()
router
.
get
(
'/addToolBox'
,
(
req
,
res
)
=>
{
getMysql
.
then
(
Mysql
=>
{
router
.
get
(
'/addToolBox'
,
(
req
,
res
)
=>
{
const
{
toolbox_name
,
toolbox_icon
,
toolbox_desc
,
toolbox_url
,
type_id
,
child_type_id
}
=
req
.
query
const
SQL
=
'INSERT INTO toolbox (toolbox_name, toolbox_icon, toolbox_desc, toolbox_url,sort_id) VALUES (?,?,?,?,?)'
...
...
@@ -35,9 +35,9 @@ router.get('/addToolBox', (req, res) => {
})
})
})
})
})
router
.
get
(
'/addType'
,
(
req
,
res
)
=>
{
router
.
get
(
'/addType'
,
(
req
,
res
)
=>
{
const
{
type_name
,
child_type_name
,
type_id
}
=
req
.
query
console
.
log
(
req
.
query
)
let
SQL
=
'INSERT INTO type (type_name) VALUES (?)'
...
...
@@ -67,7 +67,8 @@ router.get('/addType', (req, res) => {
}
catch
(
e
)
{
console
.
error
(
e
)
}
})
})
}).
catch
(
e
=>
console
.
error
(
e
))
module
.
exports
=
router
server/routes/delete.js
View file @
2014702d
const
express
=
require
(
'express'
)
const
request
=
require
(
'request'
)
const
Mysql
=
require
(
"../SQLPool"
);
const
getMysql
=
require
(
'../SQLPool'
)
const
router
=
express
.
Router
()
router
.
get
(
'/deleteToolBoxById'
,
(
req
,
res
)
=>
{
getMysql
.
then
(
Mysql
=>
{
router
.
get
(
'/deleteToolBoxById'
,
(
req
,
res
)
=>
{
const
{
toolbox_id
}
=
req
.
query
const
SQL
=
'DELETE FROM toolbox WHERE toolbox_id = ?'
try
{
...
...
@@ -24,6 +25,7 @@ router.get('/deleteToolBoxById', (req, res) => {
console
.
error
(
e
)
}
})
})
}).
catch
(
e
=>
console
.
error
(
e
))
module
.
exports
=
router
server/routes/page.js
View file @
2014702d
const
express
=
require
(
'express'
);
const
Mysql
=
require
(
'../SQLPool'
)
const
get
Mysql
=
require
(
'../SQLPool'
)
const
fs
=
require
(
"fs"
);
const
request
=
require
(
"request"
);
const
path
=
require
(
"path"
);
const
router
=
express
.
Router
();
router
.
post
(
'/addPage'
,
(
req
,
res
)
=>
{
getMysql
.
then
(
Mysql
=>
{
router
.
post
(
'/addPage'
,
(
req
,
res
)
=>
{
const
{
page_name
,
code
}
=
req
.
body
const
SQL
=
`INSERT INTO page (page_name) VALUES (?)`
...
...
@@ -49,10 +49,10 @@ router.post('/addPage', (req, res) => {
}
}
})
})
})
router
.
get
(
'/queryPage'
,
(
req
,
res
)
=>
{
router
.
get
(
'/queryPage'
,
(
req
,
res
)
=>
{
const
SQL
=
'SELECT * FROM page'
Mysql
.
query
(
SQL
,
[],
(
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -75,9 +75,9 @@ router.get('/queryPage', (req, res) => {
data
:
_result
})
})
})
})
router
.
post
(
'/updatePage'
,
(
req
,
res
)
=>
{
router
.
post
(
'/updatePage'
,
(
req
,
res
)
=>
{
const
{
page_id
,
page_name
,
code
}
=
req
.
body
const
SQL
=
'UPDATE page SET page_name=? WHERE page_id = ?'
Mysql
.
query
(
SQL
,
[
page_name
,
page_id
],
(
err
,
result
)
=>
{
...
...
@@ -102,6 +102,8 @@ router.post('/updatePage', (req, res) => {
}
})
})
})
}).
catch
(
e
=>
console
.
error
(
e
))
module
.
exports
=
router
server/routes/typeManage.js
View file @
2014702d
const
express
=
require
(
'express'
)
const
request
=
require
(
"request"
);
const
Mysql
=
require
(
'../SQLPool'
)
const
get
Mysql
=
require
(
'../SQLPool'
)
const
router
=
express
.
Router
()
router
.
get
(
'/queryType'
,
(
req
,
res
)
=>
{
getMysql
.
then
(
Mysql
=>
{
router
.
get
(
'/queryType'
,
(
req
,
res
)
=>
{
const
SQL
=
'SELECT * FROM type'
Mysql
.
query
(
SQL
,
(
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -18,9 +18,9 @@ router.get('/queryType', (req, res) => {
data
:
result
})
})
})
})
router
.
get
(
'/queryChildType'
,
(
req
,
res
)
=>
{
router
.
get
(
'/queryChildType'
,
(
req
,
res
)
=>
{
const
SQL
=
'SELECT * FROM child_type'
Mysql
.
query
(
SQL
,
(
err
,
result
)
=>
{
if
(
err
)
{
...
...
@@ -35,9 +35,9 @@ router.get('/queryChildType', (req, res) => {
data
:
result
})
})
})
})
router
.
get
(
'/queryTypeForManage'
,
(
req
,
res
)
=>
{
router
.
get
(
'/queryTypeForManage'
,
(
req
,
res
)
=>
{
const
SQL
=
'SELECT child_type.child_type_id, child_type.child_type_name, child_type.type_id, type.type_name FROM child_type INNER JOIN type ON child_type.type_id = type.type_id'
Mysql
.
query
(
SQL
,
[],
(
err
,
result
)
=>
{
const
dataArr
=
[]
...
...
@@ -62,9 +62,9 @@ router.get('/queryTypeForManage', (req, res) => {
data
:
dataArr
})
})
})
})
router
.
get
(
'/deleteChildType'
,
((
req
,
res
)
=>
{
router
.
get
(
'/deleteChildType'
,
((
req
,
res
)
=>
{
const
{
child_type_id
}
=
req
.
query
let
SQL
=
'DELETE FROM child_type WHERE child_type_id = ?;'
...
...
@@ -85,9 +85,9 @@ router.get('/deleteChildType', ((req, res) => {
})
})
}))
}))
router
.
get
(
'/updateType'
,
(
req
,
res
)
=>
{
router
.
get
(
'/updateType'
,
(
req
,
res
)
=>
{
const
{
type_id
,
type_name
,
child_type_id
,
child_type_name
}
=
req
.
query
let
SQL
const
values
=
[]
...
...
@@ -112,6 +112,8 @@ router.get('/updateType', (req, res) => {
success
:
true
,
})
})
})
})
}).
catch
(
e
=>
console
.
error
(
e
))
module
.
exports
=
router
server/routes/update.js
View file @
2014702d
const
express
=
require
(
'express'
)
const
router
=
express
.
Router
()
const
Mysql
=
require
(
'../SQLPool'
)
const
get
Mysql
=
require
(
'../SQLPool'
)
router
.
get
(
'/updateToolBox'
,
(
req
,
res
)
=>
{
getMysql
.
then
(
Mysql
=>
{
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 = ?'
...
...
@@ -18,7 +20,7 @@ router.get('/updateToolBox', (req, res) => {
data
:
result
})
})
})
})
// router.get('/updateToolBoxSort',(req, res) => {
// const {sortArr} = req.query
...
...
@@ -28,5 +30,7 @@ router.get('/updateToolBox', (req, res) => {
// data: sortArr
// })
// })
}).
catch
(
e
=>
console
.
error
(
e
))
module
.
exports
=
router
server/routes/users.js
View file @
2014702d
...
...
@@ -10,17 +10,18 @@ getMysql.then(Mysql => {
/* GET users listing. */
router
.
get
(
'/getUser'
,
function
(
req
,
res
,
next
)
{
let
{
uid
}
=
req
.
cookies
if
(
!
uid
){
uid
=
req
.
query
.
uid
}
// if (!uid) {
// res.send({
// success: false,
// code: ErrorCode.USER_NOT_LOGIN,
// data: '用户尚未登录'
// })
// return
console
.
info
(
req
.
cookies
)
// if (!uid){
// uid = req.query.uid
// }
if
(
!
uid
)
{
res
.
send
({
success
:
false
,
code
:
ErrorCode
.
USER_NOT_LOGIN
,
data
:
'用户尚未登录'
})
return
}
const
SQL
=
'SELECT * FROM `user` WHERE `user`.uid = ?'
Mysql
.
query
(
SQL
,
[
uid
],
(
err
,
result
)
=>
{
if
(
err
||
!
result
||
!
result
.
length
)
{
...
...
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