Commit 5a57824c authored by wty's avatar wty

上线test

parent c12f0786
...@@ -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
......
...@@ -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://172.16.227.78:3000' global.domain = 'http://127.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({
......
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment