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")); }