Commit 5a57824c authored by wty's avatar wty

上线test

parent c12f0786
......@@ -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
......
......@@ -24,7 +24,7 @@ const app = express();
if (config === 'local'){
let server = http.createServer(app);
server.listen(3000)
global.domain = 'http://172.16.227.78:3000'
global.domain = 'http://127.0.0.1:3000'
}else {
global.domain = 'http://' + os.networkInterfaces()['eth0'][0]['address']
const dockerApp = new DockerApp({
......
......@@ -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
......
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