测试:增加一个测试用接口;修改 config.json 中的默认环境

This commit is contained in:
liangtongchuan
2021-05-19 11:30:43 +08:00
parent 05b95bef87
commit de33a02525
3 changed files with 27 additions and 3 deletions

View File

@@ -263,4 +263,23 @@ export class EntryHandler {
const token = await UserModel.findTokenByTel(tel);
return resResult(STATUS.SUCCESS, { token });
}
/**
* ! 仅用于测试
* @description 测试接口,用于查询和返回 token
* @param {{ seqId: string, magicWord: string }} msg 要查询的手机号;需要验证的密码
* @param {FrontendSession} session
* @returns
* @memberof EntryHandler
*/
async debugQueryTokenById(msg: { uid: number, magicWord: string }, session: FrontendSession) {
const { uid, magicWord } = msg;
console.log('debugQueryTokenById msg:', msg);
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
const user = await UserModel.findTokenByUid(uid);
console.log('debugQueryTokenById got user:', user);
return resResult(STATUS.SUCCESS, { user });
}
}

View File

@@ -1 +1 @@
{"env":"dev"}
{"env":"development"}

View File

@@ -182,8 +182,13 @@ export default class User extends BaseModel {
public static async findTokenByTel(tel: string) {
const { token } = await UserModel.findOne({ tel }).select('token').lean({ getters: true });
return token;
const user: UserType = await UserModel.findOne({ tel }).lean();
return user.token;
}
public static async findTokenByUid(uid: number) {
const user: UserType = await UserModel.findOne({ uid }).lean();
return user ? user.token : null;
}
public static async findUserByTel(tel: string) {