diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index a40a2da46..e873f62be 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -10,6 +10,8 @@ export const TEL_ENCRYPT_KEY = 'fiqaxijabbantusm'; export const DEBUG_MAGIC_WORD = 'zyz666server518'; +export const CLIENT_VERSION = 1;//客户端最低版本号 + export const AUTH_SMS_CNT_PER_DAY = 8; export const ADULT_AGE = 18; diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 757958964..77b060be9 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -8,6 +8,7 @@ export const STATUS = { LOGIN_ERR: { code: 5, simStr: '检测到您的账号异地登录,已被迫下线' }, REDLOCK_ERR: { code: 6, simStr: 'redlock错误' }, SERVER_MAINTENANCE: { code: 7, simStr: '服务器维护中' }, + VERSION_ERR: { code: 8, simStr: '版本号太低,请更新' }, GLOBAL_ERR: { code: 1003, simStr: '服务器内部错误' }, // 账号相关状态 10000 - 19999 @@ -337,7 +338,7 @@ export const STATUS = { GACHA_VISITED_COUNT_OVER: { code: 31107, simStr: '今天武将拜访已超过次数' }, // 礼包码 31201-31300 - GIFT_CODE_USED_NUM_MAX: { code: 31201, simStr: '礼包码使用次数超过' }, + GIFT_CODE_USED_NUM_MAX: { code: 31201, simStr: '礼包码使用次数超过' }, YOU_HAVE_USED_THIS_CODE: { code: 31202, simStr: '您已使用过该码' }, GIFT_CODE_NOT_START: { code: 31203, simStr: '礼包码未生效' }, GIFT_CODE_HAS_EXPIRED: { code: 31204, simStr: '礼包码已失效' }, diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index af3ab1d5f..b98940984 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -1,4 +1,4 @@ -import { STATUS } from '@consts'; +import { CLIENT_VERSION, STATUS } from '@consts'; import { GameModel } from '@db/Game'; import { Controller } from 'egg'; import { RoleModel } from '@db/Role'; @@ -9,31 +9,42 @@ import { ServerlistModel } from '@db/Serverlist'; export default class GameController extends Controller { + public async checkVersion() { + const { ctx } = this; + const { version } = ctx.request.body; + if (version < CLIENT_VERSION) {//版本号太低 + ctx.body = ctx.service.utils.resResult(STATUS.VERSION_ERR, { version: CLIENT_VERSION }); + return; + } + ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS); + return; + } + public async getServerList() { const { ctx } = this; - let { serverType, auth, uid } = ctx; - + let { serverType, auth, uid, clientVersion } = ctx; + console.log('clientVersion', clientVersion); let serverList = new Array(); let loginServerList = new Array(); - let allServers = await ServerlistModel.findByServerType(auth == 1? null: serverType); + let allServers = await ServerlistModel.findByServerType(auth == 1 ? null : serverType); let roles = await RoleModel.findAllByUid(uid, true, true); - for(let server of allServers) { + for (let server of allServers) { let curGroup = serverList.find(cur => cur.groupId == server.groupId); - if(!curGroup) { + if (!curGroup) { curGroup = new GroupParam(server); serverList.push(curGroup); } curGroup.pushServer(server); let role = roles.find(role => role.serverId == server.id); - if(!!role) { + if (!!role) { let curLoginInfo = new ServerParamWithRole(role, server); loginServerList.push(curLoginInfo); } } - loginServerList.sort((a, b) => { return b.updatedAt.getTime() - a.updatedAt.getTime()}); + loginServerList.sort((a, b) => { return b.updatedAt.getTime() - a.updatedAt.getTime() }); if (serverList && serverList.length > 0) { ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { serverList, loginServerList }); @@ -69,14 +80,14 @@ export default class GameController extends Controller { let notice = await NoticeModel.getAllNotice(serverType); let result = notice.map(cur => { - let {id, title, tag, type, content, time} = cur; + let { id, title, tag, type, content, time } = cur; return { id, title, tag, type, content, time } }) ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { notice: result }); - return + return } @@ -84,11 +95,11 @@ export default class GameController extends Controller { const { ctx } = this; try { - + reloadResources(); ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: true }); return; - } catch(e) { + } catch (e) { ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isOK: false, err: e.stack }); return; } diff --git a/web-server/app/router.ts b/web-server/app/router.ts index cc7ce9d4e..8f30d64e4 100644 --- a/web-server/app/router.ts +++ b/web-server/app/router.ts @@ -16,6 +16,7 @@ export default (app: Application) => { router.post('/user/createrole', tokenParser, checkMainten, controller.account.createRole); router.post('/user/bind', tokenParser, controller.account.bind); router.post('/user/authentication', tokenParser, controller.account.authentication); + router.post('/user/checkversion', tokenParser, controller.game.checkVersion); router.post('/game/getserverlist', tokenParser, controller.game.getServerList); router.post('/game/getnotice', tokenParser, controller.game.getnotice); router.post('/web/reloadresource', app.middleware.gmTokenParser(), controller.game.reloadResource);