From 3afe1c715d1617b9eb27df5c0702f67a54d6f487 Mon Sep 17 00:00:00 2001 From: xupei <1779019091@qq.com> Date: Tue, 19 Sep 2023 15:52:33 +0800 Subject: [PATCH] =?UTF-8?q?generate=20=E6=8E=A5=E5=8F=A3=E7=96=8F=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ai/da/python/PythonService.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 987d78c2..829a4e4d 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -1636,7 +1636,7 @@ public class PythonService { content.put("user_id", userId); content.put("image_url", url); content.put("category", category); - content.put("mode",mode); // + content.put("mode",mode); content.put("str", text); content.put("version",2); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); @@ -1650,32 +1650,32 @@ public class PythonService { .build(); Response response = null; String bodyString = null; -// try { + try { log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content)); -// response = client.newCall(request).execute(); -// bodyString = response.body().string(); - bodyString = "{\n" + - " \"code\": 200,\n" + - " \"data\": {\n" + - " \"list\": [\n" + - " \"aida-users/12/print_1695088687_0.png\"\n" + - " ]\n" + - " },\n" + - " \"msg\": \"OK!\"\n" + - "}"; -// } catch (IOException ioException) { -// log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException)); -// } + response = client.newCall(request).execute(); + bodyString = response.body().string(); +// bodyString = "{\n" + +// " \"code\": 200,\n" + +// " \"data\": {\n" + +// " \"list\": [\n" + +// " \"aida-users/12/print_1695088687_0.png\"\n" + +// " ]\n" + +// " },\n" + +// " \"msg\": \"OK!\"\n" + +// "}"; + } catch (IOException ioException) { + log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException)); + } //去除限流 AccessLimitUtils.validateOut("generateSketchOrPrint"); // 生成失败 -// if (Objects.isNull(response) || StringUtil.isNullOrEmpty(bodyString)) { -// log.error("PythonService##generateSketchOrPrint异常###{}", "response or body is empty!"); -// throw new BusinessException("generate exception!"); -// } + if (Objects.isNull(response) || StringUtil.isNullOrEmpty(bodyString)) { + log.error("PythonService##generateSketchOrPrint异常###{}", "response or body is empty!"); + throw new BusinessException("generate exception!"); + } JSONObject jsonObject = JSON.parseObject(bodyString); -// Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful"); - Boolean result = Boolean.TRUE; + Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful"); +// Boolean result = Boolean.TRUE; if (result) { return setGenerateImageList(jsonObject.getJSONObject("data")); }