Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -124,15 +124,8 @@ public class GenerateController {
|
||||
return Response.success(generateResultVO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "拼贴图画布保存")
|
||||
@GetMapping("/saveReconCanvas")
|
||||
public Response<String> sketchReconstructionSave(@RequestParam("file") MultipartFile file, @RequestParam("projectId") Long projectId){
|
||||
generateService.sketchReconstructionSave(file, projectId);
|
||||
return Response.success("success");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取拼贴图画布")
|
||||
@GetMapping("/getReconCanvas")
|
||||
@ApiOperation(value = "获取拼贴图最后一次生成结果")
|
||||
@GetMapping("/getReconLastResult")
|
||||
public Response<SketchReconstructionVO> getSketchReconstruction(@RequestParam("projectId") Long projectId){
|
||||
SketchReconstructionVO sketchReconstruction = generateService.getSketchReconstruction(projectId);
|
||||
return Response.success(sketchReconstruction);
|
||||
|
||||
@@ -15,6 +15,4 @@ public class SketchReconstruction extends BaseEntity{
|
||||
|
||||
private Long generateDetailId;
|
||||
|
||||
private String canvasUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,5 +32,5 @@ public class ModuleChooseVO {
|
||||
private List<CollectionSketchVO> boundingBox;
|
||||
// private moodBoardModuleChooseVO poseTransfer;
|
||||
// private moodBoardModuleChooseVO patternMaking3D;
|
||||
// private moodBoardModuleChooseVO deReconstruction;
|
||||
private SketchReconstructionVO deReconstruction;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public class SketchReconstructionVO {
|
||||
|
||||
private JSONObject canvasFile;
|
||||
|
||||
private String collageSketchUrl;
|
||||
|
||||
private boolean isLiked;
|
||||
|
||||
@@ -56,7 +56,5 @@ public interface GenerateService extends IService<Generate> {
|
||||
|
||||
GenerateResultVO sketchReconstructionGenerate(SketchReconstructionDTO sketchReconstructionDTO);
|
||||
|
||||
String sketchReconstructionSave(MultipartFile multipartFile, Long projectId);
|
||||
|
||||
SketchReconstructionVO getSketchReconstruction(Long projectId);
|
||||
}
|
||||
|
||||
@@ -1123,68 +1123,21 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
return generateResultVO;
|
||||
}
|
||||
|
||||
public String sketchReconstructionSave(MultipartFile multipartFile, Long projectId){
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
// 元素都在画布上,不用额外保存
|
||||
String object = accountId + "/CollageSketchFile/" + projectId;
|
||||
String canvasFilePath = minioUtil.upload("aida-users", object, multipartFile,null);
|
||||
|
||||
// 将画布文件上传到minio,地址保存到project表中
|
||||
QueryWrapper<SketchReconstruction> qw = new QueryWrapper<>();
|
||||
qw.eq("project_id", projectId).isNotNull("canvas_url").orderByDesc("id");
|
||||
SketchReconstruction sketchReconstruction = sketchReconstructionMapper.selectOne(qw);
|
||||
if (Objects.isNull(sketchReconstruction)){
|
||||
sketchReconstruction = new SketchReconstruction();
|
||||
sketchReconstruction.setProjectId(projectId);
|
||||
sketchReconstruction.setCanvasUrl(canvasFilePath);
|
||||
sketchReconstruction.setCreateTime(LocalDateTime.now());
|
||||
sketchReconstructionMapper.insert(sketchReconstruction);
|
||||
}else if (StringUtil.isNullOrEmpty(sketchReconstruction.getCanvasUrl())){
|
||||
sketchReconstruction.setCanvasUrl(canvasFilePath);
|
||||
sketchReconstructionMapper.updateById(sketchReconstruction);
|
||||
}
|
||||
|
||||
// 需要返回哪些信息呢?
|
||||
return null;
|
||||
}
|
||||
|
||||
public SketchReconstructionVO getSketchReconstruction(Long projectId){
|
||||
QueryWrapper<SketchReconstruction> qw = new QueryWrapper<>();
|
||||
qw.eq("project_id", projectId);
|
||||
SketchReconstruction sketchReconstruction = sketchReconstructionMapper.selectOne(qw);
|
||||
if (Objects.isNull(sketchReconstruction) || StringUtil.isNullOrEmpty(sketchReconstruction.getCanvasUrl())){
|
||||
if (Objects.isNull(sketchReconstruction)){
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
InputStream download = minioUtil.download(sketchReconstruction.getCanvasUrl());
|
||||
String convert = convert(download);
|
||||
JSONObject jsonObject = JSONObject.parseObject(convert);
|
||||
JSONArray objects = jsonObject.getJSONArray("objects");
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
JSONObject jsonObject1 = objects.getJSONObject(i);
|
||||
String type = jsonObject1.getString("type");
|
||||
if (type.equals("image")) {
|
||||
String minioUrl = jsonObject1.getString("minioUrl");
|
||||
jsonObject1.put("src", minioUtil.getPreSignedUrl(minioUrl, 24 * 60));
|
||||
}
|
||||
objects.set(i, jsonObject1);
|
||||
}
|
||||
jsonObject.put("objects", objects);
|
||||
log.info(String.valueOf(jsonObject));
|
||||
|
||||
// 除返回jsonObject之外,还要返回最后一次生成的线稿图以及like状态
|
||||
SketchReconstructionVO vo = new SketchReconstructionVO();
|
||||
vo.setCanvasFile(jsonObject);
|
||||
if (Objects.nonNull(sketchReconstruction.getGenerateDetailId())){
|
||||
GenerateDetail generateDetail = generateDetailMapper.selectById(sketchReconstruction.getGenerateDetailId());
|
||||
vo.setCollageSketchUrl(minioUtil.getPreSignedUrl(generateDetail.getUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
||||
vo.setLiked(generateDetail.getIsLike().equals((byte)1));
|
||||
}
|
||||
return vo;
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1288,6 +1288,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
return convert;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
@Override
|
||||
public ModuleChooseVO getModuleContent(ProjectDTO projectDTO) {
|
||||
ModuleChooseVO moduleChooseVO = new ModuleChooseVO();
|
||||
@@ -1544,6 +1546,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
}
|
||||
moduleChooseVO.setRelight(toProductImageResultVOS);
|
||||
}else if (module.equals(Module.deReconstruction.name())){
|
||||
SketchReconstructionVO sketchReconstruction = generateService.getSketchReconstruction(projectDTO.getId());
|
||||
moduleChooseVO.setDeReconstruction(sketchReconstruction);
|
||||
}
|
||||
}
|
||||
return moduleChooseVO;
|
||||
|
||||
Reference in New Issue
Block a user