添加ip归属地
This commit is contained in:
@@ -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