|
@@ -10,7 +10,7 @@ import com.kmall.admin.service.*;
|
|
|
import com.kmall.admin.utils.ParamUtils;
|
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
|
import com.kmall.api.cache.UserTokenCache;
|
|
|
-import com.kmall.common.ImgException;
|
|
|
+import com.kmall.common.utils.ImgException;
|
|
|
import com.kmall.common.constant.Dict;
|
|
|
import com.kmall.common.constant.JxlsXmlTemplateName;
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
@@ -414,10 +414,10 @@ public class GoodsController {
|
|
|
// 如果是文件夹,就创建个文件夹
|
|
|
}
|
|
|
if(null==entryList){
|
|
|
- throw new RRException("文件夹内无图片信息,请检查后重试");
|
|
|
+ throw new ImgException("文件夹内无图片信息,请检查后重试");
|
|
|
}
|
|
|
if(entryList.size()>30){
|
|
|
- throw new RRException("最多上传30张图片");
|
|
|
+ throw new ImgException("最多上传30张图片");
|
|
|
}
|
|
|
try {
|
|
|
for(ZipEntry entry : entryList){
|
|
@@ -444,10 +444,15 @@ public class GoodsController {
|
|
|
}
|
|
|
|
|
|
MultipartFile mulFileByPath = getMulFileByPath(destDirPath + "/" + entry.getName());
|
|
|
- String imgg = entry.getName().split("\\.")[1];
|
|
|
- if ("jpg".equals(imgg)&&!"jpeg".equals(imgg)) {
|
|
|
- throw new RRException("图片格式不正确,请检查!");
|
|
|
- }
|
|
|
+ long fileSize = mulFileByPath.getSize();
|
|
|
+ int maxSize = 1 * 1024 * 1024;
|
|
|
+ if (fileSize > maxSize) {
|
|
|
+ throw new RRException("商品图片过大(最大1M),请检查!");
|
|
|
+ }
|
|
|
+// String imgg = entry.getName().split("\\.")[1];
|
|
|
+// if (!"jpg".equals(imgg)&&!"jpeg".equals(imgg)) {
|
|
|
+// throw new RRException("图片格式不正确,请检查!");
|
|
|
+// }
|
|
|
|
|
|
//上传文件
|
|
|
String url = FileManager.upload(mulFileByPath);
|
|
@@ -480,11 +485,9 @@ public class GoodsController {
|
|
|
}
|
|
|
long end = System.currentTimeMillis();
|
|
|
System.out.println("解压完成,耗时:" + (end - start) +" ms");
|
|
|
- } catch (RRException e) {
|
|
|
- throw new RRException("图片格式不正确,请检查!",e);
|
|
|
- }catch (ImgException e) {
|
|
|
- throw new ImgException("商品图片存在命名格式不正确,请检查!",e);
|
|
|
- } catch (Exception e) {
|
|
|
+ }catch (RRException e) {
|
|
|
+ throw new RRException("商品图片过大(最大1M),请检查!", e);
|
|
|
+ }catch (Exception e) {
|
|
|
throw new RuntimeException("unzip error from ZipUtils", e);
|
|
|
} finally {
|
|
|
if(zipFile != null){
|