package com.yeshi.buwan.service.manager;
|
|
import com.yeshi.buwan.util.IPUtil;
|
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.stereotype.Component;
|
|
@Component
|
public class IPManager {
|
|
@Cacheable(value = "ipCache", key = "'getIPInfo-'+#ip")
|
public IPUtil.IPInfo getIPInfo(String ip) throws Exception {
|
IPUtil.IPInfo ipInfo = IPUtil.getLocalIPInfo(ip);
|
if (ipInfo == null) {
|
throw new Exception("获取IP信息失败");
|
}
|
return ipInfo;
|
}
|
|
}
|