Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
3095f373
Commit
3095f373
authored
May 11, 2020
by
ZhengJie
Browse files
[代码完善](v2.5): v2.5 beta ip归属地查询改为用太平洋IP地址查询接口
2.5 Beta 详情:
https://www.ydyno.com/archives/1225.html
parent
a51aeb60
Changes
9
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/aspect/LimitType.java
View file @
3095f373
...
@@ -23,5 +23,5 @@ public enum LimitType {
...
@@ -23,5 +23,5 @@ public enum LimitType {
// 默认
// 默认
CUSTOMER
,
CUSTOMER
,
// by ip addr
// by ip addr
IP
;
IP
}
}
eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java
View file @
3095f373
...
@@ -3,14 +3,13 @@ package me.zhengjie.base;
...
@@ -3,14 +3,13 @@ package me.zhengjie.base;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @
D
ate 2019年10月24日20:48:53
* @
d
ate 2019年10月24日20:48:53
*/
*/
@Getter
@Getter
@Setter
@Setter
...
...
eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java
View file @
3095f373
...
@@ -21,10 +21,9 @@ import org.springframework.stereotype.Component;
...
@@ -21,10 +21,9 @@ import org.springframework.stereotype.Component;
import
java.util.Optional
;
import
java.util.Optional
;
/**
/**
* @
描述
: 设置审计
* @
description
: 设置审计
* @author : Dong ZhaoYang
* @author : Dong ZhaoYang
* @日期 : 2019/10/28
* @date : 2019/10/28
* @时间 : 10:29
*/
*/
@Component
(
"auditorAware"
)
@Component
(
"auditorAware"
)
public
class
AuditorConfig
implements
AuditorAware
<
String
>
{
public
class
AuditorConfig
implements
AuditorAware
<
String
>
{
...
...
eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java
View file @
3095f373
...
@@ -153,7 +153,7 @@ public class RedisConfig extends CachingConfigurerSupport {
...
@@ -153,7 +153,7 @@ public class RedisConfig extends CachingConfigurerSupport {
*/
*/
class
FastJsonRedisSerializer
<
T
>
implements
RedisSerializer
<
T
>
{
class
FastJsonRedisSerializer
<
T
>
implements
RedisSerializer
<
T
>
{
private
Class
<
T
>
clazz
;
private
final
Class
<
T
>
clazz
;
FastJsonRedisSerializer
(
Class
<
T
>
clazz
)
{
FastJsonRedisSerializer
(
Class
<
T
>
clazz
)
{
super
();
super
();
...
...
eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
View file @
3095f373
...
@@ -22,11 +22,6 @@ package me.zhengjie.utils;
...
@@ -22,11 +22,6 @@ package me.zhengjie.utils;
*/
*/
public
class
ElAdminConstant
{
public
class
ElAdminConstant
{
/**
* 用于IP定位转换
*/
public
static
final
String
REGION
=
"内网IP|内网IP"
;
/**
/**
* win 系统
* win 系统
*/
*/
...
@@ -41,6 +36,9 @@ public class ElAdminConstant {
...
@@ -41,6 +36,9 @@ public class ElAdminConstant {
* 常用接口
* 常用接口
*/
*/
public
static
class
Url
{
public
static
class
Url
{
// 免费图床
public
static
final
String
SM_MS_URL
=
"https://sm.ms/api"
;
public
static
final
String
SM_MS_URL
=
"https://sm.ms/api"
;
// IP归属地查询
public
static
final
String
IP_URL
=
"http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true"
;
}
}
}
}
eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
View file @
3095f373
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
me.zhengjie.utils
;
package
me.zhengjie.utils
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.poi.excel.BigExcelWriter
;
import
cn.hutool.poi.excel.BigExcelWriter
;
...
@@ -23,7 +22,6 @@ import cn.hutool.poi.excel.ExcelUtil;
...
@@ -23,7 +22,6 @@ import cn.hutool.poi.excel.ExcelUtil;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
org.apache.poi.util.IOUtils
;
import
org.apache.poi.util.IOUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.activation.MimetypesFileTypeMap
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -126,26 +124,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -126,26 +124,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
return
resultSize
;
return
resultSize
;
}
}
/**
* inputStream 转 File
*/
static
File
inputStreamToFile
(
InputStream
ins
,
String
name
)
throws
Exception
{
File
file
=
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
)
+
File
.
separator
+
name
);
if
(
file
.
exists
())
{
return
file
;
}
OutputStream
os
=
new
FileOutputStream
(
file
);
int
bytesRead
;
int
len
=
8192
;
byte
[]
buffer
=
new
byte
[
len
];
while
((
bytesRead
=
ins
.
read
(
buffer
,
0
,
len
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
bytesRead
);
}
os
.
close
();
ins
.
close
();
return
file
;
}
/**
/**
* 将文件名解析成文件的上传路径
* 将文件名解析成文件的上传路径
*/
*/
...
@@ -173,16 +151,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -173,16 +151,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
return
null
;
return
null
;
}
}
public
static
String
fileToBase64
(
File
file
)
throws
Exception
{
FileInputStream
inputFile
=
new
FileInputStream
(
file
);
String
base64
;
byte
[]
buffer
=
new
byte
[(
int
)
file
.
length
()];
inputFile
.
read
(
buffer
);
inputFile
.
close
();
base64
=
Base64
.
encode
(
buffer
);
return
base64
.
replaceAll
(
"[\\s*\t\n\r]"
,
""
);
}
/**
/**
* 导出excel
* 导出excel
*/
*/
...
@@ -222,11 +190,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -222,11 +190,6 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
}
}
}
public
static
String
getFileTypeByMimeType
(
String
type
)
{
String
mimeType
=
new
MimetypesFileTypeMap
().
getContentType
(
"."
+
type
);
return
mimeType
.
split
(
"/"
)[
0
];
}
public
static
void
checkSize
(
long
maxSize
,
long
size
)
{
public
static
void
checkSize
(
long
maxSize
,
long
size
)
{
// 1M
// 1M
int
len
=
1024
*
1024
;
int
len
=
1024
*
1024
;
...
...
eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java
View file @
3095f373
...
@@ -15,16 +15,12 @@
...
@@ -15,16 +15,12 @@
*/
*/
package
me.zhengjie.utils
;
package
me.zhengjie.utils
;
import
cn.hutool.core.io.resource.ClassPathResource
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
eu.bitwalker.useragentutils.Browser
;
import
eu.bitwalker.useragentutils.Browser
;
import
eu.bitwalker.useragentutils.UserAgent
;
import
eu.bitwalker.useragentutils.UserAgent
;
import
org.lionsoul.ip2region.DataBlock
;
import
org.lionsoul.ip2region.DbConfig
;
import
org.lionsoul.ip2region.DbSearcher
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.net.UnknownHostException
;
import
java.util.Calendar
;
import
java.util.Calendar
;
...
@@ -159,35 +155,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
...
@@ -159,35 +155,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* 根据ip获取详细地址
* 根据ip获取详细地址
*/
*/
public
static
String
getCityInfo
(
String
ip
)
{
public
static
String
getCityInfo
(
String
ip
)
{
DbSearcher
searcher
=
null
;
String
api
=
String
.
format
(
ElAdminConstant
.
Url
.
IP_URL
,
ip
);
try
{
JSONObject
object
=
JSONUtil
.
parseObj
(
HttpUtil
.
get
(
api
));
String
path
=
"ip2region/ip2region.db"
;
return
object
.
get
(
"addr"
,
String
.
class
);
String
name
=
"ip2region.db"
;
DbConfig
config
=
new
DbConfig
();
File
file
=
FileUtil
.
inputStreamToFile
(
new
ClassPathResource
(
path
).
getStream
(),
name
);
searcher
=
new
DbSearcher
(
config
,
file
.
getPath
());
Method
method
;
method
=
searcher
.
getClass
().
getMethod
(
"btreeSearch"
,
String
.
class
);
DataBlock
dataBlock
;
dataBlock
=
(
DataBlock
)
method
.
invoke
(
searcher
,
ip
);
String
address
=
dataBlock
.
getRegion
().
replace
(
"0|"
,
""
);
char
symbol
=
'|'
;
if
(
address
.
charAt
(
address
.
length
()-
1
)
==
symbol
){
address
=
address
.
substring
(
0
,
address
.
length
()
-
1
);
}
return
address
.
equals
(
ElAdminConstant
.
REGION
)?
"内网IP"
:
address
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
searcher
!=
null
){
try
{
searcher
.
close
();
}
catch
(
IOException
ignored
)
{
}
}
}
return
""
;
}
}
public
static
String
getBrowser
(
HttpServletRequest
request
){
public
static
String
getBrowser
(
HttpServletRequest
request
){
...
...
eladmin-system/src/main/resources/ip2region/ip2region.db
deleted
100644 → 0
View file @
a51aeb60
File deleted
pom.xml
View file @
3095f373
...
@@ -140,12 +140,6 @@
...
@@ -140,12 +140,6 @@
<optional>
true
</optional>
<optional>
true
</optional>
</dependency>
</dependency>
<!--https://gitee.com/lionsoul/ip2region/tree/v1.4-release/-->
<dependency>
<groupId>
org.lionsoul
</groupId>
<artifactId>
ip2region
</artifactId>
<version>
1.7.2
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<artifactId>
poi
</artifactId>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment