| | |
| | | * https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html |
| | | * @return |
| | | */ |
| | | public void generateWXMiniCode(Locks locks){ |
| | | SystemDictData systemDictData = systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.ACCESS_TOKEN); |
| | | public void generateWXMiniCode(Locks locks,SystemDictData systemDictData){ |
| | | |
| | | if(Objects.isNull(systemDictData)){ |
| | | return; |
| | | } |
| | |
| | | body.put("env_version", "release"); |
| | | // 透明,根据你的场景自行设置body参数 |
| | | body.put("is_hyaline", false); |
| | | // body.put("page","pages/index/index"); |
| | | body.put("check_path", false); |
| | | body.put("page","pages/index/index"); |
| | | OkHttpClient client = new OkHttpClient().newBuilder().build(); |
| | | okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json"); |
| | | okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSONObject.toJSONString(body)); |
| | |
| | | Response response = client.newCall(request).execute(); |
| | | if (response.isSuccessful()) { |
| | | InputStream inputStream = new ByteArrayInputStream(response.body().bytes()); |
| | | int i = inputStream.available(); // 得到文件大小 |
| | | |
| | | // 得到文件大小 |
| | | int i = inputStream.available(); |
| | | byte[] mFileBody = new byte[i]; |
| | | inputStream.read(mFileBody); // 读数据 |
| | | // 读数据 |
| | | inputStream.read(mFileBody); |
| | | locks.setInfo("data:image/Jpeg;base64," + Base64.getEncoder().encodeToString(mFileBody)); |
| | | /* |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | byte[] buffer = new byte[1024]; |
| | | int len = -1; |
| | | while ((len = inputStream.read(buffer)) != -1) { |
| | | baos.write(buffer, 0, len); |
| | | }*/ |
| | | |
| | | |
| | | // FileOutputStream out = new FileOutputStream("d:\\test.png"); |
| | | // byte[] buffer = new byte[8192]; |
| | | // int bytesRead = 0; |
| | | // while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) { |
| | | // out.write(buffer, 0, bytesRead); |
| | | // } |
| | | // out.flush(); |
| | | // inputStream.close(); |
| | | // out.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |