|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.yihu.fastdfs.FastDFSUtil;
|
|
|
import com.yihu.jw.base.util.ErrorCodeUtil;
|
|
|
import com.yihu.jw.entity.util.AesEncryptUtils;
|
|
|
import com.yihu.jw.exception.code.BaseErrorCode;
|
|
|
import com.yihu.jw.file_upload.FileManageService;
|
|
|
import com.yihu.jw.file_upload.FileUploadService;
|
|
@ -60,6 +61,10 @@ public class FileUploadController extends EnvelopRestEndpoint {
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Autowired
|
|
|
private FileManageService fileManageService;
|
|
|
@Value("${spring.profiles}")
|
|
|
private String springProfiles;
|
|
|
|
|
|
private final String entranceUrl="http://10.90.32.3:22174/cityihealth/base/";
|
|
|
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
|
|
@ -94,6 +99,51 @@ public class FileUploadController extends EnvelopRestEndpoint {
|
|
|
return success("上传成功", uploadVO);
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = "upload_stream_img_out")
|
|
|
@ApiOperation(value = "外网文件流上传图片", notes = "文件流上传图片")
|
|
|
public ObjEnvelop<UploadVO> uploadImgOut(@ApiParam(value = "文件", required = true)
|
|
|
@RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
|
|
|
|
|
|
|
|
|
UploadVO uploadVO = new UploadVO();
|
|
|
if ("jwZnygProd".equals(springProfiles)){
|
|
|
//外网 发送到内网中内网上传
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
String[] fs = originalFilename.split("\\.");
|
|
|
String type = fs[1];
|
|
|
String rs = fileUploadService.request(entranceUrl+"open/fileUpload/upload_stream_img",file,type);
|
|
|
logger.info(rs);
|
|
|
JSONObject json = JSON.parseObject(rs);
|
|
|
if (json.get("status").equals("200")) {
|
|
|
JSONObject jsonObjecta = JSONObject.parseObject(AesEncryptUtils.agDecrypt(json.get("data").toString()));
|
|
|
uploadVO = objectMapper.readValue(jsonObjecta.getJSONObject("obj").toJSONString(),UploadVO.class);
|
|
|
}else {
|
|
|
return ObjEnvelop.getError(rs);
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
if (isClose.equalsIgnoreCase("1")){
|
|
|
Map<String, Object> map = fileUploadService.uploadImg(file);
|
|
|
uploadVO.setFullUri(map.get("accessory").toString());
|
|
|
}else if(isClose.equals("2")){
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
String[] fs = originalFilename.split("\\.");
|
|
|
String type = fs[1];
|
|
|
//内网上传
|
|
|
String rs = fileUploadService.request(remote_inner_url,file,type);
|
|
|
logger.info(rs);
|
|
|
JSONObject json = JSON.parseObject(rs);
|
|
|
uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class);
|
|
|
|
|
|
}else {
|
|
|
// 得到文件的完整名称 xxx.txt
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
|
InputStream inputStream = file.getInputStream();
|
|
|
uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
|
|
|
}
|
|
|
}
|
|
|
return success("上传成功", uploadVO);
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_ATTACHMENT)
|
|
|
@ApiOperation(value = "文件流上传附件", notes = "文件流上传附件")
|