ecb31759 by ja

添加base64上传方法

1 parent 78e06b0a
......@@ -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);
......