@Test public void testAddTemplate() throws Exception{ List<Integer> list = Lists.newArrayList(); list.add(1); list.add(20); list.add(84); WxMaTemplateAddResult result = this.wxService.getTemplateService().addTemplate("AT0004", list); Assert.assertNotNull(result.getTemplateId()); System.out.println(result); }
@Override public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("id", id); params.put("keyword_id_list", keywordIdList.toArray()); String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText); if(wxError.getErrorCode() == 0){ return WxMaTemplateAddResult.fromJson(responseText); }else { throw new WxErrorException(wxError); } }
WxMaTemplateServiceImpl implements WxMaTemplateService { @Override public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("id", id); params.put("keyword_id_list", keywordIdList.toArray()); String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText); if(wxError.getErrorCode() == 0){ return WxMaTemplateAddResult.fromJson(responseText); }else { throw new WxErrorException(wxError); } } }
WxMaTemplateServiceImpl implements WxMaTemplateService { @Override public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("id", id); params.put("keyword_id_list", keywordIdList.toArray()); String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText); if(wxError.getErrorCode() == 0){ return WxMaTemplateAddResult.fromJson(responseText); }else { throw new WxErrorException(wxError); } } WxMaTemplateServiceImpl(WxMaService wxMaService); }
WxMaTemplateServiceImpl implements WxMaTemplateService { @Override public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("id", id); params.put("keyword_id_list", keywordIdList.toArray()); String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText); if(wxError.getErrorCode() == 0){ return WxMaTemplateAddResult.fromJson(responseText); }else { throw new WxErrorException(wxError); } } WxMaTemplateServiceImpl(WxMaService wxMaService); @Override WxMaTemplateLibraryListResult findTemplateLibraryList(int offset, int count); @Override WxMaTemplateLibraryGetResult findTemplateLibraryKeywordList(String id); @Override WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList); @Override WxMaTemplateListResult findTemplateList(int offset, int count); @Override boolean delTemplate(String templateId); }
WxMaTemplateServiceImpl implements WxMaTemplateService { @Override public WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("id", id); params.put("keyword_id_list", keywordIdList.toArray()); String responseText = this.wxMaService.post(TEMPLATE_ADD_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText); if(wxError.getErrorCode() == 0){ return WxMaTemplateAddResult.fromJson(responseText); }else { throw new WxErrorException(wxError); } } WxMaTemplateServiceImpl(WxMaService wxMaService); @Override WxMaTemplateLibraryListResult findTemplateLibraryList(int offset, int count); @Override WxMaTemplateLibraryGetResult findTemplateLibraryKeywordList(String id); @Override WxMaTemplateAddResult addTemplate(String id, List<Integer> keywordIdList); @Override WxMaTemplateListResult findTemplateList(int offset, int count); @Override boolean delTemplate(String templateId);  }