Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neo4jRelation
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qiuchaofei
neo4jRelation
Commits
7eeed456
Commit
7eeed456
authored
May 17, 2022
by
qiuchaofei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.日志信息添加ip地址
parent
a5ae1679
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
2 deletions
+74
-2
RelationalGraphController.java
...etadataRelation/controller/RelationalGraphController.java
+74
-2
No files found.
src/main/java/com/keymobile/metadata/metadataRelation/controller/RelationalGraphController.java
View file @
7eeed456
...
@@ -17,7 +17,12 @@ import org.springframework.security.core.userdetails.UserDetails;
...
@@ -17,7 +17,12 @@ import org.springframework.security.core.userdetails.UserDetails;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
...
@@ -242,7 +247,7 @@ public class RelationalGraphController {
...
@@ -242,7 +247,7 @@ public class RelationalGraphController {
@RequestMapping
(
path
=
"/getRelationTablesTableId"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/getRelationTablesTableId"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
List
<
ReturnNode
>>
getRelationTablesTableId
(
String
tableId
){
public
Map
<
String
,
List
<
ReturnNode
>>
getRelationTablesTableId
(
String
tableId
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LogManager
.
logInfo
(
LogConstants
.
CTX_RELATION
,
"
用户
"
+
getUserName
()
+
" 在 "
+
sdf
.
format
(
new
Date
())
+
" 查看了 "
+
tableId
+
"的全链分析"
);
LogManager
.
logInfo
(
LogConstants
.
CTX_RELATION
,
"
ip: "
+
getIp
()+
",用户:
"
+
getUserName
()
+
" 在 "
+
sdf
.
format
(
new
Date
())
+
" 查看了 "
+
tableId
+
"的全链分析"
);
Map
<
String
,
List
<
ReturnNode
>>
relationTables
=
new
HashMap
<>();
Map
<
String
,
List
<
ReturnNode
>>
relationTables
=
new
HashMap
<>();
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
...
@@ -261,6 +266,66 @@ public class RelationalGraphController {
...
@@ -261,6 +266,66 @@ public class RelationalGraphController {
return
relationTables
;
return
relationTables
;
}
}
private
String
getIp
(){
HttpServletRequest
request
=
getRequest
();
if
(
request
==
null
)
{
return
"127.0.0.1"
;
}
else
{
// return getIpAddr(request);
return
request
.
getRemoteHost
();
}
}
public
String
getIpAddr
(
HttpServletRequest
request
)
{
String
ipAddress
=
null
;
try
{
ipAddress
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getRemoteAddr
();
if
(
ipAddress
.
equals
(
"127.0.0.1"
))
{
// 根据网卡取本机配置的IP
InetAddress
inet
=
null
;
try
{
inet
=
InetAddress
.
getLocalHost
();
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
ipAddress
=
inet
.
getHostAddress
();
}
}
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if
(
ipAddress
!=
null
&&
ipAddress
.
length
()
>
15
)
{
// "***.***.***.***".length()
// = 15
if
(
ipAddress
.
indexOf
(
","
)
>
0
)
{
ipAddress
=
ipAddress
.
substring
(
0
,
ipAddress
.
indexOf
(
","
));
}
}
}
catch
(
Exception
e
)
{
ipAddress
=
""
;
}
// ipAddress = this.getRequest().getRemoteAddr();
return
ipAddress
;
}
//获取请求对象
public
static
HttpServletRequest
getRequest
()
{
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
==
null
)
{
return
null
;
}
else
{
return
requestAttributes
.
getRequest
();
}
}
private
String
getUserName
()
{
private
String
getUserName
()
{
Object
obj
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
Object
obj
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
if
(
obj
instanceof
String
)
{
if
(
obj
instanceof
String
)
{
...
@@ -275,13 +340,20 @@ public class RelationalGraphController {
...
@@ -275,13 +340,20 @@ public class RelationalGraphController {
return
username
;
return
username
;
}
}
@ApiOperation
(
tags
=
""
,
value
=
"获取IP地址"
)
@RequestMapping
(
path
=
"/getIp"
,
method
=
RequestMethod
.
GET
)
public
String
getIp
(
Integer
numbers
)
{
String
ip
=
getIp
();
System
.
out
.
println
(
"请求的ip是:"
+
ip
);
return
ip
;
}
//表的分析,关系分析--表与模型,表与质量,表与标准,表与作业的关系
//表的分析,关系分析--表与模型,表与质量,表与标准,表与作业的关系
@ApiOperation
(
tags
=
""
,
value
=
"传入表的id,返回与表相关的模型,标准,质量,资产,作业等对象"
)
@ApiOperation
(
tags
=
""
,
value
=
"传入表的id,返回与表相关的模型,标准,质量,资产,作业等对象"
)
@RequestMapping
(
path
=
"/getRelationObjectByTableId"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/getRelationObjectByTableId"
,
method
=
RequestMethod
.
GET
)
public
Map
<
String
,
List
<
ReturnNode
>>
getRelationObjectByTableId
(
String
tableId
){
public
Map
<
String
,
List
<
ReturnNode
>>
getRelationObjectByTableId
(
String
tableId
){
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
LogManager
.
logInfo
(
LogConstants
.
CTX_RELATION
,
"
用户
"
+
getUserName
()
+
" 在 "
+
sdf
.
format
(
new
Date
())
+
" 查看了 "
+
tableId
+
"的关系分析"
);
LogManager
.
logInfo
(
LogConstants
.
CTX_RELATION
,
"
ip: "
+
getIp
()+
",用户
"
+
getUserName
()
+
" 在 "
+
sdf
.
format
(
new
Date
())
+
" 查看了 "
+
tableId
+
"的关系分析"
);
long
start
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
Map
<
String
,
List
<
ReturnNode
>>
relationObjects
=
tableService
.
getRelationObjectByTableId
(
tableId
);
Map
<
String
,
List
<
ReturnNode
>>
relationObjects
=
tableService
.
getRelationObjectByTableId
(
tableId
);
...
...
Write
Preview
Markdown
is supported
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