|
|
@@ -5,6 +5,7 @@ import com.uas.platform.b2c.advertise.ad.service.FloorsService;
|
|
|
import com.uas.platform.b2c.core.config.MicroServicesConf;
|
|
|
import com.uas.platform.b2c.core.utils.JacksonUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
@@ -35,4 +36,37 @@ public class FloorsServiceImpl implements FloorsService {
|
|
|
String result = restTemplate.getForEntity(url, String.class).getBody();
|
|
|
return JacksonUtils.fromJsonArray(result, JSONObject.class);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|