From ae91cac28afc0ae4eca71000aead892ec42d9c1e Mon Sep 17 00:00:00 2001 From: xupei Date: Mon, 11 Dec 2023 15:32:53 +0800 Subject: [PATCH] =?UTF-8?q?BUGFIX:=E6=B7=BB=E5=8A=A0=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ai/da/controller/ElementController.java | 2 +- .../java/com/ai/da/python/PythonService.java | 18 +++++++++++------- .../impl/CollectionElementServiceImpl.java | 3 +++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/ai/da/controller/ElementController.java b/src/main/java/com/ai/da/controller/ElementController.java index a319abe4..40dbcde1 100644 --- a/src/main/java/com/ai/da/controller/ElementController.java +++ b/src/main/java/com/ai/da/controller/ElementController.java @@ -49,7 +49,7 @@ public class ElementController { public Response upload(@RequestParam("file") MultipartFile file, @ApiParam("一级类型 Moodboard Printboard Sketchboard MarketingSketch Colorboard") @RequestParam(value = "level1Type") String level1Type, - @RequestParam(value = "gender") String gender, + @RequestParam(name = "gender", required = false) String gender, @ApiParam("本地时区,比如 'Asia/Tokyo' 东京时间 , 'Asia/Shanghai' 北京时间 由js本地获取") @RequestParam(value = "timeZone") String timeZone) { if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) { diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index f8f390c5..2f9bbeea 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -2383,14 +2383,18 @@ public class PythonService { } } JSONObject jsonObject = JSON.parseObject(bodyString); - Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful"); - if (result && jsonObject.get("msg").equals("OK!")) { - JSONObject data = jsonObject.getJSONObject("data"); - JSONArray list = JSONArray.parseArray(data.get("list").toString()); - JSONObject map = (JSONObject) list.get(0); - return map.get("category").toString(); + try{ + Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful"); + if (result && jsonObject.get("msg").equals("OK!")) { + JSONObject data = jsonObject.getJSONObject("data"); + JSONArray list = JSONArray.parseArray(data.get("list").toString()); + JSONObject map = (JSONObject) list.get(0); + return map.get("category").toString(); + } + }catch (NullPointerException e){ + log.info("getClothCategory 失败###{},未返回category", jsonObject); + throw new BusinessException("cloth-classification.interface.exception"); } - log.info("getClothCategory 失败###{}", jsonObject); //生成失败 throw new BusinessException("cloth-classification.interface.exception"); } diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index 0ef568bd..94ff5792 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -88,6 +88,9 @@ public class CollectionElementServiceImpl extends ServiceImpl