ecb31759 by ja

添加base64上传方法

1 parent 78e06b0a
...@@ -64,6 +64,44 @@ public class ImgInfoController { ...@@ -64,6 +64,44 @@ public class ImgInfoController {
64 return builder.success(flag).content(imgInfo).code(code).create(); 64 return builder.success(flag).content(imgInfo).code(code).create();
65 } 65 }
66 66
67
68 @RequestMapping(value = "/upload/base64", method = RequestMethod.POST)
69 public MessageEntity uploadbase64(HttpServletRequest request,@RequestBody String base64,@ModelAttribute ImgInfo imgInfo,
70 String access_token, String state, String timestamp, String rands, String jsondata, String checksum, String secret) {
71 MessageEntity.Builder builder = new MessageEntity.Builder(request);
72 String code = "9000";
73 String openid = imgInfo.getOpenid();
74 boolean flag = false;
75 if(StringUtils.isNotBlank(jsondata)){
76 jsondata = URLDecoder.decode(jsondata);
77 ObjectMapper objectMapper = new ObjectMapper();
78 Map map = null;
79 try {
80 map = objectMapper.readValue(jsondata, Map.class);
81 } catch (IOException e) {
82 e.printStackTrace();
83 }
84 if(map != null && map.containsKey("gtmc_code") && map.get("gtmc_code").toString().equals("200")){
85 String checksum1 = MD5Utils.hash(access_token + openid + state + timestamp + rands + jsondata + secret);
86 if(checksum1.equals(checksum)){
87 imgInfo.setGtmcUid(map.get("gtmc_uid").toString());
88 imgInfo.setGtmcDepartment(map.get("gtmc_department").toString());
89 imgInfo.setGtmcName(map.get("gtmc_name").toString());
90 FileUploadInfo info = new DefaultFileUpload().uploadBase64("/data/home/app/4Q0i/uimg", base64);
91 String url = info.getUrl();
92 imgInfo.setImgUrl(url);
93 boolean b = this.imgInfoService.create(imgInfo);
94 if(b){
95 code = "2000";
96 flag = true;
97 }
98 }
99 }
100 }
101
102 return builder.success(flag).content(imgInfo).code(code).create();
103 }
104
67 @RequestMapping("/getbyopenid") 105 @RequestMapping("/getbyopenid")
68 public MessageEntity getbyopenid(HttpServletRequest request, @RequestParam String openid) { 106 public MessageEntity getbyopenid(HttpServletRequest request, @RequestParam String openid) {
69 MessageEntity.Builder builder = new MessageEntity.Builder(request); 107 MessageEntity.Builder builder = new MessageEntity.Builder(request);
......