Commit 5a57824c authored by wty's avatar wty

上线test

parent c12f0786
......@@ -13,12 +13,22 @@ 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 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']
......@@ -38,19 +48,6 @@ const getMysql = new Promise(async (resolve) => {
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'
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) => {
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
if (err) {
res.send({
success: false,
err: err
})
reject(err)
}
result.forEach(v => {
combineType(v)
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: dataArr
})
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