ソースを参照

针对传入信息进行字段值校验处理

hejq 7 年 前
コミット
f9d81fcc86

+ 6 - 4
src/main/java/com/uas/platform/b2c/prod/commodity/service/impl/ProductServiceImpl.java

@@ -2412,6 +2412,7 @@ public class ProductServiceImpl implements ProductService {
         product.setPbrand(product.getBrand());
         product.setPbranden(product.getBrand());
         product.setPcmpcode(product.getCmpCode());
+        product.setKind(product.getProdName());
         List<Product> existProducts = productDao.findProductByPcmpcodeAndPbrandenAndEnUU(product.getCmpCode(), product.getBrand(), enUU);
         // PCB产品做标准判断处理
         if (null != isPcb && Objects.equals(IntegerConstant.YES_SHORT, isPcb)) {
@@ -2466,6 +2467,7 @@ public class ProductServiceImpl implements ProductService {
         int maxBrandEnLength = 50;
         int maxBrandCnLength = 25;
         int maxKindLength = 20;
+        int maxCmpCodeLength = 100;
         // 验证品牌
         if (StringUtils.isEmpty(product.getBrand())) {
             jointErrMsg(errMsg, ErrorInfoConstant.BRAND_EMPTY_INFO.getInfo());
@@ -2479,12 +2481,12 @@ public class ProductServiceImpl implements ProductService {
                 jointErrMsg(errMsg, e.getMessage());
             }
         }
-        // 校验类目
-        if (StringUtils.isEmpty(product.getKind())) {
+        // 校验名称
+        if (StringUtils.isEmpty(product.getProdName())) {
             jointErrMsg(errMsg, ErrorInfoConstant.KIND_EMPTY_INFO.getInfo());
         } else {
             try {
-                if (product.getKind().getBytes(GBK_CHARSET_NAME).length > maxKindLength) {
+                if (product.getProdName().getBytes(GBK_CHARSET_NAME).length > maxKindLength) {
                     jointErrMsg(errMsg, ErrorInfoConstant.KIND_LENGTH_INFO.getInfo());
                 }
             } catch (UnsupportedEncodingException e) {
@@ -2499,7 +2501,7 @@ public class ProductServiceImpl implements ProductService {
                 jointErrMsg(errMsg, ErrorInfoConstant.CODE_PATTERN_INFO.getInfo());
             }
             try {
-                if (code.getBytes("GBK").length > 100) {
+                if (code.getBytes(GBK_CHARSET_NAME).length > maxCmpCodeLength) {
                     jointErrMsg(errMsg, ErrorInfoConstant.CODE_LENGTH_INFO.getInfo());
                 }
             } catch (UnsupportedEncodingException e) {