Bläddra i källkod

http://192.168.0.21/index.php?m=bug&f=view&bugID=25938
获取直播间广告位

lyhzzz 3 år sedan
förälder
incheckning
66f2ad1db5

+ 23 - 0
platform-common/src/main/java/com/platform/service/impl/ZhiHouseService.java

@@ -359,4 +359,27 @@ public class ZhiHouseService {
         //把信息封装为json
         return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getMessage()));
     }
+
+    public Integer getCountRecommendByBrandIds(Integer[] ids) {
+        try {
+            if(ids == null || ids.length <=0){
+                throw new CommonBaseException(ResultCodeEnum.D101 , "入参不全");
+            }
+            String url = zhiHouseHost + "recommend/getCountRecommendByBrandIds";
+            Map<String ,Object> params = new HashMap<>(1);
+            params.put("ids",ids);
+            ResponseEntity<ReturnDTO> responseEntity = restTemplate.postForEntity(url,params,ReturnDTO.class);
+            if(responseEntity.getStatusCode()!= HttpStatus.OK){
+                throw new CommonBaseException(ResultCodeEnum.D100);
+            }
+            if (responseEntity.getBody().getCode() != 200) {
+                throw new CommonBaseException(ResultCodeEnum.D100,responseEntity.getBody().getError());
+            }
+            //把信息封装为json
+            return Integer.valueOf(JSONObject.toJSONString(responseEntity.getBody().getMessage()));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
 }

+ 7 - 0
platform-shop/src/main/java/com/platform/controller/BrandController.java

@@ -165,6 +165,9 @@ public class BrandController extends AbstractController{
             return Result.failure("参数有误!");
         }
         BrandEntity brand = brandService.queryObject(brandEntity.getId().intValue());
+        if(brand == null ){
+            throw new RRException("直播间为空!");
+        }
         BrandRspVo brandRspVo = new BrandRspVo();
         BeanUtils.copyProperties(brand,brandRspVo);
         JSONObject jsonObject = zhiHouseService.queryBySceneNum(brand.getSceneNum(),token);
@@ -295,6 +298,10 @@ public class BrandController extends AbstractController{
             return Result.success();
         }
 
+        Integer recommendCount = zhiHouseService.getCountRecommendByBrandIds(ids);
+        if(recommendCount == null || recommendCount >0){
+           throw new RRException("直播间数据已被绑定,请先解除绑定!");
+        }
 
         // 判断场景是否绑定商品,如果绑定商品,不允许删除;
         Map<String, Object> params = new HashMap<>();