From b0560b840fa6bd4301815716b64d9d27d5a3f6da Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Wed, 26 Mar 2025 15:12:55 +0800 Subject: [PATCH] =?UTF-8?q?TASK:=E6=A8=A1=E5=9D=97=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SavedCollectionController.java | 6 +-- .../da/mapper/primary/entity/ExportFile.java | 3 +- .../com/ai/da/model/dto/ExportSearchDTO.java | 5 +- .../ai/da/service/UserLikeGroupService.java | 4 +- .../impl/UserLikeGroupServiceImpl.java | 52 ++++++++++++++----- 5 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/ai/da/controller/SavedCollectionController.java b/src/main/java/com/ai/da/controller/SavedCollectionController.java index 82938fe5..19d8e595 100644 --- a/src/main/java/com/ai/da/controller/SavedCollectionController.java +++ b/src/main/java/com/ai/da/controller/SavedCollectionController.java @@ -175,14 +175,14 @@ public class SavedCollectionController { @ApiOperation(value = "exportSave") @PostMapping("/exportSave") - public Response exportSave(@RequestParam("file") MultipartFile file, @RequestParam("userLikeGroupId") Long userLikeGroupId) { - return Response.success(userLikeGroupService.exportSave(file, userLikeGroupId)); + public Response exportSave(@RequestParam("file") MultipartFile file, @RequestParam("projectId") Long projectId, @RequestParam("module") String module) { + return Response.success(userLikeGroupService.exportSave(file, projectId, module)); } @ApiOperation(value = "exportSearch") @PostMapping("/exportSearch") public Response exportSearch(@Valid @RequestBody ExportSearchDTO exportSearchDTO) { - return Response.success(userLikeGroupService.exportSearch(exportSearchDTO.getUserLikeGroupId())); + return Response.success(userLikeGroupService.exportSearch(exportSearchDTO)); } @ApiOperation(value = "toProduct") diff --git a/src/main/java/com/ai/da/mapper/primary/entity/ExportFile.java b/src/main/java/com/ai/da/mapper/primary/entity/ExportFile.java index c62706b2..46294be2 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/ExportFile.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/ExportFile.java @@ -20,5 +20,6 @@ public class ExportFile implements Serializable { private Long id; private String url; - private Long userLikeGroupId; + private Long projectId; + private String module; } diff --git a/src/main/java/com/ai/da/model/dto/ExportSearchDTO.java b/src/main/java/com/ai/da/model/dto/ExportSearchDTO.java index f7f5ccda..23cdbd36 100644 --- a/src/main/java/com/ai/da/model/dto/ExportSearchDTO.java +++ b/src/main/java/com/ai/da/model/dto/ExportSearchDTO.java @@ -4,5 +4,8 @@ import lombok.Data; @Data public class ExportSearchDTO { - private Long userLikeGroupId; +// private Long userLikeGroupId; + + private Long projectId; + private String module; } diff --git a/src/main/java/com/ai/da/service/UserLikeGroupService.java b/src/main/java/com/ai/da/service/UserLikeGroupService.java index 56ca416c..174d9ada 100644 --- a/src/main/java/com/ai/da/service/UserLikeGroupService.java +++ b/src/main/java/com/ai/da/service/UserLikeGroupService.java @@ -41,7 +41,7 @@ public interface UserLikeGroupService extends IService { void updateDate(Long id,String timeZone); - Boolean exportSave(MultipartFile file, Long userLikeGroupId); + Boolean exportSave(MultipartFile file, Long projectId, String module); List toProduct(ToProductImageDTO toProductImageDTO); @@ -53,7 +53,7 @@ public interface UserLikeGroupService extends IService { List getToProductImageResultList(List taskIdList); - JSONObject exportSearch(Long userLikeGroupId); + JSONObject exportSearch(ExportSearchDTO exportSearchDTO); CanvasElementUpload canvasElementUpload(MultipartFile file); diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index e5f0cffd..a699b692 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -354,20 +354,21 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.lambda().eq(ExportFile::getUserLikeGroupId, userLikeGroupId); + qw.lambda().eq(ExportFile::getProjectId, projectId); + qw.lambda().eq(ExportFile::getModule, module); List exportFiles = exportFileMapper.selectList(qw); if (CollectionUtil.isNotEmpty(exportFiles)) { ExportFile exportFile = exportFiles.get(0); - exportFile.setUserLikeGroupId(userLikeGroupId); exportFile.setUrl(upload); exportFileMapper.updateById(exportFile); }else { ExportFile exportFile = new ExportFile(); - exportFile.setUserLikeGroupId(userLikeGroupId); + exportFile.setProjectId(projectId); + exportFile.setModule(module); exportFile.setUrl(upload); exportFileMapper.insert(exportFile); } @@ -651,26 +652,49 @@ public class UserLikeGroupServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); - qw.lambda().eq(ExportFile::getUserLikeGroupId, userLikeGroupId); + qw.lambda().eq(ExportFile::getProjectId, exportSearchDTO.getProjectId()); + qw.lambda().eq(ExportFile::getModule, exportSearchDTO.getModule()); List exportFiles = exportFileMapper.selectList(qw); if (CollectionUtil.isNotEmpty(exportFiles)) { try { InputStream download = minioUtil.download(exportFiles.get(0).getUrl()); 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"); + JSONArray objectJSONArrayLevel1 = jsonObject.getJSONArray("objects"); + for (int i = 0; i < objectJSONArrayLevel1.size(); i++) { + JSONObject jsonObjectLevel1 = objectJSONArrayLevel1.getJSONObject(i); + String type = jsonObjectLevel1.getString("type"); if (type.equals("image")) { - String minioUrl = jsonObject1.getString("minioUrl"); - jsonObject1.put("src", minioUtil.getPreSignedUrl(minioUrl, 24 * 60)); + String minioUrl = jsonObjectLevel1.getString("minioUrl"); + jsonObjectLevel1.put("src", minioUtil.getPreSignedUrl(minioUrl, 24 * 60)); } - objects.set(i, jsonObject1); + if (type.equals("group")) { + JSONArray objectJSONArrayLevel2 = jsonObjectLevel1.getJSONArray("objects"); + for (int j = 0; j < objectJSONArrayLevel2.size(); j++) { + JSONObject jsonObjectLevel2 = objectJSONArrayLevel2.getJSONObject(j); + String typeGroup = jsonObjectLevel2.getString("type"); + if (typeGroup.equals("image")) { + String minioUrl = jsonObjectLevel2.getString("minioUrl"); + jsonObjectLevel2.put("src", minioUtil.getPreSignedUrl(minioUrl, 24 * 60)); + } + objectJSONArrayLevel2.set(j, jsonObjectLevel2); + } + jsonObjectLevel1.put("objects", objectJSONArrayLevel2); + } + if (type.equals("rect")) { + JSONObject custom = jsonObjectLevel1.getJSONObject("custom"); + if (custom.getString("type").equals("init")) { + String minioUrl = jsonObjectLevel1.getString("minioUrl"); + JSONObject fill = jsonObjectLevel1.getJSONObject("fill"); + fill.put("source", minioUtil.getPreSignedUrl(minioUrl, 24 * 60)); + jsonObjectLevel1.put("fill", fill); + } + } + objectJSONArrayLevel1.set(i, jsonObjectLevel1); } - jsonObject.put("objects", objects); + jsonObject.put("objects", objectJSONArrayLevel1); System.out.println(jsonObject); return jsonObject; }catch (Exception e){