| @@ -52,18 +52,13 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public GoodsTemplateGet templateGet(Integer category_id, Integer product_type) throws WxErrorException { | |||
| TtWebGoodsCategoryGetRequestExecutor getExecutor = new TtWebGoodsCategoryGetRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.TEMPLATE_GET; | |||
| String param = "category_id=" + category_id | |||
| + "&product_type=" + product_type; | |||
| String result = this.service.execute(getExecutor, apiUrl, param); | |||
| BaseGoodsResult<GoodsTemplateGet> baseResult = GSON.fromJson(result, | |||
| new TypeReference<BaseGoodsResult<GoodsTemplateGet>>(){}.getType()); | |||
| if(baseResult.isSuccess()){ | |||
| return baseResult.getData(); | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| return GSON.fromJson(result, GoodsTemplateGet.class); | |||
| } | |||
| @Override | |||
| @@ -77,19 +72,14 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| param = "out_ids=" + out_ids; | |||
| } | |||
| String result = this.service.execute(getExecutor, apiUrl, param+"&account_id="+accountId); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| Map map = (Map) baseResult.getData(); | |||
| if(map != null){ | |||
| Object product_draft_list = map.get("product_drafts"); | |||
| List<Product> list = GSON.fromJson(GSON.toJson(product_draft_list), | |||
| new TypeReference<List<Product>>() {}.getType()); | |||
| return list; | |||
| } | |||
| return null; | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| // GsonHelper.get(jsonObject,"product_id"); | |||
| JsonArray product_drafts = jsonObject.getAsJsonArray("product_drafts"); | |||
| List<Product> list = GSON.fromJson(GSON.toJson(product_drafts), | |||
| new TypeReference<List<Product>>() {}.getType()); | |||
| return list; | |||
| } | |||
| @Override | |||
| @@ -109,13 +99,9 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| param += "&status=" + status; | |||
| } | |||
| String result = this.service.execute(getExecutor, apiUrl, param+"&account_id="+accountId); | |||
| BaseGoodsResult<ProductPage> baseResult = GSON.fromJson(result, | |||
| new TypeReference<BaseGoodsResult<ProductPage>>() {}.getType()); | |||
| if(baseResult.isSuccess()){ | |||
| return baseResult.getData(); | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| return GSON.fromJson(result,ProductPage.class); | |||
| } | |||
| @Override | |||
| @@ -129,19 +115,14 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| param = "out_ids=" + out_ids; | |||
| } | |||
| String result = this.service.execute(getExecutor, apiUrl, param+"&account_id="+accountId); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| Map map = (Map) baseResult.getData(); | |||
| if(map != null){ | |||
| Object product_online_list = map.get("product_onlines"); | |||
| List<Product> list = GSON.fromJson(GSON.toJson(product_online_list), | |||
| new TypeReference<List<Product>>() {}.getType()); | |||
| return list; | |||
| } | |||
| return null; | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| // GsonHelper.get(jsonObject,"product_id"); | |||
| JsonArray product_online_list = jsonObject.getAsJsonArray("product_onlines"); | |||
| List<Product> list = GSON.fromJson(GSON.toJson(product_online_list), | |||
| new TypeReference<List<Product>>() {}.getType()); | |||
| return list; | |||
| } | |||
| @Override | |||
| @@ -161,13 +142,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| param += "&status=" + status; | |||
| } | |||
| String result = this.service.execute(getExecutor, apiUrl, param+"&account_id="+accountId); | |||
| BaseGoodsResult<ProductPage> baseResult = GSON.fromJson(result, | |||
| new TypeReference<BaseGoodsResult<ProductPage>>() {}.getType()); | |||
| if(baseResult.isSuccess()){ | |||
| return baseResult.getData(); | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| return GSON.fromJson(result,ProductPage.class); | |||
| } | |||
| @Override | |||