BUGFIX:添加入参判断

This commit is contained in:
2023-12-11 15:32:53 +08:00
parent cd41229f9e
commit ae91cac28a
3 changed files with 15 additions and 8 deletions

View File

@@ -49,7 +49,7 @@ public class ElementController {
public Response<CollectionElementVO> 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())) {

View File

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

View File

@@ -88,6 +88,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String level2Type = null;
if (uploadDTO.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())){
if (StringUtil.isNullOrEmpty(uploadDTO.getGender())) {
throw new BusinessException("gender.cannot.be.empty");
}
level2Type = pythonService.getClothCategory(path,uploadDTO.getGender());
}