添加ip归属地

This commit is contained in:
luying
2022-08-04 13:38:43 +08:00
parent b83d9db979
commit d656d12a74
9 changed files with 35 additions and 2 deletions
+13
View File
@@ -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)
}
}