From 9bae02406c92214e34f524e9ea748f2edb9ede57 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 19 Feb 2024 11:03:28 +0800 Subject: [PATCH 01/21] =?UTF-8?q?TASK:dev=E5=88=86=E6=94=AF=E8=B0=83?= =?UTF-8?q?=E7=94=A8python=E7=AB=AF=E7=AB=AF=E5=8F=A3=E4=BF=AE=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-dev.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index d940a1a3..1687258d 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -43,7 +43,7 @@ spring.servlet.multipart.max-request-size= 10MB #access.python.ip=http://43.198.80.117 access.python.ip=http://18.167.251.121 #access.python.ip=http://18.167.251.121:9991/ -access.python.port=9990 +access.python.port=9992 minio.endpoint=https://www.minio.aida.com.hk:9000 minio.accessKey=admin From b86f168fe8bdfab92de6981f4ca5ece9db9badcd Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 10 May 2024 17:17:28 +0800 Subject: [PATCH 02/21] =?UTF-8?q?TASK:design=20=E6=B8=90=E5=8F=98=E8=89=B2?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/common/RabbitMQ/GenerateConsumer.java | 118 +++++++++--------- .../com/ai/da/common/RabbitMQ/SRConsumer.java | 24 ++-- .../ai/da/common/config/MyTaskScheduler.java | 5 + .../com/ai/da/common/task/PaypalTask.java | 2 +- .../com/ai/da/common/utils/MinioUtil.java | 21 ++++ .../com/ai/da/common/utils/SendEmailUtil.java | 34 +++++ .../primary/entity/CollectionElement.java | 2 + .../ai/da/mapper/primary/entity/Gradient.java | 14 +++ .../mapper/primary/entity/GradientItem.java | 9 ++ .../com/ai/da/mapper/primary/entity/RGBA.java | 11 ++ .../ai/da/model/dto/CollectionColorDTO.java | 7 ++ .../ai/da/model/dto/CollectionSketchDTO.java | 1 + .../ai/da/model/dto/DesignSingleItemDTO.java | 2 +- .../java/com/ai/da/python/PythonService.java | 18 ++- .../com/ai/da/python/vo/DesignPythonItem.java | 6 +- .../impl/CollectionElementServiceImpl.java | 18 ++- src/main/resources/application-dev.properties | 1 + 17 files changed, 210 insertions(+), 83 deletions(-) create mode 100644 src/main/java/com/ai/da/mapper/primary/entity/Gradient.java create mode 100644 src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java create mode 100644 src/main/java/com/ai/da/mapper/primary/entity/RGBA.java diff --git a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java index 3e8e6a6e..876dfd2c 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java @@ -154,63 +154,63 @@ public class GenerateConsumer { } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer1(Message msg, Channel channel) { - generate(msg, channel, "consumer 1"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer2(Message msg, Channel channel) { - generate(msg, channel, "consumer 2"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer3(Message msg, Channel channel) { - generate(msg, channel, "consumer 3"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer4(Message msg, Channel channel) { - generate(msg, channel, "consumer 4"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer5(Message msg, Channel channel) { - generate(msg, channel, "consumer 5"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer6(Message msg, Channel channel) { - generate(msg, channel, "consumer 6"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer7(Message msg, Channel channel) { - generate(msg, channel, "consumer 7"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer8(Message msg, Channel channel) { - generate(msg, channel, "consumer 8"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer9(Message msg, Channel channel) { - generate(msg, channel, "consumer 9"); - } - - @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) - @RabbitHandler - public void getGenerateResult(Message msg, Channel channel) { - processGenerateResult(msg, channel); - } +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer1(Message msg, Channel channel) { +// generate(msg, channel, "consumer 1"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer2(Message msg, Channel channel) { +// generate(msg, channel, "consumer 2"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer3(Message msg, Channel channel) { +// generate(msg, channel, "consumer 3"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer4(Message msg, Channel channel) { +// generate(msg, channel, "consumer 4"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer5(Message msg, Channel channel) { +// generate(msg, channel, "consumer 5"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer6(Message msg, Channel channel) { +// generate(msg, channel, "consumer 6"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer7(Message msg, Channel channel) { +// generate(msg, channel, "consumer 7"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer8(Message msg, Channel channel) { +// generate(msg, channel, "consumer 8"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer9(Message msg, Channel channel) { +// generate(msg, channel, "consumer 9"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) +// @RabbitHandler +// public void getGenerateResult(Message msg, Channel channel) { +// processGenerateResult(msg, channel); +// } } diff --git a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java index 6ad261bd..b8ba32f2 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java @@ -218,17 +218,17 @@ public class SRConsumer { taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null); } - @RabbitListener(queues = MQConfig.SR_QUEUE) - @RabbitHandler - public void SRConsumer1(Message msg, Channel channel) { - superResolution(msg, channel, "consumer 1"); - } - - - @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) - @RabbitHandler - public void SRResultConsumer1(Message msg, Channel channel) { - getSRResult(msg, channel, "consumer 1"); - } +// @RabbitListener(queues = MQConfig.SR_QUEUE) +// @RabbitHandler +// public void SRConsumer1(Message msg, Channel channel) { +// superResolution(msg, channel, "consumer 1"); +// } +// +// +// @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) +// @RabbitHandler +// public void SRResultConsumer1(Message msg, Channel channel) { +// getSRResult(msg, channel, "consumer 1"); +// } } diff --git a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java index f505796e..6e443ba9 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -127,6 +127,11 @@ public class MyTaskScheduler { } catch (IOException e) { e.printStackTrace(); } + }else { + SendEmailUtil.sendNoExcelEmail("1023316923@qq.com", null); + SendEmailUtil.sendNoExcelEmail("calvinwong@aidlab.hk", null); + SendEmailUtil.sendNoExcelEmail("kaicpang.pang@connect.polyu.hk", null); + SendEmailUtil.sendNoExcelEmail("kimwong@code-create.com.hk", null); } } } diff --git a/src/main/java/com/ai/da/common/task/PaypalTask.java b/src/main/java/com/ai/da/common/task/PaypalTask.java index bc0e24dd..65d5b8a3 100644 --- a/src/main/java/com/ai/da/common/task/PaypalTask.java +++ b/src/main/java/com/ai/da/common/task/PaypalTask.java @@ -23,7 +23,7 @@ public class PaypalTask { @Resource private PayPalCheckoutService payPalCheckoutService; - @Scheduled(cron = "0/30 * * * * ?") +// @Scheduled(cron = "0/30 * * * * ?") public void orderConfirm() throws SerializeException { log.info("PayPal orderConfirm 被执行......"); diff --git a/src/main/java/com/ai/da/common/utils/MinioUtil.java b/src/main/java/com/ai/da/common/utils/MinioUtil.java index 352b4d79..14e9e2fb 100644 --- a/src/main/java/com/ai/da/common/utils/MinioUtil.java +++ b/src/main/java/com/ai/da/common/utils/MinioUtil.java @@ -16,6 +16,7 @@ import java.io.*; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; +import java.util.Base64; import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -126,6 +127,26 @@ public class MinioUtil { return names; } + public String uploadImageFromBase64(String bucketName, String base64Image, String imageType) { + byte[] imageBytes = Base64.getDecoder().decode(base64Image); + String fileName = UUID.randomUUID().toString() + "." + imageType; // or any other image format + + try (InputStream in = new ByteArrayInputStream(imageBytes)) { + minioClient.putObject(PutObjectArgs.builder() + .bucket(bucketName) + .object(fileName) + .stream(in, in.available(), -1) + .contentType("image/png") // Set the content type according to your image format + .build() + ); + + return bucketName + "/" + fileName; + } catch (Exception e) { + e.printStackTrace(); + return null; // or throw an exception + } + } + /** * description: 上传文件 * diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 930c2cd9..ebc40753 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -134,6 +134,7 @@ public class SendEmailUtil { private final static Long NOTIFICATION_TEMPLATE_ID = 117216L; private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L; private final static Long TRIAL_ORDER_LIST_ID = 122273L; + private final static Long NO_TRIAL_ORDER_LIST_ID = 122591L; public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) { try { // 实例化一个认证对象 @@ -227,6 +228,39 @@ public class SendEmailUtil { throw new BusinessException("failed.to.send.mail"); } } + + public static void sendNoExcelEmail(String receiverAddress, String senderAddress) { + try { + // 实例化一个认证对象 + Credential cred = new Credential(SECRET_ID, SECRET_KEy); + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("ses.tencentcloudapi.com"); + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + SesClient client = new SesClient(cred, "ap-hongkong", clientProfile); + SendEmailRequest req = new SendEmailRequest(); + if (StringUtils.isEmpty(senderAddress)) { + senderAddress = SEND_ADDRESS; + } + req.setFromEmailAddress(senderAddress); + req.setDestination(new String[]{receiverAddress}); + + // 根据邮件类型设置不同的主题和模板 + String subject = ""; + Template template = new Template(); + subject = "昨日试用订单数据"; + template.setTemplateID(NO_TRIAL_ORDER_LIST_ID); + + req.setSubject(subject); + req.setTemplate(template); + // 发送邮件 + SendEmailResponse resp = client.SendEmail(req); + log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp)); + } catch (TencentCloudSDKException e) { + log.info("邮件发送失败###{}", e.toString()); + throw new BusinessException("failed.to.send.mail"); + } + } private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L; public static void sendWillBeExpiredEmail(Account account, String senderAddress) { try { diff --git a/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java b/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java index b15b9418..fa3a6df0 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/CollectionElement.java @@ -75,6 +75,8 @@ public class CollectionElement implements Serializable { */ private String md5; + private String gradientString; + /** * 创建时间 */ diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java b/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java new file mode 100644 index 00000000..e8d40d3b --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java @@ -0,0 +1,14 @@ +package com.ai.da.mapper.primary.entity; + +import lombok.Data; + +import java.util.List; + +@Data +public class Gradient { + private List gradientList; + private int angle; + private int selectIndex; + private boolean gradientShow; + private String colorImg; +} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java b/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java new file mode 100644 index 00000000..37a8c8ca --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java @@ -0,0 +1,9 @@ +package com.ai.da.mapper.primary.entity; + +import lombok.Data; + +@Data +public class GradientItem { + private RGBA rgba; + private String left; +} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java b/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java new file mode 100644 index 00000000..9ee98a71 --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java @@ -0,0 +1,11 @@ +package com.ai.da.mapper.primary.entity; + +import lombok.Data; + +@Data +public class RGBA { + private int r; + private int g; + private int b; + private double a; +} diff --git a/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java b/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java index f569182f..9de66e9c 100644 --- a/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java +++ b/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java @@ -1,5 +1,6 @@ package com.ai.da.model.dto; +import com.ai.da.mapper.primary.entity.Gradient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -25,4 +26,10 @@ public class CollectionColorDTO { @ApiModelProperty("潘通RGB值") private String rgbValue; + private Gradient gradient; + +// private String gradientString; + + private String gradientMinioUrl; + } diff --git a/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java b/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java index 73fa47d5..68ad0914 100644 --- a/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java +++ b/src/main/java/com/ai/da/model/dto/CollectionSketchDTO.java @@ -1,5 +1,6 @@ package com.ai.da.model.dto; +import com.ai.da.mapper.primary.entity.Gradient; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java index 77b8b431..d0d2c6ab 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java @@ -49,7 +49,7 @@ public class DesignSingleItemDTO { private Integer priority; @ApiModelProperty("渐变 起始/目标 颜色") - private List> gradient; + private String gradient; @ApiModelProperty("渐变角度") private Float gradient_angle; diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 10762887..72a9d908 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -1548,7 +1548,9 @@ public class PythonService { pythonItem.setPath(sysFileVO.getUrl()); pythonItem.setBusinessId(sysFileVO.getId()); if (SysFileLevel2TypeEnum.SHOES.getRealName().equals(type)) { - pythonItem.setColor(getRandomColor(elementVO.getColorBoards())); + CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards()); + pythonItem.setColor(randomColor.getRgbValue()); + pythonItem.setGradient(randomColor.getGradientMinioUrl()); } } } @@ -1911,7 +1913,9 @@ public class PythonService { designPythonItemBlouse.setPath(path); //所有的icon都是none designPythonItemBlouse.setIcon("none"); - designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards())); + CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards()); + designPythonItemBlouse.setColor(randomColor.getRgbValue()); + designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl()); if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") && elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) { DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class); @@ -1937,7 +1941,9 @@ public class PythonService { designPythonItemBlouse.setPath(collectionElement.getUrl()); //所有的icon都是none designPythonItemBlouse.setIcon("none"); - designPythonItemBlouse.setColor(getRandomColor(elementVO.getColorBoards())); + CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards()); + designPythonItemBlouse.setColor(randomColor.getRgbValue()); + designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl()); if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") && elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) { DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class); @@ -2216,14 +2222,14 @@ public class PythonService { return sysFileVo.get(key.intValue()); } - private String getRandomColor(List colorBoards) { + private CollectionColorDTO getRandomColor(List colorBoards) { if (colorBoards.size() == 1) { - return colorBoards.get(0).getRgbValue(); + return colorBoards.get(0); } long maxColor = colorBoards.size(); long minColor = 0; Long randomIndex = RandomsUtil.randomSysFile(minColor, maxColor); - return colorBoards.get(randomIndex.intValue()).getRgbValue(); + return colorBoards.get(randomIndex.intValue()); } private CollectionElement getRandomSketchLibrary(List sketchBoardElementOlds, List hasUseMd5List) { diff --git a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java index 5e327086..b1514908 100644 --- a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java +++ b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java @@ -28,6 +28,8 @@ public class DesignPythonItem { */ private String color; + private String gradient; + /** * 对应的print图片的绝对路径 */ @@ -74,7 +76,7 @@ public class DesignPythonItem { */ private Integer priority; - private List> gradient; +// private List> gradient; private Float gradient_angle; @@ -126,7 +128,7 @@ public class DesignPythonItem { this.priority = priority; } - public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List offset, Float resize_scale,Integer priority, List> gradient, Float gradient_angle) { + public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List offset, Float resize_scale,Integer priority, String gradient, Float gradient_angle) { this.type = type; this.path = path; this.color = color; diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index fc1455ec..86c7a212 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -35,6 +35,7 @@ import org.springframework.util.StringUtils; import javax.annotation.Resource; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -76,6 +77,8 @@ public class CollectionElementServiceImpl extends ServiceImpl colorBoards = elementVO.getColorBoards(); + for (CollectionColorDTO colorBoard : colorBoards) { + String colorImg = colorBoard.getGradient().getColorImg(); + String[] parts = colorImg.split(","); + String imageType = parts[0].split("/")[1].split(";")[0]; + String base64Data = parts[1]; + String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType); + colorBoard.setGradientMinioUrl(gradientMinioUrl); + colorBoard.getGradient().setColorImg(null); + } + elementVO.setColorBoards(colorBoards); List usedElementIds = elementVO.getUsedElementIds(); List libraryCollectionElements = elementVO.getLibraryCollectionElements(); List generateCollectionElements = elementVO.getGenerateCollectionElements(); @@ -767,7 +780,8 @@ public class CollectionElementServiceImpl extends ServiceImpl Date: Fri, 10 May 2024 17:18:25 +0800 Subject: [PATCH 03/21] =?UTF-8?q?TASK:design=20=E6=B8=90=E5=8F=98=E8=89=B2?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/common/RabbitMQ/GenerateConsumer.java | 118 +++++++++--------- .../com/ai/da/common/RabbitMQ/SRConsumer.java | 24 ++-- .../com/ai/da/common/task/PaypalTask.java | 2 +- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java index 876dfd2c..3e8e6a6e 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java @@ -154,63 +154,63 @@ public class GenerateConsumer { } -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer1(Message msg, Channel channel) { -// generate(msg, channel, "consumer 1"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer2(Message msg, Channel channel) { -// generate(msg, channel, "consumer 2"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer3(Message msg, Channel channel) { -// generate(msg, channel, "consumer 3"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer4(Message msg, Channel channel) { -// generate(msg, channel, "consumer 4"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer5(Message msg, Channel channel) { -// generate(msg, channel, "consumer 5"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer6(Message msg, Channel channel) { -// generate(msg, channel, "consumer 6"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer7(Message msg, Channel channel) { -// generate(msg, channel, "consumer 7"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer8(Message msg, Channel channel) { -// generate(msg, channel, "consumer 8"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) -// @RabbitHandler -// public void generateConsumer9(Message msg, Channel channel) { -// generate(msg, channel, "consumer 9"); -// } -// -// @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) -// @RabbitHandler -// public void getGenerateResult(Message msg, Channel channel) { -// processGenerateResult(msg, channel); -// } + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer1(Message msg, Channel channel) { + generate(msg, channel, "consumer 1"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer2(Message msg, Channel channel) { + generate(msg, channel, "consumer 2"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer3(Message msg, Channel channel) { + generate(msg, channel, "consumer 3"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer4(Message msg, Channel channel) { + generate(msg, channel, "consumer 4"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer5(Message msg, Channel channel) { + generate(msg, channel, "consumer 5"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer6(Message msg, Channel channel) { + generate(msg, channel, "consumer 6"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer7(Message msg, Channel channel) { + generate(msg, channel, "consumer 7"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer8(Message msg, Channel channel) { + generate(msg, channel, "consumer 8"); + } + + @RabbitListener(queues = MQConfig.GENERATE_QUEUE) + @RabbitHandler + public void generateConsumer9(Message msg, Channel channel) { + generate(msg, channel, "consumer 9"); + } + + @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) + @RabbitHandler + public void getGenerateResult(Message msg, Channel channel) { + processGenerateResult(msg, channel); + } } diff --git a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java index b8ba32f2..6ad261bd 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java @@ -218,17 +218,17 @@ public class SRConsumer { taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null); } -// @RabbitListener(queues = MQConfig.SR_QUEUE) -// @RabbitHandler -// public void SRConsumer1(Message msg, Channel channel) { -// superResolution(msg, channel, "consumer 1"); -// } -// -// -// @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) -// @RabbitHandler -// public void SRResultConsumer1(Message msg, Channel channel) { -// getSRResult(msg, channel, "consumer 1"); -// } + @RabbitListener(queues = MQConfig.SR_QUEUE) + @RabbitHandler + public void SRConsumer1(Message msg, Channel channel) { + superResolution(msg, channel, "consumer 1"); + } + + + @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) + @RabbitHandler + public void SRResultConsumer1(Message msg, Channel channel) { + getSRResult(msg, channel, "consumer 1"); + } } diff --git a/src/main/java/com/ai/da/common/task/PaypalTask.java b/src/main/java/com/ai/da/common/task/PaypalTask.java index 65d5b8a3..bc0e24dd 100644 --- a/src/main/java/com/ai/da/common/task/PaypalTask.java +++ b/src/main/java/com/ai/da/common/task/PaypalTask.java @@ -23,7 +23,7 @@ public class PaypalTask { @Resource private PayPalCheckoutService payPalCheckoutService; -// @Scheduled(cron = "0/30 * * * * ?") + @Scheduled(cron = "0/30 * * * * ?") public void orderConfirm() throws SerializeException { log.info("PayPal orderConfirm 被执行......"); From 7b83f42ed87697f1e6d46bbfbb9687adb029c073 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 13 May 2024 14:23:08 +0800 Subject: [PATCH 04/21] =?UTF-8?q?TASK:design=20=E6=B8=90=E5=8F=98=E8=89=B2?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ai/da/mapper/primary/entity/DesignItemDetail.java | 2 ++ src/main/java/com/ai/da/model/dto/CollectionColorDTO.java | 2 +- src/main/java/com/ai/da/python/PythonService.java | 3 +++ src/main/java/com/ai/da/python/vo/DesignPythonItem.java | 2 ++ .../com/ai/da/service/impl/CollectionElementServiceImpl.java | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ai/da/mapper/primary/entity/DesignItemDetail.java b/src/main/java/com/ai/da/mapper/primary/entity/DesignItemDetail.java index 437a9264..969c306b 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/DesignItemDetail.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/DesignItemDetail.java @@ -64,6 +64,8 @@ public class DesignItemDetail implements Serializable { */ private String color; + private String gradientString; + /** * 对应的print图片的绝对路径 */ diff --git a/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java b/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java index 9de66e9c..d5581ee9 100644 --- a/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java +++ b/src/main/java/com/ai/da/model/dto/CollectionColorDTO.java @@ -28,7 +28,7 @@ public class CollectionColorDTO { private Gradient gradient; -// private String gradientString; + private String gradientString; private String gradientMinioUrl; diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 72a9d908..e29647ab 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -1551,6 +1551,7 @@ public class PythonService { CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards()); pythonItem.setColor(randomColor.getRgbValue()); pythonItem.setGradient(randomColor.getGradientMinioUrl()); + pythonItem.setGradientString(randomColor.getGradientString()); } } } @@ -1916,6 +1917,7 @@ public class PythonService { CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards()); designPythonItemBlouse.setColor(randomColor.getRgbValue()); designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl()); + designPythonItemBlouse.setGradientString(randomColor.getGradientString()); if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") && elementVO.getDesignPrintPictureTypeLayoutList().contains(type)) { DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class); @@ -1944,6 +1946,7 @@ public class PythonService { CollectionColorDTO randomColor = getRandomColor(elementVO.getColorBoards()); designPythonItemBlouse.setColor(randomColor.getRgbValue()); designPythonItemBlouse.setGradient(randomColor.getGradientMinioUrl()); + designPythonItemBlouse.setGradientString(randomColor.getGradientString()); if (!elementVO.getDesignPythonItemPrint().getPath().equals("none") && elementVO.getDesignPrintPictureTypeLayoutList().contains(collectionElement.getLevel2Type())) { DesignPythonItemPrint designPythonItemPrint = CopyUtil.copyObject(elementVO.getDesignPythonItemPrint(), DesignPythonItemPrint.class); diff --git a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java index b1514908..21d931df 100644 --- a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java +++ b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java @@ -30,6 +30,8 @@ public class DesignPythonItem { private String gradient; + private String gradientString; + /** * 对应的print图片的绝对路径 */ diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index 86c7a212..0a6bfb8c 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -360,6 +360,7 @@ public class CollectionElementServiceImpl extends ServiceImpl usedElementIds = elementVO.getUsedElementIds(); From d1fab003d21aec534a6d5ab60b43397c208e906b Mon Sep 17 00:00:00 2001 From: xupei Date: Mon, 13 May 2024 16:23:37 +0800 Subject: [PATCH 05/21] =?UTF-8?q?designSingle=20=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=B8=90=E5=8F=98=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/common/utils/MinioUtil.java | 7 +++++ .../ai/da/model/dto/DesignSingleItemDTO.java | 7 +++-- .../model/vo/DesignItemClothesDetailVO.java | 4 +++ .../java/com/ai/da/python/PythonService.java | 26 ++++++++++++++++++- .../com/ai/da/python/vo/DesignPythonItem.java | 24 +++-------------- .../service/impl/DesignItemServiceImpl.java | 18 +++++-------- .../ai/da/service/impl/DesignServiceImpl.java | 8 +----- 7 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/ai/da/common/utils/MinioUtil.java b/src/main/java/com/ai/da/common/utils/MinioUtil.java index 14e9e2fb..9341e3ea 100644 --- a/src/main/java/com/ai/da/common/utils/MinioUtil.java +++ b/src/main/java/com/ai/da/common/utils/MinioUtil.java @@ -436,6 +436,13 @@ public class MinioUtil { return false; } } + + public String base64Upload(String base64, String bucketName){ + String[] parts = base64.split(","); + String imageType = parts[0].split("/")[1].split(";")[0]; + String base64Data = parts[1]; + return uploadImageFromBase64(bucketName, base64Data, imageType); + } } diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java index d0d2c6ab..4c76d5cc 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java @@ -1,5 +1,6 @@ package com.ai.da.model.dto; +import com.ai.da.mapper.primary.entity.Gradient; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -48,9 +49,7 @@ public class DesignSingleItemDTO { @ApiModelProperty("图层优先级") private Integer priority; - @ApiModelProperty("渐变 起始/目标 颜色") - private String gradient; + @ApiModelProperty("渐变 颜色") + private Gradient gradient; - @ApiModelProperty("渐变角度") - private Float gradient_angle; } diff --git a/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java b/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java index 2b5c3667..130948d7 100644 --- a/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java +++ b/src/main/java/com/ai/da/model/vo/DesignItemClothesDetailVO.java @@ -1,5 +1,6 @@ package com.ai.da.model.vo; +import com.ai.da.mapper.primary.entity.Gradient; import com.ai.da.model.dto.DesignSinglePrintDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -51,6 +52,9 @@ public class DesignItemClothesDetailVO { @ApiModelProperty("衣服所在图层") private Integer priority; + @ApiModelProperty("渐变色信息") + private Gradient gradient; + public DesignItemClothesDetailVO() { } diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index a8c68a48..7b831e23 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -31,6 +31,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import io.netty.util.internal.StringUtil; import lombok.extern.slf4j.Slf4j; import okhttp3.*; import org.springframework.beans.factory.annotation.Value; @@ -67,10 +68,15 @@ public class PythonService { private String accessPythonPort; @Value("${access.python.sr}") private String srPythonPort; + @Value("${minio.bucketName.gradient}") + private String gradientBucketName; @Resource private PythonTAllInfoService pythonTAllInfoService; + @Resource + private MinioUtil minioUtil; + /** * 生成打印的图片 二合一 (废弃于2024/01/02) * @@ -2611,6 +2617,22 @@ public class PythonService { }else { businessId = designSingleItem.getId(); } + + // 判断是否是渐变色 + String minioPath = null; + String gradientString = null; + if (!Objects.isNull(designSingleItem.getGradient())){ + String colorImg = designSingleItem.getGradient().getColorImg(); + if (StringUtil.isNullOrEmpty(colorImg)){ + throw new BusinessException("The base64 data of the image is empty"); + } + minioPath = minioUtil.base64Upload(colorImg, gradientBucketName); + designSingleItem.getGradient().setColorImg(null); + gradientString = JSONObject.toJSONString(designSingleItem.getGradient()); + + // todo 当渐变色不为空时,是否需要将颜色置为 0 0 0 + } + response.add(new DesignPythonItem( designSingleItem.getType(), designSingleItem.getPath(), @@ -2622,7 +2644,9 @@ public class PythonService { pythonTAllInfoService.getImageIdByPath(designSingleItem.getPath()), designSingleItem.getOffset(), designSingleItem.getScale(), - designSingleItem.getPriority())); + designSingleItem.getPriority(), + minioPath, + gradientString)); }); diff --git a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java index 3d220fe4..b2416fe8 100644 --- a/src/main/java/com/ai/da/python/vo/DesignPythonItem.java +++ b/src/main/java/com/ai/da/python/vo/DesignPythonItem.java @@ -78,10 +78,6 @@ public class DesignPythonItem { */ private Integer priority; -// private List> gradient; - - private Float gradient_angle; - public static List OUTWEAR_DRESS_BLOUSE = Arrays.asList(CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.DRESS.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName()); @@ -117,7 +113,8 @@ public class DesignPythonItem { this.image_id = image_id; } - public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List offset, Float resize_scale,Integer priority) { + public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, + Long image_id, List offset, Float resize_scale, Integer priority, String gradient, String gradientString) { this.type = type; this.path = path; this.color = color; @@ -128,23 +125,10 @@ public class DesignPythonItem { this.offset = offset; this.resize_scale = resize_scale; this.priority = priority; + this.gradient = gradient; + this.gradientString = gradientString; } -// public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, Long businessId, Long image_id, List offset, Float resize_scale,Integer priority) { -// this.type = type; -// this.path = path; -// this.color = color; -// this.print = print; -//// this.icon = icon; -// this.businessId = businessId; -// this.image_id = image_id; -// this.offset = offset; -// this.resize_scale = resize_scale; -// this.priority = priority; -//// this.gradient = gradient; -//// this.gradient_angle = gradient_angle; -// } - public DesignPythonItem(String type, String path, String color, DesignPythonItemPrint print, String icon, Long businessId, Long image_id) { this.type = type; this.path = path; diff --git a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java index 613d8e71..ae26cc7e 100644 --- a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java @@ -309,7 +309,7 @@ public class DesignItemServiceImpl extends ServiceImpl saveDesignSingleItemDetailAndLayers(DesignPythonObjects pythonObjects - , Long designId, Long designItemId, AuthPrincipalVo userInfo + , Long designId, Long designItemId, Long userId , JSONObject outfit, String timeZone, List designSingleItemDTOList) { DesignItem designItem = new DesignItem(); @@ -328,7 +328,7 @@ public class DesignItemServiceImpl extends ServiceImpl> typeOffset = designSingleItemDTOList.stream() -// .collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset)); Map> priorityOffset = designSingleItemDTOList.stream() .collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset)); - List list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userInfo.getId(), priorityOffset); + List list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userId, priorityOffset); designPythonOutfitDetailService.saveBatch(list); @@ -420,7 +417,7 @@ public class DesignItemServiceImpl extends ServiceImpl " + designSingleIncludeLayersDTO.toString()); - AuthPrincipalVo userInfo = UserContext.getUserHolder(); + Long userId = UserContext.getUserHolder().getId(); DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId()); if (Objects.isNull(designItem)) { throw new BusinessException("designItem.not.found"); @@ -477,8 +474,6 @@ public class DesignItemServiceImpl extends ServiceImpl> typeOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream() -// .collect(Collectors.toMap(d -> d.getType().toLowerCase(), DesignSingleItemDTO::getOffset)); Map> priorityOffset = new HashMap<>(); try{ priorityOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream() @@ -492,12 +487,12 @@ public class DesignItemServiceImpl extends ServiceImpl detailsVO = new ArrayList<>(); @@ -644,6 +639,7 @@ public class DesignItemServiceImpl extends ServiceImpl (singleItem.getType().toLowerCase().equals(layers.getImageCategory().split("_")[0]) && (flag ? Boolean.TRUE : singleItem.getPriority().equals(layers.getPriority()))) ).collect(Collectors.toList())); + designItemClothesDetailVO.setGradient(singleItem.getGradient()); body.setLayersObject(layersObject.stream().filter(layers -> layers.getImageCategory().equals("body")).collect(Collectors.toList())); clothes.add(designItemClothesDetailVO); diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index f5fe6222..20142a05 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -993,6 +993,7 @@ public class DesignServiceImpl extends ServiceImpl impleme d.setPath(minioUtil.getPresignedUrl(o.getPath(), 24 * 60)); d.setMinIOPath(o.getPath()); d.setLevel1Type(converTypeToLevel1(o.getType())); + d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class)); // 根据designItemDetailId获取印花 List prints = designItemDetailPrintService.getByDesignItemDetailId(o.getId()); // 判断有无印花 @@ -1000,13 +1001,6 @@ public class DesignServiceImpl extends ServiceImpl impleme // 有印花 d.setPrintObject(convertToDesignSinglePrintDTO(prints)); } -// String printJson = o.getPrintJson(); -// if (StringUtils.isEmpty(printJson)) { -// d.setPrintObject(new DesignPythonItemPrint(o.getPrintPath(), -// CollectionLevel1TypeEnum.PRINT_BOARD.getRealName(), 0.3f, Boolean.FALSE)); -// } else { -// d.setPrintObject(JSON.parseObject(printJson, DesignPythonItemPrint.class)); -// } })); //single 和 Models(模特)时候 系统元素为空 List filterDetail2 = designItemDetails.stream() From f4766d4ab4489cd56aa13c36a8ebbaf1bd182c14 Mon Sep 17 00:00:00 2001 From: xupei Date: Mon, 13 May 2024 17:22:21 +0800 Subject: [PATCH 06/21] =?UTF-8?q?designSingle=20=E5=85=A5=E5=8F=82?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +++++ .../com/ai/da/mapper/primary/entity/Gradient.java | 3 ++- .../com/ai/da/mapper/primary/entity/GradientItem.java | 4 +++- .../java/com/ai/da/mapper/primary/entity/RGBA.java | 4 +++- .../ai/da/model/dto/DesignSingleIncludeLayersDTO.java | 3 ++- .../java/com/ai/da/model/dto/DesignSingleItemDTO.java | 3 ++- .../com/ai/da/model/dto/DesignSinglePrintDTO.java | 3 ++- .../java/com/ai/da/model/vo/DesignSinglePrint.java | 3 ++- .../com/ai/da/service/impl/DesignItemServiceImpl.java | 11 ++++++++++- 9 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 21b1264b..966478f8 100644 --- a/pom.xml +++ b/pom.xml @@ -226,6 +226,11 @@ 2.17.1 + + com.stripe + stripe-java + 25.0.0 + diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java b/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java index e8d40d3b..688918f1 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/Gradient.java @@ -2,10 +2,11 @@ package com.ai.da.mapper.primary.entity; import lombok.Data; +import java.io.Serializable; import java.util.List; @Data -public class Gradient { +public class Gradient implements Serializable { private List gradientList; private int angle; private int selectIndex; diff --git a/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java b/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java index 37a8c8ca..717cf157 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/GradientItem.java @@ -2,8 +2,10 @@ package com.ai.da.mapper.primary.entity; import lombok.Data; +import java.io.Serializable; + @Data -public class GradientItem { +public class GradientItem implements Serializable { private RGBA rgba; private String left; } diff --git a/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java b/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java index 9ee98a71..b0548615 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/RGBA.java @@ -2,8 +2,10 @@ package com.ai.da.mapper.primary.entity; import lombok.Data; +import java.io.Serializable; + @Data -public class RGBA { +public class RGBA implements Serializable { private int r; private int g; private int b; diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java index b2b5828d..bed41e4e 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleIncludeLayersDTO.java @@ -5,10 +5,11 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import java.io.Serializable; import java.util.List; @Data -public class DesignSingleIncludeLayersDTO { +public class DesignSingleIncludeLayersDTO implements Serializable { @ApiModelProperty("designItemId") @NotNull(message = "designItemId.cannot.be.empty") diff --git a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java index 4c76d5cc..11bbd0ed 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSingleItemDTO.java @@ -7,10 +7,11 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import java.io.Serializable; import java.util.List; @Data -public class DesignSingleItemDTO { +public class DesignSingleItemDTO implements Serializable { @NotNull(message = "id.cannot.be.empty") @ApiModelProperty("切换图片对应的id") diff --git a/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java b/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java index 5d70a929..eebc36c8 100644 --- a/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java +++ b/src/main/java/com/ai/da/model/dto/DesignSinglePrintDTO.java @@ -5,11 +5,12 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; import java.util.List; @Data @ApiModel("design single 印花请求信息") -public class DesignSinglePrintDTO { +public class DesignSinglePrintDTO implements Serializable { // @ApiModelProperty("印花url") // private String path; diff --git a/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java b/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java index 54818442..1d231b3d 100644 --- a/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java +++ b/src/main/java/com/ai/da/model/vo/DesignSinglePrint.java @@ -6,11 +6,12 @@ import lombok.Data; import org.hibernate.validator.constraints.Range; import javax.validation.constraints.Min; +import java.io.Serializable; import java.util.List; @Data @ApiModel("design single 印花详情") -public class DesignSinglePrint { +public class DesignSinglePrint implements Serializable { @ApiModelProperty("印花是用户上传的还是从library中选的 collection/library") private String designType; diff --git a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java index ae26cc7e..691c4a39 100644 --- a/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignItemServiceImpl.java @@ -28,6 +28,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Lists; import io.netty.util.internal.StringUtil; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.SerializationUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -415,7 +416,15 @@ public class DesignItemServiceImpl extends ServiceImpl " + designSingleIncludeLayersDTO.toString()); + // 记录入参 base64数据太长,所以这里去掉 + DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO); + clone.getDesignSingleItemDTOList().forEach( i -> { + if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())){ + i.getGradient().setColorImg(null); + } + }); + + log.info("designSingle request入参 ==> " + JSONObject.toJSONString(clone)); Long userId = UserContext.getUserHolder().getId(); DesignItem designItem = selectById(designSingleIncludeLayersDTO.getDesignItemId()); From 3790b8ee7235f340d4f077f25bf3c98685697b06 Mon Sep 17 00:00:00 2001 From: xupei Date: Wed, 15 May 2024 15:38:11 +0800 Subject: [PATCH 07/21] =?UTF-8?q?Alipay-HK=20=E5=88=9B=E5=BB=BA=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=92=8C=E5=BC=82=E6=AD=A5=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 + .../da/common/constant/AlipayHKConstant.java | 20 ++ .../com/ai/da/common/enums/PayTypeEnum.java | 7 +- .../security/filter/AuthenticationFilter.java | 2 +- .../common/utils/AlipayHKEncryptionUtil.java | 60 ++++- .../da/common/utils/AlipayHKRequestUtil.java | 22 +- .../ai/da/controller/AlipayHKController.java | 30 ++- .../da/mapper/primary/entity/PaymentInfo.java | 2 +- .../ai/da/model/dto/AlipayHKCallbackDTO.java | 30 +++ .../com/ai/da/service/AlipayHKService.java | 10 + .../com/ai/da/service/PaymentInfoService.java | 3 + .../da/service/impl/AlipayHKServiceImpl.java | 245 ++++++++++++++++-- .../service/impl/PaymentInfoServiceImpl.java | 41 ++- src/main/resources/alipay-hk.properties | 11 - src/main/resources/alipay-sandbox.properties | 7 + src/main/resources/application-dev.properties | 2 +- 16 files changed, 429 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/ai/da/common/constant/AlipayHKConstant.java create mode 100644 src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java delete mode 100644 src/main/resources/alipay-hk.properties diff --git a/pom.xml b/pom.xml index 21b1264b..f816c5ca 100644 --- a/pom.xml +++ b/pom.xml @@ -226,6 +226,12 @@ 2.17.1 + + com.stripe + stripe-java + 25.0.0 + + diff --git a/src/main/java/com/ai/da/common/constant/AlipayHKConstant.java b/src/main/java/com/ai/da/common/constant/AlipayHKConstant.java new file mode 100644 index 00000000..aa290cc1 --- /dev/null +++ b/src/main/java/com/ai/da/common/constant/AlipayHKConstant.java @@ -0,0 +1,20 @@ +package com.ai.da.common.constant; + +public class AlipayHKConstant { + + // 服务名 + public static final String CREATE_ORDER = "create_order"; + public static final String ORDER_DETAILS = "order_details"; + public static final String TRANSACTION_DETAILS = "transaction_details"; + public static final String GET_FILE = "get_file"; + public static final String CREATE_AUTO_DEBIT = "create_auto_debit"; + public static final String REFRESH_TRANSACTION_STATUS = "refresh_transaction_status"; + public static final String REFUND_TRANSACTION = "refund_transaction"; + + // 订单状态 + public static final String STATUS_NEW = "new"; + public static final String STATUS_WAIT = "wait"; + public static final String STATUS_PAID = "paid"; + public static final String STATUS_EXPIRED = "expired"; + public static final String STATUS_LIQUIDATED = "liquidated"; +} diff --git a/src/main/java/com/ai/da/common/enums/PayTypeEnum.java b/src/main/java/com/ai/da/common/enums/PayTypeEnum.java index 70067578..5bc14b21 100644 --- a/src/main/java/com/ai/da/common/enums/PayTypeEnum.java +++ b/src/main/java/com/ai/da/common/enums/PayTypeEnum.java @@ -19,7 +19,12 @@ public enum PayTypeEnum { /** * PayPal */ - PAYPAL("PayPal"); + PAYPAL("PayPal"), + + /** + * 香港支付宝 + */ + ALIPAY_HK("Alipay-HK"); /** * 类型 diff --git a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java index 9e404107..4256b8fe 100644 --- a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java +++ b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java @@ -49,7 +49,7 @@ public class AuthenticationFilter extends OncePerRequestFilter { "/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew", "/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl", // "/api/python/chatStream", - "/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back" + "/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify" ); @Override diff --git a/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java b/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java index 205c7f94..5e8662a3 100644 --- a/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java +++ b/src/main/java/com/ai/da/common/utils/AlipayHKEncryptionUtil.java @@ -6,9 +6,16 @@ import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import lombok.extern.slf4j.Slf4j; +import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; +import org.bouncycastle.crypto.digests.SHA256Digest; +import org.bouncycastle.crypto.params.AsymmetricKeyParameter; +import org.bouncycastle.crypto.signers.RSADigestSigner; +import org.bouncycastle.crypto.util.PublicKeyFactory; +import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.util.io.pem.PemObject; import org.bouncycastle.util.io.pem.PemReader; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import javax.crypto.*; import javax.crypto.spec.IvParameterSpec; @@ -25,22 +32,24 @@ import java.util.HashMap; import java.util.UUID; @Slf4j +@Component public class AlipayHKEncryptionUtil { - @Value("${alipay.hk.merchant-id}") - private static String merchantId; + @Value("${alipayHK.merchantId}") + private String merchantId; - @Value("${alipay.hk.segment-id}") - private static String segmentId; + @Value("${alipayHK.segmentId}") + private String segmentId; - @Value("${alipay.hk.AESKey}") - private static String aesKey; + @Value("${alipayHK.AESKey}") + private String aesKey; - @Value("${alipay.hk.rsaPrivateKey}") - private static String privateKeyPath; + @Value("${alipayHK.rsaPrivateKey}") + private String privateKeyPath; + + @Value("${alipayHK.rsaPublicKey}") + private String publicKeyPath; - @Value("${alipay.hk.rsaPublicKey}") - private static String publicKeyPath; /** * 加密 @@ -55,7 +64,7 @@ public class AlipayHKEncryptionUtil { * @throws BadPaddingException * @throws IOException */ - public static AlipayHKRequestDTO AESCBCWithRSA(HashMap param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException { + public AlipayHKRequestDTO AESCBCWithRSA(HashMap param, String serviceName) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException { // Pre-shared secret key, DO NOT hardcode this key String key = aesKey; // The path to the rsa private key file, DO NOT save this key to a publicly accessible location @@ -187,7 +196,7 @@ public class AlipayHKEncryptionUtil { /** * 使用 AES 密钥和随机向量进行解密 */ - public static String decryptAES(String encryptedText, String iv) throws Exception { + public String decryptAES(String encryptedText, String iv) throws Exception { byte[] encryptedBytes = Base64.getDecoder().decode(encryptedText); byte[] ivBytes = Base64.getDecoder().decode(iv); @@ -201,7 +210,7 @@ public class AlipayHKEncryptionUtil { return new String(decryptedBytes, StandardCharsets.UTF_8); } - public static void test() throws Exception { + public void test() throws Exception { // 加密数据 AlipayHKParametersDTO requestMessage = new AlipayHKParametersDTO(); requestMessage.setService("create_order"); @@ -326,4 +335,29 @@ public class AlipayHKEncryptionUtil { random.nextBytes(iv); return iv; } + + public Boolean signatureVerification(String data, String signatureBase64){ + + Base64.Decoder decoder = Base64.getDecoder(); + // Verify key + try { +// PublicKey publicKey = readPublicKey(new File(publicKeyPath)); + InputStreamReader isrPub = new InputStreamReader(new FileInputStream(publicKeyPath)); + PEMParser pemParserPub = new PEMParser(isrPub); + SubjectPublicKeyInfo pubInfo = (SubjectPublicKeyInfo) pemParserPub.readObject(); + AsymmetricKeyParameter pubKey = PublicKeyFactory.createKey(pubInfo); + // Verifying + RSADigestSigner verifier = new RSADigestSigner(new SHA256Digest()); + verifier.init(false, pubKey); + byte[] signMessageForVerifing = data.getBytes(); + byte[] signatureBase64ForVerifing = decoder.decode(signatureBase64); + verifier.update(signMessageForVerifing, 0, signMessageForVerifing.length); + Boolean verifyResult = verifier.verifySignature(signatureBase64ForVerifing); + return verifyResult; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + } diff --git a/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java b/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java index 331c01ed..771f5154 100644 --- a/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java +++ b/src/main/java/com/ai/da/common/utils/AlipayHKRequestUtil.java @@ -11,11 +11,13 @@ import java.time.Instant; import java.util.concurrent.TimeUnit; import com.alibaba.fastjson.JSONObject; +import org.springframework.stereotype.Component; @Slf4j +@Component public class AlipayHKRequestUtil { - public static String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException { + public String createOrder(AlipayHKRequestDTO alipayHKRequestDTO) throws IOException { OkHttpClient client = new OkHttpClient().newBuilder() .connectTimeout(30, TimeUnit.SECONDS) .pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒) @@ -32,22 +34,28 @@ public class AlipayHKRequestUtil { RequestBody body = RequestBody.create(mediaType, jsonString); Request request = new Request.Builder() -// .url("https://aqs-api.sandbox-codpayment.com") .url("https://aqs-api.sandbox-codpayment.com/v1/service") .method("POST", body) .addHeader("Content-Type", "application/json;charset=utf-8") .build(); - Response response = null; + Response response; String bodyString; try { -// log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(alipayHKRequestDTO, SerializerFeature.WriteMapNullValue)); response = client.newCall(request).execute(); + assert response.body() != null; + bodyString = response.body().string(); } catch (Exception e) { -// log.error("PythonService##generateSketchOrPrint异常###{}", ExceptionUtil.getThrowableList(ioException)); -// throw new BusinessException("generate.interface.error"); throw new BusinessException(e.getMessage()); } - return response.body().string(); + JSONObject jsonObject = JSONObject.parseObject(bodyString); + boolean success = (boolean) jsonObject.get("success"); + if (success){ + return bodyString; + } else { + String message = jsonObject.get("error_code").toString() + ":" + jsonObject.get("error"); + log.error("Alipay return message : {}", message); + throw new BusinessException("Alipay return message : " + message); + } } } diff --git a/src/main/java/com/ai/da/controller/AlipayHKController.java b/src/main/java/com/ai/da/controller/AlipayHKController.java index 9b2fca11..38f2da9b 100644 --- a/src/main/java/com/ai/da/controller/AlipayHKController.java +++ b/src/main/java/com/ai/da/controller/AlipayHKController.java @@ -1,22 +1,40 @@ package com.ai.da.controller; import com.ai.da.common.response.Response; +import com.ai.da.service.AlipayHKService; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; @CrossOrigin @RestController -@RequestMapping("/api/ali-pay-hk") +@RequestMapping("/api/alipay-hk") @Api(tags = "网站支付 香港支付宝") @Slf4j public class AlipayHKController { - public Response createOrder(){ - return Response.success(); + @Resource + private AlipayHKService alipayHKService; + + @ApiOperation(value = "创建订单") + @PostMapping(value = "/createOrder") + public Response createOrder(@RequestParam Integer amount, @RequestParam String wallet) { + String order = alipayHKService.createOrder(amount, wallet); + return Response.success(order); + } + + @ApiOperation("支付通知") + @PostMapping("/trade/notify") + public String callback(@RequestParam Map params){ + return alipayHKService.callback(params); } + + + } diff --git a/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java b/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java index 8557aa83..2d7cf881 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/PaymentInfo.java @@ -17,7 +17,7 @@ public class PaymentInfo extends BaseEntity{ private String tradeState;//交易状态 - private Integer payerTotal;//支付金额(分) + private Long payerTotal;//支付金额(元) private String content;//通知参数 } diff --git a/src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java b/src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java new file mode 100644 index 00000000..d1e40107 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/AlipayHKCallbackDTO.java @@ -0,0 +1,30 @@ +package com.ai.da.model.dto; + +import lombok.Data; + +@Data +public class AlipayHKCallbackDTO { + + private String transaction_id; + + private Long amount; + + private String currency; + + private String payment_time; + + private String merchant_id; + + private String segment_id; + + private String out_trade_no; + + private String type; + + private String status; + + private String pid; + + private String subject; + +} diff --git a/src/main/java/com/ai/da/service/AlipayHKService.java b/src/main/java/com/ai/da/service/AlipayHKService.java index baf56c8e..47f06d2b 100644 --- a/src/main/java/com/ai/da/service/AlipayHKService.java +++ b/src/main/java/com/ai/da/service/AlipayHKService.java @@ -1,4 +1,14 @@ package com.ai.da.service; +import com.ai.da.model.dto.AlipayHKCallbackDTO; + +import java.util.Map; + public interface AlipayHKService { + + String createOrder(Integer amount, String wallet); + + String callback(Map params); + + void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO); } diff --git a/src/main/java/com/ai/da/service/PaymentInfoService.java b/src/main/java/com/ai/da/service/PaymentInfoService.java index 4a350dff..de9526b1 100644 --- a/src/main/java/com/ai/da/service/PaymentInfoService.java +++ b/src/main/java/com/ai/da/service/PaymentInfoService.java @@ -1,5 +1,6 @@ package com.ai.da.service; +import com.ai.da.model.dto.AlipayHKCallbackDTO; import com.paypal.orders.Order; import java.util.Map; @@ -11,4 +12,6 @@ public interface PaymentInfoService { void createPaymentInfoForAliPay(Map params); void createPaymentInfoForPayPal(Order order); + + void createPaymentInfoForAliPayHK(AlipayHKCallbackDTO alipayHKCallbackDTO); } diff --git a/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java b/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java index 4445c6cb..0876991a 100644 --- a/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AlipayHKServiceImpl.java @@ -1,50 +1,113 @@ package com.ai.da.service.impl; +import com.ai.da.common.constant.AlipayHKConstant; import com.ai.da.common.enums.CreditsEventsEnum; -import com.ai.da.service.AlipayHKService; +import com.ai.da.common.enums.OrderStatusEnum; +import com.ai.da.common.enums.PayTypeEnum; +import com.ai.da.common.utils.AlipayHKEncryptionUtil; +import com.ai.da.common.utils.AlipayHKRequestUtil; +import com.ai.da.mapper.primary.entity.OrderInfo; +import com.ai.da.model.dto.AlipayHKCallbackDTO; +import com.ai.da.model.dto.AlipayHKRequestDTO; +import com.ai.da.service.*; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocketFactory; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Arrays; import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.locks.ReentrantLock; @Service @Slf4j public class AlipayHKServiceImpl implements AlipayHKService { - @Value("${alipay.hk.merchant-id}") - private static String merchantId; + @Value("${alipayHK.merchantId}") + private String merchantId; - @Value("${alipay.hk.segment-id}") - private static String segmentId; + @Value("${alipayHK.segmentId}") + private String segmentId; - @Value("${alipay.hk.AESKey}") - private static String aesKey; + @Value("${alipayHK.AESKey}") + private String aesKey; - @Value("${alipay.hk.rsaPrivateKey}") - private static String privateKeyPath; + @Value("${alipayHK.rsaPrivateKey}") + private String privateKeyPath; - @Value("${alipay.hk.rsaPublicKey}") - private static String publicKeyPath; + @Value("${alipayHK.rsaPublicKey}") + private String publicKeyPath; + + @Resource + private OrderInfoService orderInfoService; + @Resource + private PaymentInfoService paymentInfoService; + @Resource + private CreditsService creditsService; + @Resource + private AlipayHKEncryptionUtil alipayHKEncryptionUtil; + @Resource + private AlipayHKRequestUtil alipayHKRequestUtil; /** * 创建订单 */ - public void createOrder(Integer amount){ + @Override + public String createOrder(Integer amount, String wallet){ - HashMap param = new HashMap<>(); - String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); - param.put("order_ref", orderRef); - param.put("amount", Integer.parseInt(CreditsEventsEnum.PRICE.getValue()) * amount); - param.put("subject", "AiDA Credits Purchase"); - param.put("wallet", "ALIPAYHK"); - param.put("segment_id", segmentId); - param.put("payment_solution", "WAP"); + try{ + HashMap param = new HashMap<>(); + String orderRef = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); + param.put("order_ref", orderRef); + param.put("amount", Integer.parseInt(CreditsEventsEnum.PRICE.getValue()) * amount); + param.put("subject", "AiDA Credits Purchase"); + // ALIPAYHK 或者 ALIPAYCN + param.put("wallet", wallet); + param.put("segment_id", segmentId); + param.put("payment_solution", "WAP"); + log.info("alipay-hk 创建订单,参数信息: {}", param); + // 生成订单 + log.info("创建订单"); + OrderInfo orderInfo = orderInfoService.createOrderByProductId(amount, PayTypeEnum.ALIPAY_HK.getType()); + // 加密 + AlipayHKRequestDTO alipayHKRequestDTO = alipayHKEncryptionUtil.AESCBCWithRSA(param, AlipayHKConstant.CREATE_ORDER); + // 请求Alipay服务端 + String response = alipayHKRequestUtil.createOrder(alipayHKRequestDTO); + // 获取response中的加密数据 + JSONObject responseObj = JSONObject.parseObject(response); + JSONObject resultObj = JSONObject.parseObject(responseObj.get("result").toString()); + String nonce = resultObj.get("nonce").toString(); + String message = resultObj.get("message").toString(); + // 解密 + String s = alipayHKEncryptionUtil.decryptAES(message, nonce); + JSONObject jsonObject = JSONObject.parseObject(s); + String orderId = jsonObject.get("out_trade_no").toString(); + + orderInfoService.updateOrderNoById(orderInfo.getId(), orderId); + + + log.info("create_order 接口返回信息 :{}", s); + + return s; + + + }catch (Exception e){ + log.error("订单创建失败 : {}", e.getMessage()); + // todo 或者抛异常 + return null; + } } @@ -53,8 +116,122 @@ public class AlipayHKServiceImpl implements AlipayHKService { * 异步回调 * @return */ - public void callback(){ + public String callback(Map params){ + log.info("支付通知正在执行"); + log.info("通知参数 ===> {}", params); + String result = "failure"; + + String data = params.get("data"); + String signature = params.get("signature"); + + try { + // 异步回调验签 + Boolean verification = alipayHKEncryptionUtil.signatureVerification(data, signature); + + if (!verification){ + log.error("alipay-hk 验签失败"); + return result; + } + + AlipayHKCallbackDTO alipayHKCallbackDTO = JSONObject.parseObject(data, AlipayHKCallbackDTO.class); + //按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验, + //1 商户需要验证该通知数据中的 out_trade_no 是否为商户系统中创建的订单号 + String outTradeNo = alipayHKCallbackDTO.getOut_trade_no(); + OrderInfo order = orderInfoService.getOrderByOrderNo(outTradeNo); + if(order == null){ + log.error("订单不存在"); + return result; + } + + //2 判断 total_amount 是否确实为该订单的实际金额(即商户订单创建时的金额) + Long totalAmount = alipayHKCallbackDTO.getAmount(); + Long totalFee = order.getTotalFee().longValue(); + if(totalAmount != totalFee){ + log.error("金额校验失败"); + return result; + } + + //3 校验通知中的 seller_id(或者 seller_email) 是否为 out_trade_no 这笔单据的对应的操作方 + String sellerId = alipayHKCallbackDTO.getMerchant_id(); + String sellerIdProperty = merchantId; + if(!sellerId.equals(sellerIdProperty)){ + log.error("商家pid校验失败"); + return result; + } + + //4 验证 app_id 是否为该商户本身 + String segId = alipayHKCallbackDTO.getSegment_id(); + String segmentIdProperty = segmentId; + if(!segId.equals(segmentIdProperty)){ + log.error("segmentId校验失败"); + return result; + } + + //在支付宝的业务通知中,只有交易通知状态为 TRADE_SUCCESS时, + // 支付宝才会认定为买家付款成功。 + String tradeStatus = alipayHKCallbackDTO.getStatus(); + if(!AlipayHKConstant.STATUS_PAID.equals(tradeStatus)){ + log.error("支付未成功"); + return result; + } + + processOrder(alipayHKCallbackDTO); + result = "success"; + }catch (Exception e){ + log.error(e.getMessage()); + } + + + return result; + + } + + private final ReentrantLock lock = new ReentrantLock(); + + + @Transactional(rollbackFor = Exception.class) + @Override + public void processOrder(AlipayHKCallbackDTO alipayHKCallbackDTO) { + + log.info("处理订单"); + + //获取订单号 + String orderNo = alipayHKCallbackDTO.getOut_trade_no(); + String totalAmount = alipayHKCallbackDTO.getAmount().toString(); + + /*在对业务数据进行状态检查和处理之前, + 要采用数据锁进行并发控制, + 以避免函数重入造成的数据混乱*/ + //尝试获取锁: + // 成功获取则立即返回true,获取失败则立即返回false。不必一直等待锁的释放 + if(lock.tryLock()) { + try { + //处理重复通知 + //接口调用的幂等性:无论接口被调用多少次,以下业务执行一次 +// String orderStatus = orderInfoService.getOrderStatus(orderNo); + OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(orderNo); + String orderStatus = orderByOrderNo.getOrderStatus(); + // 当订单状态处于未支付或超时已关闭时,更新订单状态 + if (!OrderStatusEnum.NOT_PAY.getType().equals(orderStatus) || !OrderStatusEnum.TIMEOUT_CLOSED.getType().equals(orderStatus)) { + return; + } + //更新订单状态 + orderInfoService.updateStatusByOrderNo(orderNo, OrderStatusEnum.SUCCESS); + //记录支付日志 + paymentInfoService.createPaymentInfoForAliPayHK(alipayHKCallbackDTO); + // 添加积分变更记录 + creditsService.insertToCreditsDetail(orderByOrderNo.getAccountId(), + CreditsEventsEnum.BUY_CREDITS.getName() + "--AlipayHK", + CreditsEventsEnum.BUY_CREDITS.getValue(), + "positive"); + // 更新积分 + creditsService.buyCredits(orderByOrderNo.getAccountId(),Integer.parseInt(totalAmount) / Integer.parseInt(CreditsEventsEnum.PRICE.getValue())); + } finally { + //要主动释放锁 + lock.unlock(); + } + } } @@ -88,10 +265,28 @@ public class AlipayHKServiceImpl implements AlipayHKService { - public static void main(String[] args) throws Exception { -// test(); -// AESCBCWithRSA(); -// decrypt(); +// public static void main(String[] args) throws Exception { +//// test(); +//// AESCBCWithRSA(); +//// decrypt(); +// } + + public static void main(String[] args) { + System.out.println("Supported TLS versions:"); + String[] tlsVersions = getSupportedTLSVersions(); + Arrays.stream(tlsVersions).forEach(System.out::println); + } + + public static String[] getSupportedTLSVersions() { + try { + SSLContext context = SSLContext.getDefault(); + SSLSocketFactory factory = context.getSocketFactory(); + String[] supportedProtocols = factory.getDefaultCipherSuites(); + return supportedProtocols; + } catch (Exception e) { + e.printStackTrace(); + return new String[0]; + } } diff --git a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java index 367dd376..224bfd91 100644 --- a/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PaymentInfoServiceImpl.java @@ -3,6 +3,7 @@ package com.ai.da.service.impl; import com.ai.da.common.enums.PayTypeEnum; import com.ai.da.mapper.primary.PaymentInfoMapper; import com.ai.da.mapper.primary.entity.PaymentInfo; +import com.ai.da.model.dto.AlipayHKCallbackDTO; import com.ai.da.service.PaymentInfoService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.gson.Gson; @@ -48,7 +49,8 @@ public class PaymentInfoServiceImpl extends ServiceImpl Date: Thu, 16 May 2024 15:32:39 +0800 Subject: [PATCH 08/21] =?UTF-8?q?generate=20text=E5=AD=98db=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ai/da/service/impl/GenerateServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 48f3655a..fbe8715d 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -259,7 +259,7 @@ public class GenerateServiceImpl extends ServiceImpl i switch (level1Type) { case "Moodboard": text = translated + ",high quality"; - generate.setText(text); +// generate.setText(text); break; case "Printboard": if (userInput.contains("Painting Style")) { @@ -270,11 +270,11 @@ public class GenerateServiceImpl extends ServiceImpl i userInput = "Still life photography,hyper realism,3d,deepened projection,increased permutation value,increased concavity and convexity value," + translated; } text = userInput + ", fabric print, high quality"; - generate.setText(text); +// generate.setText(text); break; case "Sketchboard": text = "clear lines, simple outlines monochrome white vector image of " + translated + ", no background, sketch flat, front view display, best quality, ultra-high resolution 8k"; - generate.setText(text); +// generate.setText(text); default: } return text; From ebb6577e98a53ff393a1189f736994aad65eed48 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 17 May 2024 10:19:34 +0800 Subject: [PATCH 09/21] TASK:portfolio; --- .../com/ai/da/common/utils/SendEmailUtil.java | 12 +- .../ai/da/controller/PortfolioController.java | 59 +++ .../ai/da/mapper/primary/PortfolioMapper.java | 7 + .../da/mapper/primary/entity/Portfolio.java | 55 ++ .../com/ai/da/model/dto/PortfolioDTO.java | 10 + .../da/model/dto/QueryPortfolioPageDTO.java | 14 + .../java/com/ai/da/model/vo/PortfolioVO.java | 16 + .../com/ai/da/service/PortfolioService.java | 21 + .../com/ai/da/service/UserLikeService.java | 2 + .../com/ai/da/service/WorkspaceService.java | 2 + .../da/service/impl/AccountServiceImpl.java | 13 +- .../impl/CollectionElementServiceImpl.java | 22 +- .../da/service/impl/PortfolioServiceImpl.java | 474 ++++++++++++++++++ .../impl/UserLikeGroupServiceImpl.java | 9 - .../da/service/impl/UserLikeServiceImpl.java | 7 + .../da/service/impl/WorkspaceServiceImpl.java | 15 + 16 files changed, 715 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/ai/da/controller/PortfolioController.java create mode 100644 src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java create mode 100644 src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java create mode 100644 src/main/java/com/ai/da/model/dto/PortfolioDTO.java create mode 100644 src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java create mode 100644 src/main/java/com/ai/da/model/vo/PortfolioVO.java create mode 100644 src/main/java/com/ai/da/service/PortfolioService.java create mode 100644 src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 7b5462dd..15f2e95b 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -355,7 +355,8 @@ public class SendEmailUtil { } private final static Long UPGRADE_NOTIFICATION_ID = 118855L; - public static void sendUpgradeNotification(Account account, String senderAddress) { + private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L; + public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) { try { // 实例化一个认证对象 Credential cred = new Credential(SECRET_ID, SECRET_KEy); @@ -374,8 +375,13 @@ public class SendEmailUtil { // 根据邮件类型设置不同的主题和模板 String subject = ""; Template template = new Template(); - subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance"; - template.setTemplateID(UPGRADE_NOTIFICATION_ID); + if (type == 1) { + subject = "Upcoming System Upgrade for AiDA 3.0"; + template.setTemplateID(UPGRADE_NOTIFICATION_ID); + }else { + subject = "即将到来的AiDA 3.0系统升级"; + template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE); + } template.setTemplateData(buildAccountData(account)); req.setSubject(subject); diff --git a/src/main/java/com/ai/da/controller/PortfolioController.java b/src/main/java/com/ai/da/controller/PortfolioController.java new file mode 100644 index 00000000..32337e46 --- /dev/null +++ b/src/main/java/com/ai/da/controller/PortfolioController.java @@ -0,0 +1,59 @@ +package com.ai.da.controller; + +import com.ai.da.common.response.PageBaseResponse; +import com.ai.da.common.response.Response; +import com.ai.da.model.dto.PortfolioDTO; +import com.ai.da.model.dto.QueryPortfolioPageDTO; +import com.ai.da.model.vo.PortfolioVO; +import com.ai.da.model.vo.UserLikeChooseVO; +import com.ai.da.service.PortfolioService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.Valid; + +@Api(tags = "Portfolio模块") +@Slf4j +@RestController +@RequestMapping("/api/portfolio") +public class PortfolioController { + + @Resource + private PortfolioService portfolioService; + + @ApiOperation(value = "发布作品集") + @PostMapping("/publish") + public Response preLogin(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.publish(portfolioDTO)); + } + + @ApiOperation(value = "作品集page") + @PostMapping("/page") + public Response> page(@Valid @RequestBody QueryPortfolioPageDTO query) { + return Response.success(portfolioService.page(query)); + } + + @ApiOperation(value = "作品详情") + @PostMapping("/detail") + public Response detail(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.detail(portfolioDTO)); + } + + @ApiOperation(value = "选择作品") + @PostMapping("/choose") + public Response choose(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.choose(portfolioDTO)); + } + + @ApiOperation(value = "更新作品") + @PostMapping("/update") + public Response update(@Valid @RequestBody PortfolioDTO portfolioDTO) { + return Response.success(portfolioService.update(portfolioDTO)); + } +} diff --git a/src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java b/src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java new file mode 100644 index 00000000..54ef023b --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/PortfolioMapper.java @@ -0,0 +1,7 @@ +package com.ai.da.mapper.primary; + +import com.ai.da.common.config.mybatis.plus.CommonMapper; +import com.ai.da.mapper.primary.entity.Portfolio; + +public interface PortfolioMapper extends CommonMapper { +} diff --git a/src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java b/src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java new file mode 100644 index 00000000..3c1831ca --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/entity/Portfolio.java @@ -0,0 +1,55 @@ +package com.ai.da.mapper.primary.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +@Data +@ApiModel(value = "Portfolio对象", description = "作品集") +@TableName("portfolio") +public class Portfolio implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + @ApiModelProperty(value = "collection ID") + private Long collectionId; + + @ApiModelProperty(value = "userLikeGroup源") + private Long userLikeGroupSourceId; + + @ApiModelProperty(value = "作品名称") + private String portfolioName; + + @ApiModelProperty(value = "作品描述") + private String portfolioDes; + + @ApiModelProperty(value = "作品类型") + private String portfolioType; + + @ApiModelProperty(value = "封面ID") + private Long coverId; + + @ApiModelProperty(value = "作品状态1公开0隐藏") + private Integer status; + + @ApiModelProperty(value = "作品集作者ID") + private Long accountId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createDate; + + @ApiModelProperty(value = "更新时间") + private LocalDateTime updateDate; + + @ApiModelProperty(value = "是否删除") + private Integer isDeleted; +} diff --git a/src/main/java/com/ai/da/model/dto/PortfolioDTO.java b/src/main/java/com/ai/da/model/dto/PortfolioDTO.java new file mode 100644 index 00000000..90f39bb0 --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/PortfolioDTO.java @@ -0,0 +1,10 @@ +package com.ai.da.model.dto; + +import com.ai.da.mapper.primary.entity.Portfolio; +import lombok.Data; + +@Data +public class PortfolioDTO extends Portfolio { + private Long userLikeGroupId; + +} diff --git a/src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java b/src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java new file mode 100644 index 00000000..8694035b --- /dev/null +++ b/src/main/java/com/ai/da/model/dto/QueryPortfolioPageDTO.java @@ -0,0 +1,14 @@ +package com.ai.da.model.dto; + +import com.ai.da.model.vo.PageQueryBaseVo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel("作品集分页查询") +public class QueryPortfolioPageDTO extends PageQueryBaseVo { + +} diff --git a/src/main/java/com/ai/da/model/vo/PortfolioVO.java b/src/main/java/com/ai/da/model/vo/PortfolioVO.java new file mode 100644 index 00000000..b313cc9a --- /dev/null +++ b/src/main/java/com/ai/da/model/vo/PortfolioVO.java @@ -0,0 +1,16 @@ +package com.ai.da.model.vo; + +import com.ai.da.mapper.primary.entity.CollectionElement; +import com.ai.da.mapper.primary.entity.Portfolio; +import com.ai.da.mapper.primary.entity.TDesignPythonOutfit; +import lombok.Data; + +import java.util.List; + +@Data +public class PortfolioVO extends Portfolio { + private String designPythonOutfitUrl; + + private List collectionElementList; + private List designPythonOutfitList; +} diff --git a/src/main/java/com/ai/da/service/PortfolioService.java b/src/main/java/com/ai/da/service/PortfolioService.java new file mode 100644 index 00000000..683f8c09 --- /dev/null +++ b/src/main/java/com/ai/da/service/PortfolioService.java @@ -0,0 +1,21 @@ +package com.ai.da.service; + +import com.ai.da.common.response.PageBaseResponse; +import com.ai.da.mapper.primary.entity.Portfolio; +import com.ai.da.model.dto.PortfolioDTO; +import com.ai.da.model.dto.QueryPortfolioPageDTO; +import com.ai.da.model.vo.PortfolioVO; +import com.ai.da.model.vo.UserLikeChooseVO; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface PortfolioService extends IService { + Boolean publish(PortfolioDTO portfolioDTO); + + PortfolioVO update(PortfolioDTO portfolioDTO); + + PageBaseResponse page(QueryPortfolioPageDTO query); + + PortfolioVO detail(PortfolioDTO portfolioDTO); + + UserLikeChooseVO choose(PortfolioDTO portfolioDTO); +} diff --git a/src/main/java/com/ai/da/service/UserLikeService.java b/src/main/java/com/ai/da/service/UserLikeService.java index 510d1e0c..b04d64da 100644 --- a/src/main/java/com/ai/da/service/UserLikeService.java +++ b/src/main/java/com/ai/da/service/UserLikeService.java @@ -23,4 +23,6 @@ public interface UserLikeService extends IService { UserLike getByDesignItemId(Long designItemId); void updateDate(Long designItemId,String timeZone); + + List getUserLikeList(Long id); } diff --git a/src/main/java/com/ai/da/service/WorkspaceService.java b/src/main/java/com/ai/da/service/WorkspaceService.java index 17a66f29..87b5675c 100644 --- a/src/main/java/com/ai/da/service/WorkspaceService.java +++ b/src/main/java/com/ai/da/service/WorkspaceService.java @@ -46,4 +46,6 @@ public interface WorkspaceService extends IService { void maleDataInsert() throws FileNotFoundException; List delete(List workspaceList); + + Workspace getCurrentWorkspace(); } diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index 77f44f4f..a5932fae 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -184,6 +184,7 @@ public class AccountServiceImpl extends ServiceImpl impl } private void validateUserValidaExpire(Account account) { + Long currentTime = new Date().getTime(); if (Objects.nonNull(account.getValidStartTime())) { if (currentTime < account.getValidStartTime()) { @@ -884,15 +885,23 @@ public class AccountServiceImpl extends ServiceImpl impl @Override public void upgradeNotification() { QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("id", 88L); queryWrapper.and(wrapper -> - wrapper.gt("valid_end_time", 1709515797000L) + wrapper.gt("valid_end_time", 1715817600000L) .or().isNull("valid_end_time")) .isNotNull("user_email"); List accountList = accountMapper.selectList(queryWrapper); System.out.println(accountList); for (Account account : accountList) { - SendEmailUtil.sendUpgradeNotification(account, null); +// SendEmailUtil.sendUpgradeNotification(account, null, 0); +// SendEmailUtil.sendUpgradeNotification(account, null, 1); + if (account.getLanguage().equals(Language.CHINESE_SIMPLIFIED.name())) { + SendEmailUtil.sendUpgradeNotification(account, null, 0); + }else { + // 英文 + SendEmailUtil.sendUpgradeNotification(account, null, 1); + } } } diff --git a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java index 0a6bfb8c..72b46e5b 100644 --- a/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/CollectionElementServiceImpl.java @@ -353,14 +353,16 @@ public class CollectionElementServiceImpl extends ServiceImpl colorBoards = elementVO.getColorBoards(); for (CollectionColorDTO colorBoard : colorBoards) { - String colorImg = colorBoard.getGradient().getColorImg(); - String[] parts = colorImg.split(","); - String imageType = parts[0].split("/")[1].split(";")[0]; - String base64Data = parts[1]; - String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType); - colorBoard.setGradientMinioUrl(gradientMinioUrl); - colorBoard.getGradient().setColorImg(null); - colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient())); + if (Objects.nonNull(colorBoard.getGradient())) { + String colorImg = colorBoard.getGradient().getColorImg(); + String[] parts = colorImg.split(","); + String imageType = parts[0].split("/")[1].split(";")[0]; + String base64Data = parts[1]; + String gradientMinioUrl = minioUtil.uploadImageFromBase64(gradientBucketName, base64Data, imageType); + colorBoard.setGradientMinioUrl(gradientMinioUrl); + colorBoard.getGradient().setColorImg(null); + colorBoard.setGradientString(JSON.toJSONString(colorBoard.getGradient())); + } } elementVO.setColorBoards(colorBoards); List usedElementIds = elementVO.getUsedElementIds(); @@ -781,7 +783,9 @@ public class CollectionElementServiceImpl extends ServiceImpl implements PortfolioService { + + @Resource + private UserLikeGroupMapper userLikeGroupMapper; + + @Resource + private CollectionMapper collectionMapper; + + @Resource + private CollectionElementService collectionElementService; + + @Resource + private CollectionElementMapper collectionElementMapper; + @Resource + private TCollectionElementRelationMapper collectionElementRelationMapper; + + @Resource + private PortfolioMapper portfolioMapper; + + @Resource + private UserLikeService userLikeService; + + @Resource + private UserLikeMapper userLikeMapper; + + @Resource + private TDesignPythonOutfitMapper designPythonOutfitMapper; + + @Resource + private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper; + + @Resource + private DesignItemMapper designItemMapper; + + @Resource + private DesignItemDetailMapper designItemDetailMapper; + + @Resource + private DesignItemDetailPrintMapper designItemDetailPrintMapper; + + + @Resource + private MinioUtil minioUtil; + + @Resource + private WorkspaceService workspaceService; + + @Resource + private DesignMapper designMapper; + + @Resource + private UserLikeGroupService userLikeGroupService; + + @Override + public Boolean publish(PortfolioDTO portfolioDTO) { + if (portfolioDTO.getPortfolioType().equals("History")) { + AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder(); + UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId()); + UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null); + userLikeGroupNew.setAccountId(-1L); + Long collectionIdOld = userLikeGroup.getCollectionId(); + Collection collectionOld = collectionMapper.selectById(collectionIdOld); + List collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld); + collectionOld.setId(null); + collectionMapper.insert(collectionOld); + Long collectionIdNew = collectionOld.getId(); + userLikeGroupNew.setCollectionId(collectionIdNew); + userLikeGroupMapper.insert(userLikeGroupNew); +// List collectionElementRelationListNew = new ArrayList<>(); + for (CollectionElement element : collectionElementListOld) { + element.setCollectionId(collectionIdNew); + element.setId(null); + collectionElementMapper.insert(element); + TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation(); + collectionElementRelationNew.setCollectionId(collectionIdNew); + collectionElementRelationNew.setElementId(element.getId()); + collectionElementRelationNew.setCreateDate(new Date()); + collectionElementRelationMapper.insert(collectionElementRelationNew); + } + Portfolio portfolio = new Portfolio(); + Long coverIdOld = portfolioDTO.getCoverId(); + portfolio.setPortfolioName(portfolioDTO.getPortfolioName()); + portfolio.setPortfolioType("History"); + portfolio.setCollectionId(collectionIdNew); + portfolio.setAccountId(authPrincipalVo.getId()); + portfolio.setCreateDate(LocalDateTime.now()); + portfolio.setUpdateDate(LocalDateTime.now()); + portfolio.setStatus(1); + portfolio.setIsDeleted(0); + portfolio.setUserLikeGroupSourceId(portfolioDTO.getUserLikeGroupId()); + portfolioMapper.insert(portfolio); + + List userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId()); +// List designPythonOutfitIdList = userLikeList.stream().map(UserLike::getDesignOutfitId).collect(Collectors.toList()); +// +// QueryWrapper qw = new QueryWrapper<>(); +// qw.lambda().in(TDesignPythonOutfit::getId, designPythonOutfitIdList); +// List designPythonOutfits = designPythonOutfitMapper.selectList(qw); + Long coverIdNew = null; + Boolean flag = false; + for (UserLike userLike : userLikeList) { + Long designOutfitIdOld = userLike.getDesignOutfitId(); + TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld); + designPythonOutfit.setDesignId(-1L); + designPythonOutfit.setDesignItemId(-1L); + designPythonOutfit.setCollectionId(collectionIdNew); + if (designPythonOutfit.getId().equals(coverIdOld)) { + flag = true; + } + designPythonOutfit.setId(null); + designPythonOutfitMapper.insert(designPythonOutfit); + Long designOutfitIdNew = designPythonOutfit.getId(); + userLike.setDesignOutfitId(designOutfitIdNew); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); + List tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw); + for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) { +// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId(); + tDesignPythonOutfitDetail.setId(null); + tDesignPythonOutfitDetail.setDesignId(-1L); + tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew); + designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail); + } + + if (flag) { + coverIdNew = designOutfitIdNew; + portfolio.setCoverId(coverIdNew); + portfolioMapper.updateById(portfolio); + flag = false; + } + + Long designItemIdOld = userLike.getDesignItemId(); + DesignItem designItemOld = designItemMapper.selectById(designItemIdOld); + designItemOld.setId(null); + designItemOld.setAccountId(-1L); + designItemOld.setDesignId(-1L); + designItemOld.setCollectionId(collectionIdNew); + designItemMapper.insert(designItemOld); + Long designItemIdNew = designItemOld.getDesignId(); + + designPythonOutfit.setDesignItemId(designItemIdNew); + designPythonOutfitMapper.updateById(designPythonOutfit); + + userLike.setDesignItemId(designItemIdNew); + userLike.setId(null); + userLike.setDesignId(-1L); + userLike.setUserLikeGroupId(userLikeGroupNew.getId()); + userLikeMapper.insert(userLike); + QueryWrapper designItemDetailQueryWrapper = new QueryWrapper<>(); + designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld); + List designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper); + for (DesignItemDetail designItemDetailOld : designItemDetailListOld) { + Long designItemDetailIdOld = designItemDetailOld.getId(); + designItemDetailOld.setAccountId(-1L); + designItemDetailOld.setDesignId(-1L); + designItemDetailOld.setDesignItemId(designItemIdNew); + designItemDetailMapper.insert(designItemDetailOld); + Long designItemDetailIdNew = designItemDetailOld.getId(); + QueryWrapper designItemDetailPrintQueryWrapper = new QueryWrapper<>(); + designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld); + DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper); + designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew); + designItemDetailPrintMapper.insert(designItemDetailPrint); + } + } + }else { + + } + + + return Boolean.TRUE; + } + + @Override + public PortfolioVO update(PortfolioDTO portfolioDTO) { + if (portfolioDTO.getPortfolioType().equals("History")) { + AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder(); + UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId()); + UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null); + userLikeGroupNew.setAccountId(-1L); + Long collectionIdOld = userLikeGroup.getCollectionId(); + Collection collectionOld = collectionMapper.selectById(collectionIdOld); + List collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld); + collectionOld.setId(null); + collectionMapper.insert(collectionOld); + Long collectionIdNew = collectionOld.getId(); + userLikeGroupNew.setCollectionId(collectionIdNew); + userLikeGroupMapper.insert(userLikeGroupNew); +// List collectionElementRelationListNew = new ArrayList<>(); + for (CollectionElement element : collectionElementListOld) { + element.setCollectionId(collectionIdNew); + element.setId(null); + collectionElementMapper.insert(element); + TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation(); + collectionElementRelationNew.setCollectionId(collectionIdNew); + collectionElementRelationNew.setElementId(element.getId()); + collectionElementRelationMapper.insert(collectionElementRelationNew); + } + Portfolio portfolio = getPortfolioByUserGroupIdSource(portfolioDTO.getUserLikeGroupId()); + Long coverIdOld = portfolioDTO.getCoverId(); + portfolio.setPortfolioName(portfolioDTO.getPortfolioName()); +// portfolio.setPortfolioType("History"); + portfolio.setCollectionId(collectionIdNew); + portfolio.setAccountId(authPrincipalVo.getId()); + portfolio.setCreateDate(LocalDateTime.now()); + portfolio.setUpdateDate(LocalDateTime.now()); + portfolio.setStatus(1); + portfolio.setIsDeleted(0); + portfolioMapper.updateById(portfolio); + + List userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId()); + + Long coverIdNew = null; + Boolean flag = false; + for (UserLike userLike : userLikeList) { + Long designOutfitIdOld = userLike.getDesignOutfitId(); + TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld); + designPythonOutfit.setDesignId(-1L); + designPythonOutfit.setDesignItemId(-1L); + designPythonOutfit.setCollectionId(collectionIdNew); + if (!flag && designPythonOutfit.getId() == coverIdOld) { + flag = true; + } + designPythonOutfit.setId(null); + designPythonOutfitMapper.insert(designPythonOutfit); + Long designOutfitIdNew = designPythonOutfit.getId(); + userLike.setDesignOutfitId(designOutfitIdNew); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); + List tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw); + for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) { +// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId(); + tDesignPythonOutfitDetail.setId(null); + tDesignPythonOutfitDetail.setDesignId(-1L); + tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew); + designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail); + } + + if (flag) { + coverIdNew = designPythonOutfit.getId(); + portfolio.setCoverId(coverIdNew); + portfolioMapper.updateById(portfolio); + } + + Long designItemIdOld = userLike.getDesignItemId(); + DesignItem designItemOld = designItemMapper.selectById(designItemIdOld); + designItemOld.setId(null); + designItemOld.setAccountId(-1L); + designItemOld.setDesignId(-1L); + designItemOld.setCollectionId(collectionIdNew); + designItemMapper.insert(designItemOld); + Long designItemIdNew = designItemOld.getDesignId(); + + designPythonOutfit.setDesignItemId(designItemIdNew); + designPythonOutfitMapper.updateById(designPythonOutfit); + + userLike.setDesignItemId(designItemIdNew); + userLike.setId(null); + userLike.setDesignId(-1L); + userLike.setUserLikeGroupId(userLikeGroupNew.getId()); + userLikeMapper.insert(userLike); + QueryWrapper designItemDetailQueryWrapper = new QueryWrapper<>(); + designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld); + List designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper); + for (DesignItemDetail designItemDetailOld : designItemDetailListOld) { + Long designItemDetailIdOld = designItemDetailOld.getId(); + designItemDetailOld.setAccountId(-1L); + designItemDetailOld.setDesignId(-1L); + designItemDetailOld.setDesignItemId(designItemIdNew); + designItemDetailMapper.insert(designItemDetailOld); + Long designItemDetailIdNew = designItemDetailOld.getId(); + QueryWrapper designItemDetailPrintQueryWrapper = new QueryWrapper<>(); + designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld); + DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper); + designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew); + designItemDetailPrintMapper.insert(designItemDetailPrint); + } + } + } + + return null; + } + + private Portfolio getPortfolioByUserGroupIdSource(Long userLikeGroupId) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(Portfolio::getUserLikeGroupSourceId, userLikeGroupId); + return portfolioMapper.selectOne(qw); + } + + @Override + public PageBaseResponse page(QueryPortfolioPageDTO query) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().orderByDesc(Portfolio::getUpdateDate); + IPage page = portfolioMapper.selectPage(new Page<>(query.getPage(), query.getSize()),qw); + IPage convert = page.convert((Function) portfolio -> { + if (portfolio != null) { + PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class); + TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(vo.getCoverId()); + vo.setDesignPythonOutfitUrl(minioUtil.getPresignedUrl(designPythonOutfit.getDesignUrl(), 24 * 60)); + return vo; + } + return null; + }); + return PageBaseResponse.success(convert); + } + + @Override + public PortfolioVO detail(PortfolioDTO portfolioDTO) { + Portfolio portfolio = portfolioMapper.selectById(portfolioDTO.getId()); + PortfolioVO vo = CopyUtil.copyObject(portfolio, PortfolioVO.class); + Long collectionId = portfolio.getCollectionId(); + List collectionElementList = collectionElementService.getByCollectionId(collectionId); + for (CollectionElement element : collectionElementList) { + if (StringUtils.isEmpty(element.getUrl())) { + continue; + } + element.setUrl(minioUtil.getPresignedUrl(element.getUrl(), 24 * 60)); + } + vo.setCollectionElementList(collectionElementList); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfit::getCollectionId, portfolio.getCollectionId()); + List designPythonOutfitList = designPythonOutfitMapper.selectList(qw); + for (TDesignPythonOutfit tDesignPythonOutfit : designPythonOutfitList) { + tDesignPythonOutfit.setDesignUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); + } + vo.setDesignPythonOutfitList(designPythonOutfitList); + return vo; + } + + @Override + public UserLikeChooseVO choose(PortfolioDTO portfolioDTO) { + AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder(); + UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId()); + UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null); + userLikeGroupNew.setAccountId(authPrincipalVo.getId()); + Long collectionIdOld = userLikeGroup.getCollectionId(); + Collection collectionOld = collectionMapper.selectById(collectionIdOld); + List collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld); + collectionOld.setId(null); + collectionMapper.insert(collectionOld); + Long collectionIdNew = collectionOld.getId(); + + Workspace workspace = workspaceService.getCurrentWorkspace(); + Design design = new Design(); + design.setCollectionId(collectionIdNew); + design.setAccountId(authPrincipalVo.getId()); + if (workspace.getSex().equals(Sex.FEMALE.getValue())) { + design.setTemplateId(workspace.getMannequinFemaleId()); + design.setModelType(workspace.getMannequinFemaleType()); + }else { + design.setTemplateId(workspace.getMannequinMaleId()); + design.setModelType(workspace.getMannequinMaleType()); + } + design.setSystemScale(BigDecimal.valueOf(workspace.getSystemDesignerPercentage())); + if (workspace.getPosition().equals(Position.OVERALL.getValue())) { + design.setSingleOverall("overall"); + design.setSwitchCategory(""); + }else { + design.setSingleOverall("single"); + design.setSwitchCategory(workspace.getPosition()); + } + design.setCreateDate(new Date()); + designMapper.insert(design); + + userLikeGroupNew.setCollectionId(collectionIdNew); + userLikeGroupMapper.insert(userLikeGroupNew); +// List collectionElementRelationListNew = new ArrayList<>(); + for (CollectionElement element : collectionElementListOld) { + element.setCollectionId(collectionIdNew); + element.setId(null); + collectionElementMapper.insert(element); + TCollectionElementRelation collectionElementRelationNew = new TCollectionElementRelation(); + collectionElementRelationNew.setCollectionId(collectionIdNew); + collectionElementRelationNew.setElementId(element.getId()); + collectionElementRelationNew.setCreateDate(new Date()); + collectionElementRelationMapper.insert(collectionElementRelationNew); + } + + List userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId()); + + for (UserLike userLike : userLikeList) { + Long designOutfitIdOld = userLike.getDesignOutfitId(); + TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld); + designPythonOutfit.setDesignId(design.getId()); + designPythonOutfit.setDesignItemId(-1L); + designPythonOutfit.setCollectionId(collectionIdNew); + + designPythonOutfit.setId(null); + designPythonOutfitMapper.insert(designPythonOutfit); + Long designOutfitIdNew = designPythonOutfit.getId(); + userLike.setDesignOutfitId(designOutfitIdNew); + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld); + List tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw); + for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) { +// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId(); + tDesignPythonOutfitDetail.setId(null); + tDesignPythonOutfitDetail.setDesignId(-1L); + tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew); + designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail); + } + + Long designItemIdOld = userLike.getDesignItemId(); + DesignItem designItemOld = designItemMapper.selectById(designItemIdOld); + designItemOld.setId(null); + designItemOld.setAccountId(-1L); + designItemOld.setDesignId(-1L); + designItemOld.setCollectionId(collectionIdNew); + designItemMapper.insert(designItemOld); + Long designItemIdNew = designItemOld.getDesignId(); + + designPythonOutfit.setDesignItemId(designItemIdNew); + designPythonOutfitMapper.updateById(designPythonOutfit); + + userLike.setDesignItemId(designItemIdNew); + userLike.setId(null); + userLike.setDesignId(design.getId()); + userLike.setUserLikeGroupId(userLikeGroupNew.getId()); + userLikeMapper.insert(userLike); + QueryWrapper designItemDetailQueryWrapper = new QueryWrapper<>(); + designItemDetailQueryWrapper.lambda().eq(DesignItemDetail::getDesignItemId, designItemOld); + List designItemDetailListOld = designItemDetailMapper.selectList(designItemDetailQueryWrapper); + for (DesignItemDetail designItemDetailOld : designItemDetailListOld) { + Long designItemDetailIdOld = designItemDetailOld.getId(); + designItemDetailOld.setAccountId(authPrincipalVo.getId()); + designItemDetailOld.setDesignId(design.getId()); + designItemDetailOld.setDesignItemId(designItemIdNew); + designItemDetailMapper.insert(designItemDetailOld); + Long designItemDetailIdNew = designItemDetailOld.getId(); + QueryWrapper designItemDetailPrintQueryWrapper = new QueryWrapper<>(); + designItemDetailPrintQueryWrapper.lambda().eq(DesignItemDetailPrint::getDesignItemDetailId, designItemDetailIdOld); + DesignItemDetailPrint designItemDetailPrint = designItemDetailPrintMapper.selectOne(designItemDetailPrintQueryWrapper); + designItemDetailPrint.setDesignItemDetailId(designItemDetailIdNew); + designItemDetailPrintMapper.insert(designItemDetailPrint); + } + } + + return userLikeGroupService.choose(userLikeGroupNew.getId()); + } +} diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index 29d70e13..4f5ff929 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -123,15 +123,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl userLikeVOS = userLikeService.getGroupDetail(userGroupId); String sex = null; -// if (CollectionUtil.isNotEmpty(userLikeVOS)) { -// Long designId = userLikeVOS.get(0).getDesignId(); -// Design design = designMapper.selectById(designId); -// if (design.getModelType().equals(ModelType.SYSTEM.getValue())) { -// sex = sysFileMapper.selectById(design.getTemplateId()).getLevel2Type(); -// }else { -// sex = libraryMapper.selectById(design.getTemplateId()).getLevel2Type(); -// } -// } userLikeVOS.forEach(o -> { TDesignPythonOutfit tDesignPythonOutfit1 = designPythonOutfitMapper.selectById(o.getDesignOutfitId()); o.setUrl(tDesignPythonOutfit1.getDesignUrl()); diff --git a/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java index 29b53710..9d44d2dd 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeServiceImpl.java @@ -81,4 +81,11 @@ public class UserLikeServiceImpl extends ServiceImpl i baseMapper.update(null,uw); } + @Override + public List getUserLikeList(Long id) { + QueryWrapper qw = new QueryWrapper<>(); + qw.lambda().eq(UserLike::getUserLikeGroupId, id); + return userLikeMapper.selectList(qw); + } + } diff --git a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java index 6d1478ec..27cf5854 100644 --- a/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/WorkspaceServiceImpl.java @@ -37,6 +37,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; +import javax.naming.Context; import java.io.*; import java.nio.file.Files; import java.util.ArrayList; @@ -483,6 +484,20 @@ public class WorkspaceServiceImpl extends ServiceImpl qw = new QueryWrapper<>(); + qw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId()); + qw.lambda().eq(Workspace::getIsLastIndex, 1); +// qw.lambda().eq(Workspace::getIsDeleted, 0); + List workspaces = workspaceMapper.selectList(qw); + if (CollectionUtils.isEmpty(workspaces)) { + throw new BusinessException("workspace not found."); + } + return workspaces.get(0); + } + // public static void main(String[] args) throws FileNotFoundException { // String b = "C:\\workspace\\fileData\\aida_men_library\\top\\mens_test_9992.png"; // File pngFile = new File(b); From b3591f879d87e78b54bb8da87c52b1e82545a3cd Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 17 May 2024 15:23:26 +0800 Subject: [PATCH 10/21] =?UTF-8?q?TASK:=E8=AF=95=E7=94=A8=E6=97=B6=E9=97=B4?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ai/da/model/dto/AccountTrialDTO.java | 2 +- .../com/ai/da/service/impl/AccountServiceImpl.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ai/da/model/dto/AccountTrialDTO.java b/src/main/java/com/ai/da/model/dto/AccountTrialDTO.java index 700426a2..c4ef92a9 100644 --- a/src/main/java/com/ai/da/model/dto/AccountTrialDTO.java +++ b/src/main/java/com/ai/da/model/dto/AccountTrialDTO.java @@ -9,5 +9,5 @@ import lombok.EqualsAndHashCode; @Data @ApiModel("AccountTrial") public class AccountTrialDTO extends TrialOrder { - + private String ref; } diff --git a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java index a5932fae..0573a0be 100644 --- a/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/AccountServiceImpl.java @@ -516,7 +516,11 @@ public class AccountServiceImpl extends ServiceImpl impl account.setIsTrial(1); account.setIsBeginner(1); account.setValidStartTime(System.currentTimeMillis()); - account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()); + if (StringUtils.isNotBlank(accountTrialDTO.getRef())) { + account.setValidEndTime(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli()); + }else { + account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()); + } accountMapper.updateById(account); }else { account.setUserName(trialOrder.getUserName()); @@ -524,7 +528,11 @@ public class AccountServiceImpl extends ServiceImpl impl account.setUserEmail(trialOrder.getEmail()); account.setLanguage(Language.ENGLISH.name()); account.setValidStartTime(System.currentTimeMillis()); - account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()); + if (StringUtils.isNotBlank(accountTrialDTO.getRef())) { + account.setValidEndTime(Instant.now().plus(14, ChronoUnit.DAYS).toEpochMilli()); + }else { + account.setValidEndTime(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()); + } account.setCreateDate(new Date()); account.setIsTrial(1); account.setIsBeginner(1); From e634481113a0a3e6a541325185978d6173f31ab1 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 17 May 2024 17:59:04 +0800 Subject: [PATCH 11/21] =?UTF-8?q?TASK:=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../da/common/RabbitMQ/GenerateConsumer.java | 118 +++++++++--------- .../com/ai/da/common/RabbitMQ/SRConsumer.java | 24 ++-- .../com/ai/da/common/task/GenerateTask.java | 2 +- .../com/ai/da/common/task/PaypalTask.java | 2 +- src/main/resources/application-dev.properties | 2 +- 5 files changed, 74 insertions(+), 74 deletions(-) diff --git a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java index 3e8e6a6e..876dfd2c 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/GenerateConsumer.java @@ -154,63 +154,63 @@ public class GenerateConsumer { } - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer1(Message msg, Channel channel) { - generate(msg, channel, "consumer 1"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer2(Message msg, Channel channel) { - generate(msg, channel, "consumer 2"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer3(Message msg, Channel channel) { - generate(msg, channel, "consumer 3"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer4(Message msg, Channel channel) { - generate(msg, channel, "consumer 4"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer5(Message msg, Channel channel) { - generate(msg, channel, "consumer 5"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer6(Message msg, Channel channel) { - generate(msg, channel, "consumer 6"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer7(Message msg, Channel channel) { - generate(msg, channel, "consumer 7"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer8(Message msg, Channel channel) { - generate(msg, channel, "consumer 8"); - } - - @RabbitListener(queues = MQConfig.GENERATE_QUEUE) - @RabbitHandler - public void generateConsumer9(Message msg, Channel channel) { - generate(msg, channel, "consumer 9"); - } - - @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) - @RabbitHandler - public void getGenerateResult(Message msg, Channel channel) { - processGenerateResult(msg, channel); - } +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer1(Message msg, Channel channel) { +// generate(msg, channel, "consumer 1"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer2(Message msg, Channel channel) { +// generate(msg, channel, "consumer 2"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer3(Message msg, Channel channel) { +// generate(msg, channel, "consumer 3"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer4(Message msg, Channel channel) { +// generate(msg, channel, "consumer 4"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer5(Message msg, Channel channel) { +// generate(msg, channel, "consumer 5"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer6(Message msg, Channel channel) { +// generate(msg, channel, "consumer 6"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer7(Message msg, Channel channel) { +// generate(msg, channel, "consumer 7"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer8(Message msg, Channel channel) { +// generate(msg, channel, "consumer 8"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_QUEUE) +// @RabbitHandler +// public void generateConsumer9(Message msg, Channel channel) { +// generate(msg, channel, "consumer 9"); +// } +// +// @RabbitListener(queues = MQConfig.GENERATE_RESULT_QUEUE) +// @RabbitHandler +// public void getGenerateResult(Message msg, Channel channel) { +// processGenerateResult(msg, channel); +// } } diff --git a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java index 6ad261bd..b8ba32f2 100644 --- a/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java +++ b/src/main/java/com/ai/da/common/RabbitMQ/SRConsumer.java @@ -218,17 +218,17 @@ public class SRConsumer { taskListService.updateTaskStatusOrOutputRedis(uniqueId, "fail", null); } - @RabbitListener(queues = MQConfig.SR_QUEUE) - @RabbitHandler - public void SRConsumer1(Message msg, Channel channel) { - superResolution(msg, channel, "consumer 1"); - } - - - @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) - @RabbitHandler - public void SRResultConsumer1(Message msg, Channel channel) { - getSRResult(msg, channel, "consumer 1"); - } +// @RabbitListener(queues = MQConfig.SR_QUEUE) +// @RabbitHandler +// public void SRConsumer1(Message msg, Channel channel) { +// superResolution(msg, channel, "consumer 1"); +// } +// +// +// @RabbitListener(queues = MQConfig.SR_RESULT_QUEUE) +// @RabbitHandler +// public void SRResultConsumer1(Message msg, Channel channel) { +// getSRResult(msg, channel, "consumer 1"); +// } } diff --git a/src/main/java/com/ai/da/common/task/GenerateTask.java b/src/main/java/com/ai/da/common/task/GenerateTask.java index 6d13d68f..038976d0 100644 --- a/src/main/java/com/ai/da/common/task/GenerateTask.java +++ b/src/main/java/com/ai/da/common/task/GenerateTask.java @@ -8,7 +8,7 @@ import org.springframework.stereotype.Component; @Slf4j public class GenerateTask { - @Scheduled(cron = "0 0 */1 * * ?") +// @Scheduled(cron = "0 0 */1 * * ?") public void generateScheduled(){ log.info("测试定时器:generate"); diff --git a/src/main/java/com/ai/da/common/task/PaypalTask.java b/src/main/java/com/ai/da/common/task/PaypalTask.java index bc0e24dd..65d5b8a3 100644 --- a/src/main/java/com/ai/da/common/task/PaypalTask.java +++ b/src/main/java/com/ai/da/common/task/PaypalTask.java @@ -23,7 +23,7 @@ public class PaypalTask { @Resource private PayPalCheckoutService payPalCheckoutService; - @Scheduled(cron = "0/30 * * * * ?") +// @Scheduled(cron = "0/30 * * * * ?") public void orderConfirm() throws SerializeException { log.info("PayPal orderConfirm 被执行......"); diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 52ec17cb..a1a25366 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -21,7 +21,7 @@ spring.security.jwtExpiration=8640000000 #spring security权限设置 认证了token还要认证权限 不然报错Full authentication is required to access this resource spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\ /api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\ - /api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR + /api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/portfolio/** spring.security.authApi=/auth/login From 4b1a58c036d97ee8f46aa4462010d54064c848a3 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Fri, 17 May 2024 20:58:54 +0800 Subject: [PATCH 12/21] =?UTF-8?q?TASK:=E6=A3=80=E6=9F=A5=E4=BB=A4=E7=89=8C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B3=A8=E9=87=8A;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/common/utils/SendEmailUtil.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 15f2e95b..ca778537 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -355,7 +355,9 @@ public class SendEmailUtil { } private final static Long UPGRADE_NOTIFICATION_ID = 118855L; + private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID = 118856L; private final static Long UPGRADE_NOTIFICATION_ID_CHINESE = 122898L; + private final static Long UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE = 122899L; public static void sendUpgradeNotification(Account account, String senderAddress, Integer type) { try { // 实例化一个认证对象 @@ -375,12 +377,19 @@ public class SendEmailUtil { // 根据邮件类型设置不同的主题和模板 String subject = ""; Template template = new Template(); +// if (type == 1) { +// subject = "Upcoming System Upgrade for AiDA 3.0"; +// template.setTemplateID(UPGRADE_NOTIFICATION_ID); +// }else { +// subject = "即将到来的AiDA 3.0系统升级"; +// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE); +// } if (type == 1) { - subject = "Upcoming System Upgrade for AiDA 3.0"; - template.setTemplateID(UPGRADE_NOTIFICATION_ID); + subject = "Successful System Upgrade and New Features in AiDA 3.0"; + template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID); }else { - subject = "即将到来的AiDA 3.0系统升级"; - template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE); + subject = "系统升级成功和AiDA 3.0新功能"; + template.setTemplateID(UPGRADE_SUCCESS_NOTIFICATION_ID_CHINESE); } template.setTemplateData(buildAccountData(account)); From c4a37f5d73a3eece4345caaa1b4c6955fc60dc80 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Mon, 20 May 2024 09:34:20 +0800 Subject: [PATCH 13/21] =?UTF-8?q?TASK:=E9=82=AE=E4=BB=B6;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/common/config/MyTaskScheduler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java index 6e443ba9..647c0f38 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -68,7 +68,7 @@ public class MyTaskScheduler { } } } - @Scheduled(cron = "0 0 8 * * ?") +// @Scheduled(cron = "0 0 8 * * ?") public void sendTrialOrderExcelToManagements() { // 获取前一天日期 LocalDate yesterday = LocalDate.now().minusDays(1); From f9ce5599152560298ca75ae904e8bf4157dfbf3d Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 21 May 2024 14:40:46 +0800 Subject: [PATCH 14/21] =?UTF-8?q?paypal=20=E5=88=87=E6=8D=A2=E5=9B=9Esandb?= =?UTF-8?q?ox=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/paypal-sandbox.properties | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/resources/paypal-sandbox.properties b/src/main/resources/paypal-sandbox.properties index 3b0eaef2..8c1e7208 100644 --- a/src/main/resources/paypal-sandbox.properties +++ b/src/main/resources/paypal-sandbox.properties @@ -9,15 +9,15 @@ #paypal.webhook_id=51V87014T6406322F # aida-sandbox-kim -#paypal.client-id=AbDDH8jnTrKqjnWLFgEu6LogYzVz2ZLuirE4W54t1M4lrofrP5OzXfhbxqktLLFB-rAO9KeYQVYFJ_tO -#paypal.client-secret=EOOoiIAe_dyR2YhY7qCIqWipZvYXCDrmBlFYchphuvkPFms1spsBGTlStlrx580y4hN-EukWwF9m_LAs -#paypal.receiver.email=sb-4xe8i29784722@business.example.com -#paypal.mode=sandbox -#paypal.webhook_id=1WH327112B602422N +paypal.client-id=AbDDH8jnTrKqjnWLFgEu6LogYzVz2ZLuirE4W54t1M4lrofrP5OzXfhbxqktLLFB-rAO9KeYQVYFJ_tO +paypal.client-secret=EOOoiIAe_dyR2YhY7qCIqWipZvYXCDrmBlFYchphuvkPFms1spsBGTlStlrx580y4hN-EukWwF9m_LAs +paypal.receiver.email=sb-4xe8i29784722@business.example.com +paypal.mode=sandbox +paypal.webhook_id=1WH327112B602422N # aida-live-kim -paypal.client-id=ASWSIZ3MXJU5w5VOeOHeigWcSw6iinl30ZCipruziKpHclxP0ryf8-7VKG1Ba2VwZwa2DMvGEzTfCTgz -paypal.client-secret=EHQg_K5PSqmp4FJlzEcOEH_kFkmq4aBzaI7jridw53L6cOQRULBAnfv2KakRfrsqaU1PDSkO4Co9Vyxc -paypal.receiver.email=kimwong@code-create.com.hk -paypal.mode=live -paypal.webhook_id=41L14847MC833625B \ No newline at end of file +#paypal.client-id=ASWSIZ3MXJU5w5VOeOHeigWcSw6iinl30ZCipruziKpHclxP0ryf8-7VKG1Ba2VwZwa2DMvGEzTfCTgz +#paypal.client-secret=EHQg_K5PSqmp4FJlzEcOEH_kFkmq4aBzaI7jridw53L6cOQRULBAnfv2KakRfrsqaU1PDSkO4Co9Vyxc +#paypal.receiver.email=kimwong@code-create.com.hk +#paypal.mode=live +#paypal.webhook_id=41L14847MC833625B \ No newline at end of file From cd817dbf574cb9d69313e71630ecf1eac4999848 Mon Sep 17 00:00:00 2001 From: shahaibo <1023316923@qq.com> Date: Wed, 22 May 2024 09:50:34 +0800 Subject: [PATCH 15/21] TASK:style; --- .../ai/da/common/config/MyTaskScheduler.java | 4 +- .../ai/da/controller/WorkspaceController.java | 19 ++- .../com/ai/da/mapper/primary/StyleMapper.java | 17 +++ .../primary/WorkspaceRelStyleMapper.java | 15 +++ .../ai/da/mapper/primary/entity/Style.java | 17 +++ .../primary/entity/WorkspaceRelStyle.java | 18 +++ .../com/ai/da/model/dto/WorkspaceDTO.java | 2 + .../java/com/ai/da/model/enums/StyleEnum.java | 57 +++++++++ src/main/java/com/ai/da/model/vo/StyleVO.java | 16 +++ .../java/com/ai/da/model/vo/WorkspaceVO.java | 2 + .../com/ai/da/service/WorkspaceService.java | 8 +- .../da/service/impl/WorkspaceServiceImpl.java | 119 ++++++++++-------- 12 files changed, 234 insertions(+), 60 deletions(-) create mode 100644 src/main/java/com/ai/da/mapper/primary/StyleMapper.java create mode 100644 src/main/java/com/ai/da/mapper/primary/WorkspaceRelStyleMapper.java create mode 100644 src/main/java/com/ai/da/mapper/primary/entity/Style.java create mode 100644 src/main/java/com/ai/da/mapper/primary/entity/WorkspaceRelStyle.java create mode 100644 src/main/java/com/ai/da/model/enums/StyleEnum.java create mode 100644 src/main/java/com/ai/da/model/vo/StyleVO.java diff --git a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java index 6e443ba9..bd8f2687 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -34,7 +34,7 @@ public class MyTaskScheduler { // 定时任务,每十五天执行一次 // @Scheduled(cron = "0 0 0 ? * MON") - @Scheduled(cron = "0 0 0 */15 * ?") +// @Scheduled(cron = "0 0 0 */15 * ?") public void checkExpiry() { // 检测正式用户是否快要过期 QueryWrapper qw = new QueryWrapper<>(); @@ -68,7 +68,7 @@ public class MyTaskScheduler { } } } - @Scheduled(cron = "0 0 8 * * ?") +// @Scheduled(cron = "0 0 8 * * ?") public void sendTrialOrderExcelToManagements() { // 获取前一天日期 LocalDate yesterday = LocalDate.now().minusDays(1); diff --git a/src/main/java/com/ai/da/controller/WorkspaceController.java b/src/main/java/com/ai/da/controller/WorkspaceController.java index b0c089f0..e5346487 100644 --- a/src/main/java/com/ai/da/controller/WorkspaceController.java +++ b/src/main/java/com/ai/da/controller/WorkspaceController.java @@ -1,10 +1,12 @@ package com.ai.da.controller; import com.ai.da.common.response.Response; +import com.ai.da.mapper.primary.entity.Style; import com.ai.da.mapper.primary.entity.Workspace; import com.ai.da.model.dto.WorkspaceDTO; import com.ai.da.model.enums.BizJson; import com.ai.da.model.vo.ModelsVO; +import com.ai.da.model.vo.StyleVO; import com.ai.da.model.vo.WorkspaceVO; import com.ai.da.service.WorkspaceService; import io.swagger.annotations.Api; @@ -44,8 +46,8 @@ public class WorkspaceController { @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入workspace") - public Response detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) { - Workspace detail = workspaceService.getByIdNew(id); + public Response detail(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) { + WorkspaceVO detail = workspaceService.getByIdNew(id); return Response.success(detail); } @@ -66,8 +68,8 @@ public class WorkspaceController { @PostMapping("/saveOrUpdate") @ApiOperationSupport(order = 3) @ApiOperation(value = "新增或编辑", notes = "传入workspace") - public Response saveOrUpdate(@Valid @RequestBody Workspace workspace) { - return Response.success(workspaceService.saveOrUpdate(workspace)); + public Response saveOrUpdate(@Valid @RequestBody WorkspaceDTO workspaceDTO) { + return Response.success(workspaceService.saveOrUpdate(workspaceDTO)); } @@ -115,10 +117,17 @@ public class WorkspaceController { } @PostMapping("maleDataInsert") - @ApiOperationSupport(order = 7) + @ApiOperationSupport(order = 8) @ApiOperation(value = "男装数据入库入minio") public Response maleDataInsert() throws FileNotFoundException { workspaceService.maleDataInsert(); return Response.success(true); } + + @PostMapping("styleList") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "获取style列表") + public Response> styleList() { + return Response.success(workspaceService.styleList()); + } } diff --git a/src/main/java/com/ai/da/mapper/primary/StyleMapper.java b/src/main/java/com/ai/da/mapper/primary/StyleMapper.java new file mode 100644 index 00000000..be697be8 --- /dev/null +++ b/src/main/java/com/ai/da/mapper/primary/StyleMapper.java @@ -0,0 +1,17 @@ +package com.ai.da.mapper.primary; + +import com.ai.da.common.config.mybatis.plus.CommonMapper; +import com.ai.da.mapper.primary.entity.Style; + +import java.util.List; + +/** + * Mapper 接口 + * + * @author easy-generator + * @since 2022-06-13 + */ +public interface StyleMapper extends CommonMapper