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
0c33d873
Commit
0c33d873
authored
Nov 22, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
集成操作日志功能
parent
1d648b2e
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
75 additions
and
14 deletions
+75
-14
AdminAuthServiceImpl.java
...olm/film/api/admin/service/impl/AdminAuthServiceImpl.java
+2
-2
AdminUserServiceImpl.java
...olm/film/api/admin/service/impl/AdminUserServiceImpl.java
+1
-1
MemberOpenApiController.java
...va/com/egolm/film/api/member/MemberOpenApiController.java
+2
-2
MemberServiceImpl.java
...egolm/film/api/member/service/impl/MemberServiceImpl.java
+1
-1
WebMvcConfig.java
src/main/java/com/egolm/film/config/WebMvcConfig.java
+2
-2
AdminLoginInterceptor.java
.../egolm/film/config/interceptor/AdminLoginInterceptor.java
+5
-0
LocaleInterceptor.java
.../com/egolm/film/config/interceptor/LocaleInterceptor.java
+2
-2
LogsUtil.java
...main/java/com/egolm/film/config/interceptor/LogsUtil.java
+46
-0
MemberLoginInterceptor.java
...egolm/film/config/interceptor/MemberLoginInterceptor.java
+5
-0
UserLoginInterceptor.java
...m/egolm/film/config/interceptor/UserLoginInterceptor.java
+5
-0
SqlWhere.java
src/main/java/com/egolm/film/util/SqlWhere.java
+4
-4
No files found.
src/main/java/com/egolm/film/api/admin/service/impl/AdminAuthServiceImpl.java
View file @
0c33d873
...
...
@@ -34,14 +34,14 @@ public class AdminAuthServiceImpl implements AdminAuthService {
@Override
public
List
<
Map
<
String
,
Object
>>
queryGroupList
(
String
keyword
,
Page
page
)
{
SqlWhere
argEdit
=
new
SqlWhere
().
l
ike
(
"group_name"
,
keyword
);
SqlWhere
argEdit
=
new
SqlWhere
().
l
k
(
"group_name"
,
keyword
);
String
sql
=
"select * from fc_admin_group"
+
StringUtil
.
join
(
" and "
,
" where "
,
""
,
""
,
argEdit
.
getStringList
());
return
jdbcTemplate
.
limit
(
sql
,
page
,
argEdit
.
getObjectList
());
}
@Override
public
List
<
Map
<
String
,
Object
>>
queryAdminList
(
String
keyword
,
Integer
group_id
,
Page
page
)
{
SqlWhere
argEdit
=
new
SqlWhere
().
olike
(
new
String
[]{
"realname"
,
"username"
},
keyword
).
eq
(
"group_id"
,
group_id
);
SqlWhere
argEdit
=
new
SqlWhere
().
lk
(
new
String
[]{
"realname"
,
"username"
},
keyword
).
eq
(
"group_id"
,
group_id
);
String
sql
=
"select * from fc_admin"
+
StringUtil
.
join
(
" and "
,
" where "
,
""
,
""
,
argEdit
.
getStringList
());
return
jdbcTemplate
.
limit
(
sql
,
page
,
argEdit
.
getObjectList
());
}
...
...
src/main/java/com/egolm/film/api/admin/service/impl/AdminUserServiceImpl.java
View file @
0c33d873
...
...
@@ -20,7 +20,7 @@ public class AdminUserServiceImpl implements AdminUserService {
@Override
public
List
<
Map
<
String
,
Object
>>
queryGroupList
(
String
keyword
,
Page
page
)
{
SqlWhere
argEdit
=
new
SqlWhere
().
l
ike
(
"group_name"
,
keyword
);
SqlWhere
argEdit
=
new
SqlWhere
().
l
k
(
"group_name"
,
keyword
);
String
sql
=
"select * from fc_user_group"
+
StringUtil
.
join
(
" and "
,
" where "
,
""
,
""
,
argEdit
.
getStringList
());
return
jdbcTemplate
.
limit
(
sql
,
page
,
argEdit
.
getObjectList
());
}
...
...
src/main/java/com/egolm/film/api/member/MemberOpenApiController.java
View file @
0c33d873
...
...
@@ -22,7 +22,7 @@ import com.egolm.film.api.common.service.Messages;
import
com.egolm.film.api.member.service.MemberService
;
import
com.egolm.film.bean.Fc_member
;
import
com.egolm.film.config.XException
;
import
com.egolm.film.config.interceptor.Locale
Cookie
Interceptor
;
import
com.egolm.film.config.interceptor.LocaleInterceptor
;
import
com.egolm.film.util.Common
;
import
io.swagger.annotations.Api
;
...
...
@@ -128,7 +128,7 @@ public class MemberOpenApiController {
@ApiImplicitParam
(
paramType
=
"query"
,
dataType
=
"String"
,
required
=
true
,
name
=
"i18n_language"
,
defaultValue
=
"zh_CN"
)
})
public
Object
setLocale
(
HttpServletResponse
response
,
String
i18n_language
)
{
Cookie
cookie
=
new
Cookie
(
Locale
Cookie
Interceptor
.
language
,
i18n_language
);
Cookie
cookie
=
new
Cookie
(
LocaleInterceptor
.
language
,
i18n_language
);
cookie
.
setMaxAge
(
3600000
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
...
...
src/main/java/com/egolm/film/api/member/service/impl/MemberServiceImpl.java
View file @
0c33d873
...
...
@@ -497,7 +497,7 @@ public class MemberServiceImpl implements MemberService {
@Override
public
List
<
Map
<
String
,
Object
>>
queryChuShenList
(
String
keyword
,
Integer
state
,
Integer
apply_state
,
String
film_type
,
String
enroll_type
,
String
film_country
,
Page
page
)
{
SqlWhere
where
=
new
SqlWhere
().
olike
(
new
String
[]{
"mf.en_name"
,
"mf.cn_name"
},
keyword
).
eq
(
"mf.state"
,
state
).
eq
(
"mf.apply_state"
,
apply_state
).
eq
(
"mf.film_type_name"
,
film_type
).
eq
(
"mf.enroll_type_name"
,
enroll_type
).
eq
(
"mf.film_country"
,
film_country
);
SqlWhere
where
=
new
SqlWhere
().
lk
(
new
String
[]{
"mf.en_name"
,
"mf.cn_name"
},
keyword
).
eq
(
"mf.state"
,
state
).
eq
(
"mf.apply_state"
,
apply_state
).
eq
(
"mf.film_type_name"
,
film_type
).
eq
(
"mf.enroll_type_name"
,
enroll_type
).
eq
(
"mf.film_country"
,
film_country
);
String
sql
=
"select mf.*, (select GROUP_CONCAT(mfd.director_name) from fc_member_film_director mfd where mfd.film_id = mf.id) director_name from fc_member_film mf"
+
StringUtil
.
join
(
" and "
,
" where "
,
""
,
""
,
where
.
getStringList
());
Object
[]
objs
=
where
.
getObjectList
();
return
jdbcTemplate
.
limit
(
sql
,
page
,
objs
);
...
...
src/main/java/com/egolm/film/config/WebMvcConfig.java
View file @
0c33d873
...
...
@@ -19,7 +19,7 @@ import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.egolm.film.config.interceptor.AdminLoginInterceptor
;
import
com.egolm.film.config.interceptor.Locale
Cookie
Interceptor
;
import
com.egolm.film.config.interceptor.LocaleInterceptor
;
import
com.egolm.film.config.interceptor.MemberLoginInterceptor
;
import
com.egolm.film.config.interceptor.UserLoginInterceptor
;
...
...
@@ -36,7 +36,7 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
private
MemberLoginInterceptor
memberLoginInterceptor
;
@Autowired
private
Locale
Cookie
Interceptor
localeSessionInterceptor
;
private
LocaleInterceptor
localeSessionInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
...
...
src/main/java/com/egolm/film/config/interceptor/AdminLoginInterceptor.java
View file @
0c33d873
...
...
@@ -18,9 +18,13 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
@Autowired
private
AdminTokenService
tokenService
;
@Autowired
private
LogsUtil
logUtil
;
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
if
(
tokenService
.
isLogin
())
{
logUtil
.
log
(
tokenService
,
req
);
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
else
{
String
sessionid
=
null
;
...
...
@@ -31,6 +35,7 @@ public class AdminLoginInterceptor extends HandlerInterceptorAdapter {
}
}
if
(
sessionid
!=
null
&&
tokenService
.
isLoginByToken
(
sessionid
))
{
logUtil
.
log
(
tokenService
,
req
);
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
throw
new
XException
(
"用户未登陆"
,
300
);
...
...
src/main/java/com/egolm/film/config/interceptor/Locale
Cookie
Interceptor.java
→
src/main/java/com/egolm/film/config/interceptor/LocaleInterceptor.java
View file @
0c33d873
...
...
@@ -14,10 +14,10 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import
com.egolm.common.StringUtil
;
@Component
public
class
Locale
Cookie
Interceptor
extends
HandlerInterceptorAdapter
{
public
class
LocaleInterceptor
extends
HandlerInterceptorAdapter
{
public
static
final
String
language
=
"i18n_language"
;
private
static
final
Logger
logger
=
Logger
.
getLogger
(
Locale
Cookie
Interceptor
.
class
);
private
static
final
Logger
logger
=
Logger
.
getLogger
(
LocaleInterceptor
.
class
);
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
...
...
src/main/java/com/egolm/film/config/interceptor/LogsUtil.java
0 → 100644
View file @
0c33d873
package
com
.
egolm
.
film
.
config
.
interceptor
;
import
java.util.Date
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.fastjson.JSON
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.web.ServletUtil
;
import
com.egolm.film.api.TokenService
;
import
com.egolm.film.api.admin.service.AdminTokenService
;
import
com.egolm.film.api.member.service.MemberTokenService
;
import
com.egolm.film.api.user.service.UserTokenService
;
import
com.egolm.film.model.LoginToken
;
@Component
public
class
LogsUtil
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
public
void
log
(
TokenService
tokenService
,
HttpServletRequest
request
)
{
LoginToken
token
=
tokenService
.
getToken
();
String
type
=
null
;
if
(
tokenService
instanceof
AdminTokenService
)
{
type
=
"admin"
;
}
else
if
(
tokenService
instanceof
MemberTokenService
)
{
type
=
"member"
;
}
else
if
(
tokenService
instanceof
UserTokenService
)
{
type
=
"user"
;
}
String
loginid
=
String
.
valueOf
(
token
.
getId
());
Date
now
=
new
Date
();
String
path
=
request
.
getRequestURI
().
replace
(
request
.
getContextPath
(),
""
);
String
prefix
=
path
.
split
(
"/"
)[
1
];
String
content
=
JSON
.
toJSONString
(
request
.
getParameterMap
());
String
ip
=
ServletUtil
.
readReqJson
(
request
);
String
sql
=
"insert into fc_logs (type, loginid, prefix, path, ip, content, create_time) values (?, ?, ?, ?, ?, ?, ?)"
;
Object
[]
objs
=
new
Object
[]{
type
,
loginid
,
prefix
,
path
,
ip
,
content
,
now
};
jdbcTemplate
.
executeUpdate
(
sql
,
objs
);
}
}
src/main/java/com/egolm/film/config/interceptor/MemberLoginInterceptor.java
View file @
0c33d873
...
...
@@ -18,9 +18,13 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
@Autowired
private
MemberTokenService
tokenService
;
@Autowired
private
LogsUtil
logUtil
;
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
if
(
tokenService
.
isLogin
())
{
logUtil
.
log
(
tokenService
,
req
);
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
else
{
String
sessionid
=
null
;
...
...
@@ -31,6 +35,7 @@ public class MemberLoginInterceptor extends HandlerInterceptorAdapter {
}
}
if
(
sessionid
!=
null
&&
tokenService
.
isLoginByToken
(
sessionid
))
{
logUtil
.
log
(
tokenService
,
req
);
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
throw
new
XException
(
"用户未登陆"
,
300
);
...
...
src/main/java/com/egolm/film/config/interceptor/UserLoginInterceptor.java
View file @
0c33d873
...
...
@@ -18,9 +18,13 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
@Autowired
private
UserTokenService
tokenService
;
@Autowired
private
LogsUtil
logUtil
;
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
if
(
tokenService
.
isLogin
())
{
logUtil
.
log
(
tokenService
,
req
);
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
else
{
String
sessionid
=
null
;
...
...
@@ -31,6 +35,7 @@ public class UserLoginInterceptor extends HandlerInterceptorAdapter {
}
}
if
(
sessionid
!=
null
&&
tokenService
.
isLoginByToken
(
sessionid
))
{
logUtil
.
log
(
tokenService
,
req
);
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
throw
new
XException
(
"用户未登陆"
,
300
);
...
...
src/main/java/com/egolm/film/util/SqlWhere.java
View file @
0c33d873
...
...
@@ -39,7 +39,7 @@ public class SqlWhere {
return
this
;
}
public
SqlWhere
g
t
e
(
String
name
,
Object
obj
)
{
public
SqlWhere
ge
(
String
name
,
Object
obj
)
{
if
(
StringUtil
.
isNotBlank
(
obj
))
{
this
.
strList
.
add
(
name
+
" >= ?"
);
this
.
objList
.
add
(
obj
);
...
...
@@ -47,7 +47,7 @@ public class SqlWhere {
return
this
;
}
public
SqlWhere
l
t
e
(
String
name
,
Object
obj
)
{
public
SqlWhere
le
(
String
name
,
Object
obj
)
{
if
(
StringUtil
.
isNotBlank
(
obj
))
{
this
.
strList
.
add
(
name
+
" <= ?"
);
this
.
objList
.
add
(
obj
);
...
...
@@ -55,7 +55,7 @@ public class SqlWhere {
return
this
;
}
public
SqlWhere
l
ike
(
String
name
,
Object
obj
)
{
public
SqlWhere
l
k
(
String
name
,
Object
obj
)
{
if
(
StringUtil
.
isNotBlank
(
obj
))
{
this
.
strList
.
add
(
name
+
" like ?"
);
this
.
objList
.
add
(
"%"
+
obj
+
"%"
);
...
...
@@ -63,7 +63,7 @@ public class SqlWhere {
return
this
;
}
public
SqlWhere
olike
(
String
[]
name
,
Object
obj
)
{
public
SqlWhere
lk
(
String
[]
name
,
Object
obj
)
{
if
(
name
!=
null
&&
name
.
length
>
0
&&
StringUtil
.
isNotBlank
(
obj
))
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"("
);
...
...
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