最低版本号

This commit is contained in:
luying
2022-04-25 20:54:37 +08:00
parent 76820cda0a
commit 5c64b3b2d1
5 changed files with 19 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { CLIENT_VERSION, STATUS } from '@consts';
import { STATUS } from '@consts';
import { GameModel } from '@db/Game';
import { Controller } from 'egg';
import { RoleModel } from '@db/Role';
@@ -9,18 +9,24 @@ import { ServerlistModel } from '@db/Serverlist';
import { dispatch } from 'app/pubUtils/dispatcher';
import { RedisClient } from 'redis';
import { REDIS_KEY } from '@consts';
import { RegionModel } from '@db/Region';
import { resResult } from 'app/pubUtils/util';
export default class GameController extends Controller {
public async checkVersion() {
const { ctx } = this;
const { version } = ctx.request.body;
if (version >= CLIENT_VERSION) {
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
if(!curRegion) return resResult(STATUS.VERSION_ERR);
if (version >= curRegion.versionCode) {
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS);
return;
}
//版本号太低
ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR, { version: CLIENT_VERSION });
ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR, { version: curRegion.versionCode });
return;
}