1
0
qng 3 лет назад
Родитель
Сommit
465ee69bc6

+ 11 - 1
kmall-admin/src/main/java/com/kmall/admin/controller/GoodsController.java

@@ -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 {

+ 2 - 2
kmall-admin/src/main/resources/conf/fastdfs.properties

@@ -9,7 +9,7 @@ base_path=/data/files/
 
 #tracker server\u662FFastDFS\u6587\u4EF6\u7CFB\u7EDF\u7684\u534F\u8C03\u8005,\u5176\u4E3B\u8981\u4F5C\u7528\u662F\u8D1F\u8F7D\u5747\u8861\u548C\u8C03\u5EA6\u3002
 #Tracker server\u5728\u5185\u5B58\u4E2D\u8BB0\u5F55\u5206\u7EC4\u548CStorage server\u7684\u72B6\u6001\u7B49\u4FE1\u606F\uFF0C\u4E0D\u8BB0\u5F55\u6587\u4EF6\u7D22\u5F15\u4FE1\u606F
-tracker_server=192.168.1.251:22122
+tracker_server=183.3.221.143:22122
 
 log_level=info
 
@@ -24,7 +24,7 @@ use_storage_id = false
 storage_ids_filename = storage_ids.conf
 
 #HTTP \u670D\u52A1\u5668\u5730\u5740
-http.tracket_nginx_addr=192.168.1.251
+http.tracket_nginx_addr=183.3.221.143
 
 #HTTP \u670D\u52A1\u5668\u7AEF\u53E3\u53F7
 http.tracker_server_port=80

+ 1 - 1
kmall-admin/src/main/webapp/WEB-INF/page/shop/goods.html

@@ -159,7 +159,7 @@
                     
                 <a href="../statics/file/goods_export_yyyy_mm_dd_v1.0.0.xls">商品模板下载</a>&nbsp;&nbsp;&nbsp;&nbsp;
                 <a href="../statics/file/general_goods_export_yyyy_mm_dd_v1.0.0.xls">普货商品模板下载</a>
-                <a href="../statics/file/goods_img.zip">商品导入示例下载</a>
+                <a href="../statics/file/goods_img.zip">商品图片批量导入示例下载</a>
                 #end
             </div>
         </Row>

+ 55 - 0
kmall-common/src/main/java/com/kmall/common/ImgException.java

@@ -0,0 +1,55 @@
+package com.kmall.common;
+
+/**
+ * 自定义异常
+ *
+ * @author Scott
+ * @email
+ * @date 2016年10月27日 下午10:11:27
+ */
+public class ImgException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    private String msg;
+    private int code = 500;
+
+    public ImgException(String msg) {
+        super(msg);
+        this.msg = msg;
+    }
+
+    public ImgException(String msg, Throwable e) {
+        super(msg, e);
+        this.msg = msg;
+    }
+
+    public ImgException(String msg, int code) {
+        super(msg);
+        this.msg = msg;
+        this.code = code;
+    }
+
+    public ImgException(String msg, int code, Throwable e) {
+        super(msg, e);
+        this.msg = msg;
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+
+}

+ 5 - 5
kmall-manager/src/main/resources/conf/redis.properties

@@ -1,11 +1,11 @@
-########## redis 配置 ##########
+########## redis \u914D\u7F6E ##########
 
 # [dev, prod]
 redis.env = dev
 
-# 开发环境
+# \u5F00\u53D1\u73AF\u5883
 redis.dev.keyPrefix=platform
-redis.dev.host=127.0.0.1
+redis.dev.host=183.3.221.143
 redis.dev.port=6379
 redis.dev.pool.maxIdle=200
 redis.dev.pool.maxWait=1000
@@ -13,7 +13,7 @@ redis.dev.pool.maxTotal=10000
 redis.dev.pool.testOnBorrow=true
 
 
-# 中网生产环境
+# \u4E2D\u7F51\u751F\u4EA7\u73AF\u5883
 redis.prod.keyPrefix=platform
 redis.prod.host=172.18.132.30
 redis.prod.port=6379
@@ -22,7 +22,7 @@ redis.prod.pool.maxWait=1000
 redis.prod.pool.maxTotal=10000
 redis.prod.pool.testOnBorrow=true
 
-## 中网国际生产环境
+## \u4E2D\u7F51\u56FD\u9645\u751F\u4EA7\u73AF\u5883
 #redis.prod.keyPrefix=platform
 #redis.prod.host=183.62.225.124
 #redis.prod.port=6379