修改游戏创建FTP账号逻辑

This commit is contained in:
yulixing 2019-05-31 15:19:58 +08:00
parent 7a212e1535
commit 9ed073ff6c

View File

@ -228,41 +228,6 @@ router.post('/create-ftp', async (req, res, next) => {
const body = req.body;
try {
const search = await GameInfo.findOne({
game_id: body.game_id,
deleted: false
});
if (!search) {
res.send({
errcode: 1,
errmsg: '游戏已删除或不存在!'
});
return;
}
const platforms = search.platforms;
for (let i = 0; i < platforms.length; i++) {
if (
platforms[i].platform.platform_id ===
body.platformInfo.platform.platform_id
) {
res.send({
errcode: 1,
errmsg: '平台已存在!'
});
return;
}
}
const save = await GameInfo.updateOne(
{
game_id: body.game_id,
deleted: false
},
{
$push: { platforms: body.platformInfo }
}
);
let token = '';
const loginRes = await axios({
url: config.minigame.api + 'gettoken/',
@ -303,6 +268,43 @@ router.post('/create-ftp', async (req, res, next) => {
const ftpStatus = ftpRes.status;
if (ftpStatus === 200) {
// 通知用户刷新页面等待ftp账号
const search = await GameInfo.findOne({
game_id: body.game_id,
deleted: false
});
if (!search) {
res.send({
errcode: 1,
errmsg: '游戏已删除或不存在!'
});
return;
}
const platforms = search.platforms;
for (let i = 0; i < platforms.length; i++) {
if (
platforms[i].platform.platform_id ===
body.platformInfo.platform.platform_id
) {
res.send({
errcode: 1,
errmsg: '平台已存在!'
});
return;
}
}
const save = await GameInfo.updateOne(
{
game_id: body.game_id,
deleted: false
},
{
$push: { platforms: body.platformInfo }
}
);
res.send({
errcode: 0,
msg: '正在创建ftp账号请等待一段时间后刷新页面'