| | |
| | | |
| | | |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.RestResponse; |
| | | import com.ycl.jxkg.configuration.property.SystemConfig; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.config.property.SystemConfig; |
| | | import com.ycl.jxkg.service.FileUpload; |
| | | import com.ycl.jxkg.service.UserService; |
| | | import com.ycl.jxkg.viewmodel.admin.file.UeditorConfigVM; |
| | | import com.ycl.jxkg.viewmodel.admin.file.UploadResultVM; |
| | | import com.ycl.jxkg.domain.vo.admin.file.UeditorConfigVO; |
| | | import com.ycl.jxkg.domain.vo.admin.file.UploadResultVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | filePath = fileUpload.uploadFile(inputStream, attachSize, imgName); |
| | | } |
| | | String imageType = imgName.substring(imgName.lastIndexOf(".")); |
| | | UploadResultVM uploadResultVM = new UploadResultVM(); |
| | | uploadResultVM.setOriginal(imgName); |
| | | uploadResultVM.setName(imgName); |
| | | uploadResultVM.setUrl(filePath); |
| | | uploadResultVM.setSize(multipartFile.getSize()); |
| | | uploadResultVM.setType(imageType); |
| | | uploadResultVM.setState("SUCCESS"); |
| | | return uploadResultVM; |
| | | UploadResultVO uploadResultVO = new UploadResultVO(); |
| | | uploadResultVO.setOriginal(imgName); |
| | | uploadResultVO.setName(imgName); |
| | | uploadResultVO.setUrl(filePath); |
| | | uploadResultVO.setSize(multipartFile.getSize()); |
| | | uploadResultVO.setType(imageType); |
| | | uploadResultVO.setState("SUCCESS"); |
| | | return uploadResultVO; |
| | | } catch (IOException e) { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | } else { |
| | | UeditorConfigVM ueditorConfigVM = new UeditorConfigVM(); |
| | | ueditorConfigVM.setImageActionName(IMAGE_UPLOAD); |
| | | ueditorConfigVM.setImageFieldName(IMAGE_UPLOAD_FILE); |
| | | ueditorConfigVM.setImageMaxSize(2048000L); |
| | | ueditorConfigVM.setImageAllowFiles(Arrays.asList(".png", ".jpg", ".jpeg", ".gif", ".bmp")); |
| | | ueditorConfigVM.setImageCompressEnable(true); |
| | | ueditorConfigVM.setImageCompressBorder(1600); |
| | | ueditorConfigVM.setImageInsertAlign("none"); |
| | | ueditorConfigVM.setImageUrlPrefix(""); |
| | | ueditorConfigVM.setImagePathFormat(""); |
| | | return ueditorConfigVM; |
| | | UeditorConfigVO ueditorConfigVO = new UeditorConfigVO(); |
| | | ueditorConfigVO.setImageActionName(IMAGE_UPLOAD); |
| | | ueditorConfigVO.setImageFieldName(IMAGE_UPLOAD_FILE); |
| | | ueditorConfigVO.setImageMaxSize(2048000L); |
| | | ueditorConfigVO.setImageAllowFiles(Arrays.asList(".png", ".jpg", ".jpeg", ".gif", ".bmp")); |
| | | ueditorConfigVO.setImageCompressEnable(true); |
| | | ueditorConfigVO.setImageCompressBorder(1600); |
| | | ueditorConfigVO.setImageInsertAlign("none"); |
| | | ueditorConfigVO.setImageUrlPrefix(""); |
| | | ueditorConfigVO.setImagePathFormat(""); |
| | | return ueditorConfigVO; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | |
| | | @RequestMapping("/image") |
| | | @ResponseBody |
| | | public RestResponse questionUploadAndReadExcel(HttpServletRequest request) { |
| | | public Result questionUploadAndReadExcel(HttpServletRequest request) { |
| | | MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request; |
| | | MultipartFile multipartFile = multipartHttpServletRequest.getFile("file"); |
| | | long attachSize = multipartFile.getSize(); |
| | |
| | | try (InputStream inputStream = multipartFile.getInputStream()) { |
| | | String filePath = fileUpload.uploadFile(inputStream, attachSize, imgName); |
| | | userService.changePicture(getCurrentUser(), filePath); |
| | | return RestResponse.ok(filePath); |
| | | return Result.ok(filePath); |
| | | } catch (IOException e) { |
| | | return RestResponse.fail(2, e.getMessage()); |
| | | return Result.fail(2, e.getMessage()); |
| | | } |
| | | } |
| | | |