Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Administrator
/
kmr-h5-java
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ecb31759
authored
2017-12-01 11:00:32 +0800
by
ja
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加base64上传方法
1 parent
78e06b0a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
kmr_dp_HDP/src/main/java/com/example/controller/ImgInfoController.java
kmr_dp_HDP/src/main/java/com/example/controller/ImgInfoController.java
View file @
ecb3175
...
...
@@ -64,6 +64,44 @@ public class ImgInfoController {
return
builder
.
success
(
flag
).
content
(
imgInfo
).
code
(
code
).
create
();
}
@RequestMapping
(
value
=
"/upload/base64"
,
method
=
RequestMethod
.
POST
)
public
MessageEntity
uploadbase64
(
HttpServletRequest
request
,
@RequestBody
String
base64
,
@ModelAttribute
ImgInfo
imgInfo
,
String
access_token
,
String
state
,
String
timestamp
,
String
rands
,
String
jsondata
,
String
checksum
,
String
secret
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
String
code
=
"9000"
;
String
openid
=
imgInfo
.
getOpenid
();
boolean
flag
=
false
;
if
(
StringUtils
.
isNotBlank
(
jsondata
)){
jsondata
=
URLDecoder
.
decode
(
jsondata
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Map
map
=
null
;
try
{
map
=
objectMapper
.
readValue
(
jsondata
,
Map
.
class
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
map
!=
null
&&
map
.
containsKey
(
"gtmc_code"
)
&&
map
.
get
(
"gtmc_code"
).
toString
().
equals
(
"200"
)){
String
checksum1
=
MD5Utils
.
hash
(
access_token
+
openid
+
state
+
timestamp
+
rands
+
jsondata
+
secret
);
if
(
checksum1
.
equals
(
checksum
)){
imgInfo
.
setGtmcUid
(
map
.
get
(
"gtmc_uid"
).
toString
());
imgInfo
.
setGtmcDepartment
(
map
.
get
(
"gtmc_department"
).
toString
());
imgInfo
.
setGtmcName
(
map
.
get
(
"gtmc_name"
).
toString
());
FileUploadInfo
info
=
new
DefaultFileUpload
().
uploadBase64
(
"/data/home/app/4Q0i/uimg"
,
base64
);
String
url
=
info
.
getUrl
();
imgInfo
.
setImgUrl
(
url
);
boolean
b
=
this
.
imgInfoService
.
create
(
imgInfo
);
if
(
b
){
code
=
"2000"
;
flag
=
true
;
}
}
}
}
return
builder
.
success
(
flag
).
content
(
imgInfo
).
code
(
code
).
create
();
}
@RequestMapping
(
"/getbyopenid"
)
public
MessageEntity
getbyopenid
(
HttpServletRequest
request
,
@RequestParam
String
openid
)
{
MessageEntity
.
Builder
builder
=
new
MessageEntity
.
Builder
(
request
);
...
...
Please
register
or
sign in
to post a comment