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

This commit is contained in:
shahaibo
2024-07-08 09:32:54 +08:00
28 changed files with 503 additions and 270 deletions

View File

@@ -17,7 +17,7 @@ public enum CreditsEventsEnum {
INIT_YEARLY("init_yearly", "6000"), INIT_YEARLY("init_yearly", "6000"),
INIT_MONTHLY("init_monthly", "5000"), INIT_MONTHLY("init_monthly", "5000"),
INIT_TRIAL("init_trial", "100"), INIT_TRIAL("init_trial", "100"),
INIT_WEEKLY("init_weekly","10000"), INIT_WEEKLY("init_weekly","6000"),
// SUPER_RESOLUTION("Super Resolution","30"), // SUPER_RESOLUTION("Super Resolution","30"),
SUPER_RESOLUTION("Super Resolution","10"), SUPER_RESOLUTION("Super Resolution","10"),

View File

@@ -1,20 +1,24 @@
package com.ai.da.common.task; package com.ai.da.common.task;
import com.ai.da.service.AccountService; import com.ai.da.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@Component @Component
@Slf4j
public class AccountTask { public class AccountTask {
@Resource @Resource
private AccountService accountService; private AccountService accountService;
/** 每周日晚上刷新 年付用户、月付用户的积分 */ /** 每周日晚上刷新 年付用户、月付用户的积分 */
// @Scheduled(cron = "59 59 23 ? * SUN") @Scheduled(cron = "59 59 23 ? * SUN")
// @Scheduled(cron = "59 59 23 * * ?")
public void refreshCreditsMonthly(){ public void refreshCreditsMonthly(){
log.info("每周日晚115959刷新付费用户积分为 6000");
accountService.refreshCreditsWeekly(); accountService.refreshCreditsWeekly();
} }

View File

@@ -373,7 +373,7 @@ public class MinioUtil {
* @param expiry 过期时间(单位:分) * @param expiry 过期时间(单位:分)
* @return 文件的临时URL如果出现异常则返回null * @return 文件的临时URL如果出现异常则返回null
*/ */
public String getPresignedUrl(String bucketName, String fileName, int expiry) { public String getPreSignedUrl(String bucketName, String fileName, int expiry) {
try { try {
return minioClient.getPresignedObjectUrl( return minioClient.getPresignedObjectUrl(
GetPresignedObjectUrlArgs.builder() GetPresignedObjectUrlArgs.builder()
@@ -389,7 +389,7 @@ public class MinioUtil {
} }
} }
public String getPresignedUrl(String path, int expiry) { public String getPreSignedUrl(String path, int expiry) {
if (LocalCacheUtils.getPresignedUrlCache(path) != null) { if (LocalCacheUtils.getPresignedUrlCache(path) != null) {
return LocalCacheUtils.getPresignedUrlCache(path); return LocalCacheUtils.getPresignedUrlCache(path);
} else { } else {
@@ -399,13 +399,13 @@ public class MinioUtil {
int index = path.indexOf("/"); int index = path.indexOf("/");
String bucketName = path.substring(0, index); String bucketName = path.substring(0, index);
String fileName = path.substring(index + 1); String fileName = path.substring(index + 1);
String presignedUrl = getPresignedUrl(bucketName, fileName, expiry); String presignedUrl = getPreSignedUrl(bucketName, fileName, expiry);
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl); LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
return presignedUrl; return presignedUrl;
} }
} }
public String getPresignedUrl(String path, int expiry, boolean resetCache) { public String getPreSignedUrl(String path, int expiry, boolean resetCache) {
if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) { if (resetCache || LocalCacheUtils.getPresignedUrlCache(path) == null) {
if (!path.contains("/")) { if (!path.contains("/")) {
throw new BusinessException("The path is error!"); throw new BusinessException("The path is error!");
@@ -413,7 +413,7 @@ public class MinioUtil {
int index = path.indexOf("/"); int index = path.indexOf("/");
String bucketName = path.substring(0, index); String bucketName = path.substring(0, index);
String fileName = path.substring(index + 1); String fileName = path.substring(index + 1);
String presignedUrl = getPresignedUrl(bucketName, fileName, expiry); String presignedUrl = getPreSignedUrl(bucketName, fileName, expiry);
LocalCacheUtils.setPresignedUrlCache(path, presignedUrl); LocalCacheUtils.setPresignedUrlCache(path, presignedUrl);
return presignedUrl; return presignedUrl;
} else { } else {
@@ -438,7 +438,7 @@ public class MinioUtil {
fileName.append("/"); fileName.append("/");
} }
} }
return getPresignedUrl(bucketName, String.valueOf(fileName), expiry); return getPreSignedUrl(bucketName, String.valueOf(fileName), expiry);
} }
public boolean doesObjectExist(String bucketName, String objectName) { public boolean doesObjectExist(String bucketName, String objectName) {

View File

@@ -2,6 +2,7 @@ package com.ai.da.common.utils;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.constant.CommonConstant; import com.ai.da.common.constant.CommonConstant;
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.stereotype.Component; import org.springframework.stereotype.Component;
@@ -57,8 +58,8 @@ public class S3Util {
private static S3Presigner s3Presigner; private static S3Presigner s3Presigner;
/** /**
* @description: 获取S3客户端对象
* @return software.amazon.awssdk.services.s3.S3Client * @return software.amazon.awssdk.services.s3.S3Client
* @description: 获取S3客户端对象
*/ */
public synchronized S3Client getS3Client() { public synchronized S3Client getS3Client() {
if (null == s3Client) { if (null == s3Client) {
@@ -74,8 +75,8 @@ public class S3Util {
} }
/** /**
* @description: 获取预签名对象
* @return software.amazon.awssdk.services.s3.presigner.S3Presigner * @return software.amazon.awssdk.services.s3.presigner.S3Presigner
* @description: 获取预签名对象
*/ */
public synchronized S3Presigner getS3PreSigner() { public synchronized S3Presigner getS3PreSigner() {
if (null == s3Presigner) { if (null == s3Presigner) {
@@ -92,6 +93,29 @@ public class S3Util {
return s3Presigner; return s3Presigner;
} }
public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) {
S3Client s3Client = getS3Client();
byte[] imageBytes = Base64.getDecoder().decode(base64Image);
String fileName = UUID.randomUUID() + "." + imageType; // or any other image format
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
.bucket(bucketName)
.contentType("image/png")
.contentLength((long) in.available())
.key(fileName)
.acl(ObjectCannedACL.PUBLIC_READ)
.build();
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(in, in.available()));
log.info("uploadImageFromBase64 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
return bucketName + "/" + fileName;
} catch (Exception e) {
e.printStackTrace();
return null; // or throw an exception
}
}
public String upload(String bucketName, String path, MultipartFile file) { public String upload(String bucketName, String path, MultipartFile file) {
S3Client s3Client = getS3Client(); S3Client s3Client = getS3Client();
try { try {
@@ -108,16 +132,111 @@ public class S3Util {
.contentType(file.getContentType()) .contentType(file.getContentType())
.contentLength(file.getSize()) .contentLength(file.getSize())
.key(fileName) .key(fileName)
// .acl(ObjectCannedACL.PUBLIC_READ) .acl(ObjectCannedACL.PUBLIC_READ)
.build(); .build();
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize())); s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
log.info("上传的位置:桶 - {},路径 - {}", bucketName, fileName); log.info("upload 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
return fileName; return bucketName + "/" + fileName;
} catch (Exception e) { } catch (Exception e) {
log.error("上传文件到S3失败 异常:{}", e.getMessage()); log.error("上传文件到S3失败 异常:{}", e.getMessage());
return null;
}
}
// todo
public String upload(String bucketName, String path, MultipartFile file, String copy) {
S3Client s3Client = getS3Client();
InputStream in = null;
try {
in = file.getInputStream();
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
.bucket(bucketName)
.contentType(file.getContentType())
.contentLength(file.getSize())
.key(path)
.acl(ObjectCannedACL.PUBLIC_READ)
.build();
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(file.getInputStream(), file.getSize()));
log.info("upload-copy 上传的位置:桶 - {},路径 - {}", bucketName, path);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return bucketName + "/" + path;
}
public InputStream download(String path) {
if (!path.contains("/")) {
throw new BusinessException("the.path.is.error");
}
int index = path.indexOf("/");
String bucketName = path.substring(0, index);
String objectName = path.substring(index + 1);
return download(bucketName, objectName);
}
public InputStream download(String bucketName, String objectName) {
try {
S3Client s3Client = getS3Client();
GetObjectRequest objectRequest = GetObjectRequest
.builder()
.key(objectName)
.bucket(bucketName)
.build();
// ResponseBytes<GetObjectResponse> objectBytes = s3.getObjectAsBytes(objectRequest);
ResponseBytes<GetObjectResponse> objectAsBytes = s3Client.getObjectAsBytes(objectRequest);
byte[] data = objectAsBytes.asByteArray();
log.info("download 下载图片位置:桶 - {},路径 - {}", bucketName, objectName);
return new ByteArrayInputStream(data);
/*// Write the data to a local file.
File myFile = new File("files/images.png");
OutputStream os = new FileOutputStream(myFile);
os.write(data);
System.out.println("Successfully obtained bytes from an S3 object");
os.close();
return null;*/
// return minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
} catch (Exception e) {
log.error("");
throw new BusinessException("");
}
}
public void deleteObject(String path) {
if (!path.contains("/")) {
throw new BusinessException("The path is error!");
}
int index = path.indexOf("/");
String bucketName = path.substring(0, index);
String objectName = path.substring(index + 1);
deleteObject(bucketName, objectName);
}
public void deleteObject(String bucketName, String objectName) {
try {
S3Client s3Client = getS3Client();
DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest
.builder()
.key(objectName)
.bucket(bucketName)
.build();
s3Client.deleteObject(deleteObjectRequest);
log.info("Object " + objectName + " successfully removed from bucket " + bucketName);
} catch (Exception e) {
e.printStackTrace();
log.info("Error while removing object " + objectName + " from bucket " + bucketName + ": " + e.getMessage());
} }
return null;
} }
public String getPreSignedUrl(String path, int expiry) { public String getPreSignedUrl(String path, int expiry) {
@@ -137,20 +256,23 @@ public class S3Util {
} }
/** /**
* @description: 生成预签名URL * @param keyName key名称: test/2022/06/123.pdf
* @param keyName key名称: test/2022/06/123.pdf
* @param signatureDurationTime 有效期 单位:秒 * @param signatureDurationTime 有效期 单位:秒
* @return java.lang.String * @return java.lang.String
* @description: 生成预签名URL
*/ */
public String getPreSignatureUrl(String bucket, String keyName, Integer signatureDurationTime) { public String getPreSignatureUrl(String bucket, String keyName, Integer signatureDurationTime) {
String preSignatureUrl = ""; String preSignatureUrl = "";
try { try {
S3Presigner s3PreSigner = getS3PreSigner(); S3Presigner s3PreSigner = getS3PreSigner();
GetObjectRequest getObjectRequest = S3Client s3Client = getS3Client();
GetObjectRequest.builder() setObjectAcl(s3Client, bucket, keyName, ObjectCannedACL.PUBLIC_READ);
.bucket(bucket)
.key(keyName) GetObjectRequest getObjectRequest = GetObjectRequest.builder()
.build(); .bucket(bucket)
.key(keyName)
.build();
//设置预签名URL可访问时间 //设置预签名URL可访问时间
signatureDurationTime = Optional.ofNullable(signatureDurationTime) signatureDurationTime = Optional.ofNullable(signatureDurationTime)
.map(item -> { .map(item -> {
@@ -169,53 +291,70 @@ public class S3Util {
s3PreSigner.presignGetObject(getObjectPresignRequest); s3PreSigner.presignGetObject(getObjectPresignRequest);
preSignatureUrl = String.valueOf(presignedGetObjectRequest.url()); preSignatureUrl = String.valueOf(presignedGetObjectRequest.url());
} catch (Exception e) { } catch (Exception e) {
log.error("生成预签名URL失败异常{}", e.getMessage()); log.error("生成预签名URL失败异常{}", e.getMessage());
} }
return preSignatureUrl; return preSignatureUrl;
} }
public InputStream download(String path) { public static void setObjectAcl(S3Client s3, String bucketName, String keyName, ObjectCannedACL acl) {
if (!path.contains("/")) { PutObjectAclRequest aclRequest = PutObjectAclRequest.builder()
throw new BusinessException("the.path.is.error"); .bucket(bucketName)
} .key(keyName)
int index = path.indexOf("/"); .acl(acl)
String bucketName = path.substring(0, index); .build();
String objectName = path.substring(index + 1); s3.putObjectAcl(aclRequest);
return download(bucketName, objectName);
} }
public boolean doesObjectExist(String bucketName, String objectName) {
public InputStream download(String bucketName, String objectName){
try { try {
S3Client s3Client = getS3Client(); S3Client s3Client = getS3Client();
GetObjectRequest objectRequest = GetObjectRequest HeadObjectRequest headObjectRequest = HeadObjectRequest.builder()
.builder()
.key(objectName)
.bucket(bucketName) .bucket(bucketName)
.key(objectName)
.build(); .build();
HeadObjectResponse headObjectResponse = s3Client.headObject(headObjectRequest);
// ResponseBytes<GetObjectResponse> objectBytes = s3.getObjectAsBytes(objectRequest); return true;
ResponseBytes<GetObjectResponse> objectAsBytes = s3Client.getObjectAsBytes(objectRequest); } catch (Exception e) {
byte[] data = objectAsBytes.asByteArray(); log.info("指定文件 {}/{} 不存在", bucketName, objectName);
return new ByteArrayInputStream(data); // 如果发生异常,说明文件不存在或者出现了其他错误
return false;
/*// Write the data to a local file.
File myFile = new File("files/images.png");
OutputStream os = new FileOutputStream(myFile);
os.write(data);
System.out.println("Successfully obtained bytes from an S3 object");
os.close();
return null;*/
// return minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
} catch (Exception e){
log.error("");
throw new BusinessException("");
} }
} }
public List<String> listAllBucket(){ public String base64UploadToPath(String base64, String bucketName, String path) {
S3Client s3Client = getS3Client();
String[] parts = base64.split(",");
String imageType = parts[0].split("/")[1].split(";")[0];
String base64Data = parts[1];
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
String fileName;
if (!StringUtil.isNullOrEmpty(path)) {
fileName = path + "." + imageType; // or any other image format
} else {
fileName = UUID.randomUUID() + "." + imageType;
}
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
.bucket(bucketName)
.contentType("image/" + imageType)
.contentLength((long) in.available())
.key(fileName)
.acl(ObjectCannedACL.PUBLIC_READ)
.build();
s3Client.putObject(putObjectRequest, RequestBody.fromInputStream(in, in.available()));
log.info("base64UploadToPath 上传的位置:桶 - {},路径 - {}", bucketName, fileName);
return bucketName + "/" + fileName;
} catch (Exception e) {
e.printStackTrace();
return null; // or throw an exception
}
}
public List<String> listAllBucket() {
S3Client s3Client = getS3Client(); S3Client s3Client = getS3Client();
ListBucketsResponse listBucketsResponse = s3Client.listBuckets(); ListBucketsResponse listBucketsResponse = s3Client.listBuckets();
List<Bucket> buckets = listBucketsResponse.buckets(); List<Bucket> buckets = listBucketsResponse.buckets();

View File

@@ -163,7 +163,7 @@ public class LibraryController {
Response<String> response = new Response(); Response<String> response = new Response();
log.info("Models打点预览入参####{}", JSON.toJSONString(modelsDotDTO)); log.info("Models打点预览入参####{}", JSON.toJSONString(modelsDotDTO));
String url = libraryModelPointService.modelsDot(modelsDotDTO); String url = libraryModelPointService.modelsDot(modelsDotDTO);
response.setData(minioUtil.getPresignedUrl(url, 24 * 60)); response.setData(minioUtil.getPreSignedUrl(url, 24 * 60));
return response; return response;
} }

View File

@@ -120,7 +120,7 @@ public class SavedCollectionController {
List<UserLikeVO> details = groupDetailMap.get(group.getId()); List<UserLikeVO> details = groupDetailMap.get(group.getId());
for (UserLikeVO detail : details) { for (UserLikeVO detail : details) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(detail.getDesignOutfitId()); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(detail.getDesignOutfitId());
detail.setUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); detail.setUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
} }
userLikeGroupVO.setGroupDetails(details); userLikeGroupVO.setGroupDetails(details);
userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size()); userLikeGroupVO.setSketchCount(CollectionUtils.isEmpty(details) ? 0 : details.size());

View File

@@ -2,6 +2,7 @@ package com.ai.da.mapper.primary.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -24,11 +25,13 @@ public class BaseEntity implements Serializable {
/** /**
* 创建时间 * 创建时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private LocalDateTime createTime; private LocalDateTime createTime;
/** /**
* 更新时间 * 更新时间
*/ */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private LocalDateTime updateTime; private LocalDateTime updateTime;
/** /**

View File

@@ -90,6 +90,10 @@ public class DesignItemDetail implements Serializable {
* item的优先级 * item的优先级
*/ */
private Integer priority; private Integer priority;
/**
* 未分割的只上了颜色或只有overall印花的图层
*/
private String undividedLayer;
/** /**
* 创建时间 * 创建时间

View File

@@ -15,17 +15,17 @@ public class DesignSinglePrintDTO implements Serializable {
// @ApiModelProperty("印花url") // @ApiModelProperty("印花url")
// private String path; // private String path;
@ApiModelProperty("single -> true,overall -> false") /*@ApiModelProperty("single -> true,overall -> false")
private Boolean ifSingle; private Boolean ifSingle;*/
@ApiModelProperty("印花详细") @ApiModelProperty("印花详细")
private List<DesignSinglePrint> prints; private List<DesignSinglePrint> prints;
public DesignSinglePrintDTO() { public DesignSinglePrintDTO() {
} }
/*
public DesignSinglePrintDTO(Boolean ifSingle, List<DesignSinglePrint> prints) { public DesignSinglePrintDTO(Boolean ifSingle, List<DesignSinglePrint> prints) {
this.ifSingle = ifSingle; this.ifSingle = ifSingle;
this.prints = prints; this.prints = prints;
} }*/
} }

View File

@@ -58,6 +58,9 @@ public class DesignItemClothesDetailVO {
@ApiModelProperty("渐变色信息") @ApiModelProperty("渐变色信息")
private Gradient gradient; private Gradient gradient;
@ApiModelProperty("未分割的图层")
private String undividedLayer;
public DesignItemClothesDetailVO() { public DesignItemClothesDetailVO() {
} }

View File

@@ -13,6 +13,9 @@ import java.util.List;
@ApiModel("design single 印花详情") @ApiModel("design single 印花详情")
public class DesignSinglePrint implements Serializable { public class DesignSinglePrint implements Serializable {
@ApiModelProperty("single -> true,overall -> false")
private Boolean ifSingle;
@ApiModelProperty("印花的类型 Slogan || Logo || Pattern") @ApiModelProperty("印花的类型 Slogan || Logo || Pattern")
private String level2Type; private String level2Type;
@@ -48,7 +51,7 @@ public class DesignSinglePrint implements Serializable {
this.scale = scale; this.scale = scale;
} }
public DesignSinglePrint(String level2Type, String path, String minIOPath, List<Double> location, Double scale, Double angle, Integer priority) { public DesignSinglePrint(String level2Type, String path, String minIOPath, List<Double> location, Double scale, Double angle, Integer priority, Boolean ifSingle) {
this.level2Type = level2Type; this.level2Type = level2Type;
this.path = path; this.path = path;
this.minIOPath = minIOPath; this.minIOPath = minIOPath;
@@ -56,5 +59,6 @@ public class DesignSinglePrint implements Serializable {
this.scale = scale; this.scale = scale;
this.angle = angle; this.angle = angle;
this.priority = priority; this.priority = priority;
this.ifSingle = ifSingle;
} }
} }

View File

@@ -1928,14 +1928,14 @@ public class PythonService {
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) { && elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) {
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class); DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
designPythonItemPrint.setIfSingle(false); // designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(Collections.singletonList(designPythonItemPrint.getPath())); designPythonItemPrint.setPrint_path_list(Collections.singletonList(designPythonItemPrint.getPath()));
designPythonItemBlouse.setPrint(designPythonItemPrint); designPythonItemBlouse.setPrint(new PrintToPython(designPythonItemPrint));
} else { } else {
DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint(); DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint();
designPythonItemPrint.setIfSingle(false); // designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(new ArrayList<>()); designPythonItemPrint.setPrint_path_list(new ArrayList<>());
designPythonItemBlouse.setPrint(designPythonItemPrint); designPythonItemBlouse.setPrint(new PrintToPython(designPythonItemPrint));
} }
return designPythonItemBlouse; return designPythonItemBlouse;
} }
@@ -1957,14 +1957,14 @@ public class PythonService {
if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") if (!elementVO.getDesignPythonItemPrint().getPath().equals("none")
&& elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) { && elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) {
DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class); DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class);
designPythonItemPrint.setIfSingle(false); // designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(Collections.singletonList(designPythonItemPrint.getPath())); designPythonItemPrint.setPrint_path_list(Collections.singletonList(designPythonItemPrint.getPath()));
designPythonItemBlouse.setPrint(designPythonItemPrint); designPythonItemBlouse.setPrint(new PrintToPython(designPythonItemPrint));
} else { } else {
DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint(); DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint();
designPythonItemPrint.setIfSingle(false); // designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(new ArrayList<>()); designPythonItemPrint.setPrint_path_list(new ArrayList<>());
designPythonItemBlouse.setPrint(designPythonItemPrint); designPythonItemBlouse.setPrint(new PrintToPython(designPythonItemPrint));
} }
return designPythonItemBlouse; return designPythonItemBlouse;
} }
@@ -2587,7 +2587,7 @@ public class PythonService {
List<DesignPythonItem> response = CopyUtil.copyList(designPythonItemDto, DesignPythonItem.class, (o, d) -> { List<DesignPythonItem> response = CopyUtil.copyList(designPythonItemDto, DesignPythonItem.class, (o, d) -> {
d.setBusinessId(o.getId()); d.setBusinessId(o.getId());
d.setIcon("none"); d.setIcon("none");
d.setPrint(resolveDesignSinglePrint(o.getPrintObject(), o.getPath())); // d.setPrint(resolveDesignSinglePrint(o.getPrintObject(), o.getPath()));
}); });
DesignPythonItem body = new DesignPythonItem(); DesignPythonItem body = new DesignPythonItem();
body.setType(SysFileLevel2TypeEnum.BODY.getRealName()); body.setType(SysFileLevel2TypeEnum.BODY.getRealName());
@@ -2636,12 +2636,13 @@ public class PythonService {
// todo 当渐变色不为空时,是否需要将颜色置为 0 0 0 // todo 当渐变色不为空时,是否需要将颜色置为 0 0 0
} }
PrintToPython printToPython = resolveDesignSinglePrint(designSingleItem.getPrintObject().getPrints());
resolveDesignElement(designSingleItem.getTrims(), printToPython);
response.add(new DesignPythonItem( response.add(new DesignPythonItem(
designSingleItem.getType(), designSingleItem.getType(),
designSingleItem.getPath(), designSingleItem.getPath(),
designSingleItem.getColor(), designSingleItem.getColor(),
resolveDesignSinglePrint(designSingleItem.getPrintObject(), null), printToPython,
resolveDesignElement(designSingleItem.getTrims()),
// businessId designItemDetailId python端确认没有作用,但是数据库需要存,作用:未知) // businessId designItemDetailId python端确认没有作用,但是数据库需要存,作用:未知)
// designSingleItem.getId(), // designSingleItem.getId(),
businessId, businessId,
@@ -2666,47 +2667,84 @@ public class PythonService {
} }
private DesignPythonItemPrint resolveDesignSinglePrint(DesignSinglePrintDTO printObject, String clothesPath) { private PrintToPython resolveDesignSinglePrint(List<DesignSinglePrint> printObject) {
// 没有印花时的参数设置 PrintToPython printToPython = new PrintToPython();
if (printObject.getIfSingle().equals(Boolean.FALSE) && CollectionUtil.isEmpty(printObject.getPrints())) { DesignPythonItemPrint printSingle = new DesignPythonItemPrint();
return new DesignPythonItemPrint(new ArrayList<>(), false); DesignPythonItemPrint printOverall = new DesignPythonItemPrint();
printToPython.setSingle(printSingle);
printToPython.setOverall(printOverall);
if (printObject.isEmpty()){
return printToPython;
} }
DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
int size = printObject.getPrints().size(); // 没有印花时的参数设置
// if (printObject.getIfSingle().equals(Boolean.FALSE) && CollectionUtil.isEmpty(printObject.getPrints())) {
// return new DesignPythonItemPrint(new ArrayList<>(), false);
// }
// DesignPythonItemPrint print = CopyUtil.copyObject(printObject, DesignPythonItemPrint.class);
int size = printObject.size();
// 占位符填充数组 // 占位符填充数组
List<List<Double>> location = new ArrayList<>(Collections.nCopies(size, null)); List<List<Double>> locationS = new ArrayList<>(Collections.nCopies(size, null));
List<Double> scale = new ArrayList<>(Collections.nCopies(size, null)); List<Double> scaleS = new ArrayList<>(Collections.nCopies(size, null));
List<Double> angle = new ArrayList<>(Collections.nCopies(size, null)); List<Double> angleS = new ArrayList<>(Collections.nCopies(size, null));
ArrayList<String> paths = new ArrayList<>(Collections.nCopies(size, null)); ArrayList<String> pathsS = new ArrayList<>(Collections.nCopies(size, null));
List<List<Double>> locationO = new ArrayList<>(Collections.nCopies(size, null));
List<Double> scaleO = new ArrayList<>(Collections.nCopies(size, null));
List<Double> angleO = new ArrayList<>(Collections.nCopies(size, null));
ArrayList<String> pathsO = new ArrayList<>(Collections.nCopies(size, null));
// 设置印花的位置、大小、旋转角度 // 设置印花的位置、大小、旋转角度
// 优先级越大越靠近顶层在传输给python的数组中越靠前 // 优先级越大越靠近顶层在传输给python的数组中越靠前
List<DesignSinglePrint> prints = printObject.getPrints(); // List<DesignSinglePrint> prints = printObject.getPrints();
prints.forEach(p -> { printObject.forEach(p -> {
p.getLocation().set(0, p.getLocation().get(0)); p.getLocation().set(0, p.getLocation().get(0));
p.getLocation().set(1, p.getLocation().get(1)); p.getLocation().set(1, p.getLocation().get(1));
Integer priority = p.getPriority(); Integer priority = p.getPriority();
location.set(size - priority, p.getLocation()); // todo 下标越界问题
scale.set(size - priority, p.getScale()); if (p.getIfSingle()){
angle.set(size - priority, p.getAngle()); locationS.set(priority - 1, p.getLocation());
paths.set(size - priority, p.getMinIOPath()); scaleS.set(priority - 1, p.getScale());
angleS.set( priority - 1, p.getAngle());
pathsS.set(priority - 1, p.getMinIOPath());
}else {
locationO.set(priority - 1, p.getLocation());
scaleO.set(priority - 1, p.getScale());
angleO.set(priority - 1, p.getAngle());
pathsO.set(priority - 1, p.getMinIOPath());
}
// log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO)); // log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO));
}); });
print.setLocation(location); locationS.removeAll(Collections.singleton(null));
print.setPrint_scale_list(scale); scaleS.removeAll(Collections.singleton(null));
print.setPrint_angle_list(angle); angleS.removeAll(Collections.singleton(null));
print.setPrint_path_list(paths); pathsS.removeAll(Collections.singleton(null));
printSingle.setLocation(locationS);
printSingle.setPrint_scale_list(scaleS);
printSingle.setPrint_angle_list(angleS);
printSingle.setPrint_path_list(pathsS);
return print; locationO.removeAll(Collections.singleton(null));
scaleO.removeAll(Collections.singleton(null));
angleO.removeAll(Collections.singleton(null));
pathsO.removeAll(Collections.singleton(null));
printOverall.setLocation(locationO);
printOverall.setPrint_scale_list(scaleO);
printOverall.setPrint_angle_list(angleO);
printOverall.setPrint_path_list(pathsO);
return printToPython;
} }
private DesignPythonItemElement resolveDesignElement(DesignSinglePrintDTO trims) { private void resolveDesignElement(DesignSinglePrintDTO trims, PrintToPython printToPython) {
// 没有design element 时的参数设置 // 没有design element 时的参数设置
if (Objects.isNull(trims.getIfSingle()) && CollectionUtil.isEmpty(trims.getPrints())) { DesignPythonItemElement element = new DesignPythonItemElement();
return null; if (CollectionUtil.isEmpty(trims.getPrints())) {
printToPython.setElement(element);
return;
} }
DesignPythonItemElement print = new DesignPythonItemElement();
int size = trims.getPrints().size(); int size = trims.getPrints().size();
// 占位符填充数组 // 占位符填充数组
@@ -2722,18 +2760,17 @@ public class PythonService {
p.getLocation().set(0, p.getLocation().get(0)); p.getLocation().set(0, p.getLocation().get(0));
p.getLocation().set(1, p.getLocation().get(1)); p.getLocation().set(1, p.getLocation().get(1));
Integer priority = p.getPriority(); Integer priority = p.getPriority();
location.set(size - priority, p.getLocation()); location.set(priority - 1, p.getLocation());
scale.set(size - priority, p.getScale()); scale.set(priority - 1, p.getScale());
angle.set(size - priority, p.getAngle()); angle.set(priority - 1, p.getAngle());
paths.set(size - priority, p.getMinIOPath()); paths.set(priority - 1, p.getMinIOPath());
// log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO)); // log.info("本次print打点locations###{}###fileVO{}", p.getLocation(), JSON.toJSONString(fileVO));
}); });
print.setLocation(location); element.setLocation(location);
print.setElement_scale_list(scale); element.setElement_scale_list(scale);
print.setElement_angle_list(angle); element.setElement_angle_list(angle);
print.setElement_path_list(paths); element.setElement_path_list(paths);
printToPython.setElement(element);
return print;
} }
private DesignPythonBasic coverToSingleBasic(DesignPythonItem designPythonItem, String singleOverall, private DesignPythonBasic coverToSingleBasic(DesignPythonItem designPythonItem, String singleOverall,
@@ -2806,9 +2843,9 @@ public class PythonService {
dress.setColor("none"); dress.setColor("none");
dress.setIcon("none"); dress.setIcon("none");
DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint(); DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint();
designPythonItemPrint.setIfSingle(false); // designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(new ArrayList<>()); designPythonItemPrint.setPrint_path_list(new ArrayList<>());
dress.setPrint(designPythonItemPrint); dress.setPrint(new PrintToPython(designPythonItemPrint));
dress.setPath("aida-sys-image/images/female/blouse/0628001551.jpg"); dress.setPath("aida-sys-image/images/female/blouse/0628001551.jpg");
response.add(dress); response.add(dress);
@@ -2817,9 +2854,9 @@ public class PythonService {
skirt.setColor("none"); skirt.setColor("none");
skirt.setIcon("none"); skirt.setIcon("none");
DesignPythonItemPrint designPythonItemPrint1 = new DesignPythonItemPrint(); DesignPythonItemPrint designPythonItemPrint1 = new DesignPythonItemPrint();
designPythonItemPrint1.setIfSingle(false); // designPythonItemPrint1.setIfSingle(false);
designPythonItemPrint1.setPrint_path_list(new ArrayList<>()); designPythonItemPrint1.setPrint_path_list(new ArrayList<>());
skirt.setPrint(designPythonItemPrint1); skirt.setPrint(new PrintToPython(designPythonItemPrint1));
skirt.setPath("aida-sys-image/images/female/skirt/0628000022.jpg"); skirt.setPath("aida-sys-image/images/female/skirt/0628000022.jpg");
// skirt.setPath("aida-sys-image/images/female/dress/0628000000.jpg"); // skirt.setPath("aida-sys-image/images/female/dress/0628000000.jpg");
response.add(skirt); response.add(skirt);
@@ -2829,9 +2866,9 @@ public class PythonService {
top.setColor("none"); top.setColor("none");
top.setIcon("none"); top.setIcon("none");
DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint(); DesignPythonItemPrint designPythonItemPrint = new DesignPythonItemPrint();
designPythonItemPrint.setIfSingle(false); // designPythonItemPrint.setIfSingle(false);
designPythonItemPrint.setPrint_path_list(new ArrayList<>()); designPythonItemPrint.setPrint_path_list(new ArrayList<>());
top.setPrint(designPythonItemPrint); top.setPrint(new PrintToPython(designPythonItemPrint));
top.setPath("aida-sys-image/images/male/tops/mens_test_10.png"); top.setPath("aida-sys-image/images/male/tops/mens_test_10.png");
response.add(top); response.add(top);
@@ -2840,9 +2877,9 @@ public class PythonService {
bottom.setColor("none"); bottom.setColor("none");
bottom.setIcon("none"); bottom.setIcon("none");
DesignPythonItemPrint designPythonItemPrint1 = new DesignPythonItemPrint(); DesignPythonItemPrint designPythonItemPrint1 = new DesignPythonItemPrint();
designPythonItemPrint1.setIfSingle(false); // designPythonItemPrint1.setIfSingle(false);
designPythonItemPrint1.setPrint_path_list(new ArrayList<>()); designPythonItemPrint1.setPrint_path_list(new ArrayList<>());
bottom.setPrint(designPythonItemPrint1); bottom.setPrint(new PrintToPython(designPythonItemPrint1));
bottom.setPath("aida-sys-image/images/male/bottoms/mens_test_6252.png"); bottom.setPath("aida-sys-image/images/male/bottoms/mens_test_6252.png");
response.add(bottom); response.add(bottom);
} }

View File

@@ -35,7 +35,7 @@ public class DesignPythonItem {
/** /**
* 对应的print图片的绝对路径 * 对应的print图片的绝对路径
*/ */
private DesignPythonItemPrint print; private PrintToPython print;
/** /**
* trims 衣服上的装饰 * trims 衣服上的装饰
@@ -118,13 +118,12 @@ public class DesignPythonItem {
this.image_id = image_id; this.image_id = image_id;
} }
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, DesignPythonItemElement element, Long businessId, public DesignPythonItem(String type, String path, String color, PrintToPython print, Long businessId,
Long image_id, List<Long> offset, Float[] resize_scale, Integer priority, String gradient, String gradientString) { Long image_id, List<Long> offset, Float[] resize_scale, Integer priority, String gradient, String gradientString) {
this.type = type; this.type = type;
this.path = path; this.path = path;
this.color = color; this.color = color;
this.print = print; this.print = print;
this.element = element;
// this.icon = icon; // this.icon = icon;
this.businessId = businessId; this.businessId = businessId;
this.image_id = image_id; this.image_id = image_id;
@@ -135,7 +134,7 @@ public class DesignPythonItem {
this.gradientString = gradientString; this.gradientString = gradientString;
} }
public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, String icon, Long businessId, Long image_id) { public DesignPythonItem(String type, String path, String color, PrintToPython print, String icon, Long businessId, Long image_id) {
this.type = type; this.type = type;
this.path = path; this.path = path;
this.color = color; this.color = color;

View File

@@ -3,21 +3,22 @@ package com.ai.da.python.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
public class DesignPythonItemElement { public class DesignPythonItemElement {
@ApiModelProperty("print的位置 传 [[0.2, 0.2]]") @ApiModelProperty("print的位置 传 [[0.2, 0.2]]")
private List<List<Double>> location; private List<List<Double>> location = new ArrayList<>();
private List<String> element_path_list; private List<String> element_path_list = new ArrayList<>();
@ApiModelProperty("print的缩放比例 传 [0.2, 0.2]") @ApiModelProperty("print的缩放比例 传 [0.2, 0.2]")
private List<Double> element_scale_list; private List<Double> element_scale_list = new ArrayList<>();
@ApiModelProperty("print的旋转角度 传 [0.2, 0.2]") @ApiModelProperty("print的旋转角度 传 [0.2, 0.2]")
private List<Double> element_angle_list; private List<Double> element_angle_list = new ArrayList<>();
public DesignPythonItemElement() { public DesignPythonItemElement() {
} }

View File

@@ -4,6 +4,9 @@ import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
@Data @Data
@@ -14,7 +17,7 @@ public class DesignPythonItemPrint {
@ApiModelProperty("图片绝对路径") @ApiModelProperty("图片绝对路径")
private String path; private String path;
private List<String> print_path_list; private List<String> print_path_list = new ArrayList<>();
@ApiModelProperty("上传时候对应的类型,一级类型 Printboard ") @ApiModelProperty("上传时候对应的类型,一级类型 Printboard ")
private String level1Type; private String level1Type;
@@ -29,28 +32,38 @@ public class DesignPythonItemPrint {
* 是否打点 * 是否打点
*/ */
@ApiModelProperty("是否打点 是传true 否则false") @ApiModelProperty("是否打点 是传true 否则false")
private Boolean IfSingle; private Boolean ifSingle;
@ApiModelProperty("print的位置 传 [[0.2, 0.2]]") @ApiModelProperty("print的位置 传 [[0.2, 0.2]]")
private List<List<Double>> location; private List<List<Double>> location = new ArrayList<>();
@ApiModelProperty("print的缩放比例 传 [0.2, 0.2]") @ApiModelProperty("print的缩放比例 传 [0.2, 0.2]")
private List<Double> print_scale_list; private List<Double> print_scale_list = new ArrayList<>();
@ApiModelProperty("print的旋转角度 传 [0.2, 0.2]") @ApiModelProperty("print的旋转角度 传 [0.2, 0.2]")
private List<Double> print_angle_list; private List<Double> print_angle_list = new ArrayList<>();
@JSONField(name = "IfSingle") @JSONField(name = "IfSingle")
public Boolean getIfSingle() { public Boolean getIfSingle() {
return IfSingle; return ifSingle;
}
public DesignPythonItemPrint(List<String> print_path_list, Boolean ifDesign) {
if (ifDesign){
this.print_path_list = print_path_list;
this.location = Collections.singletonList(Arrays.asList(0.0, 0.0));
this.print_scale_list = Arrays.asList(0.0, 0.0);
this.print_angle_list = Arrays.asList(0.0, 0.0);
}
} }
public DesignPythonItemPrint(String singlePath, String level1Type, Float scale, Boolean ifSingle) { public DesignPythonItemPrint(String singlePath, String level1Type, Float scale, Boolean ifSingle) {
this.path = singlePath; this.path = singlePath;
this.level1Type = level1Type; this.level1Type = level1Type;
this.scale = scale; this.scale = scale;
IfSingle = ifSingle; this.ifSingle = ifSingle;
} }
public DesignPythonItemPrint() { public DesignPythonItemPrint() {
@@ -60,8 +73,4 @@ public class DesignPythonItemPrint {
this.path = path; this.path = path;
} }
public DesignPythonItemPrint(List<String> print_path_list, Boolean ifSingle) {
this.print_path_list = print_path_list;
IfSingle = ifSingle;
}
} }

View File

@@ -0,0 +1,20 @@
package com.ai.da.python.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PrintToPython {
private DesignPythonItemPrint single;
private DesignPythonItemPrint overall;
private DesignPythonItemElement element;
public PrintToPython(DesignPythonItemPrint overall) {
this.overall = new DesignPythonItemPrint(overall.getPrint_path_list(),Boolean.TRUE);
single = new DesignPythonItemPrint();
element = new DesignPythonItemElement();
}
}

View File

@@ -223,7 +223,7 @@ public class ChatRobotServiceImpl implements ChatRobotService {
if (!CollectionUtils.isEmpty(libraryList)) { if (!CollectionUtils.isEmpty(libraryList)) {
chatRobotLibraryVO.setId(libraryList.get(0).getId()); chatRobotLibraryVO.setId(libraryList.get(0).getId());
} }
String aidaSysImage = minioUtil.getPresignedUrl(bucketName + "/" + path, 24 * 60); String aidaSysImage = minioUtil.getPreSignedUrl(bucketName + "/" + path, 24 * 60);
chatRobotLibraryVO.setUrl(bucketName + "/" + path); chatRobotLibraryVO.setUrl(bucketName + "/" + path);
chatRobotLibraryVO.setPresignedUrl(aidaSysImage); chatRobotLibraryVO.setPresignedUrl(aidaSysImage);
chatRobotLibraryVOList.add(chatRobotLibraryVO); chatRobotLibraryVOList.add(chatRobotLibraryVO);

View File

@@ -24,7 +24,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
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.BeanUtils; import org.springframework.beans.BeanUtils;
@@ -36,8 +35,6 @@ import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
@@ -106,7 +103,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
saveOne(collectionElement); saveOne(collectionElement);
CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class); CollectionElementVO collectionElementVO = CopyUtil.copyObject(collectionElement, CollectionElementVO.class);
collectionElementVO.setMinIOPath(collectionElementVO.getUrl()); collectionElementVO.setMinIOPath(collectionElementVO.getUrl());
collectionElementVO.setUrl(minioUtil.getPresignedUrl(collectionElementVO.getUrl(), 24 * 60)); collectionElementVO.setUrl(minioUtil.getPreSignedUrl(collectionElementVO.getUrl(), 24 * 60));
collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); collectionElementVO.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
return collectionElementVO; return collectionElementVO;
} }
@@ -247,7 +244,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
// collectionGeneratePrint.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); // collectionGeneratePrint.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
// return collectionGeneratePrint; // return collectionGeneratePrint;
return new GenerateCollectionItemVO(generateDetail.getId(), return new GenerateCollectionItemVO(generateDetail.getId(),
minioUtil.getPresignedUrl(generateUrl, 24 * 60), minioUtil.getPreSignedUrl(generateUrl, 24 * 60),
generateDetail.getIsLike().equals((byte) 0) ? Boolean.FALSE : Boolean.TRUE); generateDetail.getIsLike().equals((byte) 0) ? Boolean.FALSE : Boolean.TRUE);
} }
@@ -340,9 +337,12 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
element.setHasPin((byte) 0); element.setHasPin((byte) 0);
try { try {
element.setMd5(MD5Utils.encryptFile(minioUtil.download(path))); element.setMd5(MD5Utils.encryptFile(minioUtil.download(path)));
} catch (MinioException | IOException e) { }catch (Exception e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }
/* catch (MinioException | IOException e) {
throw new RuntimeException(e);
}*/
//按时区计算 //按时区计算
element.setCreateDate(DateUtil.getByTimeZone(timeZone)); element.setCreateDate(DateUtil.getByTimeZone(timeZone));
@@ -888,9 +888,11 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String md5; String md5;
try { try {
md5 = MD5Utils.encryptFile(minioUtil.download(url)); md5 = MD5Utils.encryptFile(minioUtil.download(url));
} catch (MinioException | IOException e) { } catch (Exception e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }/*catch (MinioException | IOException e) {
throw new RuntimeException(e);
}*/
// 通过MD5来确认当前图片是否有被like过避免重复like // 通过MD5来确认当前图片是否有被like过避免重复like
List<Map<String, Long>> libraryIds = generateDetailMapper.getLibraryIdThroughMD5(md5, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()); List<Map<String, Long>> libraryIds = generateDetailMapper.getLibraryIdThroughMD5(md5, CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
if (libraryIds.isEmpty()){ if (libraryIds.isEmpty()){

View File

@@ -80,7 +80,7 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
CollectionElement byId = collectionElementService.getById(response.getMoodTemplateId()); CollectionElement byId = collectionElementService.getById(response.getMoodTemplateId());
if (Objects.nonNull(byId)) { if (Objects.nonNull(byId)) {
response.setMoodTemplateName(byId.getName()); response.setMoodTemplateName(byId.getName());
response.setMoodTemplateUrl(minioUtil.getPresignedUrl(byId.getUrl(), 24 * 60)); response.setMoodTemplateUrl(minioUtil.getPreSignedUrl(byId.getUrl(), 24 * 60));
} }
} }
Map<String, List<CollectionElement>> maps = collectionElements Map<String, List<CollectionElement>> maps = collectionElements
@@ -95,27 +95,27 @@ public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collect
case MOOD_BOARD: case MOOD_BOARD:
response.setMoodBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> { response.setMoodBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60)); d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
})); }));
break; break;
case PRINT_BOARD: case PRINT_BOARD:
response.setPrintBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> { response.setPrintBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setIsPin(o.getHasPin()); d.setIsPin(o.getHasPin());
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60)); d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
})); }));
break; break;
case SKETCH_BOARD: case SKETCH_BOARD:
response.setSketchBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> { response.setSketchBoards(CopyUtil.copyList(v, CollectionElementVO.class, (o, d) -> {
d.setIsPin(o.getHasPin()); d.setIsPin(o.getHasPin());
d.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); d.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
d.setUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60)); d.setUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
String url = o.getUrl(); String url = o.getUrl();
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
d.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
}else { }else {
d.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); d.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
} }
})); }));
break; break;

