添加ip归属地
This commit is contained in:
@@ -21,6 +21,7 @@ import { getExpByLv } from '../../../pubUtils/data';
|
||||
import { reportCreateRoleEventToTa, reportTAEvent, reportTAUserSet } from '../../../services/sdkService';
|
||||
import { saveLoginAndOutLog } from '../../../pubUtils/logUtil';
|
||||
import { sendMessageToAllWithSuc } from '../../../services/pushService';
|
||||
import { setIpLocation } from '../../../services/roleService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -63,6 +64,8 @@ export class EntryHandler {
|
||||
return resResult(STATUS.ROLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
setIpLocation(role.roleId, this.getIp(session));
|
||||
|
||||
let serverName = this.app.getServerId();
|
||||
await roleLogin(role.roleId, user.userCode, serverName, role.createTime, role.serverId, role.lv, role.topLineupCe); // 保存在线用户
|
||||
await this.addSession(user, role, session);
|
||||
|
||||
@@ -13,6 +13,9 @@ import { Figure } from '../domain/dbGeneral';
|
||||
import { pick } from 'underscore';
|
||||
import { Reward } from '../domain/battleField/pvp';
|
||||
import { CheckMeterial } from './role/checkMaterial';
|
||||
import IP2Region from "ip2region";
|
||||
const query = new IP2Region({ disableIpv6: true });
|
||||
|
||||
|
||||
export async function getTeraphStrengthenResult(role: RoleType, count: number, dicTeraph: DicTeraph, teraph: Teraph) {
|
||||
let criAttr: number[] = [], times = 0;
|
||||
@@ -288,4 +291,14 @@ export async function getSchoolPoint(roleId: string) {
|
||||
}
|
||||
return pre;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
export async function setIpLocation(roleId: string, ip: string) {
|
||||
try {
|
||||
const res = query.search(ip);
|
||||
console.log('##### setIpLocation', res)
|
||||
await RoleModel.updateRoleInfo(roleId, { ip, ipLocation: res.province||res.country })
|
||||
} catch(e) {
|
||||
console.error('setIpLocation', e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user