TASK:模块化;
This commit is contained in:
@@ -175,14 +175,14 @@ public class SavedCollectionController {
|
||||
|
||||
@ApiOperation(value = "exportSave")
|
||||
@PostMapping("/exportSave")
|
||||
public Response<Boolean> exportSave(@RequestParam("file") MultipartFile file, @RequestParam("userLikeGroupId") Long userLikeGroupId) {
|
||||
return Response.success(userLikeGroupService.exportSave(file, userLikeGroupId));
|
||||
public Response<Boolean> 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<JSONObject> exportSearch(@Valid @RequestBody ExportSearchDTO exportSearchDTO) {
|
||||
return Response.success(userLikeGroupService.exportSearch(exportSearchDTO.getUserLikeGroupId()));
|
||||
return Response.success(userLikeGroupService.exportSearch(exportSearchDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "toProduct")
|
||||
|
||||
@@ -20,5 +20,6 @@ public class ExportFile implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String url;
|
||||
private Long userLikeGroupId;
|
||||
private Long projectId;
|
||||
private String module;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,8 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExportSearchDTO {
|
||||
private Long userLikeGroupId;
|
||||
// private Long userLikeGroupId;
|
||||
|
||||
private Long projectId;
|
||||
private String module;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
void updateDate(Long id,String timeZone);
|
||||
|
||||
Boolean exportSave(MultipartFile file, Long userLikeGroupId);
|
||||
Boolean exportSave(MultipartFile file, Long projectId, String module);
|
||||
|
||||
List<ToProductImageResult> toProduct(ToProductImageDTO toProductImageDTO);
|
||||
|
||||
@@ -53,7 +53,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
|
||||
|
||||
List<MagicToolResultVO> getToProductImageResultList(List<String> taskIdList);
|
||||
|
||||
JSONObject exportSearch(Long userLikeGroupId);
|
||||
JSONObject exportSearch(ExportSearchDTO exportSearchDTO);
|
||||
|
||||
CanvasElementUpload canvasElementUpload(MultipartFile file);
|
||||
|
||||
|
||||
@@ -354,20 +354,21 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
private ExportFileMapper exportFileMapper;
|
||||
|
||||
@Override
|
||||
public Boolean exportSave(MultipartFile file, Long userLikeGroupId) {
|
||||
public Boolean exportSave(MultipartFile file, Long projectId, String module) {
|
||||
AuthPrincipalVo userHolder = UserContext.getUserHolder();
|
||||
String upload = minioUtil.upload("aida-users", userHolder.getId() + "/exportFile", file);
|
||||
QueryWrapper<ExportFile> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ExportFile::getUserLikeGroupId, userLikeGroupId);
|
||||
qw.lambda().eq(ExportFile::getProjectId, projectId);
|
||||
qw.lambda().eq(ExportFile::getModule, module);
|
||||
List<ExportFile> 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<UserLikeGroupMapper, U
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject exportSearch(Long userLikeGroupId) {
|
||||
public JSONObject exportSearch(ExportSearchDTO exportSearchDTO) {
|
||||
QueryWrapper<ExportFile> qw = new QueryWrapper<>();
|
||||
qw.lambda().eq(ExportFile::getUserLikeGroupId, userLikeGroupId);
|
||||
qw.lambda().eq(ExportFile::getProjectId, exportSearchDTO.getProjectId());
|
||||
qw.lambda().eq(ExportFile::getModule, exportSearchDTO.getModule());
|
||||
List<ExportFile> 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){
|
||||
|
||||
Reference in New Issue
Block a user