View File

@@ -8,10 +8,7 @@ import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CollectionLevel1TypeEnum; import com.ai.da.common.enums.CollectionLevel1TypeEnum;
import com.ai.da.common.enums.SingleOverallEnum; import com.ai.da.common.enums.SingleOverallEnum;
import com.ai.da.common.enums.SysFileLevel2TypeEnum; import com.ai.da.common.enums.SysFileLevel2TypeEnum;
import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.*;
import com.ai.da.common.utils.DateUtil;
import com.ai.da.common.utils.MD5Utils;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.DesignItemMapper; import com.ai.da.mapper.primary.DesignItemMapper;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
@@ -264,7 +261,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
} }
// todo check这个方法是否还在用
private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) { , Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) {
DesignCollectionItemVO response = new DesignCollectionItemVO(); DesignCollectionItemVO response = new DesignCollectionItemVO();
@@ -298,7 +295,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetail.setBusinessId(0L); designItemDetail.setBusinessId(0L);
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
DesignPythonItemPrint printObject = detail.getPrint(); // todo
DesignPythonItemPrint printObject = detail.getPrint().getSingle();
designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintJson(JSON.toJSONString(printObject)); designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetails.add(designItemDetail); designItemDetails.add(designItemDetail);
@@ -315,7 +313,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
private List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects private List<TDesignPythonOutfitDetail> saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects
, Long designId, Long designItemId, Long userId , Long designId, Long designItemId, Long userId
, JSONObject outfit, String timeZone, List<DesignSingleItemDTO> designSingleItemDTOList) { , JSONObject outfit, String timeZone, List<DesignSingleItemDTO> designSingleItemDTOList
, Map<String, String> categoryAndUndividedLayer) {
DesignItem designItem = new DesignItem(); DesignItem designItem = new DesignItem();
// String url = pythonObjects.getObjects().get(0).getBasic().getSave_name(); // String url = pythonObjects.getObjects().get(0).getBasic().getSave_name();
@@ -346,8 +345,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetail.setPriority(0); designItemDetail.setPriority(0);
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
DesignPythonItemPrint printObject = detail.getPrint(); designItemDetail.setUndividedLayer(categoryAndUndividedLayer.get(detail.getType().toLowerCase()));
designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // 印花存储在design_item_detail_print表中 这里还要存吗?
// DesignPythonItemPrint printObject = detail.getPrintToPython();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
// 当有多个印花后返回的printObject太长导致存储到数据库时报错 // 当有多个印花后返回的printObject太长导致存储到数据库时报错
// designItemDetail.setPrintJson(JSON.toJSONString(printObject)); // designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetails.add(designItemDetail); designItemDetails.add(designItemDetail);
@@ -509,14 +510,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
throw new BusinessException("priority.cannot.be.repeated"); throw new BusinessException("priority.cannot.be.repeated");
} }
JSONArray layers = outfit.getJSONArray("layers");
Map<String, String> categoryAndUndividedLayer = setTypeAndUndividedLayer(layers);
if (!designSingleIncludeLayersDTO.getIsPreview()) { if (!designSingleIncludeLayersDTO.getIsPreview()) {
// 更新及保存图层信息 // 更新及保存图层信息
tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId(), tDesignPythonOutfitDetails = saveDesignSingleItemDetailAndLayers(objects, design.getId(), designSingleIncludeLayersDTO.getDesignItemId()
userId, outfit, designSingleIncludeLayersDTO.getTimeZone(), designSingleIncludeLayersDTO.getDesignSingleItemDTOList()); , userId, outfit, designSingleIncludeLayersDTO.getTimeZone()
, designSingleIncludeLayersDTO.getDesignSingleItemDTOList()
, categoryAndUndividedLayer);
saveCollectionElement(designSingleIncludeLayersDTO); saveCollectionElement(designSingleIncludeLayersDTO);
} else { } else {
JSONArray layers = outfit.getJSONArray("layers");
tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers, designItem.getDesignId(), null, userId, priorityOffset); tDesignPythonOutfitDetails = setTDesignPythonOutfitDetailList(layers, designItem.getDesignId(), null, userId, priorityOffset);
} }
@@ -536,11 +540,12 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
return assembleDesignSingleResponse(designItem.getId(), return assembleDesignSingleResponse(designItem.getId(),
minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60), minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60),
outfit.getString("synthesis_url"), outfit.getString("synthesis_url"),
designSingleIncludeLayersDTO.getDesignSingleItemDTOList(), designSingleIncludeLayersDTO.getDesignSingleItemDTOList(),
detailsVO, detailsVO,
design.getSingleOverall()); design.getSingleOverall(),
categoryAndUndividedLayer);
} }
private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){ private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){
@@ -563,6 +568,16 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
} }
private Map<String, String> setTypeAndUndividedLayer(JSONArray layers){
HashMap<String, String> categoryAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i);
String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !categoryAndLayer.containsKey(category)) categoryAndLayer.put(category, jsonObject.getString("pattern_image_url"));
}
return categoryAndLayer;
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException { public ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException {
@@ -591,7 +606,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 4、合成图层 // 4、合成图层
String synthesisUrl = pythonService.composeLayers(outfitDetailPythonItems); String synthesisUrl = pythonService.composeLayers(outfitDetailPythonItems);
designItemLayer.setDesignItemUrl(minioUtil.getPresignedUrl(synthesisUrl, 24 * 60)); designItemLayer.setDesignItemUrl(minioUtil.getPreSignedUrl(synthesisUrl, 24 * 60));
// 5、更新数据库根据designItemId更新designItemUrl // 5、更新数据库根据designItemId更新designItemUrl
designItem.setUpdateDate(DateUtil.getByTimeZone(positionAndScaleVO.getTimeZone())); designItem.setUpdateDate(DateUtil.getByTimeZone(positionAndScaleVO.getTimeZone()));
@@ -627,10 +642,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
layer.setImageSize(imageSize); layer.setImageSize(imageSize);
if (!StringUtil.isNullOrEmpty(layer.getImageUrl())) { if (!StringUtil.isNullOrEmpty(layer.getImageUrl())) {
layer.setImageUrl(minioUtil.getPresignedUrl(layer.getImageUrl(), 24 * 60)); layer.setImageUrl(minioUtil.getPreSignedUrl(layer.getImageUrl(), 24 * 60));
} }
if (!StringUtil.isNullOrEmpty(layer.getMaskUrl())) { if (!StringUtil.isNullOrEmpty(layer.getMaskUrl())) {
layer.setMaskUrl(minioUtil.getPresignedUrl(layer.getMaskUrl(), 24 * 60)); layer.setMaskUrl(minioUtil.getPreSignedUrl(layer.getMaskUrl(), 24 * 60));
} }
}); });
@@ -653,7 +668,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
String currentFullBodyView, String currentFullBodyView,
List<DesignSingleItemDTO> designSingleItemDTOList, List<DesignSingleItemDTO> designSingleItemDTOList,
List<DesignPythonOutfitVO> layersObject, List<DesignPythonOutfitVO> layersObject,
String singleOrOverall) { String singleOrOverall,
Map<String, String> categoryAndUndividedLayer) {
DesignSingleVO designSingleVO = new DesignSingleVO(); DesignSingleVO designSingleVO = new DesignSingleVO();
ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>(); ArrayList<DesignItemClothesDetailVO> clothes = new ArrayList<>();
@@ -662,7 +678,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 图片用于修改前后的一键对比 // 图片用于修改前后的一键对比
designSingleVO.setDesignItemUrl(designItemUrl); designSingleVO.setDesignItemUrl(designItemUrl);
// 当前全身图 // 当前全身图
designSingleVO.setCurrentFullBodyView(minioUtil.getPresignedUrl(currentFullBodyView, 24 * 60)); designSingleVO.setCurrentFullBodyView(minioUtil.getPreSignedUrl(currentFullBodyView, 24 * 60));
designSingleVO.setClothes(clothes); designSingleVO.setClothes(clothes);
// 获取每个单品的id是否被改变过该状态需要再返回给前端 // 获取每个单品的id是否被改变过该状态需要再返回给前端
@@ -677,7 +693,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemClothesDetailVO.setChanged(idChanged.get(singleItem.getId())); designItemClothesDetailVO.setChanged(idChanged.get(singleItem.getId()));
designItemClothesDetailVO.setDesignType(idDesignType.get(singleItem.getId())); designItemClothesDetailVO.setDesignType(idDesignType.get(singleItem.getId()));
designItemClothesDetailVO.setType(singleItem.getType()); designItemClothesDetailVO.setType(singleItem.getType());
designItemClothesDetailVO.setPath(minioUtil.getPresignedUrl(singleItem.getPath(), 24 * 60)); designItemClothesDetailVO.setPath(minioUtil.getPreSignedUrl(singleItem.getPath(), 24 * 60));
designItemClothesDetailVO.setMinIOPath(singleItem.getPath()); designItemClothesDetailVO.setMinIOPath(singleItem.getPath());
designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor())); designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor()));
designItemClothesDetailVO.setPrintObject(singleItem.getPrintObject()); designItemClothesDetailVO.setPrintObject(singleItem.getPrintObject());
@@ -687,6 +703,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
&& (flag ? Boolean.TRUE : singleItem.getPriority().equals(layers.getPriority()))) && (flag ? Boolean.TRUE : singleItem.getPriority().equals(layers.getPriority())))
).collect(Collectors.toList())); ).collect(Collectors.toList()));
designItemClothesDetailVO.setGradient(singleItem.getGradient()); designItemClothesDetailVO.setGradient(singleItem.getGradient());
if (categoryAndUndividedLayer.containsKey(singleItem.getType().toLowerCase())) designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(categoryAndUndividedLayer.get(singleItem.getType().toLowerCase()), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList())); body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList()));
clothes.add(designItemClothesDetailVO); clothes.add(designItemClothesDetailVO);
@@ -718,20 +735,16 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
String printType, String printType,
Map<Integer, Long> designItemDetailTypeIdMap, Map<Integer, Long> designItemDetailTypeIdMap,
String timeZone){ String timeZone){
// todo 这边这样做对吗
DesignSinglePrintDTO printObject; DesignSinglePrintDTO printObject;
if (printType.equals("print")){ if (printType.equals("print")){
printObject = designSingleItem.getPrintObject(); printObject = designSingleItem.getPrintObject();
}else { }else {
printObject = designSingleItem.getTrims(); printObject = designSingleItem.getTrims();
if (Objects.isNull(printObject.getIfSingle())){
printObject.setIfSingle(Boolean.FALSE);
}
} }
if (printObject.getIfSingle().equals(Boolean.FALSE) if (!CollectionUtil.isEmpty(printObject.getPrints())) {
&& CollectionUtil.isEmpty(printObject.getPrints())) {
return;
} else {
// 2、有印花添加到list // 2、有印花添加到list
printObject.getPrints().forEach(print -> { printObject.getPrints().forEach(print -> {
// 2.1 判断是否第一次添加印花,是:直接添加 // 2.1 判断是否第一次添加印花,是:直接添加
@@ -746,7 +759,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetailPrint.setLevel2Type(print.getLevel2Type()); designItemDetailPrint.setLevel2Type(print.getLevel2Type());
designItemDetailPrint.setPath(print.getMinIOPath()); designItemDetailPrint.setPath(print.getMinIOPath());
designItemDetailPrint.setScale(print.getScale()); designItemDetailPrint.setScale(print.getScale());
designItemDetailPrint.setSingleOrOverall(printType.equals("print") ? printObject.getIfSingle() ? "single" : "overall" : "single"); designItemDetailPrint.setSingleOrOverall(printType.equals("print") ? print.getIfSingle() ? "single" : "overall" : "single");
designItemDetailPrint.setCreateDate(LocalDateTime.now(ZoneId.of(timeZone))); designItemDetailPrint.setCreateDate(LocalDateTime.now(ZoneId.of(timeZone)));
// single、overall模式下都有position、angle和priority // single、overall模式下都有position、angle和priority
designItemDetailPrint.setPosition(print.getLocation().toString()); designItemDetailPrint.setPosition(print.getLocation().toString());
@@ -785,7 +798,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(designSingleItem -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(designSingleItem -> {
if (!StringUtil.isNullOrEmpty(designSingleItem.getDesignType()) && designSingleItem.getDesignType().equals("Collection")){ if (!StringUtil.isNullOrEmpty(designSingleItem.getDesignType()) && designSingleItem.getDesignType().equals("Collection")){
String path = minioUtil.getPresignedUrl(designSingleItem.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String path = minioUtil.getPreSignedUrl(designSingleItem.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
try { try {
String md5 = MD5Utils.encryptFile(path, false); String md5 = MD5Utils.encryptFile(path, false);
// 先判断是否需要被加入到library // 先判断是否需要被加入到library
@@ -814,7 +827,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 添加print到library // 添加print到library
designSingleItem.getPrintObject().getPrints().forEach(print -> { designSingleItem.getPrintObject().getPrints().forEach(print -> {
if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Collection")){ if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Collection")){
String path = minioUtil.getPresignedUrl(print.getMinIOPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String path = minioUtil.getPreSignedUrl(print.getMinIOPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
try { try {
String md5 = MD5Utils.encryptFile(path, false); String md5 = MD5Utils.encryptFile(path, false);
// 先判断是否已被加入到library // 先判断是否已被加入到library

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.exceptions.ExceptionUtil;
import com.ai.da.common.config.FileProperties; import com.ai.da.common.config.FileProperties;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.*; import com.ai.da.common.enums.*;
import com.ai.da.common.utils.*; import com.ai.da.common.utils.*;
@@ -382,9 +383,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String url = byId.getUrl(); String url = byId.getUrl();
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
}else { }else {
vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
} }
result.add(vo); result.add(vo);
}else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) { }else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) {
@@ -393,9 +394,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String url = generateDetail.getUrl(); String url = generateDetail.getUrl();
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
}else { }else {
vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
} }
result.add(vo); result.add(vo);
} }
@@ -411,9 +412,9 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String url = byId.getUrl(); String url = byId.getUrl();
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(split[0] + "-show." + split[1], 24 * 60)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60));
}else { }else {
vo.setUrlWithWhiteSide(minioUtil.getPresignedUrl(url + "-show", 24 * 60)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60));
} }
result.add(vo); result.add(vo);
} }
@@ -597,7 +598,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String designUrl = designPythonOutfit.getDesignUrl(); String designUrl = designPythonOutfit.getDesignUrl();
if (!StringUtils.isEmpty(designUrl) && designUrl.contains("/")) { if (!StringUtils.isEmpty(designUrl) && designUrl.contains("/")) {
int firstIndex = designUrl.indexOf("/"); int firstIndex = designUrl.indexOf("/");
designCollectionItemVO.setDesignOutfitUrl(minioUtil.getPresignedUrl(designUrl.substring(0, firstIndex) + "/" + designUrl.substring(firstIndex + 1), 24 * 60)); designCollectionItemVO.setDesignOutfitUrl(minioUtil.getPreSignedUrl(designUrl.substring(0, firstIndex) + "/" + designUrl.substring(firstIndex + 1), 24 * 60));
} }
//response //response
designCollectionItems.add(designCollectionItemVO); designCollectionItems.add(designCollectionItemVO);
@@ -623,10 +624,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
DesignPythonItemPrint printObject = detail.getPrint(); if (!detail.getType().equals("Body")){
designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
}
designItemDetailService.save(designItemDetail); designItemDetailService.save(designItemDetail);
if (!SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType()) && designItemDetail.getPrintPath() != null) { if (!SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType()) && !StringUtil.isNullOrEmpty(designItemDetail.getPrintPath())) {
DesignItemDetailPrint print = new DesignItemDetailPrint(); DesignItemDetailPrint print = new DesignItemDetailPrint();
print.setDesignItemDetailId(designItemDetail.getId()); print.setDesignItemDetailId(designItemDetail.getId());
print.setPrintType("print"); print.setPrintType("print");
@@ -686,7 +690,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setBusinessId(0L); designItemDetail.setBusinessId(0L);
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
DesignPythonItemPrint printObject = detail.getPrint(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetails.add(designItemDetail); designItemDetails.add(designItemDetail);
}); });
@@ -997,10 +1001,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
.collect(Collectors.toList()); .collect(Collectors.toList());
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> { response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
d.setId(o.getId()); d.setId(o.getId());
d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60, true)); d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60, true));
d.setMinIOPath(o.getPath()); d.setMinIOPath(o.getPath());
d.setLevel1Type(converTypeToLevel1(o.getType())); d.setLevel1Type(converTypeToLevel1(o.getType()));
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class)); d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));
if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())) d.setUndividedLayer(minioUtil.getPreSignedUrl(o.getUndividedLayer(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
// 根据designItemDetailId获取印花 // 根据designItemDetailId获取印花
List<DesignItemDetailPrint> prints = designItemDetailPrintService.getByDesignItemDetailId(o.getId(), "print"); List<DesignItemDetailPrint> prints = designItemDetailPrintService.getByDesignItemDetailId(o.getId(), "print");
// 判断有无印花 // 判断有无印花
@@ -1025,12 +1030,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// todo 不确定businessId的作用暂时取消传递,查看影响 // todo 不确定businessId的作用暂时取消传递,查看影响
// d.setId(o.getBusinessId()); // d.setId(o.getBusinessId());
d.setId(0L); d.setId(0L);
d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60)); d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60));
d.setMinIOPath(o.getPath()); d.setMinIOPath(o.getPath());
d.setPrintObject(new DesignPythonItemPrint()); d.setPrintObject(new DesignPythonItemPrint());
})); }));
return editDesignItemLayer(flag, designPythonOutfit, return editDesignItemLayer(flag, designPythonOutfit,
minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60), minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60),
editResponseColor(designItemDetails, response)); editResponseColor(designItemDetails, response));
} }
@@ -1169,7 +1174,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
}); });
// 2、将查询出的图层信息填充到designItemDetailVO中 // 2、将查询出的图层信息填充到designItemDetailVO中
designItemDetailVO.setDesignItemUrl(minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60)); designItemDetailVO.setDesignItemUrl(minioUtil.getPreSignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60));
// 2.1 填充clothes // 2.1 填充clothes
designItemDetailVO.getClothes().forEach(c -> { designItemDetailVO.getClothes().forEach(c -> {
// String type = c.getType().toLowerCase(); // String type = c.getType().toLowerCase();
@@ -1204,29 +1209,31 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (designItemDetailPrints.size() == 1) { if (designItemDetailPrints.size() == 1) {
DesignItemDetailPrint detailPrint = designItemDetailPrints.get(0); DesignItemDetailPrint detailPrint = designItemDetailPrints.get(0);
DesignSinglePrint designSinglePrint = new DesignSinglePrint(); DesignSinglePrint designSinglePrint = new DesignSinglePrint();
designSinglePrintDTO.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE); // designSinglePrintDTO.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE);
designSinglePrint.setLevel2Type(detailPrint.getLevel2Type()); designSinglePrint.setLevel2Type(detailPrint.getLevel2Type());
designSinglePrint.setLocation(JSONArray.parseArray(detailPrint.getPosition(), Double.class)); designSinglePrint.setLocation(JSONArray.parseArray(detailPrint.getPosition(), Double.class));
designSinglePrint.setAngle(detailPrint.getAngle()); designSinglePrint.setAngle(detailPrint.getAngle());
designSinglePrint.setPriority(detailPrint.getPriority()); designSinglePrint.setPriority(detailPrint.getPriority());
designSinglePrint.setPath(minioUtil.getPresignedUrl(detailPrint.getPath(), 24 * 60)); designSinglePrint.setPath(minioUtil.getPreSignedUrl(detailPrint.getPath(), 24 * 60));
designSinglePrint.setMinIOPath(detailPrint.getPath()); designSinglePrint.setMinIOPath(detailPrint.getPath());
designSinglePrint.setScale(detailPrint.getScale()); designSinglePrint.setScale(detailPrint.getScale());
designSinglePrint.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE);
prints.add(designSinglePrint); prints.add(designSinglePrint);
} else { } else {
// single模式下多个印花 // single模式下多个印花
designSinglePrintDTO.setIfSingle(Boolean.TRUE); // designSinglePrintDTO.setIfSingle(Boolean.TRUE);
designItemDetailPrints.forEach(print -> { designItemDetailPrints.forEach(print -> {
if (print.getSingleOrOverall().equals("single")) { // if (print.getSingleOrOverall().equals("single")) {
prints.add(new DesignSinglePrint( prints.add(new DesignSinglePrint(
print.getLevel2Type(), print.getLevel2Type(),
minioUtil.getPresignedUrl(print.getPath(), 24 * 60), minioUtil.getPreSignedUrl(print.getPath(), 24 * 60),
print.getPath(), print.getPath(),
JSONArray.parseArray(print.getPosition(), Double.class), JSONArray.parseArray(print.getPosition(), Double.class),
print.getScale(), print.getScale(),
print.getAngle(), print.getAngle(),
print.getPriority())); print.getPriority(),
} print.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE));
// }
}); });
} }
designSinglePrintDTO.setPrints(prints); designSinglePrintDTO.setPrints(prints);
@@ -1250,13 +1257,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList()); List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList());
if (!CollectionUtil.isEmpty(modelFromLibIds)){ if (!CollectionUtil.isEmpty(modelFromLibIds)){
models.addAll(libraryService.getByIds(modelFromLibIds).stream() models.addAll(libraryService.getByIds(modelFromLibIds).stream()
.map(d -> minioUtil.getPresignedUrl(d.getUrl(), 24 * 60)) .map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList()); List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList());
if (!CollectionUtil.isEmpty(modelFromSysIds)){ if (!CollectionUtil.isEmpty(modelFromSysIds)){
models.addAll(sysFileService.getByIds(modelFromSysIds).stream() models.addAll(sysFileService.getByIds(modelFromSysIds).stream()
.map(d -> minioUtil.getPresignedUrl(d.getUrl(), 24 * 60)) .map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }

View File

@@ -213,7 +213,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
} }
} }
// Generate generate = selectByUniqueId(taskId); // Generate generate = selectByUniqueId(taskId);
String md5 = MD5Utils.encryptFile(minioUtil.getPresignedUrl(url, 24 * 60), Boolean.FALSE); String md5 = MD5Utils.encryptFile(minioUtil.getPreSignedUrl(url, 24 * 60), Boolean.FALSE);
// 通过MD5值和level1Type,判断不同level1Type下相同的图片是否被like过 // 通过MD5值和level1Type,判断不同level1Type下相同的图片是否被like过
List<Map<String, Long>> libraryIdList = generateDetailMapper.getLibraryIdThroughMD5(md5, generate.getLevel1Type()); List<Map<String, Long>> libraryIdList = generateDetailMapper.getLibraryIdThroughMD5(md5, generate.getLevel1Type());
if (!libraryIdList.isEmpty()) { if (!libraryIdList.isEmpty()) {
@@ -543,7 +543,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
collectionElement.setName(name); collectionElement.setName(name);
collectionElement.setUrl(path); collectionElement.setUrl(path);
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setMd5(MD5Utils.encryptFile(minioUtil.getPresignedUrl(path, 24 * 60), Boolean.FALSE)); collectionElement.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(path, 24 * 60), Boolean.FALSE));
collectionElement.setCreateDate(DateUtil.getByTimeZone(generateThroughImageTextDTO.getTimeZone())); collectionElement.setCreateDate(DateUtil.getByTimeZone(generateThroughImageTextDTO.getTimeZone()));
collectionElementService.save(collectionElement); collectionElementService.save(collectionElement);
@@ -633,7 +633,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) { if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) {
generateResultVO.setStatus("Invalid"); generateResultVO.setStatus("Invalid");
} else { } else {
generateResultVO.setUrl(minioUtil.getPresignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); generateResultVO.setUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
} else if (Objects.isNull(generateResultVO)) { } else if (Objects.isNull(generateResultVO)) {
generateResultVO = new GenerateResultVO(); generateResultVO = new GenerateResultVO();

View File

@@ -8,10 +8,7 @@ import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.*; import com.ai.da.common.enums.*;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.ResultEnum; import com.ai.da.common.response.ResultEnum;
import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.*;
import com.ai.da.common.utils.DateUtil;
import com.ai.da.common.utils.FileUtil;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.*; import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
@@ -209,7 +206,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library, QueryLibraryPageVO.class); QueryLibraryPageVO libraryPageVO = CopyUtil.copyObject(library, QueryLibraryPageVO.class);
libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName()); libraryPageVO.setDesignType(DesignTypeEnum.LIBRARY.getRealName());
libraryPageVO.setMinIOPath(library.getUrl()); libraryPageVO.setMinIOPath(library.getUrl());
libraryPageVO.setUrl(minioUtil.getPresignedUrl(library.getUrl(), 24 * 60)); libraryPageVO.setUrl(minioUtil.getPreSignedUrl(library.getUrl(), 24 * 60));
if (finalMap != null && finalMap.containsKey(library.getId())) { if (finalMap != null && finalMap.containsKey(library.getId())) {
libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId())); libraryPageVO.setLibraryModelPoint(finalMap.get(library.getId()));
} }
@@ -273,7 +270,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath); Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class); LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl()); libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 24 * 60)); libraryUpdateVo.setUrl(minioUtil.getPreSignedUrl(newFilePath, 24 * 60));
libraryUpdateVo.setCheckMd5(Boolean.TRUE); libraryUpdateVo.setCheckMd5(Boolean.TRUE);
return libraryUpdateVo; return libraryUpdateVo;
} else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) { } else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
@@ -285,7 +282,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath); Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class); LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl()); libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 24 * 60)); libraryUpdateVo.setUrl(minioUtil.getPreSignedUrl(newFilePath, 24 * 60));
libraryUpdateVo.setCheckMd5(Boolean.TRUE); libraryUpdateVo.setCheckMd5(Boolean.TRUE);
return libraryUpdateVo; return libraryUpdateVo;
} else { } else {
@@ -300,7 +297,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
Library library = resolveData(libraryUploadDTO, userInfo, filePath); Library library = resolveData(libraryUploadDTO, userInfo, filePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class); LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl()); libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(libraryUpdateVo.getUrl(), 24 * 60)); libraryUpdateVo.setUrl(minioUtil.getPreSignedUrl(libraryUpdateVo.getUrl(), 24 * 60));
libraryUpdateVo.setCheckMd5(Boolean.TRUE); libraryUpdateVo.setCheckMd5(Boolean.TRUE);
return libraryUpdateVo; return libraryUpdateVo;
} }

