diff --git a/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index 49160b17..4348d9d0 100644 --- a/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -71,64 +71,64 @@ public class OssController { private final static String KEY = ModuleConstant.CLOUD_STORAGE_CONFIG_KEY; - @GetMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = ossService.page(params); - - return new Result>().ok(page); - } - - @GetMapping("info") - public Result info(){ - CloudStorageConfig config = paramsRemoteService.getValueObject(KEY, CloudStorageConfig.class); - - return new Result().ok(config); - } - - @PostMapping -// @LogOperation("保存云存储配置信息") - public Result saveConfig(@RequestBody CloudStorageConfig config){ - //校验类型 - ValidatorUtils.validateEntity(config); - - if(config.getType() == OssTypeEnum.QINIU.value()){ - //校验七牛数据 - ValidatorUtils.validateEntity(config, QiniuGroup.class); - }else if(config.getType() == OssTypeEnum.ALIYUN.value()){ - //校验阿里云数据 - ValidatorUtils.validateEntity(config, AliyunGroup.class); - }else if(config.getType() == OssTypeEnum.QCLOUD.value()){ - //校验腾讯云数据 - ValidatorUtils.validateEntity(config, QcloudGroup.class); - } - - paramsRemoteService.updateValueByCode(KEY, new Gson().toJson(config)); - - return new Result(); - } - - @PostMapping("upload") - public Result upload(@RequestPart("file") MultipartFile file) throws Exception { - if (file.isEmpty()) { - return new Result().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); - } - - //上传文件 - String extension = FilenameUtils.getExtension(file.getOriginalFilename()); - String url = OssFactory.build().uploadSuffix(file.getBytes(), extension, null); - - //保存文件信息 - OssEntity ossEntity = new OssEntity(); - ossEntity.setUrl(url); - ossService.insertOssEntity(ossEntity); - - //文件信息 - UploadDTO dto = new UploadDTO(); - dto.setUrl(url); - dto.setSize(file.getSize()); - - return new Result().ok(dto); - } +// @GetMapping("page") +// public Result> page(@RequestParam Map params){ +// PageData page = ossService.page(params); +// +// return new Result>().ok(page); +// } +// +// @GetMapping("info") +// public Result info(){ +// CloudStorageConfig config = paramsRemoteService.getValueObject(KEY, CloudStorageConfig.class); +// +// return new Result().ok(config); +// } + +// @PostMapping +//// @LogOperation("保存云存储配置信息") +// public Result saveConfig(@RequestBody CloudStorageConfig config){ +// //校验类型 +// ValidatorUtils.validateEntity(config); +// +// if(config.getType() == OssTypeEnum.QINIU.value()){ +// //校验七牛数据 +// ValidatorUtils.validateEntity(config, QiniuGroup.class); +// }else if(config.getType() == OssTypeEnum.ALIYUN.value()){ +// //校验阿里云数据 +// ValidatorUtils.validateEntity(config, AliyunGroup.class); +// }else if(config.getType() == OssTypeEnum.QCLOUD.value()){ +// //校验腾讯云数据 +// ValidatorUtils.validateEntity(config, QcloudGroup.class); +// } +// +// paramsRemoteService.updateValueByCode(KEY, new Gson().toJson(config)); +// +// return new Result(); +// } + +// @PostMapping("upload") +// public Result upload(@RequestPart("file") MultipartFile file) throws Exception { +// if (file.isEmpty()) { +// return new Result().error(ModuleErrorCode.UPLOAD_FILE_EMPTY); +// } +// +// //上传文件 +// String extension = FilenameUtils.getExtension(file.getOriginalFilename()); +// String url = OssFactory.build().uploadSuffix(file.getBytes(), extension, null); +// +// //保存文件信息 +// OssEntity ossEntity = new OssEntity(); +// ossEntity.setUrl(url); +// ossService.insertOssEntity(ossEntity); +// +// //文件信息 +// UploadDTO dto = new UploadDTO(); +// dto.setUrl(url); +// dto.setSize(file.getSize()); +// +// return new Result().ok(dto); +// } @DeleteMapping // @LogOperation("删除") @@ -150,182 +150,182 @@ public class OssController { return ossService.uploadImg(file, null); } - /** - * 压缩上传 - * - * @param file - * @return com.epmet.commons.tools.utils.Result - * @author zhy - * @date 2022/5/24 13:32 - */ - @PostMapping("compressuploadimg") - public Result compressUploadImg(@RequestParam("file") MultipartFile file) { - return ossService.compressUploadImg(file, null,200L); - } - - @PostMapping("uploadwximg") - public Result uploadWxImg(@RequestPart("media") MultipartFile media) { - return ossService.uploadImg(media, null); - } - - @PostMapping("uploadqrcode") - public Result uploadQrCode(@RequestPart(value = "file") MultipartFile file) { - return ossService.uploadImg(file, null); - } - - /** - * 上传客户logo(考虑到以后可能会针对不同的业务有不同的限制条件,这里不再使用通用的接口 - * 针对每一个业务新建上传接口) - * @param file - * @return - */ - @PostMapping("customerlogo/upload") - public Result uploadCustomerLogo(@RequestParam("file") MultipartFile file) { - - // 校验文件类型 - if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); - } - - // 校验文件体积,不超过1m - long maxSize = 1024 * 1024; - long size = file.getSize(); - if (size > maxSize) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); - } - - return ossService.uploadImg(file, null); - } - - @PostMapping("function/upload") - public Result uploadFunctionLogo(@RequestParam("file") MultipartFile file) { - - // 校验文件类型 - if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); - } - - // 校验文件体积,不超过1m - long maxSize = 1024 * 1024; - long size = file.getSize(); - if (size > maxSize) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); - } - - return ossService.uploadImg(file, null); - } - - /** - * desc: 党建声音模块 上传图片(2M)或附件(5M) - * - * @param file - * @return com.epmet.commons.tools.utils.Result - * @author LiuJanJun - * @date 2021/3/29 4:56 下午 - */ - @PostMapping("article/upload") - public Result uploadArticleImg(@RequestParam("file") MultipartFile file) { - - // 校验文件类型 图片或pdf - if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType()) - && !MediaType.IMAGE_JPEG_VALUE.equals(file.getContentType()) - && !ModuleConstant.FILE_CONTENT_TYPE_JPG.equals(file.getContentType()) - && !ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType()) - && !file.getContentType().startsWith(ModuleConstant.FILE_CONTENT_TYPE_VEDIO_PREFIX) - ) { - log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); - } - long size = file.getSize(); - if (ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType())) { - // 校验文件大小,不超过5m - long maxSize = 5 * 1024 * 1024; - if (size > maxSize) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); - } - } else if (file.getContentType().startsWith(ModuleConstant.FILE_CONTENT_TYPE_VEDIO_PREFIX)) { - // 校验文件大小,不超过5m - long maxSize = 25 * 1024 * 1024; - if (size > maxSize) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); - } - } - Result result =null; - String originFileName = file.getOriginalFilename(); - String format = "-" + originFileName.substring(originFileName.lastIndexOf(".") + NumConstant.ONE) + "-"; - format = format.toLowerCase(); - int compressSize = 2 * 1024 * 1024; - // 如果是图片,超过2M的压缩一下 - if (ModuleConstant.PROJECT_FILE_IMAGE.contains(format) && file.getSize() > compressSize) { - // 单个图片10M - result= ossService.compressUploadImg(file, null, 2 * 1024); - } else { - result=ossService.uploadImg(file, null); - } - if (result != null && result.success() ){ - UploadImgResultDTO data = result.getData(); - if ( data!= null && StringUtils.isNotBlank(data.getUrl())){ - String path = data.getUrl().replace(data.getDomain(), StrConstant.EPMETY_STR); - if (path.startsWith(StrConstant.SEPARATOR)){ - path = path.replaceFirst(StrConstant.SEPARATOR,StrConstant.EPMETY_STR); - } - String fileName = data.getUrl().substring(data.getUrl().lastIndexOf(StrConstant.SEPARATOR)+1); - redisUtils.set(RedisKeys.getOssFileKey(fileName),path,RedisUtils.MINUTE_THIRTY_EXPIRE); - } - } - return result; - } - - - @PostMapping("uploadimg/badgeicon") - public Result badgeIcon(@RequestParam("file") MultipartFile file) throws IOException { - - // 校验文件类型 - if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { - log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); - throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getCode() - , EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getMsg()); - } - - // 校验文件体积,不超过2m - long maxSize = 2 * 1024 * 1024; - long size = file.getSize(); - if (size > maxSize) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); - } - - BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); - int width = bufferedImage.getWidth(); - int height = bufferedImage.getHeight(); - if (width != 200 || height != 200) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getCode() - , EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getMsg()); - - } - return ossService.uploadImg(file, null); - } - - /** - * @param byteFile fileName - * @Description 外挂-文件上传 - * @Author sun - **/ - @PostMapping("ext/upload") - public Result extUpload(@RequestParam("byteFile") byte[] byteFile, @RequestParam("fileName") String fileName) throws IOException { - //public Result extUpload(@RequestParam("file") MultipartFile file, @RequestParam("fileName") String fileName) throws IOException { - //byte[] byteFile = file.getBytes(); - InputStream inputStream = new ByteArrayInputStream(byteFile); - MultipartFile filse = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream); - return ossService.extUpload(filse,fileName, null); - } +// /** +// * 压缩上传 +// * +// * @param file +// * @return com.epmet.commons.tools.utils.Result +// * @author zhy +// * @date 2022/5/24 13:32 +// */ +// @PostMapping("compressuploadimg") +// public Result compressUploadImg(@RequestParam("file") MultipartFile file) { +// return ossService.compressUploadImg(file, null,200L); +// } + +// @PostMapping("uploadwximg") +// public Result uploadWxImg(@RequestPart("media") MultipartFile media) { +// return ossService.uploadImg(media, null); +// } +// +// @PostMapping("uploadqrcode") +// public Result uploadQrCode(@RequestPart(value = "file") MultipartFile file) { +// return ossService.uploadImg(file, null); +// } + +// /** +// * 上传客户logo(考虑到以后可能会针对不同的业务有不同的限制条件,这里不再使用通用的接口 +// * 针对每一个业务新建上传接口) +// * @param file +// * @return +// */ +// @PostMapping("customerlogo/upload") +// public Result uploadCustomerLogo(@RequestParam("file") MultipartFile file) { +// +// // 校验文件类型 +// if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); +// } +// +// // 校验文件体积,不超过1m +// long maxSize = 1024 * 1024; +// long size = file.getSize(); +// if (size > maxSize) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); +// } +// +// return ossService.uploadImg(file, null); +// } + +// @PostMapping("function/upload") +// public Result uploadFunctionLogo(@RequestParam("file") MultipartFile file) { +// +// // 校验文件类型 +// if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); +// } +// +// // 校验文件体积,不超过1m +// long maxSize = 1024 * 1024; +// long size = file.getSize(); +// if (size > maxSize) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); +// } +// +// return ossService.uploadImg(file, null); +// } + +// /** +// * desc: 党建声音模块 上传图片(2M)或附件(5M) +// * +// * @param file +// * @return com.epmet.commons.tools.utils.Result +// * @author LiuJanJun +// * @date 2021/3/29 4:56 下午 +// */ +// @PostMapping("article/upload") +// public Result uploadArticleImg(@RequestParam("file") MultipartFile file) { +// +// // 校验文件类型 图片或pdf +// if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType()) +// && !MediaType.IMAGE_JPEG_VALUE.equals(file.getContentType()) +// && !ModuleConstant.FILE_CONTENT_TYPE_JPG.equals(file.getContentType()) +// && !ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType()) +// && !file.getContentType().startsWith(ModuleConstant.FILE_CONTENT_TYPE_VEDIO_PREFIX) +// ) { +// log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); +// } +// long size = file.getSize(); +// if (ModuleConstant.FILE_CONTENT_TYPE_PDF.equals(file.getContentType())) { +// // 校验文件大小,不超过5m +// long maxSize = 5 * 1024 * 1024; +// if (size > maxSize) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); +// } +// } else if (file.getContentType().startsWith(ModuleConstant.FILE_CONTENT_TYPE_VEDIO_PREFIX)) { +// // 校验文件大小,不超过5m +// long maxSize = 25 * 1024 * 1024; +// if (size > maxSize) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); +// } +// } +// Result result =null; +// String originFileName = file.getOriginalFilename(); +// String format = "-" + originFileName.substring(originFileName.lastIndexOf(".") + NumConstant.ONE) + "-"; +// format = format.toLowerCase(); +// int compressSize = 2 * 1024 * 1024; +// // 如果是图片,超过2M的压缩一下 +// if (ModuleConstant.PROJECT_FILE_IMAGE.contains(format) && file.getSize() > compressSize) { +// // 单个图片10M +// result= ossService.compressUploadImg(file, null, 2 * 1024); +// } else { +// result=ossService.uploadImg(file, null); +// } +// if (result != null && result.success() ){ +// UploadImgResultDTO data = result.getData(); +// if ( data!= null && StringUtils.isNotBlank(data.getUrl())){ +// String path = data.getUrl().replace(data.getDomain(), StrConstant.EPMETY_STR); +// if (path.startsWith(StrConstant.SEPARATOR)){ +// path = path.replaceFirst(StrConstant.SEPARATOR,StrConstant.EPMETY_STR); +// } +// String fileName = data.getUrl().substring(data.getUrl().lastIndexOf(StrConstant.SEPARATOR)+1); +// redisUtils.set(RedisKeys.getOssFileKey(fileName),path,RedisUtils.MINUTE_THIRTY_EXPIRE); +// } +// } +// return result; +// } + + +// @PostMapping("uploadimg/badgeicon") +// public Result badgeIcon(@RequestParam("file") MultipartFile file) throws IOException { +// +// // 校验文件类型 +// if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { +// log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getCode() +// , EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getMsg()); +// } +// +// // 校验文件体积,不超过2m +// long maxSize = 2 * 1024 * 1024; +// long size = file.getSize(); +// if (size > maxSize) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); +// } +// +// BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); +// int width = bufferedImage.getWidth(); +// int height = bufferedImage.getHeight(); +// if (width != 200 || height != 200) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getCode() +// , EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getMsg()); +// +// } +// return ossService.uploadImg(file, null); +// } + +// /** +// * @param byteFile fileName +// * @Description 外挂-文件上传 +// * @Author sun +// **/ +// @PostMapping("ext/upload") +// public Result extUpload(@RequestParam("byteFile") byte[] byteFile, @RequestParam("fileName") String fileName) throws IOException { +// //public Result extUpload(@RequestParam("file") MultipartFile file, @RequestParam("fileName") String fileName) throws IOException { +// //byte[] byteFile = file.getBytes(); +// InputStream inputStream = new ByteArrayInputStream(byteFile); +// MultipartFile filse = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream); +// return ossService.extUpload(filse,fileName, null); +// } /** * @param file @@ -388,16 +388,16 @@ public class OssController { return new Result().ok(ossService.articleRemoveFile(formDTO)); } - /** - * 运营端生成小程序体验码,传递客户Id [开发、测试环境会直接访问生产third,没有token,需要业务中传递客户Id值] - * @param file 文件 - * @param file 文件 - * @author sun - */ - @PostMapping("uploadqrcodeV2") - public Result uploadQrCodeV2(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) { - return ossService.uploadImgV2(file, null, customerId); - } +// /** +// * 运营端生成小程序体验码,传递客户Id [开发、测试环境会直接访问生产third,没有token,需要业务中传递客户Id值] +// * @param file 文件 +// * @param file 文件 +// * @author sun +// */ +// @PostMapping("uploadqrcodeV2") +// public Result uploadQrCodeV2(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) { +// return ossService.uploadImgV2(file, null, customerId); +// } /** * @Description 上传报事文件(目前只有图片) @@ -432,51 +432,51 @@ public class OssController { return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); } - /** - * @Description 办事指南上传附件 - * @Param file - * @Param customerId - * @Return {@link Result< UploadImgResultDTO>} - * @Author zhaoqifeng - * @Date 2021/9/8 17:14 - */ - @PostMapping("upload-guide-file") - public Result uploadGuideFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) { - String fileName = file.getOriginalFilename(); - String format = "-" + fileName.substring(fileName.lastIndexOf(".") + NumConstant.ONE) + "-"; - format = format.toLowerCase(); - // 体积限制 - int sizeMb = 10; - // 大小限制10m - int sizeThreshold = sizeMb * 1024 * 1024; - if (file.getSize() > sizeThreshold) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode(), - EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg().concat(",限制在").concat(String.valueOf(sizeMb)).concat("M以内")); - } - - // 格式限制,只允许png和jpeg - if (!ModuleConstant.GUIDE_FILE_DOC.contains(format)) { - throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() - , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); - } - - return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); - } +// /** +// * @Description 办事指南上传附件 +// * @Param file +// * @Param customerId +// * @Return {@link Result< UploadImgResultDTO>} +// * @Author zhaoqifeng +// * @Date 2021/9/8 17:14 +// */ +// @PostMapping("upload-guide-file") +// public Result uploadGuideFile(@RequestPart(value = "file") MultipartFile file, @RequestParam("customerId") String customerId) { +// String fileName = file.getOriginalFilename(); +// String format = "-" + fileName.substring(fileName.lastIndexOf(".") + NumConstant.ONE) + "-"; +// format = format.toLowerCase(); +// // 体积限制 +// int sizeMb = 10; +// // 大小限制10m +// int sizeThreshold = sizeMb * 1024 * 1024; +// if (file.getSize() > sizeThreshold) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode(), +// EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg().concat(",限制在").concat(String.valueOf(sizeMb)).concat("M以内")); +// } +// +// // 格式限制,只允许png和jpeg +// if (!ModuleConstant.GUIDE_FILE_DOC.contains(format)) { +// throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getCode() +// , EpmetErrorCode.OPER_UPLOAD_FILE_TYPE_ERROR.getMsg()); +// } +// +// return ossService.uploadImgV2(file, PrivacyType.EXTERNAL, customerId); +// } @GetMapping("getOssFileUrl") public Result download(@RequestParam(required = false) String filePath,@RequestParam(required = false) String privacy){ return new Result().ok(ossService.getOssFileUrl(filePath,privacy)); } - /** - * 上传任务描述文件 - * 不限制大小 - * @param file - * @return - */ - @PostMapping("/importTaskDescFile/upload") - public Result uploadImportTaskDescFile(@RequestPart("file") MultipartFile file) { - return ossService.uploadImg(file, null); - } +// /** +// * 上传任务描述文件 +// * 不限制大小 +// * @param file +// * @return +// */ +// @PostMapping("/importTaskDescFile/upload") +// public Result uploadImportTaskDescFile(@RequestPart("file") MultipartFile file) { +// return ossService.uploadImg(file, null); +// } } diff --git a/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/TestController.java b/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/TestController.java index 041d419c..a9d09da8 100644 --- a/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/TestController.java +++ b/code/smart-community/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/TestController.java @@ -13,57 +13,57 @@ import java.io.*; import java.net.Inet4Address; import java.net.InetAddress; import java.net.UnknownHostException; -@Slf4j -@RestController -@RequestMapping("test") +//@Slf4j +//@RestController +//@RequestMapping("test") public class TestController { - @Autowired - private OssService ossService; - - @PostMapping("local-upload") - public Result localUpload(@RequestPart("file") MultipartFile file, @RequestParam("fileName") String fileName) { - - final File tempFile = new File("/opt/upload_files/" + fileName); - - try(InputStream inputStream = file.getInputStream()) { - FileUtils.copyInputStreamToFile(inputStream, tempFile); - } catch (IOException e) { - log.error("method exception", e); - } - return new Result(); - } - - @PostMapping("upload2aliyun") - public Result upload2aliyun() { - try (final FileInputStream fis = new FileInputStream("C:\\Users\\wxz\\Documents\\微信截图_20230101224521.png")) { - final MockMultipartFile mockMultipartFile = new MockMultipartFile("1.png", fis); - return ossService.uploadImg(mockMultipartFile, null); - } catch (FileNotFoundException e) { - log.error("method exception", e); - } catch (IOException e) { - log.error("method exception", e); - } - return new Result(); - } - - /** - * @Description ribbon测试 - * @return - * @author wxz - * @date 2021.08.05 16:28 - */ - @PostMapping("test-ribbon-rcv/{sleep}") - public Result testRibbonRcv(@PathVariable("sleep") Long sleep) { - InetAddress localHost = null; - try { - Thread.sleep(sleep); - localHost = Inet4Address.getLocalHost(); - } catch (UnknownHostException e) { - log.error("method exception", e); - } catch (InterruptedException e) { - log.error("method exception", e); - } - return new Result().ok(localHost); - } +// @Autowired +// private OssService ossService; +// +// @PostMapping("local-upload") +// public Result localUpload(@RequestPart("file") MultipartFile file, @RequestParam("fileName") String fileName) { +// +// final File tempFile = new File("/opt/upload_files/" + fileName); +// +// try(InputStream inputStream = file.getInputStream()) { +// FileUtils.copyInputStreamToFile(inputStream, tempFile); +// } catch (IOException e) { +// log.error("method exception", e); +// } +// return new Result(); +// } +// +// @PostMapping("upload2aliyun") +// public Result upload2aliyun() { +// try (final FileInputStream fis = new FileInputStream("C:\\Users\\wxz\\Documents\\微信截图_20230101224521.png")) { +// final MockMultipartFile mockMultipartFile = new MockMultipartFile("1.png", fis); +// return ossService.uploadImg(mockMultipartFile, null); +// } catch (FileNotFoundException e) { +// log.error("method exception", e); +// } catch (IOException e) { +// log.error("method exception", e); +// } +// return new Result(); +// } +// +// /** +// * @Description ribbon测试 +// * @return +// * @author wxz +// * @date 2021.08.05 16:28 +// */ +// @PostMapping("test-ribbon-rcv/{sleep}") +// public Result testRibbonRcv(@PathVariable("sleep") Long sleep) { +// InetAddress localHost = null; +// try { +// Thread.sleep(sleep); +// localHost = Inet4Address.getLocalHost(); +// } catch (UnknownHostException e) { +// log.error("method exception", e); +// } catch (InterruptedException e) { +// log.error("method exception", e); +// } +// return new Result().ok(localHost); +// } }