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
5a57824c
Commit
5a57824c
authored
Nov 03, 2021
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上线test
parent
c12f0786
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
56 deletions
+53
-56
SQLPool.js
server/SQLPool.js
+29
-32
app.js
server/app.js
+1
-1
typeManage.js
server/routes/typeManage.js
+23
-23
No files found.
server/SQLPool.js
View file @
5a57824c
...
...
@@ -13,44 +13,41 @@ const getApollo = async () => {
})
console
.
info
(
apolloConfig
)
const
sourcesArray
=
apolloConfig
.
propertySources
.
map
(
v
=>
v
.
source
);
const
sources
=
Object
.
assign
({},...
sourcesArray
)
const
sources
=
Object
.
assign
({},
...
sourcesArray
)
global
[
'SSO_APP_SECRET'
]
=
sources
[
'spring.application.secret'
]
return
sources
}
const
getMysql
=
new
Promise
(
async
(
resolve
)
=>
{
const
source
=
await
getApollo
()
const
username
=
source
[
'apollo.mysql.duiba_web_tool.username'
]
const
password
=
source
[
'apollo.mysql.duiba_web_tool.password'
]
const
database
=
source
[
'apollo.mysql.duiba_web_tool.database'
]
const
host
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
0
]
const
port
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
1
]
const
Mysql
=
MYSQL
.
createPool
({
'host'
:
host
,
'port'
:
port
,
'user'
:
username
,
'password'
:
password
,
'database'
:
database
,
'connectionLimit'
:
1000
})
// console.info('MysqlConfig:',Mysql.config)
console
.
info
(
'OBJMysql'
,
Mysql
)
resolve
(
Mysql
)
const
getMysql
=
config
===
'local'
?
new
Promise
((
resolve
)
=>
{
const
Mysql
=
MYSQL
.
createPool
({
'host'
:
'127.0.0.1'
,
'port'
:
3306
,
'user'
:
'wty'
,
'password'
:
'wty990215'
,
'database'
:
'dui123'
,
'connectionLimit'
:
1000
})
resolve
(
Mysql
)
})
:
new
Promise
(
async
(
resolve
)
=>
{
const
source
=
await
getApollo
()
const
username
=
source
[
'apollo.mysql.duiba_web_tool.username'
]
const
password
=
source
[
'apollo.mysql.duiba_web_tool.password'
]
const
database
=
source
[
'apollo.mysql.duiba_web_tool.database'
]
const
host
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
0
]
const
port
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
1
]
const
Mysql
=
MYSQL
.
createPool
({
'host'
:
host
,
'port'
:
port
,
'user'
:
username
,
'password'
:
password
,
'database'
:
database
,
'connectionLimit'
:
1000
})
// console.info('MysqlConfig:',Mysql.config)
console
.
info
(
'OBJMysql'
,
Mysql
)
resolve
(
Mysql
)
})
// 本地数据库
// const getMysql = new Promise((resolve)=>{
//
// const Mysql = MYSQL.createPool({
// 'host': '127.0.0.1',
// 'port': 3306,
// 'user': 'wty',
// 'password': 'wty990215',
// 'database': 'dui123',
// 'connectionLimit': 1000
// })
// resolve(Mysql)
// })
module
.
exports
=
getMysql
...
...
server/app.js
View file @
5a57824c
...
...
@@ -24,7 +24,7 @@ const app = express();
if
(
config
===
'local'
){
let
server
=
http
.
createServer
(
app
);
server
.
listen
(
3000
)
global
.
domain
=
'http://1
72.16.227.78
:3000'
global
.
domain
=
'http://1
27.0.0.1
:3000'
}
else
{
global
.
domain
=
'http://'
+
os
.
networkInterfaces
()[
'eth0'
][
0
][
'address'
]
const
dockerApp
=
new
DockerApp
({
...
...
server/routes/typeManage.js
View file @
5a57824c
...
...
@@ -37,33 +37,33 @@ getMysql.then(Mysql => {
})
})
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
=
[]
const
combineType
=
(
value
)
=>
{
if
(
dataArr
.
filter
(
v
=>
v
.
type_id
===
value
.
type_id
).
length
)
return
const
childType
=
result
.
filter
(
v
=>
v
.
type_id
===
value
.
type_id
).
map
(
v
=>
({
child_type_id
:
v
.
child_type_id
,
child_type_name
:
v
.
child_type_name
}))
dataArr
.
push
({
type_id
:
value
.
type_id
,
type_name
:
value
.
type_name
,
children
:
childType
})
}
result
.
forEach
(
v
=>
{
combineType
(
v
)
})
res
.
send
({
success
:
true
,
data
:
dataArr
router
.
get
(
'/queryTypeForManage'
,
async
(
req
,
res
)
=>
{
const
SQL1
=
'SELECT * FROM type'
const
SQL2
=
'SELECT * FROM child_type'
const
query
=
(
SQL
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
Mysql
.
query
(
SQL
,
[],
(
err
,
result
)
=>
{
if
(
err
)
{
res
.
send
({
success
:
false
,
err
:
err
})
reject
(
err
)
}
resolve
(
result
)
})
})
const
queryType
=
query
(
SQL1
)
const
queryChildType
=
query
(
SQL2
)
const
typeArr
=
await
queryType
const
childTypeArr
=
await
queryChildType
const
data
=
typeArr
.
map
(
v
=>
({...
v
,
children
:
childTypeArr
.
filter
(
_v
=>
_v
.
type_id
===
v
.
type_id
)}))
res
.
send
({
success
:
true
,
data
:
data
})
})
router
.
get
(
'/deleteChildType'
,
((
req
,
res
)
=>
{
const
{
child_type_id
}
=
req
.
query
...
...
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