|
@@ -10,6 +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.constant.Dict;
|
|
|
import com.kmall.common.constant.JxlsXmlTemplateName;
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
@@ -443,13 +444,18 @@ 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("图片格式不正确,请检查!");
|
|
|
+ }
|
|
|
+
|
|
|
//上传文件
|
|
|
String url = FileManager.upload(mulFileByPath);
|
|
|
list.add(url);
|
|
|
if(type == 1){
|
|
|
String sku = entry.getName().split("\\.")[0];
|
|
|
if (null==sku||"".equals(sku)) {
|
|
|
- throw new RRException("文件名为:" + sku + "的商品命名格式不正确,请检查!");
|
|
|
+ throw new ImgException("文件为:" + sku + "的商品命名格式不正确,请检查!");
|
|
|
}
|
|
|
GoodsEntity goodsEntity = goodsService.queryBySku(sku);
|
|
|
goodsEntity.setPrimaryPicUrl(url);
|
|
@@ -474,6 +480,10 @@ 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) {
|
|
|
throw new RuntimeException("unzip error from ZipUtils", e);
|
|
|
} finally {
|