|
|
@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
@ -401,11 +403,14 @@ public class UpfilePersionServiceImpl |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Result<String> logoImageUpload(MultipartFile[] multipartFiles, String flag) { |
|
|
|
public Result<String> logoImageUpload(MultipartFile[] multipartFiles, String flag) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.notNull(multipartFiles, "请选择文件"); |
|
|
|
|
|
|
|
Assert.notNull(flag, "flag为空"); |
|
|
|
|
|
|
|
|
|
|
|
MultipartFile file = multipartFiles[0]; |
|
|
|
MultipartFile file = multipartFiles[0]; |
|
|
|
// 当前文件的格式
|
|
|
|
// 当前文件的格式
|
|
|
|
String currentFormat = Objects.requireNonNull(file.getOriginalFilename()).substring(file.getOriginalFilename().lastIndexOf(".") + 1); |
|
|
|
String currentFormat = Objects.requireNonNull(file.getOriginalFilename()).substring(file.getOriginalFilename().lastIndexOf(".") + 1); |
|
|
|
// 验证格式
|
|
|
|
// 验证格式
|
|
|
|
if (!"png".equals(currentFormat)) { |
|
|
|
if (!"png".equalsIgnoreCase(currentFormat)) { |
|
|
|
return Result.error("文件格式不符合要求,请上传.png文件!"); |
|
|
|
return Result.error("文件格式不符合要求,请上传.png文件!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|