添加上传的接口,hospitalId,departId在参数里面
| | |
| | | */ |
| | | @PostMapping(value="byteUplaod") |
| | | FileInfo byteUplaod(@RequestParam("fileName") String fileName,@RequestBody byte[] bytes); |
| | | /** |
| | | * 文件上传 根据fileType选择上传方式 hospitalId departmentId |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping(value="/feignUploadHosIdAndDepId",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | FileInfo feignUploadHosIdAndDepId(@RequestPart("file") MultipartFile file,@RequestParam("imgType") String imgType,@RequestParam("hospitalId") String hospitalId,@RequestParam("departmentId") String departmentId); |
| | | |
| | | } |
| | |
| | | public FileInfo byteUplaod(String fileName, byte[] bytes) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public FileInfo feignUploadHosIdAndDepId(MultipartFile file, String imgType, String hospitalId, String departmentId) { |
| | | return null; |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | ResultBody baseDownLoad(Map<String, Object> map) throws Exception; |
| | | |
| | | FileInfo byteUplaod(String fileName, InputStream inputStream, int size); |
| | | /** |
| | | * 文件上传 根据fileType选择上传方式 hospitalId departmentId |
| | | * @param file |
| | | * @return |
| | | */ |
| | | FileInfo feignUploadHosIdAndDepId(MultipartFile file, String imgType, String hospitalId, String departmentId)throws Exception; |
| | | } |
| | |
| | | baseMapper.insert(newfileInfo); |
| | | return newfileInfo; |
| | | } |
| | | |
| | | @Override |
| | | public FileInfo feignUploadHosIdAndDepId(MultipartFile file, String imgType, String hospitalId, String departmentId) throws Exception { |
| | | List<String> lassStr= Arrays.asList("png","bmp","dib","gif","jfif","jpe","jpeg","jpg","tif","tiff","ico"); |
| | | String suffix=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); |
| | | if(!lassStr.contains(suffix)){ |
| | | return null; |
| | | } |
| | | String name = file.getOriginalFilename(); |
| | | String fileName= UUID.randomUUID().toString().replaceAll("-",""); |
| | | //image/jpeg;base64 |
| | | String newFileName=fileName+name.substring(name.lastIndexOf(".")); |
| | | FileInfo newfileInfo=new FileInfo(); |
| | | newfileInfo.setName(newFileName); |
| | | newfileInfo.setId(IdUtil.fastSimpleUUID()); |
| | | newfileInfo.setSize(file.getSize()); |
| | | newfileInfo.setIsImg(true); |
| | | newfileInfo.setContentType("image/jpeg"); |
| | | newfileInfo.setSource("aliyun"); |
| | | newfileInfo.setImgType(imgType); |
| | | newfileInfo.setCreateTime(new Date()); |
| | | String folderByDate =DateUtil.formatDate(new Date()); |
| | | String filePath = FilePath(imgType, folderByDate, hospitalId, departmentId); |
| | | InputStream inputStream = file.getInputStream(); |
| | | this.fileUpLoadOss(newfileInfo,filePath+newFileName,inputStream); |
| | | inputStream.close(); |
| | | baseMapper.insert(newfileInfo); |
| | | return newfileInfo; |
| | | } |
| | | } |
| | | |
| | |
| | | return fileService.uploadForThumbnails(file,imgType); |
| | | } |
| | | /** |
| | | * 文件上传 根据fileType选择上传方式 hospitalId departmentId |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping(value="/feignUploadHosIdAndDepId",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public FileInfo feignUploadHosIdAndDepId(@RequestPart("file") MultipartFile file,@RequestParam("imgType") String imgType,@RequestParam("hospitalId") String hospitalId,@RequestParam("departmentId") String departmentId) throws Exception { |
| | | return fileService.feignUploadHosIdAndDepId(file,imgType,hospitalId,departmentId); |
| | | } |
| | | /** |
| | | * base64上传图片 |
| | | */ |
| | | @PostMapping(value="baseUplaod",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |