Commit a2e1f046 authored by yaobeibei's avatar yaobeibei

test

parent 1034349b
......@@ -22,46 +22,42 @@ if (process.env.MONGO) {
dbpath = 'mongodb://localhost:27017/remarketing'
}
var dbpath_oem = null
if (process.env.MONGO) {
dbpath_oem = 'mongodb://bjwjh-admin:c9yJ2gBFkp7U6@mongo-bjwjh-rs-1.localhost:1302,mongo-bjwjh-rs-2.localhost:1302,mongo-bjwjh-rs-3.localhost:1302/oem_maitian_remarketingAgent?replicaSet=bjwjh-rs&authSource=admin'
} else {
dbpath_oem = 'mongodb://localhost:27017/remarketing2'
}
// var dbpath_oem = null
// if (process.env.MONGO) {
// dbpath_oem = 'mongodb://bjwjh-admin:c9yJ2gBFkp7U6@mongo-bjwjh-rs-1.localhost:1302,mongo-bjwjh-rs-2.localhost:1302,mongo-bjwjh-rs-3.localhost:1302/oem_maitian_remarketingAgent?replicaSet=bjwjh-rs&authSource=admin'
// } else {
// dbpath_oem = 'mongodb://localhost:27017/remarketing2'
// }
var db = {}
var db_oem_mtty = {}
mongoClient.connect(dbpath, function (err, res) {
if (err) return console.log(err)
db = res.db('remarketing')
})
mongoClient.connect(dbpath, function (err, res) {
if (err) return console.log(err)
db = res.db('remarketing')
})
mongoClient.connect(dbpath_oem, function (err, res) {
if (err) return console.log(err)
// mongoClient.connect(dbpath_oem, function (err, res) {
// if (err) return console.log(err)
if (process.env.MONGO) {
db_oem_mtty = res.db('oem_mtty_remarketing')
} else {
db_oem_mtty = res.db('remarketing2')
}
})
// if (process.env.MONGO) {
// db_oem_mtty = res.db('oem_mtty_remarketing')
// } else {
// db_oem_mtty = res.db('remarketing2')
// }
// })
function getSession (sessionID, res) {
if (!sessionID) {
// res.send({status: 500, data: '数据库连接失败'})
} else if (sessionID === 'admin') {
return db
} else {
db = db_oem_mtty
return db
}
}
// function getSession (sessionID, res) {
// if (!sessionID) {
// // res.send({status: 500, data: '数据库连接失败'})
// } else if (sessionID === 'admin') {
// return db
// } else {
// db = db_oem_mtty
// return db
// }
// }
......@@ -81,7 +77,7 @@ app.post('/login', async function (req, res) {
console.log(data)
if (data[0].OEM_password === password) {
res.send({status: 230, id: data[0]._id, message: '登陆成功'})
getSession(data[0]._id, res)
// getSession(data[0]._id, res)
} else {
res.send({status: 600, message: '密码错误'})
}
......@@ -645,7 +641,7 @@ app.post('/releaseInfo', async function (req, res) {
console.log('进入更新公告')
let {title, content, releaseMen, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
let time = new Date()
......@@ -664,7 +660,7 @@ app.post('/getInfo', async function (req, res) {
console.log(req.body)
let { currentPage, pageSize, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
console.log(db)
......@@ -692,7 +688,7 @@ app.post('/checkCall', async function (req, res) {
let { startTime, endTime, total, pageSize, currentPage, choose, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
console.log(req.body)
......@@ -807,7 +803,7 @@ app.post('/send', async function (req, res) {
console.log(req.body)
let {taskId, groupId, interestlist, hostlist, status, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
if (status === 8) {
await db.collection('bills').update({ '_id': mongodb.ObjectId(taskId) }, { $unset: { 'checkStatus': '' } })
......@@ -832,7 +828,7 @@ app.post('/getCheckNote', async function (req, res) {
let { startTime, endTime, total, pageSize, currentPage, chooseId, operatorId, sessionID} = req.body
getSession(sessionID, res)
console.log(req.body)
console.log(chooseId)
......@@ -969,7 +965,7 @@ app.post('/sendCheckNote', async function (req, res) {
console.log('进入send')
console.log(req.body)
let { taskId, status, sendNum, operatorId, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
if (status === 8) {
db.collection('dspTask').update({ '_id': mongodb.ObjectId(taskId) }, { $set: { 'status': 0 } })
......@@ -1019,7 +1015,7 @@ app.post('/getAccount', async function (req, res) {
console.log('进入用户控制')
console.log(req.body)
let { currentPage, pageSize, choose, sessionID } = req.body
getSession(sessionID, res)
let accounts = await db.collection('account').find().toArray()
let dataArr = []
let emailArr = []
......@@ -1060,7 +1056,7 @@ app.post('/deleteAccount', async function (req, res) {
console.log('进入用户控制')
console.log(req.body)
let { accountId, status, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
if (status === 0 || status === '0') {
await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isDelete': true } })
res.send({ status: 200, data: '用户注销成功' })
......@@ -1076,7 +1072,7 @@ app.post('/closeBtn', async function (req, res) {
console.log('进入自动备案')
console.log(req.body)
let { accountId, status, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
if (status === 0 || status === '0') {
await db.collection('account').update({ '_id': mongodb.ObjectId(accountId) }, { $set: { 'isCloseAuto': true } })
res.send({ status: 200, data: '自动备案关闭成功' })
......@@ -1094,7 +1090,7 @@ app.post('/getSlot', async function (req, res) {
let { currentPage, pageSize, choose, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
let company = await db.collection('account').find({}).toArray()
......@@ -1149,7 +1145,7 @@ app.post('/getSlot', async function (req, res) {
app.post('/slotAutoRule', async function (req, res) {
console.log(req.body)
let { slotId, autoRule, sessionID} = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'autoRule': autoRule } })
res.send({ status: 200, message: '备案策略更改成功' })
})
......@@ -1159,7 +1155,7 @@ app.post('/deleteSlot', async function (req, res) {
console.log('进入代码位控制')
console.log(req.body)
let { slotId, status, sessionID } = req.body
getSession(sessionID, res)
// getSession(sessionID, res)
if (status === 0 || status === '0') {
await db.collection('slotTemps').update({ '_id': mongodb.ObjectId(slotId) }, { $set: { 'isSlotDelete': true } })
res.send({ status: 200, data: '代码位注销成功' })
......
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