|
@ -1,13 +1,20 @@
|
|
package com.yihu.jw.hospital.endpoint.file_upload;
|
|
package com.yihu.jw.hospital.endpoint.file_upload;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
|
|
import com.yihu.jw.file_upload.FileUploadService;
|
|
import com.yihu.jw.file_upload.FileUploadService;
|
|
import com.yihu.jw.restmodel.iot.common.UploadVO;
|
|
import com.yihu.jw.restmodel.iot.common.UploadVO;
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@ -24,12 +31,19 @@ import java.util.Map;
|
|
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
|
|
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
|
|
public class FileUploadEndpoint extends EnvelopRestEndpoint {
|
|
public class FileUploadEndpoint extends EnvelopRestEndpoint {
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(EnvelopRestEndpoint.class);
|
|
|
|
|
|
@Value("${fastDFS.fastdfs_file_url}")
|
|
@Value("${fastDFS.fastdfs_file_url}")
|
|
private String fastdfs_file_url;
|
|
private String fastdfs_file_url;
|
|
@Autowired
|
|
@Autowired
|
|
FileUploadService fileUploadService;
|
|
FileUploadService fileUploadService;
|
|
@Value("${testPattern.sign}")
|
|
@Value("${testPattern.sign}")
|
|
private String isClose;
|
|
private String isClose;
|
|
|
|
@Value("${testPattern.remote_inner_url}")
|
|
|
|
private String remote_inner_url;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
|
|
@PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
|
|
@ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
|
|
@ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
|
|
@ -61,6 +75,13 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
|
|
if (isClose.equalsIgnoreCase("1")){
|
|
if (isClose.equalsIgnoreCase("1")){
|
|
Map<String, Object> map = fileUploadService.uploadImg(file);
|
|
Map<String, Object> map = fileUploadService.uploadImg(file);
|
|
uploadVO.setFullUri(map.get("accessory").toString());
|
|
uploadVO.setFullUri(map.get("accessory").toString());
|
|
|
|
}else if(isClose.equals("2")){
|
|
|
|
//内网上传
|
|
|
|
String rs = fileUploadService.request(remote_inner_url,file,null);
|
|
|
|
logger.info(rs);
|
|
|
|
JSONObject json = JSON.parseObject(rs);
|
|
|
|
uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
|
|
|
|
|
|
}else {
|
|
}else {
|
|
// 得到文件的完整名称 xxx.txt
|
|
// 得到文件的完整名称 xxx.txt
|
|
String originalFilename = file.getOriginalFilename();
|
|
String originalFilename = file.getOriginalFilename();
|