design Single 允许画笔修改sketch后进行design
This commit is contained in:
@@ -29,6 +29,7 @@ import com.google.common.collect.Lists;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -81,6 +82,9 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
@Resource
|
||||
private UserLikeGroupService userLikeGroupService;
|
||||
|
||||
@Value("${minio.bucketName.modifiedSketch}")
|
||||
private String modifiedSketchBucket;
|
||||
|
||||
@Override
|
||||
public Long saveOne(DesignItem designItem) {
|
||||
if (designItemMapper.insertDesignItem(designItem) <= 0) {
|
||||
@@ -419,9 +423,16 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
// 记录入参 base64数据太长,所以这里去掉
|
||||
DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO);
|
||||
clone.getDesignSingleItemDTOList().forEach( i -> {
|
||||
// 渐变色
|
||||
if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())){
|
||||
log.info("set gradient colorImage为空,便于日志打印");
|
||||
i.getGradient().setColorImg(null);
|
||||
}
|
||||
// 画笔修改过的sketch
|
||||
if (!StringUtil.isNullOrEmpty(i.getSketchString())){
|
||||
log.info("set sketchString为空,便于日志打印");
|
||||
i.setSketchString(null);
|
||||
}
|
||||
});
|
||||
|
||||
log.info("designSingle request入参 ==> " + JSONObject.toJSONString(clone));
|
||||
@@ -470,6 +481,11 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl);
|
||||
}
|
||||
|
||||
// 画笔修改的sketch截图 上传后替换path
|
||||
// 由于用户在系统或自己上传sketch的基础上修改过的衣服,再次修改后,第一次修改的衣服不会回到某个池子被再次利用,
|
||||
// 所以,这里选择使用system或collection相同的地址,只是放在不同的桶,这样能保证图片服务器上,类似的sketch不会存在很多
|
||||
sketchBase64ToPath(designSingleIncludeLayersDTO);
|
||||
|
||||
// 组装入参
|
||||
DesignPythonObjects objects = pythonService.covertDesignSingleParam(
|
||||
designSingleIncludeLayersDTO, design.getSingleOverall(), design.getSwitchCategory(), designLibraryModelPointVO);
|
||||
@@ -527,6 +543,26 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
design.getSingleOverall());
|
||||
}
|
||||
|
||||
private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){
|
||||
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
|
||||
// 如果sketch截图不为空,则将该截图上传,并替换path
|
||||
if (!StringUtil.isNullOrEmpty(item.getSketchString())){
|
||||
if (StringUtil.isNullOrEmpty(item.getPath())){
|
||||
throw new BusinessException("path.cannot.be.empty");
|
||||
}
|
||||
String sourcePath = item.getPath();
|
||||
String path = sourcePath.substring(sourcePath.indexOf("/") + 1, sourcePath.lastIndexOf("."));
|
||||
// 将原图地址作为修改后的图片地址,放在不同的桶
|
||||
String newPath = minioUtil.base64UploadToPath(item.getSketchString(), modifiedSketchBucket, path);
|
||||
if (StringUtil.isNullOrEmpty(newPath)){
|
||||
log.error("修改过的sketch图片上传失败");
|
||||
throw new BusinessException("image.modify.failed");
|
||||
}
|
||||
item.setPath(newPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user