|
@@ -23,7 +23,9 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
public class UploadController {
|
|
@@ -38,13 +40,18 @@ public class UploadController {
|
|
|
|
|
|
|
|
|
@PostMapping("/putObject")
|
|
|
- public AjaxResult upLoadImage(@RequestParam("stream") MultipartFile stream,
|
|
|
+ public JSONObject upLoadImage(@RequestParam("stream") MultipartFile stream,
|
|
|
@RequestParam(value = "cameraCode", required = false) String cameraCode,
|
|
|
@RequestParam(value = "size", required = false) Long size,
|
|
|
@RequestParam(value = "contentType", required = false) String contentType,
|
|
|
@RequestParam(value = "lineDir", required = false) Integer lineDir) throws Exception {
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
if (stream.isEmpty()) {
|
|
|
- return AjaxResult.error("不能上传空文件哦");
|
|
|
+ jsonObject.put("resultCode", 2);
|
|
|
+ jsonObject.put("message", "失败");
|
|
|
+ jsonObject.put("data", "不能上传空文件哦");
|
|
|
+ return jsonObject;
|
|
|
}
|
|
|
//图片保存路径
|
|
|
//String fileUploadPath ="/"+userId+"/image";
|
|
@@ -73,9 +80,17 @@ public class UploadController {
|
|
|
uploadFile = "/" + baseCameraManagement.getRailwayCode() + "/" + line + "/" + baseCameraManagement.getInstallMile() + "/" + format1 + "/" + filename;
|
|
|
}
|
|
|
} else {
|
|
|
- return AjaxResult.error("上传功能出错");
|
|
|
+ jsonObject.put("resultCode", 2);
|
|
|
+ jsonObject.put("message", "失败");
|
|
|
+ jsonObject.put("data", "图片为null");
|
|
|
+ return jsonObject;
|
|
|
}
|
|
|
- return AjaxResult.success(uploadFile);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("imageUrl", uploadFile);
|
|
|
+ jsonObject.put("resultCode", 1);
|
|
|
+ jsonObject.put("message", "成功");
|
|
|
+ jsonObject.put("data", map);
|
|
|
+ return jsonObject;
|
|
|
}
|
|
|
|
|
|
// public static void main(String[] args) {
|