✨ feat(测试): 自动测试用删除账号接口
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
@@ -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: '请求超时' },
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user