diff --git a/game-server/app/services/utilService.ts b/game-server/app/services/utilService.ts index 507788d20..5bd26e267 100644 --- a/game-server/app/services/utilService.ts +++ b/game-server/app/services/utilService.ts @@ -1,6 +1,6 @@ import { pinus } from "pinus"; +import { isDevelopEnv as pubIsDevelopEnv } from '../pubUtils/util'; export function isDevelopEnv() { - const envs = ['development', 'monitor', 'alpha', 'dev']; - return envs.indexOf(pinus.app.get('env')) != -1; + return pubIsDevelopEnv(pinus.app.get('env')); } \ No newline at end of file diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index a8f912cda..a6474d368 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -23,6 +23,7 @@ export const STATUS = { GLOBAL_ERR: { code: 1003, simStr: '服务器内部错误' }, UPDATE_INFO_ERR: {code: 1004, simStr: '热更新配置错误'}, DEBUG_FUNCTION_ERR: {code: 1005, simStr: '功能逻辑已改,debug接口不再提供'}, + DEVELOP_ONLY: {code: 1006, simStr: '只有测试环境才可以使用该接口'}, // http请求 REQUEST_TIME_OUT: { code: 2000, simStr: '请求超时' }, diff --git a/shared/pubUtils/roleUtil.ts b/shared/pubUtils/roleUtil.ts index 12ebf005f..b9441090d 100644 --- a/shared/pubUtils/roleUtil.ts +++ b/shared/pubUtils/roleUtil.ts @@ -207,13 +207,13 @@ export async function deletRole(roleId: string) { await WishPoolReportModel.deleteMany({ dntRoleId: roleId}); await RoleCeModel.deleteMany({ roleId }); await LadderMatchModel.deleteMany({ roleId }); + } let doc = new RoleModel(); const update = Object.assign(doc.toJSON(), pick(role, ['serverType', 'userInfo', 'seqId', 'serverId']), { roleName: role.roleId }); delete update._id; await RoleModel.updateMany({ roleId }, { $set: update }); - } return true; } diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index d29ad9b46..ad2ceb517 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -806,4 +806,9 @@ export function getGachaRemainFloor(gachaId: number, userFloor: Floor[]) { } } return 0 +} + +export function isDevelopEnv(env: string) { + const envs = ['development', 'monitor', 'alpha', 'dev']; + return envs.indexOf(env) != -1; } \ No newline at end of file diff --git a/web-server/app/controller/account.ts b/web-server/app/controller/account.ts index 2f68f8127..d3775a5d6 100644 --- a/web-server/app/controller/account.ts +++ b/web-server/app/controller/account.ts @@ -66,4 +66,10 @@ export default class AccountController extends Controller { const { ctx } = this; ctx.body = await ctx.service.auth.channelLogin(ctx.request.body); } + + public async deleteRole() { + const { ctx } = this; + const { roleId, magicWord } = ctx.request.body; + ctx.body = await ctx.service.auth.deleteRole(roleId, magicWord); + } } diff --git a/web-server/app/router.ts b/web-server/app/router.ts index 9446fc063..3fa3d76aa 100644 --- a/web-server/app/router.ts +++ b/web-server/app/router.ts @@ -22,6 +22,7 @@ export default (app: Application) => { router.post('/user/authentication', tokenParser, controller.account.authentication); router.post('/user/checkversion', tokenParser, controller.game.checkVersion); router.post('/user/checkv', tokenParser, controller.game.checkVersion); // 增加一个接口,规避 iOS 敏感词 + router.post('/user/deleterole', controller.account.deleteRole); router.post('/game/getserverlist', tokenParser, controller.game.getServerList); router.post('/game/getnotice', tokenParser, controller.game.getnotice); router.post('/gate/queryenter', tokenParser, controller.game.queryEnter); diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index 8b242fe23..2af4f7e49 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -1,5 +1,5 @@ -import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, BLOCK_TYPE } from '@consts'; +import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, BLOCK_TYPE, DEBUG_MAGIC_WORD } from '@consts'; import { RoleModel, WarStar } from '@db/Role'; import { UserModel, UserType } from '@db/User'; import { STATUS, GET_SMS_TYPE, ADDICTION_PREVENTION_CODE } from '@consts'; @@ -9,14 +9,15 @@ import Counter from '@db/Counter'; import { gameData, getExpByLv } from '../pubUtils/data'; import { isString } from 'underscore'; import { getAge, nowSeconds } from '../pubUtils/timeUtil'; -import { resResult } from '../pubUtils/util'; +import { isDevelopEnv, resResult } from '../pubUtils/util'; import { checkTeeanAgerTime } from '../pubUtils/authenticateUtil'; // import { authenticate } from '../pubUtils/httpUtil'; import { getChannelId, loginValidata } from '../pubUtils/sdkUtil'; import { LoginValidateData37 } from 'app/domain/sdk'; import { ServerlistModel } from '@db/Serverlist'; -import { DicWar } from 'app/pubUtils/dictionary/DicWar'; +import { DicWar } from '../pubUtils/dictionary/DicWar'; import { RScriptRecordModel } from '@db/RScriptRecord'; +import { deletRole } from '../pubUtils/roleUtil'; /** * Test Service @@ -465,4 +466,19 @@ export default class Auth extends Service { }); } + + public async deleteRole(roleId: string, magicWord: string) { + console.log('enter Auth deleteRole'); + const ctx = this.ctx; + if(magicWord != DEBUG_MAGIC_WORD) { + return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + } + if(!isDevelopEnv(ctx.app.config.realEnv)) { + return ctx.service.utils.resResult(STATUS.DEVELOP_ONLY); + } + let result = await deletRole(roleId); + if(!result) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + return ctx.service.utils.resResult(STATUS.SUCCESS); + } + }