diff --git a/src/controllers/games/games.js b/src/controllers/games/games.js index c27097e..d2ea7d0 100644 --- a/src/controllers/games/games.js +++ b/src/controllers/games/games.js @@ -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账号,请等待一段时间后刷新页面!'