@Test public void testGetQrCode() throws Exception { byte[] qrCode = wxService.getCodeService().getQrCode(); assertTrue(qrCode.length > 0); }
@Override public byte[] getQrCode() throws WxErrorException { String appId = this.wxMaService.getWxMaConfig().getAppid(); Path qrCodeFilePath = null; try { RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("weixin-java-tools-ma-" + appId).toFile()); qrCodeFilePath = this.wxMaService.execute(executor, GET_QRCODE_URL, null).toPath(); return Files.readAllBytes(qrCodeFilePath); } catch (IOException e) { throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } finally { if (qrCodeFilePath != null) { try { Files.delete(qrCodeFilePath); } catch (Exception ignored) { } } } }
WxMaCodeServiceImpl implements WxMaCodeService { @Override public byte[] getQrCode() throws WxErrorException { String appId = this.wxMaService.getWxMaConfig().getAppid(); Path qrCodeFilePath = null; try { RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("weixin-java-tools-ma-" + appId).toFile()); qrCodeFilePath = this.wxMaService.execute(executor, GET_QRCODE_URL, null).toPath(); return Files.readAllBytes(qrCodeFilePath); } catch (IOException e) { throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } finally { if (qrCodeFilePath != null) { try { Files.delete(qrCodeFilePath); } catch (Exception ignored) { } } } } }
WxMaCodeServiceImpl implements WxMaCodeService { @Override public byte[] getQrCode() throws WxErrorException { String appId = this.wxMaService.getWxMaConfig().getAppid(); Path qrCodeFilePath = null; try { RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("weixin-java-tools-ma-" + appId).toFile()); qrCodeFilePath = this.wxMaService.execute(executor, GET_QRCODE_URL, null).toPath(); return Files.readAllBytes(qrCodeFilePath); } catch (IOException e) { throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } finally { if (qrCodeFilePath != null) { try { Files.delete(qrCodeFilePath); } catch (Exception ignored) { } } } } WxMaCodeServiceImpl(WxMaService wxMaService); }
WxMaCodeServiceImpl implements WxMaCodeService { @Override public byte[] getQrCode() throws WxErrorException { String appId = this.wxMaService.getWxMaConfig().getAppid(); Path qrCodeFilePath = null; try { RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("weixin-java-tools-ma-" + appId).toFile()); qrCodeFilePath = this.wxMaService.execute(executor, GET_QRCODE_URL, null).toPath(); return Files.readAllBytes(qrCodeFilePath); } catch (IOException e) { throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } finally { if (qrCodeFilePath != null) { try { Files.delete(qrCodeFilePath); } catch (Exception ignored) { } } } } WxMaCodeServiceImpl(WxMaService wxMaService); @Override void commit(WxMaCodeCommitRequest commitRequest); @Override byte[] getQrCode(); @Override List<WxMaCategory> getCategory(); @Override List<String> getPage(); @Override long submitAudit(WxMaCodeSubmitAuditRequest auditRequest); @Override WxMaCodeAuditStatus getAuditStatus(long auditId); @Override WxMaCodeAuditStatus getLatestAuditStatus(); @Override void release(); @Override void changeVisitStatus(String action); @Override void revertCodeRelease(); @Override WxMaCodeVersionDistribution getSupportVersion(); @Override void setSupportVersion(String version); @Override void undoCodeAudit(); }
WxMaCodeServiceImpl implements WxMaCodeService { @Override public byte[] getQrCode() throws WxErrorException { String appId = this.wxMaService.getWxMaConfig().getAppid(); Path qrCodeFilePath = null; try { RequestExecutor<File, String> executor = BaseMediaDownloadRequestExecutor .create(this.wxMaService.getRequestHttp(), Files.createTempDirectory("weixin-java-tools-ma-" + appId).toFile()); qrCodeFilePath = this.wxMaService.execute(executor, GET_QRCODE_URL, null).toPath(); return Files.readAllBytes(qrCodeFilePath); } catch (IOException e) { throw new WxErrorException(WxError.builder().errorMsg(e.getMessage()).build(), e); } finally { if (qrCodeFilePath != null) { try { Files.delete(qrCodeFilePath); } catch (Exception ignored) { } } } } WxMaCodeServiceImpl(WxMaService wxMaService); @Override void commit(WxMaCodeCommitRequest commitRequest); @Override byte[] getQrCode(); @Override List<WxMaCategory> getCategory(); @Override List<String> getPage(); @Override long submitAudit(WxMaCodeSubmitAuditRequest auditRequest); @Override WxMaCodeAuditStatus getAuditStatus(long auditId); @Override WxMaCodeAuditStatus getLatestAuditStatus(); @Override void release(); @Override void changeVisitStatus(String action); @Override void revertCodeRelease(); @Override WxMaCodeVersionDistribution getSupportVersion(); @Override void setSupportVersion(String version); @Override void undoCodeAudit();  }