Merge remote-tracking branch 'origin/main'

main
wangqing 10 months ago
commit f4a3acd769

@ -1,17 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.luoo</groupId> <modelVersion>4.0.0</modelVersion>
<artifactId>luoo_parent</artifactId> <parent>
<version>1.0-SNAPSHOT</version> <groupId>com.luoo</groupId>
</parent> <artifactId>luoo_parent</artifactId>
<artifactId>luoo_user</artifactId> <version>1.0-SNAPSHOT</version>
<dependencies> </parent>
<dependency> <artifactId>luoo_user</artifactId>
<groupId>org.springframework.boot</groupId> <dependencies>
<artifactId>spring-boot-starter-data-mongodb</artifactId> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<dependency> <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
@ -19,48 +21,48 @@
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.luoo</groupId> <groupId>com.luoo</groupId>
<artifactId>luoo_common</artifactId> <artifactId>luoo_common</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId> <artifactId>spring-cloud-starter-config</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId> <artifactId>spring-cloud-bus</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId> <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<optional>true</optional> <optional>true</optional>
@ -71,35 +73,39 @@
<version>1.0.21</version> <version>1.0.21</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>software.amazon.awssdk</groupId>-->
<!-- <artifactId>s3</artifactId>-->
<!-- <version>2.20.29</version>-->
<!-- </dependency>-->
<!-- amazon s3 --> <!-- <dependency>-->
<dependency> <!-- <groupId>software.amazon.awssdk</groupId>-->
<groupId>software.amazon.awssdk</groupId> <!-- <artifactId>s3</artifactId>-->
<artifactId>s3</artifactId> <!-- <version>2.20.29</version>-->
</dependency> <!-- </dependency>-->
<dependency> <!-- amazon s3 -->
<groupId>com.aliyun</groupId> <dependency>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId> <groupId>software.amazon.awssdk</groupId>
<version>1.0.0</version> <artifactId>s3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.5</version>
</dependency>
</dependencies> <dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build> <build>
<finalName>app</finalName> <finalName>app</finalName>
<plugins> <plugins>
@ -107,15 +113,18 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
<!-- docker的maven插件官网 https://github.com/spotify/docker-maven-plugin --> <!-- docker的maven插件官网
https://github.com/spotify/docker-maven-plugin -->
<plugin> <plugin>
<groupId>com.spotify</groupId> <groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId> <artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version> <version>0.4.13</version>
<configuration> <configuration>
<imageName>116.62.145.60:5000/${project.artifactId}:${project.version}</imageName> <imageName>
116.62.145.60:5000/${project.artifactId}:${project.version}</imageName>
<baseImage>jdk1.8</baseImage> <baseImage>jdk1.8</baseImage>
<entryPoint>["java", "-jar","/${project.build.finalName}.jar"]</entryPoint> <entryPoint>["java",
"-jar","/${project.build.finalName}.jar"]</entryPoint>
<resources> <resources>
<resource> <resource>
<targetPath>/</targetPath> <targetPath>/</targetPath>

@ -1,7 +1,30 @@
package com.luoo.user.util; package com.luoo.user.util;
import java.io.InputStream;
import org.lionsoul.ip2region.xdb.Searcher;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;
public class IpUtil { public class IpUtil {
private static final String IP2REGION_DB_FILE_PATH = "ip2region.xdb";
private static final String UNKNOW_IP = "未知IP";
private static final Searcher searcher = initSearcher();
private static Searcher initSearcher() {
try (InputStream is = new ClassPathResource(IP2REGION_DB_FILE_PATH).getInputStream();) {
byte[] cBuff = StreamUtils.copyToByteArray(is);// Searcher.loadContent(randomAccessFile);
return Searcher.newWithBuffer(cBuff);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String getIpLocation(String ip) { public static String getIpLocation(String ip) {
return "中国"; try {
return searcher.search(ip).split("\\|")[2].replaceFirst("省", "");
} catch (Exception e) {
return UNKNOW_IP;
}
} }
} }

@ -0,0 +1,15 @@
package com.luoo.user.util;
import static org.junit.Assert.*;
import org.junit.Test;
public class IpUtilTest {
@Test
public void test() {
String ip="121.8.215.106";
System.out.println(IpUtil.getIpLocation(ip));
}
}
Loading…
Cancel
Save