generateSketch 功能--空指针异常 修改

This commit is contained in:
徐佩
2023-08-17 16:11:26 +08:00
parent 5b41b51859
commit c5e5b51852

View File

@@ -87,14 +87,18 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper,Generate> 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<CollectionElement> 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<CollectionElement> 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<GenerateMapper,Generate> im
GenerateCollectionVO generateCollectionVO = new GenerateCollectionVO();
List<GenerateCollectionItemVO> 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保存到数据库