commit
f4f909eda8
@ -0,0 +1,2 @@
|
|||||||
|
# 解析IP三方库
|
||||||
|
https://github.com/jarod/qqwry-java
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.luoo.comment.config;
|
||||||
|
|
||||||
|
import org.springframework.context.ResourceLoaderAware;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MyConfiguration implements ResourceLoaderAware {
|
||||||
|
private ResourceLoader resourceLoader;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||||
|
this.resourceLoader = resourceLoader;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.luoo.comment.enums;
|
||||||
|
|
||||||
|
public enum Province {
|
||||||
|
BEIJING("Beijing", "北京"),
|
||||||
|
TIANJIN("Tianjin", "天津"),
|
||||||
|
SHANGHAI("Shanghai", "上海"),
|
||||||
|
CHONGQING("Chongqing", "重庆"),
|
||||||
|
HEBEI("Hebei", "河北"),
|
||||||
|
SHANXI("Shanxi", "山西"),
|
||||||
|
LIAONING("Liaoning", "辽宁"),
|
||||||
|
JILIN("Jilin", "吉林"),
|
||||||
|
HEILONGJIANG("Heilongjiang", "黑龙江"),
|
||||||
|
JIANGSU("Jiangsu", "江苏"),
|
||||||
|
ZHEJIANG("Zhejiang", "浙江"),
|
||||||
|
ANHUI("Anhui", "安徽"),
|
||||||
|
FUJIAN("Fujian", "福建"),
|
||||||
|
JIANGXI("Jiangxi", "江西"),
|
||||||
|
SHANDONG("Shandong", "山东"),
|
||||||
|
HENAN("Henan", "河南"),
|
||||||
|
HUBEI("Hubei", "湖北"),
|
||||||
|
HUNAN("Hunan", "湖南"),
|
||||||
|
GUANGDONG("Guangdong", "广东"),
|
||||||
|
GUANGXI("Guangxi", "广西"),
|
||||||
|
HAINAN("Hainan", "海南"),
|
||||||
|
SICHUAN("Sichuan", "四川"),
|
||||||
|
GUIZHOU("Guizhou", "贵州"),
|
||||||
|
YUNNAN("Yunnan", "云南"),
|
||||||
|
TIBET("Tibet", "西藏"),
|
||||||
|
SHAANXI("Shaanxi", "陕西"),
|
||||||
|
GANSU("Gansu", "甘肃"),
|
||||||
|
QINGHAI("Qinghai", "青海"),
|
||||||
|
NINGXIA("Ningxia", "宁夏"),
|
||||||
|
XINJIANG("Xinjiang", "新疆");
|
||||||
|
|
||||||
|
private final String englishName;
|
||||||
|
private final String chineseName;
|
||||||
|
|
||||||
|
Province(String englishName, String chineseName) {
|
||||||
|
this.englishName = englishName;
|
||||||
|
this.chineseName = chineseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEnglishName() {
|
||||||
|
return englishName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChineseName() {
|
||||||
|
return chineseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCityName(String englishName) {
|
||||||
|
for (Province province : Province.values()) {
|
||||||
|
if (englishName.equalsIgnoreCase(province.englishName)) {
|
||||||
|
return province.chineseName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "未知IP";
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue