@Test public void testMaterialFileList() throws WxErrorException { WxMpMaterialFileBatchGetResult wxMpMaterialVoiceBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VOICE, 0, 20); WxMpMaterialFileBatchGetResult wxMpMaterialVideoBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.VIDEO, 0, 20); WxMpMaterialFileBatchGetResult wxMpMaterialImageBatchGetResult = this.wxService.getMaterialService().materialFileBatchGet(WxConsts.MaterialType.IMAGE, 0, 20); assertNotNull(wxMpMaterialVoiceBatchGetResult); assertNotNull(wxMpMaterialVideoBatchGetResult); assertNotNull(wxMpMaterialImageBatchGetResult); }
@Override public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("type", type); params.put("offset", offset); params.put("count", count); String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText, WxType.MP); if (wxError.getErrorCode() == 0) { return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class); } else { throw new WxErrorException(wxError); } }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("type", type); params.put("offset", offset); params.put("count", count); String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText, WxType.MP); if (wxError.getErrorCode() == 0) { return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class); } else { throw new WxErrorException(wxError); } } }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("type", type); params.put("offset", offset); params.put("count", count); String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText, WxType.MP); if (wxError.getErrorCode() == 0) { return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class); } else { throw new WxErrorException(wxError); } } WxMpMaterialServiceImpl(WxMpService wxMpService); }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("type", type); params.put("offset", offset); params.put("count", count); String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText, WxType.MP); if (wxError.getErrorCode() == 0) { return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class); } else { throw new WxErrorException(wxError); } } WxMpMaterialServiceImpl(WxMpService wxMpService); @Override WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream); @Override WxMediaUploadResult mediaUpload(String mediaType, File file); @Override File mediaDownload(String mediaId); @Override WxMediaImgUploadResult mediaImgUpload(File file); @Override WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material); @Override WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news); @Override InputStream materialImageOrVoiceDownload(String mediaId); @Override WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId); @Override WxMpMaterialNews materialNewsInfo(String mediaId); @Override boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate); @Override boolean materialDelete(String mediaId); @Override WxMpMaterialCountResult materialCount(); @Override WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count); @Override WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count); }
WxMpMaterialServiceImpl implements WxMpMaterialService { @Override public WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count) throws WxErrorException { Map<String, Object> params = new HashMap<>(); params.put("type", type); params.put("offset", offset); params.put("count", count); String responseText = this.wxMpService.post(MATERIAL_BATCHGET_URL, WxGsonBuilder.create().toJson(params)); WxError wxError = WxError.fromJson(responseText, WxType.MP); if (wxError.getErrorCode() == 0) { return WxMpGsonBuilder.create().fromJson(responseText, WxMpMaterialFileBatchGetResult.class); } else { throw new WxErrorException(wxError); } } WxMpMaterialServiceImpl(WxMpService wxMpService); @Override WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream); @Override WxMediaUploadResult mediaUpload(String mediaType, File file); @Override File mediaDownload(String mediaId); @Override WxMediaImgUploadResult mediaImgUpload(File file); @Override WxMpMaterialUploadResult materialFileUpload(String mediaType, WxMpMaterial material); @Override WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news); @Override InputStream materialImageOrVoiceDownload(String mediaId); @Override WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId); @Override WxMpMaterialNews materialNewsInfo(String mediaId); @Override boolean materialNewsUpdate(WxMpMaterialArticleUpdate wxMpMaterialArticleUpdate); @Override boolean materialDelete(String mediaId); @Override WxMpMaterialCountResult materialCount(); @Override WxMpMaterialNewsBatchGetResult materialNewsBatchGet(int offset, int count); @Override WxMpMaterialFileBatchGetResult materialFileBatchGet(String type, int offset, int count);  }