Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
C
chinafrica
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
chinafrica
Commits
99dec99f
提交
99dec99f
authored
1月 14, 2021
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
用户区分注册国家
上级
0aeac2a4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
76 行增加
和
4 行删除
+76
-4
uploadController.java
...in/java/com/platform/controller/api/uploadController.java
+64
-4
TbCfUserInfoEntity.java
...src/main/java/com/platform/entity/TbCfUserInfoEntity.java
+10
-0
TbCfUserInfoDao.xml
...n/src/main/resources/com/platform/dao/TbCfUserInfoDao.xml
+1
-0
tbcfuserinfo.js
platform-admin/src/main/webapp/js/sys/tbcfuserinfo.js
+1
-0
没有找到文件。
platform-admin/src/main/java/com/platform/controller/api/uploadController.java
浏览文件 @
99dec99f
...
...
@@ -4,15 +4,17 @@ import com.platform.annotation.IgnoreAuth;
import
com.platform.entity.BASE64DecodedMultipartFile
;
import
com.platform.utils.OssUtil
;
import
com.platform.utils.R
;
import
com.platform.utils.util.HttpUtils
;
import
com.platform.utils.util.UuidUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.File
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.Map
;
/**
...
...
@@ -24,6 +26,10 @@ import java.util.Map;
@RequestMapping
(
value
=
"/api/upload"
,
produces
=
"application/json;charset=UTF-8"
)
public
class
uploadController
{
public
static
final
String
LOCAL_IP
=
"127.0.0.1"
;
//本地ip地址
public
static
final
String
DEFAULT_IP
=
"0:0:0:0:0:0:0:1"
;
//默认ip地址
public
static
final
int
DEFAULT_IP_LENGTH
=
15
;
//默认ip地址长度
@IgnoreAuth
@ResponseBody
@RequestMapping
(
value
=
"/uploadFile"
,
produces
=
"application/json;charset=UTF-8"
)
...
...
@@ -65,6 +71,60 @@ public class uploadController {
return
R
.
error
().
put
(
"fail"
,
"删除失败"
);
}
}
@IgnoreAuth
@GetMapping
(
"/getRealIp"
)
@ResponseBody
public
R
getRealIp
(
HttpServletRequest
request
)
{
String
ip
=
this
.
getRealIpAddress
(
request
);
return
R
.
ok
().
put
(
"ip"
,
ip
);
}
/**
* 获取合法ip地址
* @param request
* @return
*/
public
static
String
getRealIpAddress
(
HttpServletRequest
request
)
{
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
//squid 服务代理
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
//apache服务代理
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
//weblogic 代理
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"HTTP_CLIENT_IP"
);
//有些代理
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"X-Real-IP"
);
//nginx代理
}
/*
* 如果此时还是获取不到ip地址,那么最后就使用request.getRemoteAddr()来获取
* */
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
if
(
StringUtils
.
equals
(
ip
,
LOCAL_IP
)
||
StringUtils
.
equals
(
ip
,
DEFAULT_IP
))
{
//根据网卡取本机配置的IP
InetAddress
iNet
=
null
;
try
{
iNet
=
InetAddress
.
getLocalHost
();
}
catch
(
UnknownHostException
e
)
{
}
ip
=
iNet
.
getHostAddress
();
}
}
//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
//"***.***.***.***".length() = 15
if
(!
StringUtils
.
isEmpty
(
ip
)
&&
ip
.
length
()>
DEFAULT_IP_LENGTH
){
if
(
ip
.
indexOf
(
","
)
>
0
){
ip
=
ip
.
substring
(
0
,
ip
.
indexOf
(
","
));
}
}
return
ip
;
}
//
// @IgnoreAuth
// @ResponseBody
...
...
platform-admin/src/main/java/com/platform/entity/TbCfUserInfoEntity.java
浏览文件 @
99dec99f
...
...
@@ -101,6 +101,16 @@ public class TbCfUserInfoEntity implements Serializable {
*/
private
Integer
emailFlag
;
private
String
country
;
public
String
getCountry
()
{
return
country
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
Integer
getSource
()
{
return
source
;
}
...
...
platform-admin/src/main/resources/com/platform/dao/TbCfUserInfoDao.xml
浏览文件 @
99dec99f
...
...
@@ -25,6 +25,7 @@
<result
property=
"invitedCount"
column=
"invited_count"
/>
<result
property=
"enableFlag"
column=
"enable_flag"
/>
<result
property=
"emailFlag"
column=
"email_flag"
/>
<result
property=
"country"
column=
"country"
/>
</resultMap>
<select
id=
"queryObject"
resultType=
"com.platform.entity.TbCfUserInfoEntity"
>
...
...
platform-admin/src/main/webapp/js/sys/tbcfuserinfo.js
浏览文件 @
99dec99f
...
...
@@ -6,6 +6,7 @@ $(function () {
{
label
:
'用户编号'
,
name
:
'userNo'
,
index
:
'user_no'
,
width
:
160
},
{
label
:
'用户类型'
,
name
:
'userType'
,
index
:
'user_type'
,
width
:
80
,
formatter
:
userTypeFormat
},
{
label
:
'账号'
,
name
:
'account'
,
index
:
'account'
,
width
:
120
},
{
label
:
'国家'
,
name
:
'country'
,
index
:
'country'
,
width
:
100
},
{
label
:
'注册来源'
,
name
:
'source'
,
index
:
'source'
,
width
:
60
,
formatter
:
signTypeFormat
},
{
label
:
'用户头像地址'
,
name
:
'avatar'
,
index
:
'avatar'
,
width
:
100
,
formatter
:
imageFormat
},
{
label
:
'用户名'
,
name
:
'nick'
,
index
:
'nick'
,
width
:
80
},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论