From bb62066b8240d746189568adbdddcc72af5f46ab Mon Sep 17 00:00:00 2001 From: fanxb Date: Thu, 23 May 2024 22:07:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dbing=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ConfigServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java index 39812cd..6d22553 100644 --- a/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java +++ b/bookMarkService/common/src/main/java/com/fanxb/bookmark/common/service/impl/ConfigServiceImpl.java @@ -74,14 +74,18 @@ public class ConfigServiceImpl implements ConfigService { } private String getBingImg() { - JSONObject bingObj = HttpUtil.getObj(bingHost + bingUrl, null, false); - String path = bingObj.getJSONArray("images").getJSONObject(0).getString("url"); - String picUrl = bingHost + path; - Request request = new Request.Builder().url(picUrl).build(); - try (Response res = HttpUtil.getClient(false).newCall(request).execute()) { - byte[] bytes = res.body().bytes(); - String filePath = CommonConstant.fileSavePath + "/files/public/bing.jpg"; - FileUtil.writeBytes(bytes, filePath); + try { + JSONObject bingObj = HttpUtil.getObj(bingHost + bingUrl, null, false); + String path = bingObj.getJSONArray("images").getJSONObject(0).getString("url"); + String picUrl = bingHost + path; + Request request = new Request.Builder().url(picUrl).build(); + try (Response res = HttpUtil.getClient(false).newCall(request).execute()) { + byte[] bytes = res.body().bytes(); + String filePath = CommonConstant.fileSavePath + "/files/public/bing.jpg"; + FileUtil.writeBytes(bytes, filePath); + } catch (Exception e) { + log.error("获取bing每日一图错误:{}", e.getLocalizedMessage(), e); + } } catch (Exception e) { log.error("获取bing每日一图错误:{}", e.getLocalizedMessage(), e); } -- 2.47.1