diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index cb2dbda5..1cfa5865 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -87,14 +87,18 @@ public class GenerateServiceImpl extends ServiceImpl im // 3、将请求信息落库 // 3.1 sketch在t_collection_element表中的信息是否需要更新 如 level2Type - CollectionElement collectionElement = collectionElementMapper.selectById(sketchId); - if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(generateThroughImageTextDTO.getLevel2Type()) ){ - collectionElement.setLevel2Type(generateThroughImageTextDTO.getLevel2Type()); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("id", sketchId); - collectionElementMapper.update(collectionElement,queryWrapper); + CollectionElement collectionElement = null; + if(!Objects.isNull(sketchId)){ + collectionElement = collectionElementMapper.selectById(sketchId); + if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(generateThroughImageTextDTO.getLevel2Type()) ){ + collectionElement.setLevel2Type(generateThroughImageTextDTO.getLevel2Type()); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id", sketchId); + collectionElementMapper.update(collectionElement,queryWrapper); + } } + // 3.2 将本次generate的请求信息添加到t_generate表中 save(generate); @@ -106,7 +110,7 @@ public class GenerateServiceImpl extends ServiceImpl im GenerateCollectionVO generateCollectionVO = new GenerateCollectionVO(); List generatedCollectionItems = new ArrayList<>(); generateCollectionVO.setGenerateId(generate.getId()); - generateCollectionVO.setCollectionId(collectionElement.getCollectionId()); + generateCollectionVO.setCollectionId(Objects.isNull(collectionElement) ? null : collectionElement.getCollectionId()); generateCollectionVO.setGeneratedCollectionItems(generatedCollectionItems); // 5、处理模型返回的数据 // 5.1 将相应的url保存到数据库