Pārlūkot izejas kodu

根据品牌和型号,返回类目接口增加判空

dongbw 7 gadi atpakaļ
vecāks
revīzija
3560961f11

+ 2 - 2
src/main/java/com/uas/ps/product/service/impl/ProductServiceImpl.java

@@ -552,11 +552,11 @@ public class ProductServiceImpl implements ProductService {
         // 获取品牌
         String brandUrl = urlProperties.getB2cUrl() + "/api/product/brand/byName/brand?name=" + brand;
         BrandInfo brandInfo = restTemplate.getForEntity(brandUrl, BrandInfo.class).getBody();
-        if (brandInfo.getUuid() != null) {
+        if (null != brandInfo && null != brandInfo.getUuid()) {
             String componentUrl = urlProperties.getB2cUrl() + "/api/product/component/codeAndBrand/info?brandId="
                     + brandInfo.getId() + "&cmpCode=" + cmpCode;
             ComponentInfo component = restTemplate.getForEntity(componentUrl, ComponentInfo.class).getBody();
-            if (null != component.getKind()) {
+            if (null != component && null != component.getKind()) {
                 kind = component.getKind().getNameCn();
             }
         }