|
@ -10,6 +10,8 @@ package com.epmet.controller; |
|
|
|
|
|
|
|
|
import com.epmet.cloud.CloudStorageConfig; |
|
|
import com.epmet.cloud.CloudStorageConfig; |
|
|
import com.epmet.cloud.OssFactory; |
|
|
import com.epmet.cloud.OssFactory; |
|
|
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
@ -29,6 +31,7 @@ import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import org.apache.commons.io.FilenameUtils; |
|
|
import org.apache.commons.io.FilenameUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
@ -145,6 +148,21 @@ public class OssController { |
|
|
*/ |
|
|
*/ |
|
|
@PostMapping("customerlogo/upload") |
|
|
@PostMapping("customerlogo/upload") |
|
|
public Result uploadCustomerLogo(@RequestParam("file") MultipartFile file) { |
|
|
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); |
|
|
return ossService.uploadImg(file); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|