|
|
@@ -1,5 +1,6 @@
|
|
|
package com.uas.platform.b2c.advertise.ad.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
import com.uas.platform.b2c.advertise.ad.service.FloorsService;
|
|
|
@@ -39,16 +40,35 @@ public class FloorsServiceImpl implements FloorsService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean setFloorsItem(String floorId, String body) {
|
|
|
- if ("".equals(floorId)){
|
|
|
- return false;
|
|
|
- }
|
|
|
- String url = conf.getRequestUrlForFloor(20040, "/floors/"+floorId+"/item");
|
|
|
- HttpStatus status = restTemplate.postForEntity(url,body,String.class).getStatusCode();
|
|
|
+ public Boolean setFloorsItem(JSONObject item){ //(String name, String brandEn ,String kind, String pictureUrl, String hrefUrl) {
|
|
|
+
|
|
|
+ String url = conf.getRequestUrlForFloor(20040, "/floors/"+item.get("floorId").toString()+"/item");
|
|
|
+ item.remove("floorId");
|
|
|
+ HttpStatus status = restTemplate.postForEntity(url,item,String.class).getStatusCode();
|
|
|
if (status.equals(HttpStatus.OK)){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject isInHome(String batchCode) {
|
|
|
+ String url = conf.getRequestUrlForFloor(20040, "/floors?usedFor=home-v3");
|
|
|
+ String result = restTemplate.getForEntity(url, String.class).getBody();
|
|
|
+ List<JSONObject> floors = JacksonUtils.fromJsonArray(result,JSONObject.class);
|
|
|
+ List<JSONObject> items;
|
|
|
+ for (JSONObject floor : floors){
|
|
|
+ if (floor.get("name").equals("器件楼层")){
|
|
|
+ String floorId = floor.get("id").toString();
|
|
|
+ items = JacksonUtils.fromJsonArray(floor.get("items").toString(),JSONObject.class);
|
|
|
+ for (JSONObject item : items){
|
|
|
+ if (item.get("hrefUrl").toString().indexOf(batchCode) != -1){
|
|
|
+ return item.fluentPut("floorId",floorId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|