View File

@@ -3,7 +3,6 @@ package com.ai.da.service.impl;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response;
import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.MinioUtil; import com.ai.da.common.utils.MinioUtil;
import com.ai.da.common.utils.RedisUtil; import com.ai.da.common.utils.RedisUtil;
@@ -35,7 +34,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
@Service @Service
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService { public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
@@ -438,7 +436,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (portfolio != null) { if (portfolio != null) {
PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class); PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class);
Canvas canvas = canvasMapper.selectById(vo.getCanvasId()); Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
vo.setCanvasUrl(minioUtil.getPresignedUrl(canvas.getUrl(), 24 * 60)); vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
vo.setLikeNum(redisUtil.getLikeCount(vo.getId())); vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
vo.setViewNums(redisUtil.getViewCount(vo.getId())); vo.setViewNums(redisUtil.getViewCount(vo.getId()));
Long accountId = vo.getAccountId(); Long accountId = vo.getAccountId();
@@ -465,19 +463,19 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (StringUtils.isEmpty(element.getUrl())) { if (StringUtils.isEmpty(element.getUrl())) {
continue; continue;
} }
element.setUrl(minioUtil.getPresignedUrl(element.getUrl(), 24 * 60)); element.setUrl(minioUtil.getPreSignedUrl(element.getUrl(), 24 * 60));
} }
vo.setCollectionElementList(collectionElementList); vo.setCollectionElementList(collectionElementList);
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>(); QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId()); qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId());
List<TDesignPythonOutfit> designPythonOutfitList = designPythonOutfitMapper.selectList(qw); List<TDesignPythonOutfit> designPythonOutfitList = designPythonOutfitMapper.selectList(qw);
for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) { for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) {
tDesignPythonOutfit.setDesignUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); tDesignPythonOutfit.setDesignUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
} }
vo.setDesignPythonOutfitList(designPythonOutfitList); vo.setDesignPythonOutfitList(designPythonOutfitList);
} }
Canvas canvas = canvasMapper.selectById(vo.getCanvasId()); Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
vo.setCanvasUrl(minioUtil.getPresignedUrl(canvas.getUrl(), 24 * 60)); vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
vo.setLikeNum(redisUtil.getLikeCount(vo.getId())); vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
if (userHolder == null) { if (userHolder == null) {
vo.setIsLike(0); vo.setIsLike(0);

View File

@@ -33,7 +33,7 @@ import static com.ai.da.common.enums.LayersPriorityEnum.BODY;
public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPythonOutfitDetailMapper, TDesignPythonOutfitDetail> implements ITDesignPythonOutfitDetailService { public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPythonOutfitDetailMapper, TDesignPythonOutfitDetail> implements ITDesignPythonOutfitDetailService {
@Resource @Resource
private MinioUtil minIoUtil; private MinioUtil minioUtil;
@Override @Override
public IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail) { public IPage<TDesignPythonOutfitDetailVO> selectTDesignPythonOutfitDetailPage(IPage<TDesignPythonOutfitDetailVO> page, TDesignPythonOutfitDetailVO tDesignPythonOutfitDetail) {
@@ -57,9 +57,9 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail, DesignPythonOutfitVO.class); DesignPythonOutfitVO designPythonOutfitVO = CopyUtil.copyObject(detail, DesignPythonOutfitVO.class);
designPythonOutfitVO.setPosition(StringUtil.isNullOrEmpty(detail.getPosition()) ? null : (List<Long>) JSON.parse(detail.getPosition())); designPythonOutfitVO.setPosition(StringUtil.isNullOrEmpty(detail.getPosition()) ? null : (List<Long>) JSON.parse(detail.getPosition()));
designPythonOutfitVO.setImageSize(StringUtil.isNullOrEmpty(detail.getImageSize()) ? null : (List<Long>) JSON.parse(detail.getImageSize())); designPythonOutfitVO.setImageSize(StringUtil.isNullOrEmpty(detail.getImageSize()) ? null : (List<Long>) JSON.parse(detail.getImageSize()));
designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minIoUtil.getPresignedUrl(detail.getImageUrl(), 24 * 60)); designPythonOutfitVO.setImageUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : minioUtil.getPreSignedUrl(detail.getImageUrl(), 24 * 60));
designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl()); designPythonOutfitVO.setImageMinioUrl(StringUtil.isNullOrEmpty(detail.getImageUrl()) ? null : detail.getImageUrl());
designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minIoUtil.getPresignedUrl(detail.getMaskUrl(), 24 * 60)); designPythonOutfitVO.setMaskUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : minioUtil.getPreSignedUrl(detail.getMaskUrl(), 24 * 60));
designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl()); designPythonOutfitVO.setMaskMinioUrl(StringUtil.isNullOrEmpty(detail.getMaskUrl()) ? null : detail.getMaskUrl());
// designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale())); // designPythonOutfitVO.setScale(Float.parseFloat(detail.getScale()));
designPythonOutfitVO.setScale(modifyScale(detail.getScale())); designPythonOutfitVO.setScale(modifyScale(detail.getScale()));

