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
20c28efb
Commit
20c28efb
authored
Apr 19, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
76b2cd47
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
180 additions
and
2 deletions
+180
-2
WebApiController.java
src/main/java/com/egolm/film/api/web/WebApiController.java
+105
-0
WebMvcConfig.java
src/main/java/com/egolm/film/config/WebMvcConfig.java
+5
-1
WebApiInterceptor.java
.../com/egolm/film/config/interceptor/WebApiInterceptor.java
+66
-0
application-dev.properties
src/main/resources/application-dev.properties
+4
-1
No files found.
src/main/java/com/egolm/film/api/web/WebApiController.java
0 → 100644
View file @
20c28efb
package
com
.
egolm
.
film
.
api
.
web
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.Resource
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.Util
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.film.api.service.CountryService
;
@RestController
(
"webapi"
)
public
class
WebApiController
{
@Autowired
JdbcTemplate
jdbcTemplate
;
Map
<
String
,
String
>
countryMap
;
@Resource
public
void
setCountryMap
(
CountryService
countryService
)
{
countryMap
=
countryService
.
queryCountryMapReverse
();
}
public
Object
getFilmList
()
{
String
sql0
=
"select mf.id, mf.film_no, mf.cn_name, mf.en_name, mf.film_country, r.enroll_type_id, r.review_state, mf.film_type_name_short from fc_member_film mf left join fc_review r on r.film_id = mf.id, fc_film_group fg where mf.film_group_id = fg.id"
;
String
sql1
=
"select * from fc_member_film_ext"
;
List
<
Map
<
String
,
Object
>>
filmList
=
jdbcTemplate
.
queryForList
(
sql0
);
List
<
Map
<
String
,
Object
>>
playactorList
=
jdbcTemplate
.
queryForList
(
sql1
);
Map
<
String
,
Map
<
String
,
Object
>>
playactorMM
=
Util
.
listToMM
(
playactorList
,
"id"
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
Map
<
String
,
Object
>
filmMap
:
filmList
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Integer
id
=
(
Integer
)
filmMap
.
get
(
"id"
);
Integer
film_no
=
(
Integer
)
filmMap
.
get
(
"film_no"
);
String
cn_name
=
(
String
)
filmMap
.
get
(
"cn_name"
);
String
en_name
=
(
String
)
filmMap
.
get
(
"en_name"
);
String
film_country
=
(
String
)
filmMap
.
get
(
"film_country"
);
Integer
enroll_type_id
=
(
Integer
)
filmMap
.
get
(
"enroll_type_id"
);
Integer
review_state
=
(
Integer
)
filmMap
.
get
(
"review_state"
);
String
film_type_name_short
=
(
String
)
filmMap
.
get
(
"film_type_name_short"
);
map
.
put
(
"film_no"
,
StringUtil
.
formatLength
(
film_no
,
"0000"
));
map
.
put
(
"cn_name"
,
cn_name
);
map
.
put
(
"en_name"
,
en_name
);
map
.
put
(
"film_country_en"
,
film_country
);
map
.
put
(
"film_country_cn"
,
countryMap
.
get
(
film_country
));
map
.
put
(
"film_type_name_short"
,
film_type_name_short
);
{
String
review_state_text
=
"参赛"
;
if
(
review_state
==
1
)
{
if
(
enroll_type_id
==
4
||
enroll_type_id
==
3
)
{
review_state_text
=
"参展"
;
}
else
{
review_state_text
=
"参赛"
;
}
}
else
if
(
review_state
==
3
||
review_state
==
4
)
{
review_state_text
=
"参赛"
;
}
else
if
(
review_state
==
5
)
{
review_state_text
=
"参展"
;
}
else
{
continue
;
}
map
.
put
(
"review_state"
,
review_state_text
);
}
Map
<
String
,
Object
>
extMap
=
playactorMM
.
get
(
String
.
valueOf
(
id
));
{
String
director_cn
=
(
String
)
extMap
.
get
(
"director_cn"
);
String
director_en
=
(
String
)
extMap
.
get
(
"director_en"
);
String
[]
directorCnArray
=
director_cn
.
split
(
","
);
String
[]
directorEnArray
=
director_en
.
split
(
","
,
directorCnArray
.
length
);
List
<
Map
<
String
,
Object
>>
directorList
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
int
i
=
0
;
i
<
directorCnArray
.
length
;
i
++)
{
Map
<
String
,
Object
>
directorMap
=
new
HashMap
<
String
,
Object
>();
directorMap
.
put
(
"en_name"
,
directorEnArray
[
i
]);
directorMap
.
put
(
"cn_name"
,
directorCnArray
[
i
]);
directorList
.
add
(
directorMap
);
}
map
.
put
(
"directorList"
,
directorList
);
}
{
String
producer_en
=
(
String
)
extMap
.
get
(
"producer_en"
);
String
production_en
=
(
String
)
extMap
.
get
(
"production_en"
);
String
[]
producerArray
=
producer_en
.
split
(
","
);
List
<
Map
<
String
,
Object
>>
producerList
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
int
i
=
0
;
i
<
producerArray
.
length
;
i
++)
{
Map
<
String
,
Object
>
producerMap
=
new
HashMap
<
String
,
Object
>();
producerMap
.
put
(
"producer_name"
,
producerArray
[
i
]);
producerMap
.
put
(
"production_name"
,
production_en
);
producerList
.
add
(
producerMap
);
}
map
.
put
(
"producerList"
,
producerList
);
}
list
.
add
(
map
);
}
return
Rjx
.
jsonOk
().
setData
(
list
);
}
}
src/main/java/com/egolm/film/config/WebMvcConfig.java
View file @
20c28efb
...
@@ -25,6 +25,7 @@ import com.egolm.film.config.interceptor.LocaleInterceptor;
...
@@ -25,6 +25,7 @@ import com.egolm.film.config.interceptor.LocaleInterceptor;
import
com.egolm.film.config.interceptor.LogInterceptor
;
import
com.egolm.film.config.interceptor.LogInterceptor
;
import
com.egolm.film.config.interceptor.MemberLoginInterceptor
;
import
com.egolm.film.config.interceptor.MemberLoginInterceptor
;
import
com.egolm.film.config.interceptor.UserLoginInterceptor
;
import
com.egolm.film.config.interceptor.UserLoginInterceptor
;
import
com.egolm.film.config.interceptor.WebApiInterceptor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
@Configuration
@Configuration
...
@@ -45,6 +46,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
...
@@ -45,6 +46,9 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
@Autowired
private
LogInterceptor
logInterceptor
;
private
LogInterceptor
logInterceptor
;
@Autowired
private
WebApiInterceptor
webapiInterceptor
;
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
logInterceptor
).
addPathPatterns
(
"/**"
);
registry
.
addInterceptor
(
logInterceptor
).
addPathPatterns
(
"/**"
);
...
@@ -52,7 +56,7 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
...
@@ -52,7 +56,7 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
registry
.
addInterceptor
(
adminLoginInterceptor
).
addPathPatterns
(
"/admin/**"
).
excludePathPatterns
(
"/admin/login"
);
registry
.
addInterceptor
(
adminLoginInterceptor
).
addPathPatterns
(
"/admin/**"
).
excludePathPatterns
(
"/admin/login"
);
registry
.
addInterceptor
(
userLoginInterceptor
).
addPathPatterns
(
"/user/**"
).
excludePathPatterns
(
"/user/login"
);
registry
.
addInterceptor
(
userLoginInterceptor
).
addPathPatterns
(
"/user/**"
).
excludePathPatterns
(
"/user/login"
);
registry
.
addInterceptor
(
memberLoginInterceptor
).
addPathPatterns
(
"/member/**"
).
excludePathPatterns
(
"/member/login"
);
registry
.
addInterceptor
(
memberLoginInterceptor
).
addPathPatterns
(
"/member/**"
).
excludePathPatterns
(
"/member/login"
);
registry
.
addInterceptor
(
webapiInterceptor
).
addPathPatterns
(
"/webapi/**"
);
}
}
@Override
@Override
...
...
src/main/java/com/egolm/film/config/interceptor/WebApiInterceptor.java
0 → 100644
View file @
20c28efb
package
com
.
egolm
.
film
.
config
.
interceptor
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
com.egolm.common.StringUtil
;
import
com.egolm.film.config.XRException
;
@Component
public
class
WebApiInterceptor
extends
HandlerInterceptorAdapter
{
@Value
(
"${md5key}"
)
private
String
md5key
;
@Override
public
boolean
preHandle
(
HttpServletRequest
req
,
HttpServletResponse
resp
,
Object
handler
)
throws
Exception
{
String
timestamp
=
req
.
getParameter
(
"timestamp"
);
String
sign_string
=
req
.
getParameter
(
"sign"
);
XRException
.
assertNotBlank
(
"时间戳不能为空"
,
timestamp
);
if
(
Math
.
abs
(
System
.
currentTimeMillis
()
-
Long
.
valueOf
(
timestamp
))
>
(
1000
*
60
*
10
))
{
throw
new
XRException
(
"时间戳错误"
);
}
XRException
.
assertNotBlank
(
"签名不能为空"
,
sign_string
);
Map
<
String
,
Object
>
parameterMap
=
new
TreeMap
<
String
,
Object
>(
req
.
getParameterMap
());
parameterMap
.
remove
(
"sign"
);
StringBuffer
string
=
this
.
toString
(
parameterMap
);
String
sign_tmp
=
StringUtil
.
toMD5HexString
(
string
+
md5key
);
if
(
sign_tmp
.
equals
(
sign_string
))
{
return
super
.
preHandle
(
req
,
resp
,
handler
);
}
else
{
throw
new
XRException
(
"数据签名错误"
);
}
}
private
StringBuffer
toString
(
Object
obj
)
{
StringBuffer
sb
=
new
StringBuffer
();
if
(
obj
instanceof
Map
)
{
Map
<?,
?>
parameterMap
=
(
Map
<?,
?>)
obj
;
List
<
String
>
keys
=
parameterMap
.
keySet
().
stream
().
map
(
o
->
String
.
valueOf
(
o
)).
sorted
().
collect
(
Collectors
.
toList
());
for
(
String
key
:
keys
)
{
sb
.
append
(
this
.
toString
(
parameterMap
.
get
(
key
)));
}
}
else
if
(
obj
instanceof
List
)
{
for
(
Object
value
:
(
List
<?>)
obj
)
{
sb
.
append
(
this
.
toString
(
value
));
}
}
else
if
(
obj
instanceof
Object
[])
{
for
(
Object
value
:
(
Object
[])
obj
)
{
sb
.
append
(
this
.
toString
(
value
));
}
}
else
{
sb
.
append
(
obj
);
}
return
sb
;
}
}
src/main/resources/application-dev.properties
View file @
20c28efb
...
@@ -44,3 +44,6 @@ aliyun.video.cateID=1000018495
...
@@ -44,3 +44,6 @@ aliyun.video.cateID=1000018495
aliyun.oss.endpoint
=
oss-cn-shanghai.aliyuncs.com
aliyun.oss.endpoint
=
oss-cn-shanghai.aliyuncs.com
aliyun.oss.bucket
=
siff-film-pic
aliyun.oss.bucket
=
siff-film-pic
opt.project.type
=
1
opt.project.type
=
1
md5key
=
564cc4130ee949d4ae25b5681e784583
\ No newline at end of file
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