|
@ -7,11 +7,16 @@ import io.swagger.annotations.Api;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.io.FileSystemResource;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -55,17 +60,36 @@ public class YueRenController extends BaseController {
|
|
|
//--预约模块 end
|
|
|
|
|
|
//--四诊模块 begin
|
|
|
|
|
|
/**
|
|
|
* 上传图片音频等附件
|
|
|
* @param jsonString 附件
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/uploadattachment", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
|
|
|
@ResponseBody
|
|
|
public String uploadAttachment(@RequestBody String jsonString) {
|
|
|
JSONObject params = new JSONObject();
|
|
|
String postStr = remoteCall("/yueren/uploadattachment", params);
|
|
|
return postStr;
|
|
|
public String uploadAttachment(@RequestParam MultipartFile file) {
|
|
|
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
String filePath =Class.class.getClass().getResource("/").getPath() + "temp/" + System.currentTimeMillis() + fileName;
|
|
|
File dest = new File(filePath);
|
|
|
if (!dest.getParentFile().exists()) {
|
|
|
dest.getParentFile().mkdirs();
|
|
|
}
|
|
|
try {
|
|
|
file.transferTo(dest);
|
|
|
RestTemplate rest = new RestTemplate();
|
|
|
FileSystemResource resource = new FileSystemResource(filePath);
|
|
|
param.add("file", resource);
|
|
|
String postStr = rest.postForObject(api + "/yueren/uploadattachment", param, String.class);
|
|
|
if (dest.exists() && dest.isFile()) {
|
|
|
dest.delete();
|
|
|
}
|
|
|
return postStr;
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return "{\"status\":500,\"exception\":\"上传文件出错\"}";
|
|
|
}
|
|
|
|
|
|
/**
|