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 () => {
...
@@ -13,44 +13,41 @@ const getApollo = async () => {
})
})
console
.
info
(
apolloConfig
)
console
.
info
(
apolloConfig
)
const
sourcesArray
=
apolloConfig
.
propertySources
.
map
(
v
=>
v
.
source
);
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'
]
global
[
'SSO_APP_SECRET'
]
=
sources
[
'spring.application.secret'
]
return
sources
return
sources
}
}
const
getMysql
=
new
Promise
(
async
(
resolve
)
=>
{
const
getMysql
=
config
===
'local'
?
new
Promise
((
resolve
)
=>
{
const
source
=
await
getApollo
()
const
Mysql
=
MYSQL
.
createPool
({
const
username
=
source
[
'apollo.mysql.duiba_web_tool.username'
]
'host'
:
'127.0.0.1'
,
const
password
=
source
[
'apollo.mysql.duiba_web_tool.password'
]
'port'
:
3306
,
const
database
=
source
[
'apollo.mysql.duiba_web_tool.database'
]
'user'
:
'wty'
,
const
host
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
0
]
'password'
:
'wty990215'
,
const
port
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
1
]
'database'
:
'dui123'
,
const
Mysql
=
MYSQL
.
createPool
({
'connectionLimit'
:
1000
'host'
:
host
,
})
'port'
:
port
,
resolve
(
Mysql
)
'user'
:
username
,
})
:
new
Promise
(
async
(
resolve
)
=>
{
'password'
:
password
,
const
source
=
await
getApollo
()
'database'
:
database
,
const
username
=
source
[
'apollo.mysql.duiba_web_tool.username'
]
'connectionLimit'
:
1000
const
password
=
source
[
'apollo.mysql.duiba_web_tool.password'
]
})
const
database
=
source
[
'apollo.mysql.duiba_web_tool.database'
]
// console.info('MysqlConfig:',Mysql.config)
const
host
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
0
]
console
.
info
(
'OBJMysql'
,
Mysql
)
const
port
=
source
[
'apollo.mysql.duiba_web_tool.url'
].
split
(
':'
)[
1
]
resolve
(
Mysql
)
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
module
.
exports
=
getMysql
...
...
server/app.js
View file @
5a57824c
...
@@ -24,7 +24,7 @@ const app = express();
...
@@ -24,7 +24,7 @@ const app = express();
if
(
config
===
'local'
){
if
(
config
===
'local'
){
let
server
=
http
.
createServer
(
app
);
let
server
=
http
.
createServer
(
app
);
server
.
listen
(
3000
)
server
.
listen
(
3000
)
global
.
domain
=
'http://1
72.16.227.78
:3000'
global
.
domain
=
'http://1
27.0.0.1
:3000'
}
else
{
}
else
{
global
.
domain
=
'http://'
+
os
.
networkInterfaces
()[
'eth0'
][
0
][
'address'
]
global
.
domain
=
'http://'
+
os
.
networkInterfaces
()[
'eth0'
][
0
][
'address'
]
const
dockerApp
=
new
DockerApp
({
const
dockerApp
=
new
DockerApp
({
...
...
server/routes/typeManage.js
View file @
5a57824c
...
@@ -37,33 +37,33 @@ getMysql.then(Mysql => {
...
@@ -37,33 +37,33 @@ getMysql.then(Mysql => {
})
})
})
})
router
.
get
(
'/queryTypeForManage'
,
(
req
,
res
)
=>
{
router
.
get
(
'/queryTypeForManage'
,
async
(
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'
const
SQL1
=
'SELECT * FROM type'
Mysql
.
query
(
SQL
,
[],
(
err
,
result
)
=>
{
const
SQL2
=
'SELECT * FROM child_type'
const
dataArr
=
[]
const
query
=
(
SQL
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
const
combineType
=
(
value
)
=>
{
Mysql
.
query
(
SQL
,
[],
(
err
,
result
)
=>
{
if
(
dataArr
.
filter
(
v
=>
v
.
type_id
===
value
.
type_id
).
length
)
return
if
(
err
)
{
const
childType
=
result
.
filter
(
v
=>
v
.
type_id
===
value
.
type_id
).
map
(
v
=>
({
res
.
send
({
child_type_id
:
v
.
child_type_id
,
success
:
false
,
child_type_name
:
v
.
child_type_name
err
:
err
}))
})
dataArr
.
push
({
reject
(
err
)
type_id
:
value
.
type_id
,
}
type_name
:
value
.
type_name
,
resolve
(
result
)
children
:
childType
})
}
result
.
forEach
(
v
=>
{
combineType
(
v
)
})
res
.
send
({
success
:
true
,
data
:
dataArr
})
})
})
})
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
)
=>
{
router
.
get
(
'/deleteChildType'
,
((
req
,
res
)
=>
{
const
{
child_type_id
}
=
req
.
query
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