admin
2023-04-12 f06a592dd1a7e995bf313ccb5efe7dff73ccfc4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
    }
 
}