View File

@@ -62,8 +62,8 @@ public class TaskListServiceImpl extends ServiceImpl<TaskListMapper, TaskList> i
taskDTOS.add(new TaskDTO<>()); taskDTOS.add(new TaskDTO<>());
} else { } else {
SuperResolutionDTO inputParam = taskDTO.getInputParam(); SuperResolutionDTO inputParam = taskDTO.getInputParam();
inputParam.setImages(minioUtil.getPresignedUrl(inputParam.getImages(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); inputParam.setImages(minioUtil.getPreSignedUrl(inputParam.getImages(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
taskDTO.setOutputImage(StringUtil.isNullOrEmpty(taskDTO.getOutputImage()) ? null : minioUtil.getPresignedUrl(taskDTO.getOutputImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); taskDTO.setOutputImage(StringUtil.isNullOrEmpty(taskDTO.getOutputImage()) ? null : minioUtil.getPreSignedUrl(taskDTO.getOutputImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
taskDTOS.add(taskDTO); taskDTOS.add(taskDTO);
} }
}); });
@@ -105,8 +105,8 @@ public class TaskListServiceImpl extends ServiceImpl<TaskListMapper, TaskList> i
// 成功失败的都返回 // 成功失败的都返回
TaskVO task = new TaskVO(); TaskVO task = new TaskVO();
task.setImageName(s.getInputUrl().substring(s.getInputUrl().lastIndexOf("/") + 1)); task.setImageName(s.getInputUrl().substring(s.getInputUrl().lastIndexOf("/") + 1));
task.setInputImage(minioUtil.getPresignedUrl(s.getInputUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); task.setInputImage(minioUtil.getPreSignedUrl(s.getInputUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
task.setOutputImage(StringUtil.isNullOrEmpty(s.getOutputUrl()) ? null : minioUtil.getPresignedUrl(s.getOutputUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); task.setOutputImage(StringUtil.isNullOrEmpty(s.getOutputUrl()) ? null : minioUtil.getPreSignedUrl(s.getOutputUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
task.setStatus(s.getStatus()); task.setStatus(s.getStatus());
task.setTaskId(s.getTaskId()); task.setTaskId(s.getTaskId());
task.setCreateDate(s.getCreateTime().format(dateTimeFormatter)); task.setCreateDate(s.getCreateTime().format(dateTimeFormatter));

View File

@@ -5,10 +5,7 @@ import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.constant.CommonConstant; import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext; import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CreditsEventsEnum; import com.ai.da.common.enums.CreditsEventsEnum;
import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.*;
import com.ai.da.common.utils.DateUtil;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.common.utils.RedisUtil;
import com.ai.da.mapper.primary.*; import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.ProductImageLikeDTO; import com.ai.da.model.dto.ProductImageLikeDTO;
@@ -143,7 +140,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
int index = o.getUrl().lastIndexOf("/"); int index = o.getUrl().lastIndexOf("/");
o.setPictureName(o.getUrl().substring(index + 1)); o.setPictureName(o.getUrl().substring(index + 1));
} }
o.setDesignOutfitUrl(minioUtil.getPresignedUrl(o.getUrl(), 24 * 60)); o.setDesignOutfitUrl(minioUtil.getPreSignedUrl(o.getUrl(), 24 * 60));
QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>(); QueryWrapper<TDesignPythonOutfit> qw = new QueryWrapper<>();
qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId()); qw.lambda().eq(TDesignPythonOutfit::getDesignItemId, o.getDesignItemId());
List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw); List<TDesignPythonOutfit> tDesignPythonOutfits = designPythonOutfitMapper.selectList(qw);
@@ -322,7 +319,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductElement.setCreateTime(LocalDateTime.now()); toProductElement.setCreateTime(LocalDateTime.now());
toProductElementMapper.insert(toProductElement); toProductElementMapper.insert(toProductElement);
ToProductElementVO toProductElementVO = CopyUtil.copyObject(toProductElement, ToProductElementVO.class); ToProductElementVO toProductElementVO = CopyUtil.copyObject(toProductElement, ToProductElementVO.class);
toProductElementVO.setUrl(minioUtil.getPresignedUrl(toProductElementVO.getUrl(), 24 * 60)); toProductElementVO.setUrl(minioUtil.getPreSignedUrl(toProductElementVO.getUrl(), 24 * 60));
return toProductElementVO; return toProductElementVO;
} }
@@ -354,7 +351,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) { if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) {
magicToolResultVO.setStatus("Invalid"); magicToolResultVO.setStatus("Invalid");
} else { } else {
magicToolResultVO.setUrl(minioUtil.getPresignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>(); QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
qw.lambda().eq(ToProductImageResult::getTaskId, taskId); qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw); ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
@@ -366,10 +363,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
magicToolResultVO.setElementType(toProductImageResult.getElementType()); magicToolResultVO.setElementType(toProductImageResult.getElementType());
if (toProductImageResult.getElementType().equals("ProductElement")) { if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductElement.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else { }else {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId()); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
} }
} }
} else if (Objects.isNull(magicToolResultVO)) { } else if (Objects.isNull(magicToolResultVO)) {
@@ -397,7 +394,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
String type = jsonObject1.getString("type"); String type = jsonObject1.getString("type");
if (type.equals("image")) { if (type.equals("image")) {
String minioUrl = jsonObject1.getString("minioUrl"); String minioUrl = jsonObject1.getString("minioUrl");
jsonObject1.put("src", minioUtil.getPresignedUrl(minioUrl, 24 * 60)); jsonObject1.put("src", minioUtil.getPreSignedUrl(minioUrl, 24 * 60));
} }
objects.set(i, jsonObject1); objects.set(i, jsonObject1);
} }
@@ -418,7 +415,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
CanvasElementUpload canvasElementUpload = new CanvasElementUpload(); CanvasElementUpload canvasElementUpload = new CanvasElementUpload();
String url = minioUtil.upload("aida-users", userHolder.getId() + "/canvasElementUpload", file); String url = minioUtil.upload("aida-users", userHolder.getId() + "/canvasElementUpload", file);
canvasElementUpload.setUrl(url); canvasElementUpload.setUrl(url);
canvasElementUpload.setMinioUrl(minioUtil.getPresignedUrl(url, 24 * 60)); canvasElementUpload.setMinioUrl(minioUtil.getPreSignedUrl(url, 24 * 60));
return canvasElementUpload; return canvasElementUpload;
} }
@@ -429,19 +426,19 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
qw.lambda().eq(ToProductImageResult::getUserLikeGroupId, toProductImageDTO.getUserLikeGroupId()); qw.lambda().eq(ToProductImageResult::getUserLikeGroupId, toProductImageDTO.getUserLikeGroupId());
List<ToProductImageResult> toProductImageResults = toProductImageResultMapper.selectList(qw); List<ToProductImageResult> toProductImageResults = toProductImageResultMapper.selectList(qw);
for (ToProductImageResult toProductImageResult : toProductImageResults) { for (ToProductImageResult toProductImageResult : toProductImageResults) {
toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60)); toProductImageResult.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), 24 * 60));
} }
List<ToProductImageResultVO> toProductImageResultVOS = CopyUtil.copyList(toProductImageResults, ToProductImageResultVO.class); List<ToProductImageResultVO> toProductImageResultVOS = CopyUtil.copyList(toProductImageResults, ToProductImageResultVO.class);
for (ToProductImageResultVO toProductImageResultVO : toProductImageResultVOS) { for (ToProductImageResultVO toProductImageResultVO : toProductImageResultVOS) {
if (toProductImageResultVO.getElementType().equals("ProductElement")) { if (toProductImageResultVO.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductElement.getUrl(), 24 * 60)); toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) { }else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId()); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
}else { }else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId()); ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductImageResult1.getUrl(), 24 * 60)); toProductImageResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
} }
} }
return toProductImageResultVOS; return toProductImageResultVOS;
@@ -552,7 +549,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) { if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) {
magicToolResultVO.setStatus("Invalid"); magicToolResultVO.setStatus("Invalid");
} else { } else {
magicToolResultVO.setUrl(minioUtil.getPresignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>(); QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
qw.lambda().eq(ToProductImageResult::getTaskId, taskId); qw.lambda().eq(ToProductImageResult::getTaskId, taskId);
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw); ToProductImageResult toProductImageResult = toProductImageResultMapper.selectOne(qw);
@@ -564,10 +561,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
magicToolResultVO.setElementType(toProductImageResult.getElementType()); magicToolResultVO.setElementType(toProductImageResult.getElementType());
if (toProductImageResult.getElementType().equals("ProductElement")) { if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductElement.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else { }else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId()); ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductImageResult1.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
} }
} }
} else if (Objects.isNull(magicToolResultVO)) { } else if (Objects.isNull(magicToolResultVO)) {

View File

@@ -5,10 +5,7 @@ import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.LibraryLevel1TypeEnum; import com.ai.da.common.enums.LibraryLevel1TypeEnum;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.ResultEnum; import com.ai.da.common.response.ResultEnum;
import com.ai.da.common.utils.CopyUtil; import com.ai.da.common.utils.*;
import com.ai.da.common.utils.FileUtil;
import com.ai.da.common.utils.MD5Utils;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.*; import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.WorkspaceDTO; import com.ai.da.model.dto.WorkspaceDTO;
@@ -31,7 +28,6 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.naming.Context;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
@@ -207,16 +203,16 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class); WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class);
if (o.getMannequinFemaleId() != null) { if (o.getMannequinFemaleId() != null) {
if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) { if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60)); workspaceVO.setFemalePresignedUrl(minioUtil.getPreSignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
} else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) { } else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60)); workspaceVO.setFemalePresignedUrl(minioUtil.getPreSignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
} }
} }
if (o.getMannequinMaleId() != null) { if (o.getMannequinMaleId() != null) {
if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) { if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60)); workspaceVO.setMalePresignedUrl(minioUtil.getPreSignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
} else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) { } else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60)); workspaceVO.setMalePresignedUrl(minioUtil.getPreSignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
} }
} }
Sex sex = Sex.getSex(workspaceVO.getSex()); Sex sex = Sex.getSex(workspaceVO.getSex());
@@ -235,16 +231,16 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class); WorkspaceVO workspaceVO = CopyUtil.copyObject(o, WorkspaceVO.class);
if (o.getMannequinFemaleId() != null) { if (o.getMannequinFemaleId() != null) {
if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) { if (o.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60)); workspaceVO.setFemalePresignedUrl(minioUtil.getPreSignedUrl(sysFileMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
} else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) { } else if (o.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60)); workspaceVO.setFemalePresignedUrl(minioUtil.getPreSignedUrl(libraryMapper.selectById(o.getMannequinFemaleId()).getUrl(), 24 * 60));
} }
} }
if (o.getMannequinMaleId() != null) { if (o.getMannequinMaleId() != null) {
if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) { if (o.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60)); workspaceVO.setMalePresignedUrl(minioUtil.getPreSignedUrl(sysFileMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
} else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) { } else if (o.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
workspaceVO.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60)); workspaceVO.setMalePresignedUrl(minioUtil.getPreSignedUrl(libraryMapper.selectById(o.getMannequinMaleId()).getUrl(), 24 * 60));
} }
} }
Sex sex = Sex.getSex(workspaceVO.getSex()); Sex sex = Sex.getSex(workspaceVO.getSex());
@@ -295,16 +291,16 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
WorkspaceVO vo = CopyUtil.copyObject(newIsLastIndex, WorkspaceVO.class); WorkspaceVO vo = CopyUtil.copyObject(newIsLastIndex, WorkspaceVO.class);
if (vo.getMannequinFemaleId() != null) { if (vo.getMannequinFemaleId() != null) {
if (vo.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) { if (vo.getMannequinFemaleType().equals(ModelType.SYSTEM.getValue())) {
vo.setFemalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(vo.getMannequinFemaleId()).getUrl(), 24 * 60)); vo.setFemalePresignedUrl(minioUtil.getPreSignedUrl(sysFileMapper.selectById(vo.getMannequinFemaleId()).getUrl(), 24 * 60));
} else if (vo.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) { } else if (vo.getMannequinFemaleType().equals(ModelType.LIBRARY.getValue())) {
vo.setFemalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(vo.getMannequinFemaleId()).getUrl(), 24 * 60)); vo.setFemalePresignedUrl(minioUtil.getPreSignedUrl(libraryMapper.selectById(vo.getMannequinFemaleId()).getUrl(), 24 * 60));
} }
} }
if (vo.getMannequinMaleId() != null) { if (vo.getMannequinMaleId() != null) {
if (vo.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) { if (vo.getMannequinMaleType().equals(ModelType.SYSTEM.getValue())) {
vo.setMalePresignedUrl(minioUtil.getPresignedUrl(sysFileMapper.selectById(vo.getMannequinMaleId()).getUrl(), 24 * 60)); vo.setMalePresignedUrl(minioUtil.getPreSignedUrl(sysFileMapper.selectById(vo.getMannequinMaleId()).getUrl(), 24 * 60));
} else if (vo.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) { } else if (vo.getMannequinMaleType().equals(ModelType.LIBRARY.getValue())) {
vo.setMalePresignedUrl(minioUtil.getPresignedUrl(libraryMapper.selectById(vo.getMannequinMaleId()).getUrl(), 24 * 60)); vo.setMalePresignedUrl(minioUtil.getPreSignedUrl(libraryMapper.selectById(vo.getMannequinMaleId()).getUrl(), 24 * 60));
} }
} }
Sex sex = Sex.getSex(vo.getSex()); Sex sex = Sex.getSex(vo.getSex());
@@ -346,7 +342,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
ModelVO modelVO = new ModelVO(); ModelVO modelVO = new ModelVO();
modelVO.setId(library.getId()); modelVO.setId(library.getId());
modelVO.setUrl(library.getUrl()); modelVO.setUrl(library.getUrl());
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(library.getUrl(), 24 * 60)); modelVO.setPresignedUrl(minioUtil.getPreSignedUrl(library.getUrl(), 24 * 60));
modelVOList.add(modelVO); modelVOList.add(modelVO);
} }
ModelsVO vo = new ModelsVO(); ModelsVO vo = new ModelsVO();
@@ -371,7 +367,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
ModelVO modelVO = new ModelVO(); ModelVO modelVO = new ModelVO();
modelVO.setId(sysFile.getId()); modelVO.setId(sysFile.getId());
modelVO.setUrl(sysFile.getUrl()); modelVO.setUrl(sysFile.getUrl());
modelVO.setPresignedUrl(minioUtil.getPresignedUrl(sysFile.getUrl(), 24 * 60)); modelVO.setPresignedUrl(minioUtil.getPreSignedUrl(sysFile.getUrl(), 24 * 60));
modelVOList.add(modelVO); modelVOList.add(modelVO);
} }
ModelsVO vo = new ModelsVO(); ModelsVO vo = new ModelsVO();