Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
sentinel
Project
Project
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
曲欣亮
sentinel
Commits
183f9bd4
Commit
183f9bd4
authored
Mar 18, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
52092ba6
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
88 additions
and
9 deletions
+88
-9
LogService.java
src/main/java/com/egolm/film/api/service/LogService.java
+1
-1
LogServiceImpl.java
.../java/com/egolm/film/api/service/impl/LogServiceImpl.java
+3
-1
Fc_logs_error.java
src/main/java/com/egolm/film/bean/Fc_logs_error.java
+11
-0
Fc_member_film.java
src/main/java/com/egolm/film/bean/Fc_member_film.java
+1
-1
Fc_member_film_ext.java
src/main/java/com/egolm/film/bean/Fc_member_film_ext.java
+4
-4
Fc_review_record_ext.java
src/main/java/com/egolm/film/bean/Fc_review_record_ext.java
+1
-1
ExceptionHandler.java
src/main/java/com/egolm/film/config/ExceptionHandler.java
+1
-1
WebMvcConfig.java
src/main/java/com/egolm/film/config/WebMvcConfig.java
+5
-0
LogInterceptor.java
...ava/com/egolm/film/config/interceptor/LogInterceptor.java
+61
-0
No files found.
src/main/java/com/egolm/film/api/service/LogService.java
View file @
183f9bd4
...
...
@@ -9,7 +9,7 @@ public interface LogService {
List
<
Map
<
String
,
Object
>>
queryLogList
(
String
type
,
String
username
,
Page
page
);
void
saveErrorLog
(
String
path
,
Throwable
ex
);
void
saveErrorLog
(
String
path
,
Object
params
,
Throwable
ex
);
List
<
Map
<
String
,
Object
>>
queryErrorList
(
Page
page
);
...
...
src/main/java/com/egolm/film/api/service/impl/LogServiceImpl.java
View file @
183f9bd4
...
...
@@ -7,6 +7,7 @@ import java.util.Map;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.jdbc.Page
;
...
...
@@ -29,10 +30,11 @@ public class LogServiceImpl implements LogService {
}
@Override
public
void
saveErrorLog
(
String
path
,
Throwable
ex
)
{
public
void
saveErrorLog
(
String
path
,
Object
params
,
Throwable
ex
)
{
Fc_logs_error
error
=
new
Fc_logs_error
();
error
.
setTitle
(
ex
.
getMessage
());
error
.
setPath
(
path
);
error
.
setParams
(
JSON
.
toJSONString
(
params
));
error
.
setError
(
this
.
toStackString
(
ex
).
toString
());
error
.
setCreate_time
(
new
Date
());
jdbcTemplate
.
save
(
error
);
...
...
src/main/java/com/egolm/film/bean/Fc_logs_error.java
View file @
183f9bd4
...
...
@@ -20,6 +20,9 @@ public class Fc_logs_error implements java.io.Serializable {
@Column
(
columnDefinition
=
"varchar(255)"
)
private
String
path
;
@Column
(
columnDefinition
=
"text"
)
private
String
params
;
@Column
(
columnDefinition
=
"text"
)
private
String
title
;
...
...
@@ -46,6 +49,14 @@ public class Fc_logs_error implements java.io.Serializable {
return
path
;
}
public
void
setParams
(
String
params
)
{
this
.
params
=
params
;
}
public
String
getParams
()
{
return
params
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
...
...
src/main/java/com/egolm/film/bean/Fc_member_film.java
View file @
183f9bd4
src/main/java/com/egolm/film/bean/Fc_member_film_ext.java
View file @
183f9bd4
...
...
@@ -15,10 +15,10 @@ public class Fc_member_film_ext implements java.io.Serializable {
@Column
(
columnDefinition
=
"int(11) COMMENT '影片ID'"
)
private
Integer
id
;
@Column
(
columnDefinition
=
"
varchar(255)
COMMENT '影片简介中文'"
)
@Column
(
columnDefinition
=
"
text
COMMENT '影片简介中文'"
)
private
String
synopsis_cn
;
@Column
(
columnDefinition
=
"
varchar(255)
COMMENT '影片简介英文'"
)
@Column
(
columnDefinition
=
"
text
COMMENT '影片简介英文'"
)
private
String
synopsis_en
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '导演中文名'"
)
...
...
@@ -27,10 +27,10 @@ public class Fc_member_film_ext implements java.io.Serializable {
@Column
(
columnDefinition
=
"varchar(255) COMMENT '导演英文名'"
)
private
String
director_en
;
@Column
(
columnDefinition
=
"
varchar(255)
COMMENT '导演中文简介'"
)
@Column
(
columnDefinition
=
"
text
COMMENT '导演中文简介'"
)
private
String
director_biography_cn
;
@Column
(
columnDefinition
=
"
varchar(255)
COMMENT '导演英文简介'"
)
@Column
(
columnDefinition
=
"
text
COMMENT '导演英文简介'"
)
private
String
director_biography_en
;
@Column
(
columnDefinition
=
"varchar(255) COMMENT '制片人中文名'"
)
...
...
src/main/java/com/egolm/film/bean/Fc_review_record_ext.java
View file @
183f9bd4
src/main/java/com/egolm/film/config/ExceptionHandler.java
View file @
183f9bd4
...
...
@@ -43,7 +43,7 @@ public class ExceptionHandler implements HandlerExceptionResolver {
if
(
displayInLog
)
{
logger
.
error
(
""
,
ex
);
try
{
logService
.
saveErrorLog
(
request
.
getRequestURI
().
replace
(
request
.
getContextPath
(),
""
),
ex
);
logService
.
saveErrorLog
(
request
.
getRequestURI
().
replace
(
request
.
getContextPath
(),
""
),
request
.
getParameterMap
(),
ex
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"错误日志保存失败"
,
e
);
}
...
...
src/main/java/com/egolm/film/config/WebMvcConfig.java
View file @
183f9bd4
...
...
@@ -22,6 +22,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
import
com.egolm.common.StringUtil
;
import
com.egolm.film.config.interceptor.AdminLoginInterceptor
;
import
com.egolm.film.config.interceptor.LocaleInterceptor
;
import
com.egolm.film.config.interceptor.LogInterceptor
;
import
com.egolm.film.config.interceptor.MemberLoginInterceptor
;
import
com.egolm.film.config.interceptor.UserLoginInterceptor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -41,8 +42,12 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
private
LocaleInterceptor
localeSessionInterceptor
;
@Autowired
private
LogInterceptor
logInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
logInterceptor
).
addPathPatterns
(
"/**"
);
registry
.
addInterceptor
(
localeSessionInterceptor
).
addPathPatterns
(
"/**"
);
registry
.
addInterceptor
(
adminLoginInterceptor
).
addPathPatterns
(
"/admin/**"
).
excludePathPatterns
(
"/admin/login"
);
registry
.
addInterceptor
(
userLoginInterceptor
).
addPathPatterns
(
"/user/**"
).
excludePathPatterns
(
"/user/login"
);
...
...
src/main/java/com/egolm/film/config/interceptor/LogInterceptor.java
0 → 100644
View file @
183f9bd4
package
com
.
egolm
.
film
.
config
.
interceptor
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.web.ServletUtil
;
import
com.egolm.film.api.service.AdminTokenService
;
import
com.egolm.film.api.service.MemberTokenService
;
import
com.egolm.film.api.service.UserTokenService
;
import
com.egolm.film.model.LoginToken
;
@Component
public
class
LogInterceptor
extends
HandlerInterceptorAdapter
{
@Autowired
JdbcTemplate
jdbcTemplate
;
@Autowired
MemberTokenService
memberTokenService
;
@Autowired
AdminTokenService
adminTokenService
;
@Autowired
UserTokenService
userTokenService
;
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
Date
now
=
new
Date
();
String
path
=
request
.
getRequestURI
().
replace
(
request
.
getContextPath
(),
""
);
String
prefix
=
path
.
split
(
"/"
)[
1
];
Map
<
String
,
Object
>
tokenMap
=
new
HashMap
<
String
,
Object
>();
LoginToken
token
=
null
;
if
(
prefix
.
equals
(
"admin"
))
{
token
=
adminTokenService
.
getToken
();
}
else
if
(
prefix
.
equals
(
"user"
))
{
token
=
userTokenService
.
getToken
();
}
else
if
(
prefix
.
equals
(
"member"
))
{
token
=
memberTokenService
.
getToken
();
}
else
{
tokenMap
.
put
(
"memberToken"
,
memberTokenService
.
getToken
());
tokenMap
.
put
(
"adminToken"
,
adminTokenService
.
getToken
());
tokenMap
.
put
(
"userToken"
,
userTokenService
.
getToken
());
}
String
content
=
JSON
.
toJSONString
(
request
.
getParameterMap
());
String
ip
=
ServletUtil
.
remoteIp
(
request
);
String
user_agent
=
request
.
getHeader
(
"User-Agent"
);
String
sql
=
"insert into fc_logs (type, loginid, prefix, path, ip, content, user_agent, create_time) values (?, ?, ?, ?, ?, ?, ?, ?)"
;
Object
[]
objs
=
new
Object
[]{
prefix
,
token
==
null
?
JSON
.
toJSONString
(
tokenMap
)
:
String
.
valueOf
(
token
.
getId
()),
prefix
,
path
,
ip
,
content
,
user_agent
,
now
};
jdbcTemplate
.
executeUpdate
(
sql
,
objs
);
super
.
afterCompletion
(
request
,
response
,
handler
,
ex
);
}
}
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