Merge remote-tracking branch 'origin/dev/dev' into dev/dev

This commit is contained in:
shahaibo
2025-03-28 09:37:51 +08:00

View File

@@ -24,6 +24,7 @@ import io.minio.errors.MinioException;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -1115,6 +1116,8 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public GenerateResultVO sketchReconstructionGenerate(SketchReconstructionDTO sketchReconstructionDTO){ public GenerateResultVO sketchReconstructionGenerate(SketchReconstructionDTO sketchReconstructionDTO){
log.info("sketchReconstructionGenerate params: {}", sketchReconstructionDTO);
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
// 1、线稿生成 // 1、线稿生成
String collagePictureBase64 = sketchReconstructionDTO.getCollagePicture(); String collagePictureBase64 = sketchReconstructionDTO.getCollagePicture();
@@ -1136,15 +1139,25 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
// 截取目标部分 // 截取目标部分
String targetPath = url.substring(pathStartIndex + 1, queryStartIndex); String targetPath = url.substring(pathStartIndex + 1, queryStartIndex);
if (Objects.isNull(sketchReconstruction)){ try {
sketchReconstruction = new SketchReconstruction(); if (Objects.isNull(sketchReconstruction)){
sketchReconstruction.setProjectId(projectId); sketchReconstruction = new SketchReconstruction();
sketchReconstruction.setCollageImgSketchUrl(targetPath); sketchReconstruction.setProjectId(projectId);
sketchReconstruction.setGenerateDetailId(generateResultVO.getId()); sketchReconstruction.setCollageImgSketchUrl(targetPath);
sketchReconstruction.setGender(sketchReconstructionDTO.getGender()); sketchReconstruction.setGenerateDetailId(generateResultVO.getId());
sketchReconstruction.setCreateTime(LocalDateTime.now()); sketchReconstruction.setGender(sketchReconstructionDTO.getGender());
sketchReconstructionMapper.insert(sketchReconstruction); sketchReconstruction.setCreateTime(LocalDateTime.now());
}else { sketchReconstructionMapper.insert(sketchReconstruction);
}else {
sketchReconstruction.setCollageImgSketchUrl(targetPath);
sketchReconstruction.setGenerateDetailId(generateResultVO.getId());
sketchReconstructionMapper.updateById(sketchReconstruction);
}
} catch (DuplicateKeyException e) {
// 如果发生唯一键冲突,说明其他请求已经创建了记录
// 重新查询并更新
log.info("sketch拼贴唯一键project_id冲突改为更新");
sketchReconstruction = sketchReconstructionMapper.selectOne(qw);
sketchReconstruction.setCollageImgSketchUrl(targetPath); sketchReconstruction.setCollageImgSketchUrl(targetPath);
sketchReconstruction.setGenerateDetailId(generateResultVO.getId()); sketchReconstruction.setGenerateDetailId(generateResultVO.getId());
sketchReconstructionMapper.updateById(sketchReconstruction); sketchReconstructionMapper.updateById(sketchReconstruction);