59 Commits

Author SHA1 Message Date
litianxiang
a8e3304db2 Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev-ltx 2025-11-25 11:45:49 +08:00
litianxiang
26f2299381 designSingle改为直接在源数据进行修改而不是逻辑删除再创建新数据 2025-11-25 11:45:09 +08:00
litianxiang
db1048d875 第二数据源修改库名 2025-11-21 16:49:07 +08:00
630f6b2737 Merge branch 'release/3.1' into dev/3.1_release_merge 2025-11-20 15:48:03 +08:00
d14fdfee79 Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-20 11:11:21 +08:00
c14db62c0a BUGFIX:1.添加系统sketch到个人library 2.video生成结束后总是发送失败站内信 2025-11-20 11:09:20 +08:00
litianxiang
9166bf1a1a Merge remote-tracking branch 'origin/dev-ltx' into dev/3.1_release_merge 2025-11-20 10:50:17 +08:00
litianxiang
84c024eab8 Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev-ltx 2025-11-20 10:48:57 +08:00
litianxiang
b86f3c9f7e 1.fix:高级工具转产品图不需要也没有ageGroup,会导致报错
2.上传sketch模板代码
2025-11-20 10:48:36 +08:00
e2009617db Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-19 17:00:29 +08:00
65b17fe109 TASK:调用第三方api,视频生成结束发送站内信 2025-11-19 16:59:54 +08:00
0917154283 Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-19 15:58:11 +08:00
0f525c6c00 BUGFIX: 1.系统消息已读需判断接收人员 2.本地模型视频生成失败时,发送站内信 2025-11-19 15:57:47 +08:00
4beae1094b Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-18 17:45:53 +08:00
cefdac133e BUGFIX: 获取系统通知未读数 2025-11-18 17:45:11 +08:00
a466f269c2 Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-18 16:04:37 +08:00
97f0c8f65f BUGFIX: 获取系统通知未读数 2025-11-18 16:02:26 +08:00
ad00ac08ca Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-18 14:10:24 +08:00
d236057f2a BUGFIX: 获取系统通知未读数 2025-11-18 14:09:58 +08:00
62e3e9c16f Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-18 13:32:16 +08:00
604c529b42 BUGFIX: 视频生成完成后,站内信通知 2025-11-18 13:31:18 +08:00
bc612481dc Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-18 10:28:44 +08:00
2f3fa695b2 BUGFIX: 解决部分循环注入问题 2025-11-18 10:27:29 +08:00
313fc19dac Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-17 16:56:50 +08:00
f36e0488ea TASK: video生成成功后添加站内信通知 2025-11-17 16:55:45 +08:00
f239c8c02b TASK: 订阅或试用用户账号到期邮件通知 2025-11-14 18:08:40 +08:00
litianxiang
1d4017bafd minio上传base64 log补充信息 2025-11-14 15:57:49 +08:00
litianxiang
8c98f91445 minio上传base64 log补充信息 2025-11-14 15:42:24 +08:00
18f5528d59 Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-14 14:52:29 +08:00
88ce191950 TASK:1.订阅成功和续签成功,通知商家的邮件中添加邮件和国家 2.在getModuleContent的回参中添加motion相关数据 3.修改Affiliate账号状态与修改佣金比例接口合并 2025-11-14 14:51:30 +08:00
litianxiang
f3d6d7b000 fix:进行design后library中可能会生成同样的图片
fix:ageGroup在designSingle时不会被存入数据库导致收藏页面不能显示完整
2025-11-14 13:32:57 +08:00
ef84f32ca0 TASK:添加系统sketch到个人library 性别细节修改 2025-11-13 14:24:07 +08:00
3886aeaa46 Merge branch 'dev/dev_xp' into dev/3.1_release_merge
# Conflicts:
#	src/main/java/com/ai/da/python/PythonService.java
#	src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java
2025-11-13 13:41:31 +08:00
8750ea355a TASK:1.修改affiliate状态 2.添加系统sketch到个人library 3.视频生成新增生成模型 4.获取所有pose,从过去gif改为获取video 2025-11-13 11:40:37 +08:00
litianxiang
b107fa82df 修改第二数据源位置 2025-11-13 11:24:14 +08:00
litianxiang
e56a6176a9 fix:为BoundingBox返回值排序解决每次获取可能会排序错误的bug 2025-11-13 10:51:00 +08:00
litianxiang
e35ed2c768 转产品图提示词更换 2025-11-12 17:25:46 +08:00
litianxiang
52094d58e7 Merge remote-tracking branch 'origin/dev-ltx' into dev/3.1_release_merge 2025-11-12 13:50:14 +08:00
litianxiang
e4e6cfbff7 sketch暂时修改为java端推荐,根据style进行推荐 2025-11-12 13:49:01 +08:00
litianxiang
15f2b78c94 配饰detail显示问题 2025-11-07 11:50:13 +08:00
litianxiang
1fd1f7dd47 配饰更换为其他 2025-11-06 17:20:05 +08:00
litianxiang
2a6d3c1b58 fix:初次从收藏和生成的线稿,再刷新前不会被用于design 2025-11-06 15:21:37 +08:00
59e33c22b7 Merge branch 'dev/dev_xp' into dev/3.1_release_merge 2025-11-05 17:25:21 +08:00
e5eecbfe8d BUGFIX: 路径修改 2025-11-05 17:24:46 +08:00
9759cf4740 BUGFIX: volcengine依赖包使用指定版本 2025-11-05 17:04:31 +08:00
e8766b9af3 Merge branch 'dev/dev_xp' into dev/3.1_release_merge
# Conflicts:
#	src/main/java/com/ai/da/common/config/MyTaskScheduler.java
#	src/main/java/com/ai/da/common/task/PaymentTask.java
2025-11-05 16:51:41 +08:00
4fed5f7439 BUGFIX: design single - sketch modify 2025-11-05 16:40:31 +08:00
litianxiang
c3e0a61ff7 Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev-ltx 2025-11-04 16:41:08 +08:00
litianxiang
58212e92ec 增加配饰类别 2025-11-04 16:37:57 +08:00
5efaaf01b2 task:motion 本地模型接口调用地址修改 2025-11-03 13:10:37 +08:00
18c94ad1e0 BUGFIX:取消续订提前邮件通知 2025-10-30 16:44:45 +08:00
e825c9bd75 BUGFIX:用户订阅后,订阅者和商家无法收到通知邮件 2025-10-22 10:48:29 +08:00
1af705592a BUGFIX:1.design中dislike后排序混乱 2.续订成功通知会再次通知上一次的成功订阅 2025-10-17 17:59:43 +08:00
litianxiang
d426fb34a2 Merge remote-tracking branch 'origin/dev-ltx' into dev/3.1_release_merge 2025-10-16 11:52:20 +08:00
litianxiang
a76b9ba365 Merge remote-tracking branch 'origin/dev/3.1_release_merge' into dev/3.1_release_merge 2025-10-16 11:00:36 +08:00
cd74022d04 BUGFIX:generateLike添加年龄段 2025-10-16 10:03:57 +08:00
a3e63c9877 BUGFIX:排序优化 2025-10-15 18:32:19 +08:00
0c227a1efa BUGFIX:排序优化 2025-10-15 18:03:48 +08:00
litianxiang
59602540a3 Merge remote-tracking branch 'origin/dev-ltx' into dev/3.1_release_merge 2025-10-15 16:03:56 +08:00
90 changed files with 6494 additions and 5533 deletions

1
.gitignore vendored
View File

@@ -48,3 +48,4 @@ log
temp/ temp/
docker-compose.yml docker-compose.yml
/src/main/resources/application-local.properties

View File

@@ -403,7 +403,7 @@
<dependency> <dependency>
<groupId>com.volcengine</groupId> <groupId>com.volcengine</groupId>
<artifactId>volcengine-java-sdk-ark-runtime</artifactId> <artifactId>volcengine-java-sdk-ark-runtime</artifactId>
<version>LATEST</version> <version>0.2.43</version>
</dependency> </dependency>
<!-- Google 认证库 --> <!-- Google 认证库 -->

View File

@@ -6,10 +6,7 @@ import com.ai.da.common.utils.RedisUtil;
import com.ai.da.model.dto.GenerateThroughImageTextDTO; import com.ai.da.model.dto.GenerateThroughImageTextDTO;
import com.ai.da.model.vo.GenerateResultVO; import com.ai.da.model.vo.GenerateResultVO;
import com.ai.da.model.vo.PoseTransformationVO; import com.ai.da.model.vo.PoseTransformationVO;
import com.ai.da.service.CloudTaskService; import com.ai.da.service.*;
import com.ai.da.service.DesignService;
import com.ai.da.service.GenerateService;
import com.ai.da.service.UserLikeGroupService;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
@@ -17,17 +14,16 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler; import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
@@ -37,25 +33,22 @@ import java.util.Objects;
@Slf4j @Slf4j
@Component @Component
@RequiredArgsConstructor
public class GenerateConsumer { public class GenerateConsumer {
@Resource private final GenerateService generateService;
private GenerateService generateService;
@Resource private final UserLikeGroupService userLikeGroupService;
private UserLikeGroupService userLikeGroupService;
@Resource private final DesignService designService;
private DesignService designService;
@Resource private final CloudTaskService cloudTaskService;
private CloudTaskService cloudTaskService;
@Autowired private final RabbitMQProperties rabbitMQProperties;
private RabbitMQProperties rabbitMQProperties;
@Resource private final RedisUtil redisUtil;
private RedisUtil redisUtil;
private final MessageCenterService messageCenterService;
@Value("${redis.key.orderForGenerate}") @Value("${redis.key.orderForGenerate}")
private String consumptionOrderKey; private String consumptionOrderKey;
@@ -301,8 +294,11 @@ public class GenerateConsumer {
exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("message")); exceptionInfo.put(generateResult.get("tasks_id"), generateResult.get("message"));
// 存redis // 存redis
redisUtil.addToMap(exceptionMapKey, exceptionInfo); redisUtil.addToMap(exceptionMapKey, exceptionInfo);
// 记录失败状态并向用户发送提示消息
generateService.processPTFailSituation(generateResult.get("tasks_id"));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
try { try {
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false); channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
@@ -318,6 +314,8 @@ public class GenerateConsumer {
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage); exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
// 存redis // 存redis
redisUtil.addToMap(exceptionMapKey, exceptionInfo); redisUtil.addToMap(exceptionMapKey, exceptionInfo);
// 记录失败状态并向用户发送提示消息
generateService.processPTFailSituation(generateResult.get("tasks_id"));
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();

View File

@@ -164,7 +164,7 @@ public class MyTaskScheduler {
// 定时任务,每十五天执行一次 // 定时任务,每十五天执行一次
// @Scheduled(cron = "0 0 0 ? * MON") // @Scheduled(cron = "0 0 0 ? * MON")
@Scheduled(cron = "0 0 0 */15 * ?") // @Scheduled(cron = "0 0 0 */15 * ?")
public void checkExpiry() { public void checkExpiry() {
// 检测正式用户是否快要过期 // 检测正式用户是否快要过期
QueryWrapper<Account> qw = new QueryWrapper<>(); QueryWrapper<Account> qw = new QueryWrapper<>();
@@ -200,7 +200,7 @@ public class MyTaskScheduler {
} }
} }
} }
@Scheduled(cron = "0 0 9 * * ?") // @Scheduled(cron = "0 0 9 * * ?")
public void sendTrialOrderExcelToManagements() { public void sendTrialOrderExcelToManagements() {
// 获取前一天日期 // 获取前一天日期
LocalDate yesterday = LocalDate.now().minusDays(1); LocalDate yesterday = LocalDate.now().minusDays(1);

View File

@@ -32,7 +32,8 @@ public class CommonConstant {
public static final String GENERATE_LOGO_SINGLE_CANCEL = "/api/generate_single_logo_cancel/"; public static final String GENERATE_LOGO_SINGLE_CANCEL = "/api/generate_single_logo_cancel/";
public static final String POSE_TRANSFORMATION_CANCEL = "/api/pose_transform_cancel/"; // public static final String POSE_TRANSFORMATION_CANCEL = "/api/pose_transform_cancel/";
public static final String POSE_TRANSFORMATION_CANCEL = "/api/comfyui_i_2_video_cancel/";
public static final String PYTHON_PORT_9996 = "9996"; public static final String PYTHON_PORT_9996 = "9996";

View File

@@ -68,4 +68,7 @@ public enum CollectionLevel2TypeEnum {
public static List<String> printType() { public static List<String> printType() {
return Arrays.asList(LOGO.getRealName(), SLOGAN.getRealName(), Pattern.getRealName()); return Arrays.asList(LOGO.getRealName(), SLOGAN.getRealName(), Pattern.getRealName());
} }
public static CollectionLevel2TypeEnum ofWithLoweCase(String realName) {
return Stream.of(CollectionLevel2TypeEnum.values()).filter(v -> v.getRealName().toLowerCase().equals(realName)).findFirst().orElse(null);
}
} }

View File

@@ -0,0 +1,29 @@
package com.ai.da.common.enums;
import lombok.Getter;
import java.util.stream.Stream;
@Getter
public enum MotionModeEnum {
POSE_TO_VIDEO(1, "/api/comfyui_image_pose_2_video"),
PROMPT_TO_VIDEO(2, "/api/comfyui_image_2_video"),
FIRST_LAST_FRAME_TO_VIDEO(3, "/api/comfyui_flf_2_video")
;
private int code;
private String url;
MotionModeEnum(int code, String url) {
this.code = code;
this.url = url;
}
public static MotionModeEnum of(int code) {
return Stream.of(MotionModeEnum.values()).filter(v -> v.getCode()== code).findFirst().orElse(null);
}
}

View File

@@ -64,6 +64,7 @@ public enum PoseEnum {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("id", String.valueOf(id)); map.put("id", String.valueOf(id));
map.put("gif", gifPath); map.put("gif", gifPath);
map.put("video", videoPath);
map.put("firstFrame", firstFramePath); map.put("firstFrame", firstFramePath);
return map; return map;
} }

View File

@@ -31,7 +31,7 @@ public class AccountTask {
accountService.refreshCreditsMonthly(); accountService.refreshCreditsMonthly();
} }
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes // @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
public void getPaidUser() { public void getPaidUser() {
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单 // 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
accountService.extendValidityForCC(); accountService.extendValidityForCC();

View File

@@ -6,12 +6,10 @@ import com.ai.da.mapper.primary.PoseTransformationMapper;
import com.ai.da.mapper.primary.ToProductImageResultMapper; import com.ai.da.mapper.primary.ToProductImageResultMapper;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.vo.PoseTransformationVO; import com.ai.da.model.vo.PoseTransformationVO;
import com.ai.da.service.APIGenerateService; import com.ai.da.service.*;
import com.ai.da.service.CreditsService;
import com.ai.da.service.GenerateService;
import com.ai.da.service.MessageCenterService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -25,19 +23,13 @@ import static com.ai.da.common.enums.CreditsEventsEnum.TO_PRODUCT_IMAGE;
@Slf4j @Slf4j
@Component @Component
@RequiredArgsConstructor
public class GenerateTask { public class GenerateTask {
@Resource private final APIGenerateService apiGenerateService;
private APIGenerateService apiGenerateService; private final CreditsService creditsService;
@Resource private final GenerateService generateService;
private CreditsService creditsService; private final PoseTransformationMapper poseTransformationMapper;
@Resource private final ToProductImageResultMapper toProductImageResultMapper;
private GenerateService generateService;
@Resource
private MessageCenterService messageCenterService;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private PoseTransformationMapper poseTransformationMapper;
/* /*
@@ -106,15 +98,16 @@ public class GenerateTask {
} }
// 万相 -> pose transformation 补偿 一小时执行一次 // 万相 -> pose transformation 补偿 当前任务执行完后5分钟再执行一次不会出现任务重叠的情况
@Scheduled(fixedDelay = 5 * 60 * 1000) @Scheduled(fixedDelay = 5 * 60 * 1000)
public void wxCompensationMechanism(){ public void wxCompensationMechanism(){
log.info("=====万相补偿获取结果开始=====");
List<APIGenerate> apiGenerates = apiGenerateService.getPendingTaskByStatus("wx"); List<APIGenerate> apiGenerates = apiGenerateService.getPendingTaskByStatus("wx");
if (apiGenerates != null && !apiGenerates.isEmpty()){ if (apiGenerates != null && !apiGenerates.isEmpty()){
for (APIGenerate apiGenerate : apiGenerates){ for (APIGenerate apiGenerate : apiGenerates){
String taskId = apiGenerate.getTaskId(); String taskId = apiGenerate.getTaskId();
PoseTransformation poseTransformation = poseTransformationMapper.selectOne(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId)); PoseTransformation poseTransformation = poseTransformationMapper.selectOne(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId));
if (Objects.nonNull(poseTransformation) && "Pending".equals(poseTransformation.getTaskStatus())){ if (Objects.nonNull(poseTransformation) && ("Pending".equals(poseTransformation.getTaskStatus()) || "Executing".equals(poseTransformation.getTaskStatus()))){
// 判断当前任务的超时状态 // 判断当前任务的超时状态
if (!DateUtil.isMoreThanOneDayApart(poseTransformation.getCreateTime())){ if (!DateUtil.isMoreThanOneDayApart(poseTransformation.getCreateTime())){
try { try {
@@ -122,7 +115,6 @@ public class GenerateTask {
PoseTransformationVO animateResult = generateService.getAnimateResult(taskId); PoseTransformationVO animateResult = generateService.getAnimateResult(taskId);
if (animateResult.getStatus().equals("Success")){ if (animateResult.getStatus().equals("Success")){
log.info("补偿获取结果成功,发送系统消息"); log.info("补偿获取结果成功,发送系统消息");
sendSysMsgToUser(poseTransformation.getAccountId(), "您的姿势变换生成任务已完成");
} }
} catch (BusinessException e){ } catch (BusinessException e){
log.warn("万相 animation 生成失败,原因:{}", e.getMessage()); log.warn("万相 animation 生成失败,原因:{}", e.getMessage());
@@ -136,19 +128,13 @@ public class GenerateTask {
apiGenerate.setStatus("Fail"); apiGenerate.setStatus("Fail");
apiGenerate.setUpdateTime(LocalDateTime.now()); apiGenerate.setUpdateTime(LocalDateTime.now());
apiGenerateService.updateById(apiGenerate); apiGenerateService.updateById(apiGenerate);
generateService.sendSysMsgForPT(poseTransformation);
} }
} }
} }
} }
public void sendSysMsgToUser(Long accountId, String content){
Notification notification = new Notification();
notification.setType("system");
notification.setReceiverId(accountId);
notification.setContent(content);
messageCenterService.prePushMessage(notification);
}

View File

@@ -87,9 +87,9 @@ public class PaymentTask {
// !!关闭此定时器,改为提前三天站内信提醒!! // !!关闭此定时器,改为提前三天站内信提醒!!
// 提前7天向用户发送提醒邮件,每天早上8点执行 // 提前7天向用户发送提醒邮件,每天早上8点执行
// @Scheduled(cron = "0 0 8 * * ?") // @Scheduled(cron = "0 0 8 * * ?")
public void subscriptionReminder(){ // public void subscriptionReminder(){
stripeService.subscriptionReminder(); // stripeService.subscriptionReminder();
} // }
// 如果有订阅已创建,但是没有发邮件通知的,需要主动获取回调信息并向用户发送邮件 // 如果有订阅已创建,但是没有发邮件通知的,需要主动获取回调信息并向用户发送邮件
@@ -104,7 +104,7 @@ public class PaymentTask {
} }
// 定时同步(每分钟一次) // 定时同步(每分钟一次)
@Scheduled(fixedRate = 60000) // @Scheduled(fixedRate = 60000)
public void syncLinkViewCountToDB(){ public void syncLinkViewCountToDB(){
affiliateService.syncLinkViewCountToDB(); affiliateService.syncLinkViewCountToDB();
} }
@@ -120,7 +120,7 @@ public class PaymentTask {
} }
} }
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes // @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
public void calcCouponsCommission(){ public void calcCouponsCommission(){
log.info("优惠券佣金计算定时器"); log.info("优惠券佣金计算定时器");
affiliateService.calcCouponsCommission(); affiliateService.calcCouponsCommission();

View File

@@ -0,0 +1,129 @@
package com.ai.da.common.task;
import com.ai.da.common.utils.SendEmailUtil;
import com.ai.da.mapper.primary.AccountMapper;
import com.ai.da.mapper.primary.SubscriptionInfoMapper;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.mapper.primary.entity.SubscriptionInfo;
import com.ai.da.service.StripeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RequiredArgsConstructor
public class SubscriptionReminderTask {
public final AccountMapper accountMapper;
public final SubscriptionInfoMapper subscriptionInfoMapper;
public final StripeService stripeService;
// 订阅类型与提前天数的映射配置
private static final Map<String, Integer> REMINDER_DAYS_CONFIG = new HashMap<>();
static {
REMINDER_DAYS_CONFIG.put("monthly", 7);
REMINDER_DAYS_CONFIG.put("yearly", 14);
}
public void subscriptionReminder() {
// 获取所有需要通知的订阅
List<SubscriptionInfo> subscriptionInfos = getDueSubscriptions();
for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
Integer daysBefore = REMINDER_DAYS_CONFIG.get(subscriptionInfo.getType());
if (daysBefore == null) {
log.warn("未知的订阅类型: {}", subscriptionInfo.getType());
continue;
}
boolean success = stripeService.sendEmail(subscriptionInfo.getSubscriptionId(), "reminder_subscriber", null);
if (success) {
log.info("提前{}天向用户 {} 发送续订通知邮件,订阅类型: {}",
daysBefore, subscriptionInfo.getAccountId(), subscriptionInfo.getType());
}
}
}
private List<SubscriptionInfo> getDueSubscriptions() {
List<SubscriptionInfo> results = new ArrayList<>();
for (Map.Entry<String, Integer> entry : REMINDER_DAYS_CONFIG.entrySet()) {
String subscriptionType = entry.getKey();
int daysBefore = entry.getValue();
results.addAll(getSubscriptionsDueInDays(subscriptionType, daysBefore));
}
return results;
}
private List<SubscriptionInfo> getSubscriptionsDueInDays(String subscriptionType, int daysBefore) {
LocalDateTime targetDate = LocalDateTime.now().plusDays(daysBefore);
LocalDateTime startOfDay = targetDate.toLocalDate().atStartOfDay();
LocalDateTime endOfDay = targetDate.toLocalDate().atTime(23, 59, 59);
long startTimestamp = startOfDay.toEpochSecond(ZoneOffset.UTC);
long endTimestamp = endOfDay.toEpochSecond(ZoneOffset.UTC);
QueryWrapper<SubscriptionInfo> qw = new QueryWrapper<>();
qw.ge("current_period_end", startTimestamp);
qw.lt("current_period_end", endTimestamp);
qw.eq("status", "active");
qw.eq("subscription_type", subscriptionType);
return subscriptionInfoMapper.selectList(qw);
}
public void trialReminder() {
// 今天的 00:00:00 和 23:59:59
LocalDateTime startOfDay = LocalDateTime.now().toLocalDate().atStartOfDay();
LocalDateTime endOfDay = LocalDateTime.now().toLocalDate().atTime(23, 59, 59);
// 转为时间戳
long startTimestamp = startOfDay.toEpochSecond(ZoneOffset.UTC);
long endTimestamp = endOfDay.toEpochSecond(ZoneOffset.UTC);
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().gt(Account::getValidEndTime, startTimestamp)
.lt(Account::getValidEndTime, endTimestamp)
.eq(Account::getSystemUser, 3);
List<Account> accounts = accountMapper.selectList(queryWrapper);
for (Account account : accounts) {
String language = stripeService.getLanguage(account.getLanguage(), account.getCountry(), "reminder_trial");
SendEmailUtil.subscriptionEmailReminder("reminder_trial", null, language, account.getUserEmail());
}
}
/* public void subscriptionReminder(){
// 提前7天的 00:00:00 和 23:59:59
LocalDateTime startOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atStartOfDay();
LocalDateTime endOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atTime(23, 59, 59);
// 转为时间戳
long startTimestamp = startOfDay.toEpochSecond(ZoneOffset.UTC);
long endTimestamp = endOfDay.toEpochSecond(ZoneOffset.UTC);
QueryWrapper<SubscriptionInfo> qw = new QueryWrapper<>();
qw.ge("current_period_end", startTimestamp);
qw.lt("current_period_end", endTimestamp);
qw.eq("status", "active");
List<SubscriptionInfo> subscriptionInfos = subscriptionInfoMapper.selectList(qw);
for (SubscriptionInfo subscriptionInfo : subscriptionInfos) {
boolean b = sendEmail(subscriptionInfo.getSubscriptionId(), "reminder", null);
if (b) log.info("提前7天向用户 {} 发送续订通知邮件", subscriptionInfo.getAccountId());
}
}*/
}

View File

@@ -519,6 +519,7 @@ public class MinioUtil {
return bucketName + "/" + fileName; return bucketName + "/" + fileName;
} catch (Exception e) { } catch (Exception e) {
log.info("base64上传minio失败:{}",e.getMessage());
log.error(e.getMessage()); log.error(e.getMessage());
return null; // or throw an exception return null; // or throw an exception
} }
@@ -908,6 +909,47 @@ public class MinioUtil {
return false; return false;
} }
/**
* 将A桶中的对象复制到B桶中
* @return
*/
public void copyObject(String sourceBucket, String sourceObject, String targetBucket, String targetObject) {
// 检查目标桶是否存在
boolean found;
try {
found = minioClient.bucketExists(BucketExistsArgs.builder()
.bucket(targetBucket)
.build());
} catch (Exception e) {
log.error("目标桶{},不存在", targetBucket);
throw new BusinessException("Copy object failed");
}
if (found) {
// 复制对象
try {
minioClient.copyObject(
CopyObjectArgs.builder()
.bucket(targetBucket)
.object(targetObject)
.source(
CopySource.builder()
.bucket(sourceBucket)
.object(sourceObject)
.build()
)
.build()
);
} catch (Exception e) {
log.error("对象复制失败");
throw new BusinessException("Copy object failed");
}
log.info("对象复制成功");
} else {
log.error("目标桶{},不存在", targetBucket);
throw new BusinessException("Copy object failed");
}
}
} }

View File

@@ -97,6 +97,8 @@ public class RedisUtil {
//- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - - //- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - -
public final static String VIDEO_FINISHED_TASKS = "VideoFinishedTasks";
/** /**
* 将数据放入set缓存 * 将数据放入set缓存
*/ */

View File

@@ -766,7 +766,7 @@ public class SendEmailUtil {
try { try {
String merchantEmail = "kimwong@code-create.com.hk"; String merchantEmail = "kimwong@code-create.com.hk";
String developer = "xupei3360@163.com"; String developer = "xupei3360@163.com";
String[] receiverEmail = {merchantEmail, developer}; String[] receiverEmail = {/*merchantEmail,*/ developer};
Credential cred = new Credential(SECRET_ID, SECRET_KEy); Credential cred = new Credential(SECRET_ID, SECRET_KEy);
// 实例化一个http选项可选的没有特殊需求可以跳过 // 实例化一个http选项可选的没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile(); HttpProfile httpProfile = new HttpProfile();
@@ -828,15 +828,31 @@ public class SendEmailUtil {
templateUser.setTemplateID(RENEWAL_USER_CN); templateUser.setTemplateID(RENEWAL_USER_CN);
} }
break; break;
case "reminder": case "reminder_subscriber":
if (language.equals("ENGLISH")) { if (language.equals("ENGLISH")) {
user.setSubject("[Code-Create] AiDA Subscription Renewal Reminder"); user.setSubject("[Code-Create] AiDA Subscription Renewal Reminder");
templateUser.setTemplateID(RENEWAL_REMINDER_USER_EN); templateUser.setTemplateID(156072L);
} else { } else if (language.equals("CHINESE")){
user.setSubject("[Code-Create] AiDA续订提醒"); user.setSubject("[Code-Create] AiDA续订提醒");
templateUser.setTemplateID(RENEWAL_REMINDER_USER_CN); templateUser.setTemplateID(156073L);
} else {
user.setSubject("[Code-Create] AiDA續訂提醒");
templateUser.setTemplateID(156074L);
} }
break; break;
case "reminder_trial":
if (language.equals("ENGLISH")) {
user.setSubject("[Code-Create] AiDA — Free Trial Ending");
templateUser.setTemplateID(156075L);
} else if (language.equals("CHINESE")){
user.setSubject("[Code-Create] AiDA — 免费试用结束提醒");
templateUser.setTemplateID(156076L);
} else {
user.setSubject("[Code-Create] AiDA — 免費試用結束提醒");
templateUser.setTemplateID(156077L);
}
break;
default: default:
log.error("unknown subscription email type"); log.error("unknown subscription email type");
return false; return false;
@@ -855,7 +871,7 @@ public class SendEmailUtil {
SendEmailResponse respUser = client.SendEmail(user); SendEmailResponse respUser = client.SendEmail(user);
log.info("邮件主题:{}发送结果toUser###{}", user.getSubject(), SendEmailResponse.toJsonString(respUser)); log.info("邮件主题:{}发送结果toUser###{}", user.getSubject(), SendEmailResponse.toJsonString(respUser));
} }
if (!type.equals("reminder")) { if (!type.startsWith("reminder")) {
SendEmailResponse respMerchant = client.SendEmail(merchant); SendEmailResponse respMerchant = client.SendEmail(merchant);
log.info("邮件主题:{}发送结果toMerchant###{}", merchant.getSubject(), SendEmailResponse.toJsonString(respMerchant)); log.info("邮件主题:{}发送结果toMerchant###{}", merchant.getSubject(), SendEmailResponse.toJsonString(respMerchant));
} }
@@ -937,7 +953,7 @@ public class SendEmailUtil {
req.setFromEmailAddress(SEND_ADDRESS); req.setFromEmailAddress(SEND_ADDRESS);
String merchantEmail = "kimwong@code-create.com.hk"; String merchantEmail = "kimwong@code-create.com.hk";
String developerEmail = "xupei@code-create.com.hk"; String developerEmail = "xupei@code-create.com.hk";
req.setDestination(new String[]{merchantEmail, developerEmail}); req.setDestination(new String[]{/*merchantEmail,*/ developerEmail});
Template template = new Template(); Template template = new Template();
req.setSubject("New Credit Purchase Order"); req.setSubject("New Credit Purchase Order");
template.setTemplateID(CREDITS_PURCHASE_MERCHANT); template.setTemplateID(CREDITS_PURCHASE_MERCHANT);

View File

@@ -14,6 +14,7 @@ import com.ai.da.service.ReferralService;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -55,22 +56,27 @@ public class AffiliateController {
@ApiOperation(value = "获取个人佣金图表数据") @ApiOperation(value = "获取个人佣金图表数据")
@GetMapping("/getPersonalMonthlyIncome") @GetMapping("/getPersonalMonthlyIncome")
public Response<BigDecimal[]> getPersonalMonthlyIncome(@RequestParam("year")int year) { public Response<BigDecimal[]> getPersonalMonthlyIncome(@RequestParam("year") int year) {
return Response.success(affiliateService.getPersonalMonthlyIncome(year)); return Response.success(affiliateService.getPersonalMonthlyIncome(year));
} }
@ApiOperation(value = "审批affiliate申请") @ApiOperation(value = "审批affiliate申请")
@GetMapping("/approval") @GetMapping("/approval")
public Response<Boolean> applicationApproval(@RequestParam("id") Long id, public Response<Boolean> applicationApproval(@RequestParam("id") Long id,
@RequestParam("isApproved")Boolean isApproved, @RequestParam("isApproved") Boolean isApproved,
@RequestParam(value = "commission", required = false) Float commission) { @RequestParam(value = "commission", required = false) Float commission) {
return Response.success(affiliateService.applicationApproval(id, isApproved, commission)); return Response.success(affiliateService.applicationApproval(id, isApproved, commission));
} }
@ApiOperation(value = "更新佣金比例") @ApiOperation(value = "编辑affiliate")
@GetMapping("/updateCommission") @GetMapping("/editAffiliate")
public Response<String> updateCommissionPercentage(@RequestParam("id") Long id, @RequestParam("commission") Float commission) { public Response<String> editAffiliate(@RequestParam("id") Long id,
affiliateService.updateCommissionPercentage(id, commission); @ApiParam(value = "佣金比例", example = "25")
@RequestParam(value = "commission", required = false) Float commission,
@ApiParam(value = "操作类型", example = "Active",
allowableValues = "Active,Inactive,Delete")
@RequestParam(value = "operationType", required = false) String operationType) {
affiliateService.editAffiliate(id, commission, operationType);
return Response.success("success"); return Response.success("success");
} }
@@ -122,9 +128,8 @@ public class AffiliateController {
@ApiOperation(value = "获取所有affiliate用户名") @ApiOperation(value = "获取所有affiliate用户名")
@GetMapping("/getAllAffiliateUsername") @GetMapping("/getAllAffiliateUsername")
public Response<List<Map<String, Object>>> getAllAffiliateUsername() { public Response<List<Map<String, Object>>> getAllAffiliateUsername() {
return Response.success(affiliateService.getAllAffiliateUsername()); return Response.success(affiliateService.getAllAffiliateUsername());
} }
} }

View File

@@ -243,4 +243,10 @@ public class LibraryController {
return Response.success(libraryService.getAllSubAccLib(order, page, size)); return Response.success(libraryService.getAllSubAccLib(order, page, size));
} }
@ApiOperation(value = "将系统sketch添加到library")
@GetMapping("addSysSketchToLibrary")
public Response<String> addSysSketchToLibrary(Long clothId, String path) {
return Response.success(libraryService.addSysSketchToLibrary(clothId, path));
}
} }

View File

@@ -3,13 +3,12 @@ package com.ai.da.controller;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.response.PageBaseResponse; import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.Response; import com.ai.da.common.response.Response;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
import com.ai.da.model.vo.*; import com.ai.da.model.vo.*;
import com.ai.da.model.vo.CommentVO; import com.ai.da.model.vo.CommentVO;
import com.ai.da.model.vo.PortfolioVO; import com.ai.da.model.vo.PortfolioVO;
import com.ai.da.model.vo.UserLikeChooseVO;
import com.ai.da.service.PortfolioService; import com.ai.da.service.PortfolioService;
import com.ai.da.service.UserFollowService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -29,6 +28,9 @@ public class PortfolioController {
@Resource @Resource
private PortfolioService portfolioService; private PortfolioService portfolioService;
@Resource
private UserFollowService userFollowService;
@ApiOperation(value = "发布作品集") @ApiOperation(value = "发布作品集")
@PostMapping("/publish") @PostMapping("/publish")
public Response<Long> publish(@RequestParam("file") MultipartFile canvas, @RequestParam("data") String data) { public Response<Long> publish(@RequestParam("file") MultipartFile canvas, @RequestParam("data") String data) {
@@ -138,13 +140,13 @@ public class PortfolioController {
@ApiOperation(value = "获取关注列表") @ApiOperation(value = "获取关注列表")
@PostMapping("/getFolloweeList") @PostMapping("/getFolloweeList")
public Response<List<AccountFollowVO>> getFolloweeList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) { public Response<List<AccountFollowVO>> getFolloweeList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) {
return Response.success(portfolioService.getFolloweeList(getFollowListDTO)); return Response.success(userFollowService.getFolloweeList(getFollowListDTO));
} }
@ApiOperation(value = "获取粉丝列表") @ApiOperation(value = "获取粉丝列表")
@PostMapping("/getFollowerList") @PostMapping("/getFollowerList")
public Response<List<AccountFollowVO>> getFollowerList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) { public Response<List<AccountFollowVO>> getFollowerList(@Valid @RequestBody GetFollowListDTO getFollowListDTO) {
return Response.success(portfolioService.getFollowerList(getFollowListDTO)); return Response.success(userFollowService.getFollowerList(getFollowListDTO));
} }

View File

@@ -197,8 +197,12 @@ public class SavedCollectionController {
@ApiOperation(value = "toProductImageElementUpload") @ApiOperation(value = "toProductImageElementUpload")
@PostMapping("/toProductImageElementUpload") @PostMapping("/toProductImageElementUpload")
public Response<ToProductElementVO> toProductImageElementUpload(@RequestParam("file") MultipartFile file, @RequestParam(value = "projectId", required = false) Long projectId) { public Response<ToProductElementVO> toProductImageElementUpload(@RequestParam("file") MultipartFile file,
return Response.success(userLikeGroupService.toProductImageElementUpload(file, projectId)); @RequestParam(value = "projectId", required = false) Long projectId,
@ApiParam(value = "首尾帧", example = "first",
allowableValues = "first,last")
@RequestParam(value = "type", required = false) String type) {
return Response.success(userLikeGroupService.toProductImageElementUpload(file, projectId, type));
} }
@ApiOperation(value = "toProductImageElementDelete") @ApiOperation(value = "toProductImageElementDelete")

View File

@@ -118,11 +118,11 @@ public class WorkspaceController {
return Response.success(true); return Response.success(true);
} }
@PostMapping("maleDataInsert") @GetMapping("/maleDataInsert")
@ApiOperationSupport(order = 8) @ApiOperationSupport(order = 8)
@ApiOperation(value = "男装数据入库入minio") @ApiOperation(value = "男装数据入库入minio")
public Response<Boolean> maleDataInsert() throws FileNotFoundException { public Response<Boolean> maleDataInsert() throws FileNotFoundException {
workspaceService.maleDataInsert(); // workspaceService.maleDataInsert();
return Response.success(true); return Response.success(true);
} }

View File

@@ -24,4 +24,5 @@ public interface WorkspaceMapper extends CommonMapper<Workspace> {
*/ */
List<WorkspaceVO> selectWorkspacePage(IPage page, WorkspaceVO workspace); List<WorkspaceVO> selectWorkspacePage(IPage page, WorkspaceVO workspace);
String getStyleByProjectId(Long projectId);
} }

View File

@@ -30,4 +30,6 @@ public class Affiliate extends BaseEntity{
private String link; private String link;
private String promotionMethod; private String promotionMethod;
private Integer isDeleted;
} }

View File

@@ -97,4 +97,16 @@ public class Library implements Serializable {
this.md5 = md5; this.md5 = md5;
this.createDate = createDate; this.createDate = createDate;
} }
public Library(Long accountId, String level1Type, String level2Type, String level3Type, String ageGroup, String name, String url, String md5, Date createDate) {
this.accountId = accountId;
this.level1Type = level1Type;
this.level2Type = level2Type;
this.level3Type = level3Type;
this.ageGroup = ageGroup;
this.name = name;
this.url = url;
this.md5 = md5;
this.createDate = createDate;
}
} }

View File

@@ -20,6 +20,8 @@ public class PoseTransformation extends BaseEntity {
private String productImage; private String productImage;
private String lastFrameProductImage;
private int poseId; private int poseId;
private String gifUrl; private String gifUrl;
@@ -37,6 +39,8 @@ public class PoseTransformation extends BaseEntity {
private String taskStatus; private String taskStatus;
private String prompt;
public PoseTransformation() { public PoseTransformation() {
} }

View File

@@ -19,12 +19,15 @@ public class ToProductElement implements Serializable {
@ApiModelProperty(value = "userLikeGroupId") @ApiModelProperty(value = "userLikeGroupId")
private Long userLikeGroupId; private Long userLikeGroupId;
@ApiModelProperty(value = "项目id")
private Long projectId; private Long projectId;
@ApiModelProperty(value = "url") @ApiModelProperty(value = "url")
private String url; private String url;
// private String type; @ApiModelProperty(value = "首尾帧 first | last")
private String frameType;
@ApiModelProperty(value = "createTime") @ApiModelProperty(value = "createTime")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

View File

@@ -30,4 +30,10 @@ public interface AttributeRetrievalMapper {
void updateStyleByFileName(String style, String fileName, String tableName); void updateStyleByFileName(String style, String fileName, String tableName);
String getStyleByUrl(String replace,String tableName); String getStyleByUrl(String replace,String tableName);
Integer getCountByStyle(String tableName, String style);
String getOneSystemSketchRadom(String tableName, String style, Integer randomNum);
void insertSketch(AttributeRetrieval attributeRetrievalAttrDict, String tableName);
} }

View File

@@ -22,6 +22,9 @@ public class GenerateLikeDTO {
@ApiModelProperty("当一级类型为Sketchboard时二级类型 Outwear Dress Blouse Skirt Trousers当一级类型为Printboard时二级类型 Slogan Logo Pattern") @ApiModelProperty("当一级类型为Sketchboard时二级类型 Outwear Dress Blouse Skirt Trousers当一级类型为Printboard时二级类型 Slogan Logo Pattern")
private String level2Type; private String level2Type;
@ApiModelProperty("年龄段")
private String ageGroup;
@ApiModelProperty("性别") @ApiModelProperty("性别")
private String gender; private String gender;

View File

@@ -12,10 +12,13 @@ public class PoseTransformDTO {
@ApiModelProperty("项目id") @ApiModelProperty("项目id")
private Long projectId; private Long projectId;
@ApiModelProperty("图片的minio地址") @ApiModelProperty("图片的minio地址 | 首帧图片的minio地址")
@NotBlank(message = "please select a product image") @NotBlank(message = "please select a product image")
private String productImage; private String productImage;
@ApiModelProperty("尾帧图片的minio地址")
private String lastFrameProductImage;
@ApiModelProperty("pose的编号") @ApiModelProperty("pose的编号")
@NotNull(message = "please select a pose") @NotNull(message = "please select a pose")
private Integer poseId; private Integer poseId;
@@ -26,9 +29,15 @@ public class PoseTransformDTO {
@ApiModelProperty("design结果在collectionSort中的id") @ApiModelProperty("design结果在collectionSort中的id")
private Long parentId; private Long parentId;
@ApiModelProperty("子集中的元素作为父元素") @ApiModelProperty("子集中的元素作为父元素,用于重新排序")
private Long userLikeSortId; private Long userLikeSortId;
@ApiModelProperty("是否默认喜欢") @ApiModelProperty("是否默认喜欢")
private Boolean isDefaultLike; private Boolean isDefaultLike;
@ApiModelProperty("动作描述")
private String prompt;
@ApiModelProperty("生成模式 1.pose2video | 2.prompt2video | 3.FLFrame2video ")
private Integer mode;
} }

View File

@@ -7,6 +7,12 @@ public class SubscriptionEmailParamsDTO {
// 用户名 // 用户名
private String username; private String username;
// 用户邮箱
private String email;
// 国家
private String country;
// t_payment_info id每次支付对于用户来说是一笔新订单 // t_payment_info id每次支付对于用户来说是一笔新订单
private String orderId; private String orderId;
@@ -55,5 +61,5 @@ public class SubscriptionEmailParamsDTO {
// 付款失败原因 // 付款失败原因
private String failMessage; private String failMessage;
private String days;
} }

View File

@@ -13,7 +13,8 @@ public enum FemalePosition implements IEnumDisplay {
BLOUSE("Blouse"), BLOUSE("Blouse"),
DRESS("Dress"), DRESS("Dress"),
TROUSERS("Trousers"), TROUSERS("Trousers"),
SKIRT("Skirt"); SKIRT("Skirt"),
OTHERS("Others");
private String value; private String value;

View File

@@ -11,7 +11,8 @@ public enum MalePosition implements IEnumDisplay {
TOPS("Tops"), TOPS("Tops"),
BOTTOMS("Bottoms"), BOTTOMS("Bottoms"),
OUTWEAR("Outwear"); OUTWEAR("Outwear"),
OTHERS("Others");
private String value; private String value;

View File

@@ -19,7 +19,8 @@ public enum Position implements IEnumDisplay {
SKIRT("Skirt"), SKIRT("Skirt"),
SLOGAN("Slogan"), SLOGAN("Slogan"),
LOGO("Logo"), LOGO("Logo"),
PATTERN("Pattern"); PATTERN("Pattern"),
OTHERS("Others");
private String value; private String value;

View File

@@ -37,6 +37,9 @@ public class DesignItemClothesDetailVO {
@ApiModelProperty("对应图片minIO路径") @ApiModelProperty("对应图片minIO路径")
private String minIOPath; private String minIOPath;
@ApiModelProperty("图片所属sys, user")
private String scope;
@ApiModelProperty(" 颜色 存 RGB值 中间空格分隔 比如 58 58 169") @ApiModelProperty(" 颜色 存 RGB值 中间空格分隔 比如 58 58 169")
// private String color; // private String color;
private PantoneVO color; private PantoneVO color;

View File

@@ -15,6 +15,8 @@ public class PoseTransformationVO implements AllCollectionVO{
private String productImage; private String productImage;
private String lastFrameProductImage;
private String gifUrl; private String gifUrl;
private String videoUrl; private String videoUrl;
@@ -38,6 +40,8 @@ public class PoseTransformationVO implements AllCollectionVO{
private int poseId; private int poseId;
private String prompt;
public PoseTransformationVO(Long id, String taskId, String gifUrl, String videoUrl, String firstFrameUrl, byte isLiked, String status) { public PoseTransformationVO(Long id, String taskId, String gifUrl, String videoUrl, String firstFrameUrl, byte isLiked, String status) {
this.id = id; this.id = id;
this.taskId = taskId; this.taskId = taskId;

View File

@@ -29,6 +29,7 @@ import com.google.common.collect.Maps;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -666,33 +667,24 @@ public class PythonService {
BigDecimal randomValue = generateRandomValue(); BigDecimal randomValue = generateRandomValue();
boolean useSystem = randomValue.compareTo(systemScale) <= 0; boolean useSystem = randomValue.compareTo(systemScale) <= 0;
if (useSystem) { // 用过存在用户上传,则优先使用用户上传
// 获取系统推荐sketch if (!useSystem && CollectionUtil.isNotEmpty(collectionElements)) {
String categoryParam = elementVO.getModelSex().toLowerCase() + "_" + styleCategory.toLowerCase(); int collectionNoPinSize = collectionElements.size();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, elementVO.getBrandId(), elementVO.getBrandScale()); int randomNum = RandomsUtil.randomSysFile(collectionNoPinSize);
if (!CollectionUtils.isEmpty(recommentdUrlList)) { return coverSketchToDesignPythonItem(collectionElements.get(randomNum).getId(), collectionElements.get(randomNum), elementVO);
String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, styleCategory, elementVO);
}else {
throw new BusinessException("failed.to.obtain.system.sketch.recommendation");
}
}else {
if (CollectionUtil.isNotEmpty(collectionElements)) {
int collectionNoPinSize = collectionElements.size();
int randomNum = RandomsUtil.randomSysFile(collectionNoPinSize);
return coverSketchToDesignPythonItem(collectionElements.get(randomNum).getId(), collectionElements.get(randomNum), elementVO);
}else {
String categoryParam = elementVO.getModelSex().toLowerCase() + "_" + styleCategory.toLowerCase();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, elementVO.getBrandId(), elementVO.getBrandScale());
if (!CollectionUtils.isEmpty(recommentdUrlList)) {
String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, styleCategory, elementVO);
}else {
throw new BusinessException("failed.to.obtain.system.sketch.recommendation");
}
}
} }
// 其他所有情况,都回退到使用系统推荐
String categoryParam = elementVO.getModelSex().toLowerCase() + "_" + styleCategory.toLowerCase();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, elementVO.getBrandId(), elementVO.getBrandScale(),elementVO.getStyle());
if (CollectionUtils.isEmpty(recommentdUrlList)) {
throw new BusinessException("failed.to.obtain.system.sketch.recommendation");
}
String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, styleCategory, elementVO);
// int poolNum = 20; // int poolNum = 20;
// if (CollectionUtil.isNotEmpty(collectionElements)) { // if (CollectionUtil.isNotEmpty(collectionElements)) {
// int collectionNoPinSize = collectionElements.size(); // int collectionNoPinSize = collectionElements.size();
@@ -1039,7 +1031,7 @@ public class PythonService {
// 获取随机pin sketch的category // 获取随机pin sketch的category
String category = element.getLevel2Type(); String category = element.getLevel2Type();
String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase(); String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale()); List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale(), validateElementVO.getStyle());
if (!CollectionUtils.isEmpty(recommentdUrlList)) { if (!CollectionUtils.isEmpty(recommentdUrlList)) {
String recommendSystemSketch = recommentdUrlList.get(0); String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO); return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO);
@@ -1062,7 +1054,7 @@ public class PythonService {
String category = dressings.get(randomNum).getStyleCategory(); String category = dressings.get(randomNum).getStyleCategory();
String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase(); String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale()); List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale(), validateElementVO.getStyle());
if (!CollectionUtils.isEmpty(recommentdUrlList)) { if (!CollectionUtils.isEmpty(recommentdUrlList)) {
String recommendSystemSketch = recommentdUrlList.get(0); String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO); return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO);
@@ -1098,7 +1090,7 @@ public class PythonService {
String category = element.getLevel2Type(); String category = element.getLevel2Type();
String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase(); String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale()); List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale(), validateElementVO.getStyle());
if (!CollectionUtils.isEmpty(recommentdUrlList)) { if (!CollectionUtils.isEmpty(recommentdUrlList)) {
String recommendSystemSketch = recommentdUrlList.get(0); String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO); return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO);
@@ -1122,7 +1114,7 @@ public class PythonService {
String category = dressings.get(randomNum).getStyleCategory(); String category = dressings.get(randomNum).getStyleCategory();
String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase(); String categoryParam = validateElementVO.getModelSex().toLowerCase() + "_" + category.toLowerCase();
List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale()); List<String> recommentdUrlList = getSystemSketchByCategory(categoryParam, validateElementVO.getBrandId(), validateElementVO.getBrandScale(), validateElementVO.getStyle());
if (!CollectionUtils.isEmpty(recommentdUrlList)) { if (!CollectionUtils.isEmpty(recommentdUrlList)) {
String recommendSystemSketch = recommentdUrlList.get(0); String recommendSystemSketch = recommentdUrlList.get(0);
return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO); return coverSystemSketchUrlToDesignPythonItem(recommendSystemSketch, category, validateElementVO);
@@ -3962,7 +3954,30 @@ public class PythonService {
throw new BusinessException("design.interface.exception"); throw new BusinessException("design.interface.exception");
} }
public List<String> getSystemSketchByCategory(String category, Long brandId, Double brandScale) { public List<String> getSystemSketchByCategory(String category, Long brandId, Double brandScale,String style) {
//******3.1.2版本临时使用java推荐方案去解决style未使用的问题**********
try {
//使用新库attribute_retrieval_style表命名修改为elementVO.getModelSex().toLowerCase() + "_" + styleCategory.toLowerCase()比如female_skirt,与传入的category保持一致
Integer countByStyle = attributeRetrievalMapper.getCountByStyle(category, style);
//根据数量随机获取一个系统sketch
if (countByStyle > 0) {
//获取一个不大于countByStyle的随机整数
Integer randomNum = RandomUtils.nextInt(0, countByStyle);
//返回格式为 dress/0902000649.jpg
String oneSystemSketchRadom = attributeRetrievalMapper.getOneSystemSketchRadom(category, style,randomNum);
String imgName = oneSystemSketchRadom.split("/")[1];
//补齐正确格式aida-sys-image/images/male/tops/mens_test_5689.png
//裁切category前半部分
String sex = category.split("_")[0];
String realCategory = category.split("_")[1];
String path = "aida-sys-image/images/" + sex + "/" +realCategory +"/" +imgName;
return Arrays.asList(path);
}
} catch (Exception e) {
log.info("推荐失败:{}",e.getMessage());
throw new BusinessException("system.error");
}
//**********************end***********************************
AuthPrincipalVo userHolder = UserContext.getUserHolder(); AuthPrincipalVo userHolder = UserContext.getUserHolder();
OkHttpClient client = new OkHttpClient().newBuilder() OkHttpClient client = new OkHttpClient().newBuilder()
@@ -4078,7 +4093,7 @@ public class PythonService {
//生成失败 //生成失败
throw new BusinessException("segProduct.interface.exception"); throw new BusinessException("segProduct.interface.exception");
} }
public Boolean poseTransformation(String productImage, int poseId, String taskId) { public Boolean poseTransformation(JSONObject content, String apiUri) {
OkHttpClient client = new OkHttpClient().newBuilder() OkHttpClient client = new OkHttpClient().newBuilder()
.connectTimeout(30, TimeUnit.SECONDS) .connectTimeout(30, TimeUnit.SECONDS)
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒) .pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
@@ -4086,15 +4101,11 @@ public class PythonService {
.writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒) .writeTimeout(60, TimeUnit.SECONDS)//写入超时(单位:秒)
.build(); .build();
MediaType mediaType = MediaType.parse("application/json"); MediaType mediaType = MediaType.parse("application/json");
Map<String, String> content = Maps.newHashMap();
content.put("image_url", productImage);
content.put("tasks_id", taskId);
content.put("pose_id", String.valueOf(poseId));
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
log.info("poseTransformation 请求地址: {}", accessPythonIp + ":" + accessPythonPort + "/api/pose_transform"); log.info("poseTransformation 请求地址: {}", accessPythonIp + ":" + accessPythonPort + apiUri);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(accessPythonIp + ":" + accessPythonPort + "/api/pose_transform") .url(accessPythonIp + ":" + accessPythonPort + apiUri)
.method("POST", body) .method("POST", body)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
.build(); .build();

View File

@@ -105,6 +105,9 @@ public class DesignPythonItem {
public static List<String> BOTTOMS = Arrays.asList( public static List<String> BOTTOMS = Arrays.asList(
"Bottoms"); "Bottoms");
public static List<String> OTHERS = Arrays.asList(
"Others");
public static List<String> SYS_HAIRSTYLE_SHOES_BODY = Arrays.asList( public static List<String> SYS_HAIRSTYLE_SHOES_BODY = Arrays.asList(
SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), SysFileLevel2TypeEnum.SHOES.getRealName(), SysFileLevel2TypeEnum.HAIRSTYLE.getRealName(), SysFileLevel2TypeEnum.SHOES.getRealName(),
SysFileLevel2TypeEnum.EARRINGS.getRealName(), SysFileLevel2TypeEnum.BODY.getRealName()); SysFileLevel2TypeEnum.EARRINGS.getRealName(), SysFileLevel2TypeEnum.BODY.getRealName());

View File

@@ -24,7 +24,7 @@ public interface AffiliateService extends IService<Affiliate> {
Boolean applicationApproval(Long id, Boolean isApproved, Float commission); Boolean applicationApproval(Long id, Boolean isApproved, Float commission);
void updateCommissionPercentage(Long id, Float commission); void editAffiliate(Long id, Float commission, String operationType);
void updateAffiliateInfoWithPayment(); void updateAffiliateInfoWithPayment();

View File

@@ -25,4 +25,6 @@ public interface DesignItemDetailService extends IService<DesignItemDetail> {
void saveDesignItemDetailCanvas(Long designItemDetailId, Long exportFileId); void saveDesignItemDetailCanvas(Long designItemDetailId, Long exportFileId);
DesignItemDetailCanvas getDIDCByDesignItemDetailId(Long designItemDetailId); DesignItemDetailCanvas getDIDCByDesignItemDetailId(Long designItemDetailId);
void updateDetailPathById(Long id, String path);
} }

View File

@@ -95,10 +95,6 @@ public interface DesignService extends IService<Design> {
Integer designProcess(String processId); Integer designProcess(String processId);
void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam);
void relationImageId(DesignPythonObjects objects);
List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignCollectionDTO); List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignCollectionDTO);
List<String> getModel(List<Long> designItemIdList); List<String> getModel(List<Long> designItemIdList);

View File

@@ -57,6 +57,10 @@ public interface GenerateService extends IService<Generate> {
void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl); void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl);
void processPTFailSituation(String taskId);
void sendSysMsgForPT(PoseTransformation poseTransformation);
List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList, Long projectId, Boolean like); List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList, Long projectId, Boolean like);
void updatePoseTransferStatus(String taskId, String status, PoseTransformation poseTransformation); void updatePoseTransferStatus(String taskId, String status, PoseTransformation poseTransformation);

View File

@@ -98,4 +98,6 @@ public interface LibraryService extends IService<Library> {
PageBaseResponse<Library> getPublicLib(String order, long page, long size); PageBaseResponse<Library> getPublicLib(String order, long page, long size);
PageBaseResponse<Library> getAllSubAccLib(String order, long page, long size); PageBaseResponse<Library> getAllSubAccLib(String order, long page, long size);
String addSysSketchToLibrary(Long clothId, String path);
} }

View File

@@ -27,4 +27,6 @@ public interface MessageCenterService extends IService<Notification> {
void setReadAll(String type); void setReadAll(String type);
void publishSystemNotification(PublishSysNotificationDTO message); void publishSystemNotification(PublishSysNotificationDTO message);
void videoFinishedMsg(Long userId, String projectName, boolean isSuccess);
} }

View File

@@ -0,0 +1,9 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.MoodboardPosition;
import com.baomidou.mybatisplus.extension.service.IService;
public interface MoodboardPositionService extends IService<MoodboardPosition> {
void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam);
}

View File

@@ -47,20 +47,8 @@ public interface PortfolioService extends IService<Portfolio> {
void cancelFollow(Long followeeId); void cancelFollow(Long followeeId);
Long getFolloweeCount(Long accountId);
List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO);
Long getFollowerCount(Long accountId);
List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO);
Integer getIfFollowed(Long followeeId, Long followerId);
Long getPortfolioCount(Long accountId); Long getPortfolioCount(Long accountId);
List<Long> getFolloweeList(Long accountId);
// List<PortfolioVO> queryPortfolioByTag(String tagName, Long tagId); // List<PortfolioVO> queryPortfolioByTag(String tagName, Long tagId);
void setPortfolioToPublic(Long portfolioId); void setPortfolioToPublic(Long portfolioId);

View File

@@ -2,6 +2,7 @@ package com.ai.da.service;
import com.ai.da.mapper.primary.entity.PythonTAllInfo; import com.ai.da.mapper.primary.entity.PythonTAllInfo;
import com.ai.da.python.vo.DesignPythonObjects;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/** /**
@@ -14,4 +15,6 @@ public interface PythonTAllInfoService extends IService<PythonTAllInfo> {
Long getImageIdByPath(String path); Long getImageIdByPath(String path);
void relationImageId(DesignPythonObjects pythonObjects);
} }

View File

@@ -35,11 +35,15 @@ public interface StripeService {
Map<String, String> getPaymentMethod(String paymentMethodId); Map<String, String> getPaymentMethod(String paymentMethodId);
boolean sendEmail(String subscriptionId, String type, String orderNo);
String getLanguage(String language, String country, String type);
/*void updateSubscription(String subscriptionId); /*void updateSubscription(String subscriptionId);
void resume(String subscriptionId);*/ void resume(String subscriptionId);*/
void subscriptionReminder(); // void subscriptionReminder();
void checkSubscriptionExpiration(); void checkSubscriptionExpiration();

View File

@@ -0,0 +1,9 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.ToProductImageResult;
import com.baomidou.mybatisplus.extension.service.IService;
public interface ToProductImageResultService extends IService<ToProductImageResult> {
Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url);
}

View File

@@ -0,0 +1,24 @@
package com.ai.da.service;
import com.ai.da.mapper.primary.entity.UserFollow;
import com.ai.da.model.dto.GetFollowListDTO;
import com.ai.da.model.vo.AccountFollowVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface UserFollowService extends IService<UserFollow> {
Long getFollowerCount(Long accountId);
List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO);
Long getFolloweeCount(Long accountId);
List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO);
Integer getIfFollowed(Long followeeId, Long followerId);
List<Long> getFolloweeList(Long accountId);
}

View File

@@ -42,7 +42,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
void deleteTrialData(Long id); void deleteTrialData(Long id);
void updateDate(Long id,String timeZone); void updateDate(Long id, String timeZone);
Long exportSave(MultipartFile file, Long projectId, String module, Long designItemDetailId); Long exportSave(MultipartFile file, Long projectId, String module, Long designItemDetailId);
@@ -50,7 +50,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
void toProduct(String taskId); void toProduct(String taskId);
ToProductElementVO toProductImageElementUpload(MultipartFile file, Long projectId); ToProductElementVO toProductImageElementUpload(MultipartFile file, Long projectId, String type);
CollectionSort productImageLike(ProductImageLikeDTO productImageLikeDTO); CollectionSort productImageLike(ProductImageLikeDTO productImageLikeDTO);
@@ -121,6 +121,4 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
Boolean toProductImageElementDelete(Long id); Boolean toProductImageElementDelete(Long id);
ToProductElementVO convertRelightElement(Long id); ToProductElementVO convertRelightElement(Long id);
Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url);
} }

View File

@@ -68,4 +68,8 @@ public interface WorkspaceService extends IService<Workspace> {
String getProjectSexById(Long projectId); String getProjectSexById(Long projectId);
String getStyleByProjectId(Long projectId);
String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId);
} }

View File

@@ -143,6 +143,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Resource @Resource
private AffiliateService affiliateService; private AffiliateService affiliateService;
@Resource
private UserFollowService userFollowService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) { public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) {
@@ -261,8 +264,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
//判断是否常用ip 不是则发邮件提示 //判断是否常用ip 不是则发邮件提示
calculateExceptionIp(RequestInfoUtil.getIpAddress(request), account); calculateExceptionIp(RequestInfoUtil.getIpAddress(request), account);
return response; return response;
@@ -2050,8 +2053,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
personalHomepageVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); personalHomepageVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
personalHomepageVO.setPortfolioCount(portfolioService.getPortfolioCount(accountId)); personalHomepageVO.setPortfolioCount(portfolioService.getPortfolioCount(accountId));
personalHomepageVO.setFolloweeCount(portfolioService.getFolloweeCount(accountId)); personalHomepageVO.setFolloweeCount(userFollowService.getFolloweeCount(accountId));
personalHomepageVO.setFollowerCount(portfolioService.getFollowerCount(accountId)); personalHomepageVO.setFollowerCount(userFollowService.getFollowerCount(accountId));
personalHomepageVO.setHomepageViewCount(viewPersonalHomepageCount(0L)); personalHomepageVO.setHomepageViewCount(viewPersonalHomepageCount(0L));
@@ -2061,7 +2064,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
// 只有本人才能看到个人主页浏览量 // 只有本人才能看到个人主页浏览量
personalHomepageVO.setHomepageViewCount(viewCount == null ? 0 : viewCount); personalHomepageVO.setHomepageViewCount(viewCount == null ? 0 : viewCount);
} else { } else {
personalHomepageVO.setIsFollow(portfolioService.getIfFollowed(accountId, currentUserId)); personalHomepageVO.setIsFollow(userFollowService.getIfFollowed(accountId, currentUserId));
// 非本人浏览主页时增加浏览量 // 非本人浏览主页时增加浏览量
viewsIncrease(accountId); viewsIncrease(accountId);
} }
@@ -2925,8 +2928,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
return response; return response;
} else { } else {
throw new IllegalArgumentException("Invalid ID token."); throw new IllegalArgumentException("Invalid ID token.");
@@ -3030,8 +3033,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
return response; return response;
} }
@@ -3122,8 +3125,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
avatar = account.getAvatar(); avatar = account.getAvatar();
} }
response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); response.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
response.setFolloweeCount(portfolioService.getFolloweeCount(account.getId())); response.setFolloweeCount(userFollowService.getFolloweeCount(account.getId()));
response.setFollowerCount(portfolioService.getFollowerCount(account.getId())); response.setFollowerCount(userFollowService.getFollowerCount(account.getId()));
QueryWrapper<AccountExtend> qw = new QueryWrapper<>(); QueryWrapper<AccountExtend> qw = new QueryWrapper<>();
qw.lambda().eq(AccountExtend::getAccountId, response.getUserId()); qw.lambda().eq(AccountExtend::getAccountId, response.getUserId());
@@ -3651,19 +3654,19 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
} }
// todo 机构管理员再次订阅时,需要同步机构的激活状态 // todo 机构管理员再次订阅时,需要同步机构的激活状态
private void setOrganizationStatus(Account adminAcc, boolean isActive){ private void setOrganizationStatus(Account adminAcc, boolean isActive) {
Organization organization; Organization organization;
if (Objects.nonNull(adminAcc.getOrganizationId())){ if (Objects.nonNull(adminAcc.getOrganizationId())) {
organization = organizationMapper.selectById(adminAcc.getOrganizationId()); organization = organizationMapper.selectById(adminAcc.getOrganizationId());
} else if (!StringUtil.isNullOrEmpty(adminAcc.getOrganizationName())){ } else if (!StringUtil.isNullOrEmpty(adminAcc.getOrganizationName())) {
organization = convenientInquiryService.checkOrganization(adminAcc.getSystemUser(), adminAcc.getOrganizationName()); organization = convenientInquiryService.checkOrganization(adminAcc.getSystemUser(), adminAcc.getOrganizationName());
} else { } else {
return; return;
} }
if (Objects.isNull(organization)){ if (Objects.isNull(organization)) {
organization = convenientInquiryService.addOrganization(adminAcc.getOrganizationName(), getOrganizationTypeByRole(adminAcc.getSystemUser())); organization = convenientInquiryService.addOrganization(adminAcc.getOrganizationName(), getOrganizationTypeByRole(adminAcc.getSystemUser()));
} }
if (isActive){ if (isActive) {
organization.setStatus(1); organization.setStatus(1);
} else { } else {
organization.setStatus(0); organization.setStatus(0);
@@ -3672,9 +3675,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
organizationMapper.updateById(organization); organizationMapper.updateById(organization);
} }
public String getOrganizationTypeByRole(Integer roleNum){ public String getOrganizationTypeByRole(Integer roleNum) {
String type; String type;
switch (roleNum){ switch (roleNum) {
case 5: case 5:
type = "Enterprise"; type = "Enterprise";
break; break;

View File

@@ -82,7 +82,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
// 邮件通知审批者 // 邮件通知审批者
String merchantEmail = "kimwong@code-create.com.hk"; String merchantEmail = "kimwong@code-create.com.hk";
String developer = "xupei3360@163.com"; String developer = "xupei3360@163.com";
String[] receiverEmail = {merchantEmail, developer}; String[] receiverEmail = {/*merchantEmail,*/ developer};
SendEmailUtil.affiliateEmailReminder(receiverEmail, new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new"); SendEmailUtil.affiliateEmailReminder(receiverEmail, new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new"); // emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), new AffiliateEmailParamsDTO(userHolder.getUsername(), promotionMethod), "new");
}else { }else {
@@ -173,7 +173,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
affiliate.setLink(CommonConstant.AFFILIATE_LINK + affiliate.getId()); affiliate.setLink(CommonConstant.AFFILIATE_LINK + affiliate.getId());
if (Objects.isNull(commission)) { if (Objects.isNull(commission)) {
// 未设置佣金比例的情况下默认25% // 未设置佣金比例的情况下默认25%
affiliate.setCommissionPercent(25f); affiliate.setCommissionPercent(20f);
} else { } else {
affiliate.setCommissionPercent(commission); affiliate.setCommissionPercent(commission);
} }
@@ -200,7 +200,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
return true; return true;
} }
public void updateCommissionPercentage(Long id, Float commission){ public void editAffiliate(Long id, Float commission, String operationType){
Affiliate affiliate = baseMapper.selectById(id); Affiliate affiliate = baseMapper.selectById(id);
if (Objects.isNull(affiliate)){ if (Objects.isNull(affiliate)){
log.info("未知affiliate id :{}", id); log.info("未知affiliate id :{}", id);
@@ -208,9 +208,21 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
} }
if (!Objects.equals(affiliate.getCommissionPercent(), commission)){ if (!Objects.equals(affiliate.getCommissionPercent(), commission)){
affiliate.setCommissionPercent(commission); affiliate.setCommissionPercent(commission);
affiliate.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(affiliate);
} }
// operationType Active -> 激活 | Inactive -> 关闭 | Delete -> 删除
if (!StringUtil.isNullOrEmpty(operationType)) {
if (operationType.equals("Delete")) {
baseMapper.deleteById(id);
return;
} else if (operationType.equals("Active") || operationType.equals("Inactive")) {
affiliate.setStatus(operationType);
} else {
throw new BusinessException("unknown.operationType");
}
}
affiliate.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(affiliate);
} }
// 定时计算佣金 // 定时计算佣金
@@ -389,7 +401,7 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
String merchantEmail = "kimwong@code-create.com.hk"; String merchantEmail = "kimwong@code-create.com.hk";
String developer = "xupei3360@163.com"; String developer = "xupei3360@163.com";
String[] receiverEmail = {merchantEmail, developer}; String[] receiverEmail = {/*merchantEmail,*/ developer};
// 邮件通知 // 邮件通知
SendEmailUtil.affiliateEmailReminder(receiverEmail, affiliateEmailParamsDTO, "summary"); SendEmailUtil.affiliateEmailReminder(receiverEmail, affiliateEmailParamsDTO, "summary");
// emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), affiliateEmailParamsDTO, "summary"); // emailService.affiliateEmailReminder(Arrays.asList(/*merchantEmail,*/ developer), affiliateEmailParamsDTO, "summary");
@@ -554,5 +566,4 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
coupon.setUnpaidCommission(unpaidCommission); coupon.setUnpaidCommission(unpaidCommission);
} }
} }

View File

@@ -59,30 +59,20 @@ import java.util.stream.Collectors;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementMapper, CollectionElement> implements CollectionElementService { public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementMapper, CollectionElement> implements CollectionElementService {
@Resource private final CollectionElementMapper collectionElementMapper;
private CollectionElementMapper collectionElementMapper; private final EmailService emailService;
@Resource private final FileProperties fileProperties;
private FileProperties fileProperties; private final GenerateMapper generateMapper;
@Resource private final GenerateDetailMapper generateDetailMapper;
private PanToneService panToneService; private final LibraryModelPointService libraryModelPointService;
@Resource private final LibraryService libraryService;
private PythonService pythonService; private final MinioUtil minioUtil;
@Resource private final PanToneService panToneService;
private LibraryService libraryService; private final PythonService pythonService;
@Resource private final RedisUtil redisUtil;
private SysFileService sysFileService; private final SysFileService sysFileService;
@Resource private final TCollectionElementRelationService tCollectionElementRelationService;
private GenerateMapper generateMapper; private final WorkspaceService workspaceService;
@Resource
private GenerateDetailMapper generateDetailMapper;
@Resource
private LibraryModelPointService libraryModelPointService;
@Resource
private TCollectionElementRelationService tCollectionElementRelationService;
@Resource
private MinioUtil minioUtil;
private WorkspaceService workspaceService;
@Value("${minio.bucketName.collectionElement}") @Value("${minio.bucketName.collectionElement}")
private String collectionElement; private String collectionElement;
@@ -90,13 +80,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
private String gradientBucketName; private String gradientBucketName;
@Value("${minio.bucketName.users}") @Value("${minio.bucketName.users}")
private String userBucketName; private String userBucketName;
@Resource
private RedisUtil redisUtil;
// @Resource
// private RedisUtil redisUtil;
@Resource
private EmailService emailService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
@@ -330,8 +314,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD); String name = DateUtil.dateToStr(new Date(), DateUtil.YYYY_MM_DD);
List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> { List<Library> libraryList = CopyUtil.copyList(elements, Library.class, (o, d) -> {
if (StringUtil.isNullOrEmpty(o.getLevel2Type())){ if (StringUtil.isNullOrEmpty(o.getLevel2Type())) {
switch(d.getLevel1Type()){ switch (d.getLevel1Type()) {
case "Sketchboard": case "Sketchboard":
d.setLevel2Type("Outwear"); d.setLevel2Type("Outwear");
break; break;
@@ -358,6 +342,16 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (CollectionUtils.isEmpty(elements)) { if (CollectionUtils.isEmpty(elements)) {
return Boolean.TRUE; return Boolean.TRUE;
} }
// 根据MD5去重保留第一个出现的元素其余重复MD5的丢弃
elements = elements.stream()
.collect(Collectors.collectingAndThen(
Collectors.toMap(
CollectionElement::getMd5,
e -> e,
(e1, e2) -> e1 // 冲突时保留第一个
),
map -> new ArrayList<>(map.values())
));
//获取已存在相同的library //获取已存在相同的library
List<String> md5List = elements.stream().map(CollectionElement::getMd5).collect(Collectors.toList()); List<String> md5List = elements.stream().map(CollectionElement::getMd5).collect(Collectors.toList());
List<Library> existsLibrarys = libraryService.getByMD5List(md5List); List<Library> existsLibrarys = libraryService.getByMD5List(md5List);
@@ -381,8 +375,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
// // TODO:暂不处理 // // TODO:暂不处理
// } // }
} }
if (StringUtil.isNullOrEmpty(o.getLevel2Type())){ if (StringUtil.isNullOrEmpty(o.getLevel2Type())) {
switch(d.getLevel1Type()){ switch (d.getLevel1Type()) {
case "Sketchboard": case "Sketchboard":
d.setLevel2Type("Outwear"); d.setLevel2Type("Outwear");
break; break;
@@ -585,9 +579,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
String level3Type = null; String level3Type = null;
if ("Collection".equals(sketchBoard.getDesignType())) { if ("Collection".equals(sketchBoard.getDesignType())) {
level3Type = collectionElementMapper.selectOne(new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getId, sketchBoard.getSketchBoardId()).select(CollectionElement::getLevel3Type)).getLevel3Type(); level3Type = collectionElementMapper.selectOne(new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getId, sketchBoard.getSketchBoardId()).select(CollectionElement::getLevel3Type)).getLevel3Type();
} else if ("Library".equals(sketchBoard.getDesignType())){ } else if ("Library".equals(sketchBoard.getDesignType())) {
level3Type = libraryService.getById(sketchBoard.getSketchBoardId()).getLevel3Type(); level3Type = libraryService.getById(sketchBoard.getSketchBoardId()).getLevel3Type();
} else if ("Generate".equals(sketchBoard.getDesignType())){ } else if ("Generate".equals(sketchBoard.getDesignType())) {
GenerateDetail generateDetail = generateDetailMapper.selectById(sketchBoard.getSketchBoardId()); GenerateDetail generateDetail = generateDetailMapper.selectById(sketchBoard.getSketchBoardId());
assert generateDetail != null; assert generateDetail != null;
Generate generate = generateMapper.selectById(generateDetail.getGenerateId()); Generate generate = generateMapper.selectById(generateDetail.getGenerateId());
@@ -644,7 +638,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
if (result) { if (result) {
throw new BusinessException("sketchBoards.designType.cannot.be.empty"); throw new BusinessException("sketchBoards.designType.cannot.be.empty");
} }
List<CollectionElement> sketchBoardElements = new ArrayList<>();
// 提取类型为COLLECTION的sketchBoard ID列表 // 提取类型为COLLECTION的sketchBoard ID列表
List<Long> sketchBoardIds = designDTO.getSketchBoards().stream() List<Long> sketchBoardIds = designDTO.getSketchBoards().stream()
.filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName())) .filter(f -> f.getDesignType().equals(DesignTypeEnum.COLLECTION.getRealName()))
@@ -652,12 +646,12 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(sketchBoardIds)) { if (!CollectionUtils.isEmpty(sketchBoardIds)) {
// 从数据库查询验证sketchBoard元素是否存在 // 从数据库查询验证sketchBoard元素是否存在
List<CollectionElement> sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds); sketchBoardElements = collectionElementMapper.selectBatchIds(sketchBoardIds);
if (CollectionUtil.isEmpty(sketchBoardElements) || sketchBoardElements.size() != sketchBoardIds.size()) { if (CollectionUtil.isEmpty(sketchBoardElements) || sketchBoardElements.size() != sketchBoardIds.size()) {
throw new BusinessException("get.sketchBoards.data.is.mismatch"); throw new BusinessException("get.sketchBoards.data.is.mismatch");
} }
// 设置验证通过的sketchBoard元素到结果对象
elementVO.setSketchBoardElements(sketchBoardElements);
// 记录已使用的元素ID // 记录已使用的元素ID
usedElementIds.addAll(sketchBoardIds); usedElementIds.addAll(sketchBoardIds);
} }
@@ -675,7 +669,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards() Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream() .stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v)); .collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
libraryCollectionElements.addAll(covertLibrarysToCollections(librarys, idToMap)); List<CollectionElement> librarysToCollections = covertLibrarysToCollections(librarys, idToMap);
libraryCollectionElements.addAll(librarysToCollections);
sketchBoardElements.addAll(librarysToCollections);
} }
} }
@@ -691,9 +687,13 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards() Map<Long, CollectionSketchDTO> idToMap = designDTO.getSketchBoards()
.stream() .stream()
.collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v)); .collect(Collectors.toMap(CollectionSketchDTO::getSketchBoardId, v -> v));
generateCollectionElements.addAll(covertGeneratesToCollections(generateDetailList, idToMap)); List<CollectionElement> generatesToCollections = covertGeneratesToCollections(generateDetailList, idToMap);
generateCollectionElements.addAll(generatesToCollections);
sketchBoardElements.addAll(generatesToCollections);
} }
} }
// 设置验证通过的sketchBoard元素到结果对象
elementVO.setSketchBoardElements(sketchBoardElements);
} }
} }
//校验marketingSketch //校验marketingSketch
@@ -796,7 +796,7 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId()); SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
// 设置女性模特的风格类型 // 设置女性模特的风格类型
if (Objects.nonNull(byId) && !StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) { if (Objects.nonNull(byId) && !StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
elementVO.setStyle(byId.getLevel3Type()); // elementVO.setStyle(byId.getLevel3Type());
} }
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType()); LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl())); elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
@@ -821,6 +821,10 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
elementVO.setBrandScale(designDTO.getBrandScale()); // 设置品牌比例 elementVO.setBrandScale(designDTO.getBrandScale()); // 设置品牌比例
} }
//设置风格
String style = workspaceService.getStyleByProjectId(designDTO.getProjectId());
elementVO.setStyle(style);
// 返回验证结果对象 // 返回验证结果对象
return elementVO; return elementVO;
} }
@@ -1012,8 +1016,8 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
//保存 //保存
List<TCollectionElementRelation> relations = list.stream().map(element -> List<TCollectionElementRelation> relations = list.stream().map(element ->
TCollectionElementRelation.builder().elementId(element.getId()) TCollectionElementRelation.builder().elementId(element.getId())
.collectionId(element.getCollectionId()).createDate(new Date()).build()) .collectionId(element.getCollectionId()).createDate(new Date()).build())
.collect(Collectors.toList()); .collect(Collectors.toList());
tCollectionElementRelationService.saveBatch(relations); tCollectionElementRelationService.saveBatch(relations);
pageQuery.setPage(pageQuery.getPage() + 1); pageQuery.setPage(pageQuery.getPage() + 1);

View File

@@ -227,8 +227,8 @@ public class CollectionSortServiceImpl extends ServiceImpl<CollectionSortMapper,
} }
child.setSort(collectionSort.getSort()); child.setSort(collectionSort.getSort());
// 原来排序的大于等于userLikeSortId的排序的都要1 // 原来排序的大于等于userLikeSortId的排序的都要1
// baseMapper.increaseGenerateSortAbove(parentId, /*relationType,*/ collectionSort.getSort() - 1); baseMapper.increaseGenerateSortAbove(parentId, /*relationType,*/ collectionSort.getSort() - 1);
resort(collectionSort.getProjectId(), parentId); // resort(collectionSort.getProjectId(), parentId);
// 当前的生成结果则填入userLikeSortId的排序位置 // 当前的生成结果则填入userLikeSortId的排序位置
child.setUpdateTime(LocalDateTime.now()); child.setUpdateTime(LocalDateTime.now());
baseMapper.updateById(child); baseMapper.updateById(child);
@@ -269,13 +269,17 @@ public class CollectionSortServiceImpl extends ServiceImpl<CollectionSortMapper,
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void resort(Long projectId, Long parentId) { public void resort(Long projectId, Long parentId) {
LambdaQueryWrapper<CollectionSort> wrapper = new LambdaQueryWrapper<CollectionSort>()
.eq(CollectionSort::getProjectId, projectId)
.orderByAsc(CollectionSort::getSort);
if (parentId != null) {
wrapper.eq(CollectionSort::getParentId, parentId);
} else {
wrapper.isNull(CollectionSort::getParentId);
}
// 2. 查询同组数据,按原排序升序 // 2. 查询同组数据,按原排序升序
List<CollectionSort> list = baseMapper.selectList( List<CollectionSort> list = baseMapper.selectList(wrapper);
new LambdaQueryWrapper<CollectionSort>()
.eq(CollectionSort::getProjectId, projectId)
.eq(CollectionSort::getParentId, parentId)
.orderByAsc(CollectionSort::getSort)
);
// 3. 重新编号 sort从 1 开始 // 3. 重新编号 sort从 1 开始
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {

View File

@@ -57,7 +57,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
@Resource @Resource
private AccountLoginLogService accountLoginLogService; private AccountLoginLogService accountLoginLogService;
@Resource @Resource
private GenerateService generateService; private GenerateMapper generateMapper;
@Resource @Resource
private ToProductImageResultMapper toProductImageResultMapper; private ToProductImageResultMapper toProductImageResultMapper;
@Resource @Resource
@@ -452,7 +452,8 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
Long singleDesignTimes = designItemService.getCountByUserAndTime(startTime, endTime, ids); Long singleDesignTimes = designItemService.getCountByUserAndTime(startTime, endTime, ids);
// generate -> MoodBoard\PrintBoard\SketchBoard // generate -> MoodBoard\PrintBoard\SketchBoard
List<Map<String, Object>> countGenerate = generateService.getCountByUserAndTime(startTime, endTime, ids); // List<Map<String, Object>> countGenerate = generateService.getCountByUserAndTime(startTime, endTime, ids);
List<Map<String, Object>> countGenerate = generateMapper.getByTypeAndTime(startTime, endTime, ids);
// 使用Stream API和lambda表达式将数据合并到一个Map中 // 使用Stream API和lambda表达式将数据合并到一个Map中
Map<String, Long> countGenerateMerge = countGenerate.stream() Map<String, Long> countGenerateMerge = countGenerate.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
@@ -827,9 +828,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
Account account = accountService.getById(accountId); Account account = accountService.getById(accountId);
// 允许查看数据的用户id // 允许查看数据的用户id
if (!ADMIN_IDS.contains(account.getId()) if (!ADMIN_IDS.contains(account.getId())) {
&& !ADMIN_IDS_READ_ONLY.contains(account.getId())
) {
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode()); throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
} }
Integer size = queryPaymentInfoDTO.getSize(); Integer size = queryPaymentInfoDTO.getSize();
@@ -896,9 +895,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
Account account = accountService.getById(accountId); Account account = accountService.getById(accountId);
// 允许查看数据的用户id // 允许查看数据的用户id
if (!ADMIN_IDS.contains(account.getId()) if (!ADMIN_IDS.contains(account.getId())) {
&& !ADMIN_IDS_READ_ONLY.contains(account.getId())
) {
throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode()); throw new BusinessException("have.no.permission", ResultEnum.PROMPT.getCode());
} }
// 查询数据总量 // 查询数据总量

View File

@@ -19,6 +19,7 @@ public class DesignItemDetailPrintServiceImpl extends ServiceImpl<DesignItemDeta
QueryWrapper<DesignItemDetailPrint> queryWrapper = new QueryWrapper<>(); QueryWrapper<DesignItemDetailPrint> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_item_detail_id", designItemDetailId); queryWrapper.eq("design_item_detail_id", designItemDetailId);
queryWrapper.eq("print_type", printType); queryWrapper.eq("print_type", printType);
queryWrapper.eq("is_deleted", 0);
return baseMapper.selectList(queryWrapper); return baseMapper.selectList(queryWrapper);
} }

View File

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -64,6 +65,7 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
public List<DesignItemDetail> selectByDesignItemId(Long designItemId) { public List<DesignItemDetail> selectByDesignItemId(Long designItemId) {
QueryWrapper<DesignItemDetail> queryWrapper = new QueryWrapper<>(); QueryWrapper<DesignItemDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_item_id", designItemId); queryWrapper.eq("design_item_id", designItemId);
queryWrapper.eq("is_deleted", 0);
return designItemDetailMapper.selectList(queryWrapper); return designItemDetailMapper.selectList(queryWrapper);
} }
@@ -130,4 +132,16 @@ public class DesignItemDetailServiceImpl extends ServiceImpl<DesignItemDetailMap
return designItemDetailCanvasMapper.selectOne(qw); return designItemDetailCanvasMapper.selectOne(qw);
} }
public void updateDetailPathById(Long id, String path) {
if (Objects.nonNull(id)) {
DesignItemDetail designItemDetail = baseMapper.selectById(id);
if (Objects.nonNull(designItemDetail)) {
designItemDetail.setPath(path);
designItemDetail.setUpdateDate(new Date());
baseMapper.updateById(designItemDetail);
}
}
}
} }

View File

@@ -10,6 +10,7 @@ import com.ai.da.common.enums.SingleOverallEnum;
import com.ai.da.common.enums.SysFileLevel2TypeEnum; import com.ai.da.common.enums.SysFileLevel2TypeEnum;
import com.ai.da.common.utils.*; import com.ai.da.common.utils.*;
import com.ai.da.mapper.primary.DesignItemMapper; import com.ai.da.mapper.primary.DesignItemMapper;
import com.ai.da.mapper.primary.DesignMapper;
import com.ai.da.mapper.primary.UserLikeMapper; import com.ai.da.mapper.primary.UserLikeMapper;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.*; import com.ai.da.model.dto.*;
@@ -22,11 +23,13 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -55,37 +58,25 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignItem> implements DesignItemService { public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignItem> implements DesignItemService {
@Resource
private DesignItemMapper designItemMapper; private final CollectionElementService collectionElementService;
@Resource private final DesignMapper designMapper;
private SysFileService sysFileService; private final DesignItemMapper designItemMapper;
@Resource private final DesignItemDetailService designItemDetailService;
private PythonService pythonService; private final DesignItemDetailPrintService designItemDetailPrintService;
@Resource private final ITDesignPythonOutfitService designPythonOutfitService;
private DesignService designService; private final ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
@Resource private final LibraryService libraryService;
private DesignItemDetailService designItemDetailService; private final LibraryModelPointService libraryModelPointService;
@Resource private final MinioUtil minioUtil;
private LibraryModelPointService libraryModelPointService; private final PythonService pythonService;
@Resource private final PanToneService panToneService;
private LibraryService libraryService; private final SysFileService sysFileService;
@Resource private final UserLikeService userLikeService;
private CollectionElementService collectionElementService; private final UserLikeGroupService userLikeGroupService;
@Resource private final WorkspaceService workspaceService;
private ITDesignPythonOutfitService designPythonOutfitService;
@Resource
private ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
@Resource
private PanToneService panToneService;
@Resource
private DesignItemDetailPrintService designItemDetailPrintService;
@Resource
private MinioUtil minioUtil;
@Resource
private UserLikeService userLikeService;
@Resource
private UserLikeGroupService userLikeGroupService;
@Value("${minio.bucketName.modifiedSketch}") @Value("${minio.bucketName.modifiedSketch}")
private String modifiedSketchBucket; private String modifiedSketchBucket;
@@ -182,9 +173,9 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
SysFileVO sysFileVO = sysFileService.getById(idValue); SysFileVO sysFileVO = sysFileService.getById(idValue);
if (Objects.nonNull(sysFileVO)){ if (Objects.nonNull(sysFileVO)) {
return new GetNextSysElementVO(sysFileVO.getId(), level2Type, sysFileVO.getUrl()); return new GetNextSysElementVO(sysFileVO.getId(), level2Type, sysFileVO.getUrl());
}else { } else {
return new GetNextSysElementVO(); return new GetNextSysElementVO();
} }
} }
@@ -196,7 +187,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found"); throw new BusinessException("designItem.not.found");
} }
Design design = designService.getById(designItem.getDesignId()); Design design = designMapper.selectById(designItem.getDesignId());
if (Objects.isNull(design)) { if (Objects.isNull(design)) {
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
@@ -246,7 +237,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found"); throw new BusinessException("designItem.not.found");
} }
Design design = designService.getById(designItem.getDesignId()); Design design = designMapper.selectById(designItem.getDesignId());
if (Objects.isNull(design)) { if (Objects.isNull(design)) {
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
@@ -283,6 +274,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
} }
// todo check这个方法是否还在用 // todo check这个方法是否还在用
private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects private DesignCollectionItemVO saveSingleDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) { , Long designId, Long designItemId, Long collectionId, AuthPrincipalVo userInfo, String timeZone) {
@@ -297,24 +289,50 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
response.setDesignItemUrl(url); response.setDesignItemUrl(url);
//更新item //更新item
updateById(designItem); updateById(designItem);
//删除itemDetail
designItemDetailService.deleteByDesignItemId(designItemId); // 查询现有的记录,用于 saveOrUpdate
List<DesignItemDetail> existingDetails = designItemDetailService.selectByDesignItemId(designItemId);
// 创建 Map以 priority 为 key方便快速查找
Map<Integer, DesignItemDetail> existingDetailMap = existingDetails.stream()
.collect(Collectors.toMap(DesignItemDetail::getPriority, detail -> detail, (old, newVal) -> old));
// 收集新 detail 的 priority用于后续删除不存在的旧记录
Set<Integer> newDetailPriorities = new HashSet<>();
List<DesignItemDetail> designItemDetails = Lists.newArrayList(); List<DesignItemDetail> designItemDetails = Lists.newArrayList();
pythonObjects.getObjects().get(0).getItems().forEach(detail -> { pythonObjects.getObjects().get(0).getItems().forEach(detail -> {
if (null == detail) { if (null == detail) {
return; return;
} }
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail, DesignItemDetail.class); Integer priority = SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType()) ? 0 : detail.getPriority();
newDetailPriorities.add(priority);
DesignItemDetail designItemDetail;
// 如果存在相同 priority 的记录,则更新;否则创建新记录
if (existingDetailMap.containsKey(priority)) {
// 更新现有记录
designItemDetail = existingDetailMap.get(priority);
designItemDetail.setUpdateDate(DateUtil.getByTimeZone(timeZone));
} else {
// 创建新记录
designItemDetail = new DesignItemDetail();
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
}
// 设置/更新字段
designItemDetail.setAccountId(userInfo.getId()); designItemDetail.setAccountId(userInfo.getId());
designItemDetail.setDesignId(designId); designItemDetail.setDesignId(designId);
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setType(detail.getType());
designItemDetail.setPriority(priority);
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path()); designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId //BODY不关联businessId
designItemDetail.setBusinessId(0L); designItemDetail.setBusinessId(0L);
} else {
// 非BODY类型使用path字段
designItemDetail.setPath(detail.getPath());
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
// todo // todo
@@ -323,7 +341,20 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetail.setPrintJson(JSON.toJSONString(printObject)); designItemDetail.setPrintJson(JSON.toJSONString(printObject));
designItemDetails.add(designItemDetail); designItemDetails.add(designItemDetail);
}); });
designItemDetailService.saveBatch(designItemDetails);
// 逻辑删除不在新列表中的旧记录
existingDetails.forEach(existingDetail -> {
if (!newDetailPriorities.contains(existingDetail.getPriority())) {
// 该记录不在新列表中,需要逻辑删除
UpdateWrapper<DesignItemDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", existingDetail.getId());
updateWrapper.set("is_deleted", (byte) 1);
updateWrapper.set("update_date", DateUtil.getByTimeZone(timeZone));
designItemDetailService.update(null, updateWrapper);
}
});
designItemDetailService.saveOrUpdateBatch(designItemDetails);
//封装item信息 //封装item信息
List<DesignCollectionItemVO> designCollectionItems = CopyUtil.copyList(getByDesignId(designId) List<DesignCollectionItemVO> designCollectionItems = CopyUtil.copyList(getByDesignId(designId)
, DesignCollectionItemVO.class, (o, d) -> { , DesignCollectionItemVO.class, (o, d) -> {
@@ -345,37 +376,62 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItem.setUpdateDate(DateUtil.getByTimeZone(timeZone)); designItem.setUpdateDate(DateUtil.getByTimeZone(timeZone));
designItem.setDesignUrl(outfit.getString("synthesis_url")); designItem.setDesignUrl(outfit.getString("synthesis_url"));
designItem.setId(designItemId); designItem.setId(designItemId);
if (changeModelFlag){ if (changeModelFlag) {
designItem.setModelId(modelId); designItem.setModelId(modelId);
designItem.setModelType(modelType); designItem.setModelType(modelType);
} }
// 1、更新designItem // 1、更新designItem
// updateById(designItem); // updateById(designItem);
updateDesignItem(designItem); updateDesignItem(designItem);
// 2、删除designItemDetail(逻辑删除)
designItemDetailService.deleteByDesignItemId(designItemId); // 2、查询现有的记录用于 saveOrUpdate
List<DesignItemDetail> existingDetails = designItemDetailService.selectByDesignItemId(designItemId);
// 创建 Map以 priority 为 key方便快速查找
Map<Integer, DesignItemDetail> existingDetailMap = existingDetails.stream()
.collect(Collectors.toMap(DesignItemDetail::getPriority, detail -> detail, (old, newVal) -> old));
// 收集新 detail 的 priority用于后续删除不存在的旧记录
Set<Integer> newDetailPriorities = new HashSet<>();
List<DesignItemDetail> designItemDetails = Lists.newArrayList(); List<DesignItemDetail> designItemDetails = Lists.newArrayList();
// 3、保存新的designItemDetail // 3、保存新的designItemDetail(使用 saveOrUpdate 方式)
pythonObjects.getObjects().get(0).getItems().forEach(detail -> { pythonObjects.getObjects().get(0).getItems().forEach(detail -> {
if (null == detail) { if (null == detail) {
return; return;
} }
DesignItemDetail designItemDetail = CopyUtil.copyObject(detail, DesignItemDetail.class); Integer priority = SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType()) ? 0 : detail.getPriority();
newDetailPriorities.add(priority);
DesignItemDetail designItemDetail;
// 如果存在相同 priority 的记录,则更新;否则创建新记录
if (existingDetailMap.containsKey(priority)) {
// 更新现有记录
designItemDetail = existingDetailMap.get(priority);
designItemDetail.setUpdateDate(DateUtil.getByTimeZone(timeZone));
} else {
// 创建新记录
designItemDetail = new DesignItemDetail();
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
}
// 设置/更新字段
designItemDetail.setAccountId(userId); designItemDetail.setAccountId(userId);
designItemDetail.setDesignId(designId); designItemDetail.setDesignId(designId);
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setPriority(detail.getPriority()); designItemDetail.setType(detail.getType());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setPriority(priority);
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
designItemDetail.setPath(detail.getBody_path()); designItemDetail.setPath(detail.getBody_path());
//BODY不关联businessId //BODY不关联businessId
designItemDetail.setBusinessId(0L); designItemDetail.setBusinessId(0L);
designItemDetail.setPriority(0); } else {
// 非BODY类型使用path字段
designItemDetail.setPath(detail.getPath());
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
// designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getType().toLowerCase())); // designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0)); designItemDetail.setUndividedLayer(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(0));
designItemDetail.setUndividedLayerWithSinglePrint(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(1)); designItemDetail.setUndividedLayerWithSinglePrint(priorityAndUndividedLayer.get(detail.getPriority().toString()).get(1));
@@ -389,12 +445,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designItemDetail.setPartialDesign(Objects.isNull(detail.getPrint()) ? null : detail.getPrint().getPartial()); designItemDetail.setPartialDesign(Objects.isNull(detail.getPrint()) ? null : detail.getPrint().getPartial());
designItemDetails.add(designItemDetail); designItemDetails.add(designItemDetail);
}); });
// 逻辑删除不在新列表中的旧记录
existingDetails.forEach(existingDetail -> {
if (!newDetailPriorities.contains(existingDetail.getPriority())) {
// 该记录不在新列表中,需要逻辑删除
UpdateWrapper<DesignItemDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", existingDetail.getId());
updateWrapper.set("is_deleted", (byte) 1);
updateWrapper.set("update_date", DateUtil.getByTimeZone(timeZone));
designItemDetailService.update(null, updateWrapper);
}
});
// businessId 来自t_sys_file或者t_library // businessId 来自t_sys_file或者t_library
designItemDetailService.saveBatch(designItemDetails); designItemDetailService.saveOrUpdateBatch(designItemDetails);
// 4、保存印花信息到designItemDetailPrint // 4、保存印花信息到designItemDetailPrint(使用 saveOrUpdate 方式)
List<DesignItemDetailPrint> designItemDetailPrints = setDesignItemDetailPrintList(designItemDetails, designSingleItemDTOList, timeZone); List<DesignItemDetailPrint> designItemDetailPrints = setDesignItemDetailPrintList(designItemDetails, designSingleItemDTOList, timeZone);
designItemDetailPrintService.saveBatch(designItemDetailPrints); designItemDetailPrintService.saveOrUpdateBatch(designItemDetailPrints);
// 5、覆盖designPythonOutfit表中的模特全身图 // 5、覆盖designPythonOutfit表中的模特全身图
TDesignPythonOutfit designPythonOutfit = new TDesignPythonOutfit(); TDesignPythonOutfit designPythonOutfit = new TDesignPythonOutfit();
@@ -403,20 +472,72 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designPythonOutfit.setUpdateDate(LocalDateTime.now(ZoneId.of(timeZone))); designPythonOutfit.setUpdateDate(LocalDateTime.now(ZoneId.of(timeZone)));
designPythonOutfitService.updateById(designPythonOutfit); designPythonOutfitService.updateById(designPythonOutfit);
// 6、删除designPythonOutfitDetail表中原始的图层信息逻辑删除 // 6、查询现有的图层信息,用于 saveOrUpdate
designPythonOutfitDetailService.deleteByDesignPythonOutfitIdLogical(designPythonOutfit.getId()); List<TDesignPythonOutfitDetail> existingLayers = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
// 创建 Map以 priority 为 key方便快速查找
Map<Integer, TDesignPythonOutfitDetail> existingLayerMap = existingLayers.stream()
.collect(Collectors.toMap(TDesignPythonOutfitDetail::getPriority, layer -> layer, (old, newVal) -> old));
// 7、将新生成的图层信息存入designPythonOutfitDetail表 // 收集新 layer 的 priority用于后续删除不存在的旧记录
Set<Integer> newLayerPriorities = new HashSet<>();
// 7、将新生成的图层信息存入designPythonOutfitDetail表使用 saveOrUpdate 方式)
JSONArray layers = outfit.getJSONArray("layers"); JSONArray layers = outfit.getJSONArray("layers");
Map<Integer, List<Long>> priorityOffset = null; Map<Integer, List<Long>> priorityOffset = null;
if (!isSingleCollectionFlag){ if (!isSingleCollectionFlag) {
priorityOffset = designSingleItemDTOList.stream() priorityOffset = designSingleItemDTOList.stream()
.collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset)); .collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset));
} }
List<TDesignPythonOutfitDetail> list = setTDesignPythonOutfitDetailList(layers, designId, designPythonOutfit.getId(), userId, priorityOffset); List<TDesignPythonOutfitDetail> list = new ArrayList<>();
for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i);
Integer priority = (Integer) jsonObject.get("priority");
newLayerPriorities.add(Math.abs(priority));
TDesignPythonOutfitDetail designPythonOutfitDetail;
// 如果存在相同 priority 的记录,则更新;否则创建新记录
if (existingLayerMap.containsKey(Math.abs(priority))) {
// 更新现有记录
designPythonOutfitDetail = existingLayerMap.get(Math.abs(priority));
designPythonOutfitDetail.setUpdateDate(LocalDateTime.now(ZoneId.of(timeZone)));
} else {
// 创建新记录
designPythonOutfitDetail = new TDesignPythonOutfitDetail();
designPythonOutfitDetail.setCreateDate(LocalDateTime.now(ZoneId.of(timeZone)));
}
// 设置/更新字段
designPythonOutfitDetail.setDesignId(designId);
designPythonOutfitDetail.setDesignPythonOutfitId(designPythonOutfit.getId());
designPythonOutfitDetail.setPosition(jsonObject.getString("position"));
designPythonOutfitDetail.setImageUrl(jsonObject.getString("image_url"));
designPythonOutfitDetail.setImageSize(jsonObject.getString("image_size"));
designPythonOutfitDetail.setImageCategory(jsonObject.getString("image_category"));
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale"));
designPythonOutfitDetail.setUserId(userId);
if (priorityOffset != null && !priorityOffset.isEmpty()){
designPythonOutfitDetail.setOffset(String.valueOf(priorityOffset.get(Math.abs(priority))));
}
designPythonOutfitDetail.setPriority(priority);
list.add(designPythonOutfitDetail);
}
// 逻辑删除不在新列表中的旧记录
existingLayers.forEach(existingLayer -> {
if (!newLayerPriorities.contains(Math.abs(existingLayer.getPriority()))) {
// 该记录不在新列表中,需要逻辑删除
UpdateWrapper<TDesignPythonOutfitDetail> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", existingLayer.getId());
updateWrapper.set("is_deleted", 1);
updateWrapper.set("update_date", LocalDateTime.now(ZoneId.of(timeZone)));
designPythonOutfitDetailService.update(null, updateWrapper);
}
});
designPythonOutfitDetailService.saveBatch(list); designPythonOutfitDetailService.saveOrUpdateBatch(list);
return list; return list;
} }
@@ -444,7 +565,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url")); designPythonOutfitDetail.setMaskUrl(jsonObject.getString("mask_url"));
designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale")); designPythonOutfitDetail.setScale(Objects.isNull(jsonObject.getString("resize_scale")) ? "1.0" : jsonObject.getString("resize_scale"));
designPythonOutfitDetail.setUserId(userId); designPythonOutfitDetail.setUserId(userId);
if (priorityOffset != null && !priorityOffset.isEmpty()){ if (priorityOffset != null && !priorityOffset.isEmpty()) {
designPythonOutfitDetail.setOffset(String.valueOf(priorityOffset.get(Math.abs(Integer.parseInt(jsonObject.getString("priority")))))); designPythonOutfitDetail.setOffset(String.valueOf(priorityOffset.get(Math.abs(Integer.parseInt(jsonObject.getString("priority"))))));
} }
designPythonOutfitDetail.setPriority((Integer) jsonObject.get("priority")); designPythonOutfitDetail.setPriority((Integer) jsonObject.get("priority"));
@@ -471,24 +592,24 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) { public DesignSingleVO designSingleIncludeLayers(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
// 记录入参 base64数据太长所以这里去掉 // 记录入参 base64数据太长所以这里去掉
DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO); DesignSingleIncludeLayersDTO clone = SerializationUtils.clone(designSingleIncludeLayersDTO);
clone.getDesignSingleItemDTOList().forEach( i -> { clone.getDesignSingleItemDTOList().forEach(i -> {
// 渐变色 // 渐变色
if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())){ if (!Objects.isNull(i.getGradient()) && !StringUtil.isNullOrEmpty(i.getGradient().getColorImg())) {
log.info("set gradient colorImage为空便于日志打印"); log.info("set gradient colorImage为空便于日志打印");
i.getGradient().setColorImg(null); i.getGradient().setColorImg(null);
} }
// 画笔修改过的sketch // 画笔修改过的sketch
if (!StringUtil.isNullOrEmpty(i.getSketchString())){ if (!StringUtil.isNullOrEmpty(i.getSketchString())) {
log.info("set sketchString为空便于日志打印"); log.info("set sketchString为空便于日志打印");
i.setSketchString(null); i.setSketchString(null);
} }
// 标注过的mask // 标注过的mask
if (!StringUtil.isNullOrEmpty(i.getMaskUrl())){ if (!StringUtil.isNullOrEmpty(i.getMaskUrl())) {
log.info("set labelingMask为空便于日志打印"); log.info("set labelingMask为空便于日志打印");
i.setMaskUrl(null); i.setMaskUrl(null);
} }
if (!Objects.isNull(i.getPartialDesign()) && if (!Objects.isNull(i.getPartialDesign()) &&
!StringUtil.isNullOrEmpty(i.getPartialDesign().getPartialDesignBase64())){ !StringUtil.isNullOrEmpty(i.getPartialDesign().getPartialDesignBase64())) {
log.info("set partialDesignBase64为空便于日志打印"); log.info("set partialDesignBase64为空便于日志打印");
i.getPartialDesign().setPartialDesignBase64(null); i.getPartialDesign().setPartialDesignBase64(null);
} }
@@ -501,7 +622,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (Objects.isNull(designItem)) { if (Objects.isNull(designItem)) {
throw new BusinessException("designItem.not.found"); throw new BusinessException("designItem.not.found");
} }
Design design = designService.getById(designItem.getDesignId()); Design design = designMapper.selectById(designItem.getDesignId());
if (Objects.isNull(design)) { if (Objects.isNull(design)) {
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
@@ -514,10 +635,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
Map<Integer, List<Long>> priorityOffset = new HashMap<>(); Map<Integer, List<Long>> priorityOffset = new HashMap<>();
// 单品设计标志 // 单品设计标志
boolean isSingleCollectionFlag = true; boolean isSingleCollectionFlag = true;
if (design.getSingleOverall().equals("overall")){ if (design.getSingleOverall().equals("overall")) {
isSingleCollectionFlag = false; isSingleCollectionFlag = false;
// 优先级 1、判断当前入参中是否有model数据 无 -> 2、判断design item 中是否有model数据 无 -> 3、从design表中拿model数据 仍然没有 报错 // 优先级 1、判断当前入参中是否有model数据 无 -> 2、判断design item 中是否有model数据 无 -> 3、从design表中拿model数据 仍然没有 报错
if (!Objects.isNull(designSingleIncludeLayersDTO.getModelId()) && !StringUtil.isNullOrEmpty(designSingleIncludeLayersDTO.getModelType())){ if (!Objects.isNull(designSingleIncludeLayersDTO.getModelId()) && !StringUtil.isNullOrEmpty(designSingleIncludeLayersDTO.getModelType())) {
modelId = designSingleIncludeLayersDTO.getModelId(); modelId = designSingleIncludeLayersDTO.getModelId();
modelType = designSingleIncludeLayersDTO.getModelType(); modelType = designSingleIncludeLayersDTO.getModelType();
changeModelFlag = true; changeModelFlag = true;
@@ -543,7 +664,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
modelUrl = sysFile.getUrl(); modelUrl = sysFile.getUrl();
high = 700; high = 700;
width = 320; width = 320;
} else if (modelType.equals(ModelType.LIBRARY.getValue())){ } else if (modelType.equals(ModelType.LIBRARY.getValue())) {
Library libFile = libraryService.getById(modelId); Library libFile = libraryService.getById(modelId);
if (Objects.isNull(libFile)) { if (Objects.isNull(libFile)) {
throw new BusinessException("model.not.found"); throw new BusinessException("model.not.found");
@@ -560,10 +681,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl); designLibraryModelPointVO = collectionElementService.calculateTemplatePoint(modelPoint, high, width, modelUrl);
// 通过priority将offset关联到layers // 通过priority将offset关联到layers
try{ try {
priorityOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream() priorityOffset = designSingleIncludeLayersDTO.getDesignSingleItemDTOList().stream()
.collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset)); .collect(Collectors.toMap(DesignSingleItemDTO::getPriority, DesignSingleItemDTO::getOffset));
}catch (IllegalStateException e){ } catch (IllegalStateException e) {
// priority重复 // priority重复
log.info("服装的priority重复"); log.info("服装的priority重复");
throw new BusinessException("priority.cannot.be.repeated"); throw new BusinessException("priority.cannot.be.repeated");
@@ -573,14 +694,14 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 画笔修改的sketch截图 上传后替换path // 画笔修改的sketch截图 上传后替换path
// 由于用户在系统或自己上传sketch的基础上修改过的衣服再次修改后第一次修改的衣服不会回到某个池子被再次利用 // 由于用户在系统或自己上传sketch的基础上修改过的衣服再次修改后第一次修改的衣服不会回到某个池子被再次利用
// 所以这里选择使用system或collection相同的地址只是放在不同的桶这样能保证图片服务器上,类似的sketch不会存在很多 // 所以这里选择使用system或collection相同的地址只是放在不同的桶这样能保证图片服务器上,类似的sketch不会存在很多
sketchBase64ToPath(designSingleIncludeLayersDTO); sketchBase64ToPath(designSingleIncludeLayersDTO, userId);
// 将标注后的mask上传到minio,并将minio地址传给python端 // 将标注后的mask上传到minio,并将minio地址传给python端
// todo 如果当前design使用的仍是旧的mask 则置maskUrl为null // todo 如果当前design使用的仍是旧的mask 则置maskUrl为null
// 1、查询当前design item在不在history中 // 1、查询当前design item在不在history中
UserLike userLikeDesign = userLikeService.getByDesignItemId(designItem.getId()); UserLike userLikeDesign = userLikeService.getByDesignItemId(designItem.getId());
Boolean setNull = Boolean.FALSE; Boolean setNull = Boolean.FALSE;
if (!Objects.isNull(userLikeDesign) && userLikeDesign.getConverted() == 0){ if (!Objects.isNull(userLikeDesign) && userLikeDesign.getConverted() == 0) {
setNull = Boolean.TRUE; setNull = Boolean.TRUE;
} }
maskBase64ToPath(designSingleIncludeLayersDTO, setNull); maskBase64ToPath(designSingleIncludeLayersDTO, setNull);
@@ -598,7 +719,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// preview -> 不存数据库 submit -> 存数据库 // preview -> 不存数据库 submit -> 存数据库
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails; List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails;
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
if (data == null || data.toJSONString().equals("{}") ) { if (data == null || data.toJSONString().equals("{}")) {
throw new BusinessException("python response data is null"); throw new BusinessException("python response data is null");
} }
JSONObject outfit = data.getJSONObject("0"); JSONObject outfit = data.getJSONObject("0");
@@ -626,17 +747,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId()); TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designSingleIncludeLayersDTO.getDesignItemId());
// Assert.notNull(designItem, "design item detail layers does not exists!"); // Assert.notNull(designItem, "design item detail layers does not exists!");
// 如果当前item被like过需要更新t_user_like表和t_user_like_group表 // 如果当前item被like过需要更新t_user_like表和t_user_like_group表
if (!designSingleIncludeLayersDTO.getIsPreview()){ if (!designSingleIncludeLayersDTO.getIsPreview()) {
updateUserLikeDate(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone()); updateUserLikeDate(designSingleIncludeLayersDTO.getDesignItemId(), designSingleIncludeLayersDTO.getTimeZone());
// 更新项目更新时间 // 更新项目更新时间
if (Objects.nonNull(designSingleIncludeLayersDTO.getProjectId())){ if (Objects.nonNull(designSingleIncludeLayersDTO.getProjectId())) {
projectService.modifyProjectUpdateTime(designSingleIncludeLayersDTO.getProjectId()); projectService.modifyProjectUpdateTime(designSingleIncludeLayersDTO.getProjectId());
}else { } else {
log.error("design single projectId传入空值导致项目修改时间没有更新"); log.error("design single projectId传入空值导致项目修改时间没有更新");
} }
}else { } else {
updateUserLikeConvertStatus(designSingleIncludeLayersDTO.getDesignItemId(),designSingleIncludeLayersDTO.getTimeZone()); updateUserLikeConvertStatus(designSingleIncludeLayersDTO.getDesignItemId(), designSingleIncludeLayersDTO.getTimeZone());
} }
return assembleDesignSingleResponse(designItem.getId(), return assembleDesignSingleResponse(designItem.getId(),
@@ -653,18 +774,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
return selectById(designItemId); // 普通查询,不加锁 return selectById(designItemId); // 普通查询,不加锁
} }
private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){ private void sketchBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long userId) {
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
// 如果sketch截图不为空则将该截图上传并替换path // 如果sketch截图不为空则将该截图上传并替换path
if (!StringUtil.isNullOrEmpty(item.getSketchString())){ if (!StringUtil.isNullOrEmpty(item.getSketchString())) {
if (StringUtil.isNullOrEmpty(item.getPath())){ if (StringUtil.isNullOrEmpty(item.getPath())) {
throw new BusinessException("path.cannot.be.empty"); throw new BusinessException("path.cannot.be.empty");
} }
String sourcePath = item.getPath(); String sourcePath = item.getPath();
String path = sourcePath.substring(sourcePath.indexOf("/") + 1, sourcePath.lastIndexOf(".")); String path = sourcePath.substring(sourcePath.lastIndexOf("/") + 1, sourcePath.lastIndexOf("."));
// 路径组成用户id + sketchboard + temp | modified + 原图所在不同桶的原路径
if (designSingleIncludeLayersDTO.getIsPreview()) {
path = userId + "/sketchboard/temp/" + path;
} else {
path = userId + "/sketchboard/modified/" + path;
}
// 将原图地址作为修改后的图片地址,放在不同的桶 // 将原图地址作为修改后的图片地址,放在不同的桶
String newPath = minioUtil.base64UploadToPath(item.getSketchString(), modifiedSketchBucket, path); String newPath = minioUtil.base64UploadToPath(item.getSketchString(), modifiedSketchBucket, path);
if (StringUtil.isNullOrEmpty(newPath)){ if (StringUtil.isNullOrEmpty(newPath)) {
log.error("修改过的sketch图片上传失败"); log.error("修改过的sketch图片上传失败");
throw new BusinessException("image.modify.failed"); throw new BusinessException("image.modify.failed");
} }
@@ -673,25 +801,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
} }
private void maskBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Boolean setNull){ private void maskBase64ToPath(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Boolean setNull) {
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
// 如果sketch截图不为空则将该截图上传并替换path // 如果sketch截图不为空则将该截图上传并替换path
if (setNull){ if (setNull) {
log.info("服装类型为{} set maskUrl为null", item.getType()); log.info("服装类型为{} set maskUrl为null", item.getType());
item.setMaskUrl(null); item.setMaskUrl(null);
}else { } else {
if (!StringUtil.isNullOrEmpty(item.getMaskUrl())){ if (!StringUtil.isNullOrEmpty(item.getMaskUrl())) {
log.info("服装{} 的maskUrl不为null", item.getType()); log.info("服装{} 的maskUrl不为null", item.getType());
// 由于前端不好处理这块所以当mask没有做任何修改的时候仍然会传原始mask的minio地址 // 由于前端不好处理这块所以当mask没有做任何修改的时候仍然会传原始mask的minio地址
if (!item.getMaskUrl().startsWith("data:image") && item.getMaskUrl().startsWith("https://")){ if (!item.getMaskUrl().startsWith("data:image") && item.getMaskUrl().startsWith("https://")) {
// 当没有修改mask时还是用之前的mask地址 // 当没有修改mask时还是用之前的mask地址
item.setMaskUrl(item.getMaskMinioUrl()); item.setMaskUrl(item.getMaskMinioUrl());
log.info("服装{} 的maskUrl没有被编辑", item.getType()); log.info("服装{} 的maskUrl没有被编辑", item.getType());
}else { } else {
// 将原图地址作为修改后的图片地址,放在不同的桶 // 将原图地址作为修改后的图片地址,放在不同的桶
String path = minioUtil.base64UploadToPath(item.getMaskUrl(), clothingBucket, "labelingMask/" + UUID.randomUUID()); String path = minioUtil.base64UploadToPath(item.getMaskUrl(), clothingBucket, "labelingMask/" + UUID.randomUUID());
log.info("服装{} 的maskUrl已被编辑 新的path为{}", item.getType(), path); log.info("服装{} 的maskUrl已被编辑 新的path为{}", item.getType(), path);
if (StringUtil.isNullOrEmpty(path)){ if (StringUtil.isNullOrEmpty(path)) {
log.error("标注的mask图片上传失败"); log.error("标注的mask图片上传失败");
throw new BusinessException("image.modify.failed"); throw new BusinessException("image.modify.failed");
} }
@@ -703,53 +831,55 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
} }
private void partialDesignBase64ToImage(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long accountId, boolean preview){ private void partialDesignBase64ToImage(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO, Long accountId, boolean preview) {
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(item -> {
PartialDesignDTO partialDesignDTO = item.getPartialDesign(); PartialDesignDTO partialDesignDTO = item.getPartialDesign();
if (!Objects.isNull(item.getPartialDesign()) if (!Objects.isNull(item.getPartialDesign())
&& !StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignBase64())){ && !StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignBase64())) {
String path ; String path;
if (!StringUtil.isNullOrEmpty(partialDesignDTO.getPartialDesignMinioPath()) && !preview){ if (!StringUtil.isNullOrEmpty(partialDesignDTO.getPartialDesignMinioPath()) && !preview) {
String sourcePath = partialDesignDTO.getPartialDesignMinioPath(); String sourcePath = partialDesignDTO.getPartialDesignMinioPath();
path = sourcePath.substring(sourcePath.indexOf("/") + 1, sourcePath.lastIndexOf(".")); path = sourcePath.substring(sourcePath.indexOf("/") + 1, sourcePath.lastIndexOf("."));
}else if (preview){ } else if (preview) {
path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_PREVIEW_FILENAME + "/" + UUID.randomUUID(); path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_PREVIEW_FILENAME + "/" + UUID.randomUUID();
}else { } else {
path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_FILENAME + "/" + UUID.randomUUID(); path = accountId + "/" + CommonConstant.PARTIAL_DESIGN_FILENAME + "/" + UUID.randomUUID();
} }
String newPath = minioUtil.base64UploadToPath(partialDesignDTO.getPartialDesignBase64(), partialDesignBucket, path); String newPath = minioUtil.base64UploadToPath(partialDesignDTO.getPartialDesignBase64(), partialDesignBucket, path);
if (StringUtil.isNullOrEmpty(newPath)){ if (StringUtil.isNullOrEmpty(newPath)) {
log.error("局部design图片上传失败"); log.error("局部design图片上传失败");
throw new BusinessException("partial.design.failed"); throw new BusinessException("partial.design.failed");
} }
item.getPartialDesign().setPartialDesignMinioPath(newPath); item.getPartialDesign().setPartialDesignMinioPath(newPath);
}else if (Objects.isNull(item.getPartialDesign()) } else if (Objects.isNull(item.getPartialDesign())
|| StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignMinioPath())){ || StringUtil.isNullOrEmpty(item.getPartialDesign().getPartialDesignMinioPath())) {
item.setPartialDesign(new PartialDesignDTO(null)); item.setPartialDesign(new PartialDesignDTO(null));
} }
}); });
} }
@Override @Override
public Map<String, List<String>> setPriorityAndUndividedLayer(JSONArray layers){ public Map<String, List<String>> setPriorityAndUndividedLayer(JSONArray layers) {
HashMap<String, List<String>> priorityAndLayer = new HashMap<>(); HashMap<String, List<String>> priorityAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) { for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i); JSONObject jsonObject = layers.getJSONObject(i);
String priority = jsonObject.getString("priority"); String priority = jsonObject.getString("priority");
String category = jsonObject.getString("image_category").split("_")[0]; String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !priorityAndLayer.containsKey(priority)) priorityAndLayer.put(priority, Arrays.asList(jsonObject.getString("pattern_overall_image_url"), jsonObject.getString("pattern_print_image_url"))); if (!category.equals("body") && !priorityAndLayer.containsKey(priority))
priorityAndLayer.put(priority, Arrays.asList(jsonObject.getString("pattern_overall_image_url"), jsonObject.getString("pattern_print_image_url")));
} }
return priorityAndLayer; return priorityAndLayer;
} }
// 由于在design过程中没有priority 优先级的概念并且在design时不会出现上下两件使用相同服装类型的情况所以这里依然保留这个方法。 // 由于在design过程中没有priority 优先级的概念并且在design时不会出现上下两件使用相同服装类型的情况所以这里依然保留这个方法。
@Override @Override
public Map<String, String> setTypeAndUndividedLayer(JSONArray layers){ public Map<String, String> setTypeAndUndividedLayer(JSONArray layers) {
HashMap<String, String> typeAndLayer = new HashMap<>(); HashMap<String, String> typeAndLayer = new HashMap<>();
for (int i = 0; i < layers.size(); i++) { for (int i = 0; i < layers.size(); i++) {
JSONObject jsonObject = layers.getJSONObject(i); JSONObject jsonObject = layers.getJSONObject(i);
String category = jsonObject.getString("image_category").split("_")[0]; String category = jsonObject.getString("image_category").split("_")[0];
if (!category.equals("body") && !typeAndLayer.containsKey(category)) typeAndLayer.put(category, jsonObject.getString("pattern_image_url")); if (!category.equals("body") && !typeAndLayer.containsKey(category))
typeAndLayer.put(category, jsonObject.getString("pattern_image_url"));
} }
return typeAndLayer; return typeAndLayer;
} }
@@ -760,18 +890,18 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
ComposeLayersVO designItemLayer = positionAndScaleVO.getLayers(); ComposeLayersVO designItemLayer = positionAndScaleVO.getLayers();
// 1、校验designItem是是否存在 // 1、校验designItem是是否存在
DesignItem designItem = selectById(designItemLayer.getDesignItemId()); DesignItem designItem = selectById(designItemLayer.getDesignItemId());
if (Objects.isNull(designItem)){ if (Objects.isNull(designItem)) {
throw new BusinessException("design.item.does.not.exist"); throw new BusinessException("design.item.does.not.exist");
} }
TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designItemLayer.getDesignItemId()); TDesignPythonOutfit designPythonOutfit = designPythonOutfitService.getByDesignItemId(designItemLayer.getDesignItemId());
if (Objects.isNull(designPythonOutfit)){ if (Objects.isNull(designPythonOutfit)) {
throw new BusinessException("layers.does.not.exists"); throw new BusinessException("layers.does.not.exists");
} }
// 2、校验layers是否存在 // 2、校验layers是否存在
designItemLayer.getLayers().forEach(layer -> { designItemLayer.getLayers().forEach(layer -> {
TDesignPythonOutfitDetail detail = designPythonOutfitDetailService.getById(layer.getId()); TDesignPythonOutfitDetail detail = designPythonOutfitDetailService.getById(layer.getId());
if (Objects.isNull(detail)){ if (Objects.isNull(detail)) {
log.error(layer.getImageCategory() + " layer does not exists!"); log.error(layer.getImageCategory() + " layer does not exists!");
throw new BusinessException("layers.does.not.exists"); throw new BusinessException("layers.does.not.exists");
} }
@@ -826,24 +956,25 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
}); });
// 9、如果当前item被like过需要更新t_user_like表和t_user_like_group表 // 9、如果当前item被like过需要更新t_user_like表和t_user_like_group表
updateUserLikeDate(designItemLayer.getDesignItemId(),positionAndScaleVO.getTimeZone()); updateUserLikeDate(designItemLayer.getDesignItemId(), positionAndScaleVO.getTimeZone());
return designItemLayer; return designItemLayer;
} }
private void updateUserLikeDate(Long designItemId,String timeZone){ private void updateUserLikeDate(Long designItemId, String timeZone) {
UserLike userLike = userLikeService.getByDesignItemId(designItemId); UserLike userLike = userLikeService.getByDesignItemId(designItemId);
if (!ObjectUtil.isEmpty(userLike)){ if (!ObjectUtil.isEmpty(userLike)) {
Long userLikeGroupId = userLike.getUserLikeGroupId(); Long userLikeGroupId = userLike.getUserLikeGroupId();
// 更新t_user_like和t_user_like_group表的update_date // 更新t_user_like和t_user_like_group表的update_date
userLikeService.updateDate(designItemId,timeZone); userLikeService.updateDate(designItemId, timeZone);
userLikeGroupService.updateDate(userLikeGroupId,timeZone); userLikeGroupService.updateDate(userLikeGroupId, timeZone);
} }
} }
private void updateUserLikeConvertStatus(Long designItemId,String timeZone){
private void updateUserLikeConvertStatus(Long designItemId, String timeZone) {
UserLike userLike = userLikeService.getByDesignItemId(designItemId); UserLike userLike = userLikeService.getByDesignItemId(designItemId);
if (!ObjectUtil.isEmpty(userLike) && userLike.getConverted() == 0){ if (!ObjectUtil.isEmpty(userLike) && userLike.getConverted() == 0) {
// 更新t_user_like和t_user_like_group表的update_date // 更新t_user_like和t_user_like_group表的update_date
userLikeService.updateDate(designItemId,timeZone); userLikeService.updateDate(designItemId, timeZone);
} }
} }
@@ -879,7 +1010,8 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 重置sketch的minio临时访问凭证 // 重置sketch的minio临时访问凭证
designItemClothesDetailVO.setPath(minioUtil.getPreSignedUrl(singleItem.getPath(), 24 * 60, true)); designItemClothesDetailVO.setPath(minioUtil.getPreSignedUrl(singleItem.getPath(), 24 * 60, true));
designItemClothesDetailVO.setMinIOPath(singleItem.getPath()); designItemClothesDetailVO.setMinIOPath(singleItem.getPath());
if (!StringUtil.isNullOrEmpty(singleItem.getColor())) designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor())); if (!StringUtil.isNullOrEmpty(singleItem.getColor()))
designItemClothesDetailVO.setColor(panToneService.getPantoneByRgb(singleItem.getColor()));
designItemClothesDetailVO.setPrintObject(singleItem.getPrintObject()); designItemClothesDetailVO.setPrintObject(singleItem.getPrintObject());
designItemClothesDetailVO.setTrims(singleItem.getTrims()); designItemClothesDetailVO.setTrims(singleItem.getTrims());
designItemClothesDetailVO.setLayersObject(layersObject.stream().filter( designItemClothesDetailVO.setLayersObject(layersObject.stream().filter(
@@ -891,7 +1023,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
String preSignedUrl = StringUtil.isNullOrEmpty(partialDesignMinioPath) ? null : minioUtil.getPreSignedUrl(partialDesignMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true); String preSignedUrl = StringUtil.isNullOrEmpty(partialDesignMinioPath) ? null : minioUtil.getPreSignedUrl(partialDesignMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true);
designItemClothesDetailVO.setPartialDesign(new PartialDesignDTO(partialDesignMinioPath, preSignedUrl)); designItemClothesDetailVO.setPartialDesign(new PartialDesignDTO(partialDesignMinioPath, preSignedUrl));
if (priorityAndUndividedLayer.containsKey(singleItem.getPriority().toString())){ if (priorityAndUndividedLayer.containsKey(singleItem.getPriority().toString())) {
designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(0), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true)); designItemClothesDetailVO.setUndividedLayer(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(0), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true));
designItemClothesDetailVO.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(1), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true)); designItemClothesDetailVO.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(priorityAndUndividedLayer.get(singleItem.getPriority().toString()).get(1), CommonConstant.MINIO_IMAGE_EXPIRE_TIME, true));
} }
@@ -925,48 +1057,79 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
ArrayList<DesignItemDetailPrint> designItemDetailPrints, ArrayList<DesignItemDetailPrint> designItemDetailPrints,
String printType, String printType,
Map<Integer, Long> designItemDetailTypeIdMap, Map<Integer, Long> designItemDetailTypeIdMap,
String timeZone){ String timeZone) {
// todo 这边这样做对吗
DesignSinglePrintDTO printObject; DesignSinglePrintDTO printObject;
if (printType.equals("print")){ if (printType.equals("print")) {
printObject = designSingleItem.getPrintObject(); printObject = designSingleItem.getPrintObject();
}else { } else {
printObject = designSingleItem.getTrims(); printObject = designSingleItem.getTrims();
} }
if (!CollectionUtil.isEmpty(printObject.getPrints())) { Long designItemDetailId = designItemDetailTypeIdMap.get(designSingleItem.getPriority());
// 2、有印花添加到list
printObject.getPrints().forEach(print -> { // 查询现有的记录,用于 saveOrUpdate
// 2.1 判断是否第一次添加印花,是:直接添加 List<DesignItemDetailPrint> existingPrints = designItemDetailPrintService.getByDesignItemDetailId(designItemDetailId, printType);
List<DesignItemDetailPrint> designItemDetailPrintList = designItemDetailPrintService.getByDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getPriority()), printType); // 创建 Map以 priority 为 key方便快速查找
if (!designItemDetailPrintList.isEmpty()) { Map<Integer, DesignItemDetailPrint> existingPrintMap = existingPrints.stream()
// 2.2 否:先删除原始印花,再添加新印花信息 .collect(Collectors.toMap(DesignItemDetailPrint::getPriority, print -> print, (old, newVal) -> old));
designItemDetailPrintService.deleteByDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getPriority()));
}
setUriToMinioPath(print);
DesignItemDetailPrint designItemDetailPrint = new DesignItemDetailPrint(); // 收集新 print 的 priority用于后续删除不存在的旧记录
designItemDetailPrint.setDesignItemDetailId(designItemDetailTypeIdMap.get(designSingleItem.getPriority())); Set<Integer> newPrintPriorities = new HashSet<>();
if (!CollectionUtil.isEmpty(printObject.getPrints())) {
// 处理新的印花列表
printObject.getPrints().forEach(print -> {
setUriToMinioPath(print);
Integer priority = print.getPriority();
newPrintPriorities.add(priority);
DesignItemDetailPrint designItemDetailPrint;
// 如果存在相同 priority 的记录,则更新;否则创建新记录
if (existingPrintMap.containsKey(priority)) {
// 更新现有记录
designItemDetailPrint = existingPrintMap.get(priority);
designItemDetailPrint.setUpdateDate(LocalDateTime.now(ZoneId.of(timeZone)));
} else {
// 创建新记录
designItemDetailPrint = new DesignItemDetailPrint();
designItemDetailPrint.setCreateDate(LocalDateTime.now(ZoneId.of(timeZone)));
}
// 设置/更新字段
designItemDetailPrint.setDesignItemDetailId(designItemDetailId);
designItemDetailPrint.setPrintType(printType); designItemDetailPrint.setPrintType(printType);
designItemDetailPrint.setLevel2Type(print.getLevel2Type()); designItemDetailPrint.setLevel2Type(print.getLevel2Type());
designItemDetailPrint.setPath(print.getMinIOPath()); designItemDetailPrint.setPath(print.getMinIOPath());
designItemDetailPrint.setScale(print.getScale().toString()); designItemDetailPrint.setScale(print.getScale().toString());
designItemDetailPrint.setSingleOrOverall(printType.equals("print") ? print.getIfSingle() ? "single" : "overall" : "single"); designItemDetailPrint.setSingleOrOverall(printType.equals("print") ? print.getIfSingle() ? "single" : "overall" : "single");
designItemDetailPrint.setCreateDate(LocalDateTime.now(ZoneId.of(timeZone)));
// single、overall模式下都有position、angle和priority // single、overall模式下都有position、angle和priority
designItemDetailPrint.setPosition(print.getLocation().toString()); designItemDetailPrint.setPosition(print.getLocation().toString());
designItemDetailPrint.setAngle(print.getAngle()); designItemDetailPrint.setAngle(print.getAngle());
designItemDetailPrint.setPriority(print.getPriority()); designItemDetailPrint.setPriority(priority);
designItemDetailPrints.add(designItemDetailPrint); designItemDetailPrints.add(designItemDetailPrint);
}); });
} }
// 逻辑删除不在新列表中的旧记录
existingPrints.forEach(existingPrint -> {
if (!newPrintPriorities.contains(existingPrint.getPriority())) {
// 该记录不在新列表中,需要逻辑删除
UpdateWrapper<DesignItemDetailPrint> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", existingPrint.getId());
updateWrapper.set("is_deleted", (byte) 1);
updateWrapper.set("update_date", LocalDateTime.now(ZoneId.of(timeZone)));
designItemDetailPrintService.update(null, updateWrapper);
}
});
} }
// 对印花类型为Generate的图片路径进行特殊处理 // 对印花类型为Generate的图片路径进行特殊处理
private void setUriToMinioPath(DesignSinglePrint print){ private void setUriToMinioPath(DesignSinglePrint print) {
if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Generate")){ if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Generate")) {
if (!StringUtil.isNullOrEmpty(print.getPath())){ if (!StringUtil.isNullOrEmpty(print.getPath())) {
try { try {
URI uri = new URI(print.getPath()); URI uri = new URI(print.getPath());
String path = uri.getPath(); // 获取路径部分: /aida-users/87/print/9ac32f65-6043-424d-a146-92c9c6d204ee-4-87.png String path = uri.getPath(); // 获取路径部分: /aida-users/87/print/9ac32f65-6043-424d-a146-92c9c6d204ee-4-87.png
@@ -996,20 +1159,20 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
@Override @Override
public List<DesignItem> selectDesignIdById(List<Long> designItemIdList){ public List<DesignItem> selectDesignIdById(List<Long> designItemIdList) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>(); QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",designItemIdList); queryWrapper.in("id", designItemIdList);
return designItemMapper.selectList(queryWrapper); return designItemMapper.selectList(queryWrapper);
} }
private void saveCollectionElement(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO){ private void saveCollectionElement(DesignSingleIncludeLayersDTO designSingleIncludeLayersDTO) {
ArrayList<Library> libraries = new ArrayList<>(); ArrayList<Library> libraries = new ArrayList<>();
// 添加sketch到library // 添加sketch到library
designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(designSingleItem -> { designSingleIncludeLayersDTO.getDesignSingleItemDTOList().forEach(designSingleItem -> {
if (!StringUtil.isNullOrEmpty(designSingleItem.getDesignType()) && designSingleItem.getDesignType().equals("Collection")){ if (!StringUtil.isNullOrEmpty(designSingleItem.getDesignType()) && designSingleItem.getDesignType().equals("Collection")) {
String path = minioUtil.getPreSignedUrl(designSingleItem.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String path = minioUtil.getPreSignedUrl(designSingleItem.getPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
try { try {
String md5 = MD5Utils.encryptFile(path, false); String md5 = MD5Utils.encryptFile(path, false);
@@ -1019,12 +1182,14 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
designSingleIncludeLayersDTO.getGender(), designSingleIncludeLayersDTO.getGender(),
md5); md5);
// 加入到library // 加入到library
if (needAdd){ if (needAdd) {
Library library = new Library(); Library library = new Library();
library.setAccountId(UserContext.getUserHolder().getId()); library.setAccountId(UserContext.getUserHolder().getId());
library.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName()); library.setLevel1Type(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName());
library.setLevel2Type(designSingleItem.getType()); library.setLevel2Type(designSingleItem.getType());
library.setLevel3Type(designSingleIncludeLayersDTO.getGender()); library.setLevel3Type(designSingleIncludeLayersDTO.getGender());
String ageGroup = workspaceService.getAgeGroupByProjectOrCollectionId(designSingleIncludeLayersDTO.getProjectId(), null);
library.setAgeGroup(ageGroup);
library.setUrl(designSingleItem.getPath()); library.setUrl(designSingleItem.getPath());
library.setName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); library.setName(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
library.setMd5(md5); library.setMd5(md5);
@@ -1038,7 +1203,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 添加print到library // 添加print到library
designSingleItem.getPrintObject().getPrints().forEach(print -> { designSingleItem.getPrintObject().getPrints().forEach(print -> {
if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Collection")){ if (!StringUtil.isNullOrEmpty(print.getDesignType()) && print.getDesignType().equals("Collection")) {
String path = minioUtil.getPreSignedUrl(print.getMinIOPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String path = minioUtil.getPreSignedUrl(print.getMinIOPath(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
try { try {
String md5 = MD5Utils.encryptFile(path, false); String md5 = MD5Utils.encryptFile(path, false);
@@ -1048,7 +1213,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
null, null,
md5); md5);
// 加入到library // 加入到library
if (needAdd){ if (needAdd) {
Library library = new Library(); Library library = new Library();
library.setAccountId(UserContext.getUserHolder().getId()); library.setAccountId(UserContext.getUserHolder().getId());
library.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName()); library.setLevel1Type(CollectionLevel1TypeEnum.PRINT_BOARD.getRealName());
@@ -1064,17 +1229,17 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
} }
}); });
} ); });
libraryService.saveBatch(libraries); libraryService.saveBatch(libraries);
} }
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){ public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds) {
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>(); QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
queryWrapper.gt("create_date", startTime) queryWrapper.gt("create_date", startTime)
.lt("create_date", endTime) .lt("create_date", endTime)
.select("count(distinct design_id) as count"); .select("count(distinct design_id) as count");
if (!accountIds.isEmpty()){ if (!accountIds.isEmpty()) {
queryWrapper.in("account_id", accountIds); queryWrapper.in("account_id", accountIds);
} }
@@ -1082,7 +1247,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (result != null && !result.isEmpty()) { if (result != null && !result.isEmpty()) {
Object countObj = result.get(0).get("count"); Object countObj = result.get(0).get("count");
return (Long) countObj; return (Long) countObj;
}else { } else {
return 0L; return 0L;
} }
} }
@@ -1090,14 +1255,15 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
@Resource @Resource
private UserLikeMapper userLikeMapper; private UserLikeMapper userLikeMapper;
@Override @Override
public void convertHistoryMaskWithoutGradient(){ public void convertHistoryMaskWithoutGradient() {
// 1、获取全部需要转换的designOutfitId // 1、获取全部需要转换的designOutfitId
// 1、获取t_user_like表中design_item_id不为-1的所有design_item_id, design_outfit_id // 1、获取t_user_like表中design_item_id不为-1的所有design_item_id, design_outfit_id
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>(); QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("design_item_id", -1) queryWrapper.ne("design_item_id", -1)
.ne("converted", 1) .ne("converted", 1)
.groupBy(Arrays.asList("design_outfit_id"," design_item_id")).select(" design_item_id", "design_outfit_id"); .groupBy(Arrays.asList("design_outfit_id", " design_item_id")).select(" design_item_id", "design_outfit_id");
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper); List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
// List<Map<String, Object>> userLikes = userLikeMapper.selectMaps(queryWrapper); // List<Map<String, Object>> userLikes = userLikeMapper.selectMaps(queryWrapper);
@@ -1149,10 +1315,10 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
if (suffixes.containsKey("front") && suffixes.containsKey("back")) { if (suffixes.containsKey("front") && suffixes.containsKey("back")) {
String frontMask = suffixes.get("front"); String frontMask = suffixes.get("front");
String backMask = suffixes.get("back"); String backMask = suffixes.get("back");
pairs.add(new String[]{designItemPath.get(entry.getKey()),frontMask, backMask, frontMask}); pairs.add(new String[]{designItemPath.get(entry.getKey()), frontMask, backMask, frontMask});
} }
} }
log.info("总数 count + current : {} + {} = {}", count, groupedData.size(), count.get() + groupedData.size()); log.info("总数 count + current : {} + {} = {}", count, groupedData.size(), count.get() + groupedData.size());
count.addAndGet(groupedData.size()); count.addAndGet(groupedData.size());
}); });
@@ -1164,7 +1330,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
try { try {
// 写入JSON文件 // 写入JSON文件
objectMapper.writeValue(new File("mask_pairs.json"), pairs); objectMapper.writeValue(new File("mask_pairs.json"), pairs);
log.info("待合成mask的数量{}",pairs.size()); log.info("待合成mask的数量{}", pairs.size());
System.out.println("数据已成功写入mask_pairs.json文件"); System.out.println("数据已成功写入mask_pairs.json文件");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@@ -1172,11 +1338,11 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateMaskUrl(){ public void updateMaskUrl() {
QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>(); QueryWrapper<UserLike> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("design_item_id", -1) queryWrapper.ne("design_item_id", -1)
.ne("converted", 1) .ne("converted", 1)
.groupBy(Arrays.asList("design_outfit_id"," design_item_id")).select(" design_item_id", "design_outfit_id"); .groupBy(Arrays.asList("design_outfit_id", " design_item_id")).select(" design_item_id", "design_outfit_id");
List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper); List<UserLike> userLikes = userLikeMapper.selectList(queryWrapper);
log.info("userLike 总数 {}", userLikes.size()); log.info("userLike 总数 {}", userLikes.size());
@@ -1198,7 +1364,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
// 检查是否以'front'结尾 // 检查是否以'front'结尾
if (imageCategory.endsWith("front")) { if (imageCategory.endsWith("front")) {
String maskPath = maskUrl.replace("aida-clothing", "test" ); String maskPath = maskUrl.replace("aida-clothing", "test");
String prefix = imageCategory.substring(0, imageCategory.lastIndexOf("_")); String prefix = imageCategory.substring(0, imageCategory.lastIndexOf("_"));
if (backMaskIdMap.containsKey(prefix)) { if (backMaskIdMap.containsKey(prefix)) {
TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail(); TDesignPythonOutfitDetail tDesignPythonOutfitDetail = new TDesignPythonOutfitDetail();
@@ -1206,7 +1372,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now()); tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
tDesignPythonOutfitDetail.setId(backMaskIdMap.get(prefix)); tDesignPythonOutfitDetail.setId(backMaskIdMap.get(prefix));
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail); tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
}else { } else {
frontMaskMap.put(prefix, maskPath); frontMaskMap.put(prefix, maskPath);
} }
@@ -1228,7 +1394,7 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now()); tDesignPythonOutfitDetail.setUpdateDate(LocalDateTime.now());
tDesignPythonOutfitDetail.setId(designPythonOutfitDetail.getId()); tDesignPythonOutfitDetail.setId(designPythonOutfitDetail.getId());
tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail); tDesignPythonOutfitDetails.add(tDesignPythonOutfitDetail);
}else { } else {
backMaskIdMap.put(prefix, designPythonOutfitDetail.getId()); backMaskIdMap.put(prefix, designPythonOutfitDetail.getId());
} }
} }

View File

@@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@@ -61,56 +62,47 @@ import static com.ai.da.python.vo.DesignPythonItem.*;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> implements DesignService { public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> implements DesignService {
@Resource private final CloudTaskMapper cloudTaskMapper;
private DesignMapper designMapper; private final CloudTaskService cloudTaskService;
@Resource private final CreditsService creditsService;
private CollectionElementService collectionElementService; private final CollectionElementService collectionElementService;
@Resource private final CollectionService collectionService;
private CollectionService collectionService; private final CollectionSortService collectionSortService;
@Resource private final ColorLoopUpTableService colorLoopUpTableService;
private PythonService pythonService; private final CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource private final DesignBatchMapper designBatchMapper;
private LibraryService libraryService; private final DesignMapper designMapper;
@Resource private final DesignItemService designItemService;
private GenerateDetailMapper generateDetailMapper; private final DesignItemDetailMapper designItemDetailMapper;
@Resource private final DesignItemDetailService designItemDetailService;
private DesignItemService designItemService; private final DesignItemDetailPrintService designItemDetailPrintService;
@Resource private final TDesignPythonOutfitMapper designPythonOutfitMapper;
private DesignItemDetailService designItemDetailService; private final ITDesignPythonOutfitService designPythonOutfitService;
@Resource private final ITDesignPythonOutfitDetailService designPythonOutfitDetailService;
private FileProperties fileProperties; private final FileProperties fileProperties;
@Resource private final GenerateDetailMapper generateDetailMapper;
private UserLikeGroupService userLikeGroupService; private final LibraryService libraryService;
@Resource private final MinioUtil minioUtil;
private UserLikeService userLikeService; private final MoodboardPositionMapper moodboardPositionMapper;
@Resource private final ProjectService projectService;
private SysFileService sysFileService; private final PythonService pythonService;
@Resource private final PanToneMapper panToneMapper;
private TCollectionElementRelationService tCollectionElementRelationService; private final PanToneService panToneService;
@Resource private final PoseTransformationMapper poseTransformationMapper;
private ITDesignPythonOutfitService designPythonOutfitService; private final PythonTAllInfoService pythonTAllInfoService;
@Resource private final RedisUtil redisUtil;
private ITDesignPythonOutfitDetailService designPythonOutfitDetailService; private final SysFileService sysFileService;
@Resource private final TCollectionElementRelationService tCollectionElementRelationService;
private PanToneService panToneService; private final ToProductImageResultMapper toProductImageResultMapper;
@Resource private final ToProductElementMapper toProductElementMapper;
private PythonTAllInfoService pythonTAllInfoService; private final ToProductImageRecordMapper toProductImageRecordMapper;
@Resource private final UserLikeGroupService userLikeGroupService;
private DesignItemDetailPrintService designItemDetailPrintService; private final UserLikeService userLikeService;
private final UserBehaviorMapper userBehaviorMapper;
@Resource private final UserPreferenceLogMapper userPreferenceLogMapper;
private TDesignPythonOutfitMapper designPythonOutfitMapper; private final WorkspaceService workspaceService;
@Resource
private DesignItemDetailMapper designItemDetailMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private ToProductElementMapper toProductElementMapper;
@Resource
private MoodboardPositionMapper moodboardPositionMapper;
@Resource
private CollectionSortService collectionSortService;
@Value("${minio.endpoint}") @Value("${minio.endpoint}")
private String endpoint; private String endpoint;
@@ -123,34 +115,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Value("${access.python.port:''}") @Value("${access.python.port:''}")
private String accessPythonPort; private String accessPythonPort;
@Resource
private RedisUtil redisUtil;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Resource
private DesignBatchMapper designBatchMapper;
@Resource
private ProjectService projectService;
@Resource
private WorkspaceService workspaceService;
@Resource
private CloudTaskMapper cloudTaskMapper;
@Resource
private CloudTaskService cloudTaskService;
@Resource
private CreditsService creditsService;
@Resource
private ToProductImageRecordMapper toProductImageRecordMapper;
@Resource
private ColorLoopUpTableService colorLoopUpTableService;
@Resource
private UserBehaviorMapper userBehaviorMapper;
@Resource
private UserPreferenceLogMapper userPreferenceLogMapper;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>(); private final ConcurrentHashMap<String, Map<String, Object>> designContext = new ConcurrentHashMap<>();
@@ -323,11 +287,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList()); // List<Long> reLationelementIds = reLationelements.stream().map(CollectionElement::getId).collect(Collectors.toList());
// handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds); // handleCollectionElementRelation(collectionId, (null == collectionIdParam) ? false : true, reLationelementIds);
// //保存python返回信息 // //保存python返回信息
//// return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
/// / return savePythonDesignItemAndDetail(pythonObjects,designId,collectionId,userInfo,designDTO.getTimeZone(),responseJSONObject);
// //保存designItem 和detail // //保存designItem 和detail
// return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone()); // return saveDesignItemAndDetail(pythonObjects, designId, collectionId, userInfo, designDTO.getTimeZone());
// } // }
private String designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo, private String designOrRedesignOperateNew(DesignCollectionDTO designDTO, AuthPrincipalVo userInfo,
Long collectionIdParam, ValidateElementVO elementVO) { Long collectionIdParam, ValidateElementVO elementVO) {
// if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) { // if (CollectionUtil.isNotEmpty(designDTO.getSketchBoards())) {
@@ -342,7 +306,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Long collectionId; Long collectionId;
if (null == collectionIdParam) { if (null == collectionIdParam) {
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition()); collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
}else { } else {
collectionId = collectionIdParam; collectionId = collectionIdParam;
} }
List<Long> elementIds = getElementId(elementVO); List<Long> elementIds = getElementId(elementVO);
@@ -388,7 +352,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// 生成library - 根据设计元素生成设计库信息 // 生成library - 根据设计元素生成设计库信息
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
String ageGroup = getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId); String ageGroup = workspaceService.getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId);
generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup); generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup);
//处理关联关系,修复element覆盖得情况 //处理关联关系,修复element覆盖得情况
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId); // List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
@@ -419,124 +383,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return requestId; return requestId;
} }
private String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId){
if (Objects.nonNull(projectId)){
Workspace workspace = workspaceService.getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())){
return workspace.getAgeGroup();
}
} else if (Objects.nonNull(collectionId) && collectionId != 0){
List<CollectionElement> byCollectionId = collectionElementService.getByCollectionId(collectionId);
if (byCollectionId != null && !byCollectionId.isEmpty()){
projectId = byCollectionId.get(0).getProjectId();
if (projectId != null && projectId != 0L){
Workspace workspace = workspaceService.getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())){
return workspace.getAgeGroup();
}
}
}
}
return AgeGroup.ADULT.getValue();
}
@Override
public void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam) {
if (!StringUtils.isEmpty(moodboardPosition)) {
// 将 JSON 字符串解析为 JSONObject
JSONObject moodboardPositionJson = JSONObject.parseObject(moodboardPosition);
// 准备保存的 MoodboardPosition 列表
List<MoodboardPosition> moodboardPositions = new ArrayList<>();
// 遍历 JSON 对象的 key即样式类型
for (String key : moodboardPositionJson.keySet()) {
// 特殊处理 "class" 字段
if ("class".equals(key)) {
// 获取 "class" 字段的值并将其转为 List<String>
JSONArray classArray = moodboardPositionJson.getJSONArray(key);
if (classArray != null) {
for (int j = 0; j < classArray.size(); j++) {
// 将 classList 存入 MoodboardPosition或者其他结构
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(classArray.getString(j)) // 设置 class 字段
.setSequence(j) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
continue; // 跳过 "class" 字段的常规处理
}
JSONArray styleArray = moodboardPositionJson.getJSONArray(key);
if (styleArray != null) {
for (int i = 0; i < styleArray.size(); i++) {
// 获取当前样式数据
JSONObject styleData = styleArray.getJSONObject(i);
// 构建 MoodboardPosition 实例
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(styleData.toJSONString()) // 样式数据存为 JSON 字符串
.setSequence(i) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
}
// 如果解析结果非空,保存到数据库
if (!moodboardPositions.isEmpty()) {
for (MoodboardPosition position : moodboardPositions) {
moodboardPositionMapper.insert(position);
}
log.info("成功解析并保存 {} 条 MoodboardPosition 数据", moodboardPositions.size());
} else {
log.warn("未找到可保存的 MoodboardPosition 数据");
}
} else {
log.warn("传入的 moodboardPosition 字段为空");
}
}
@Override
public void relationImageId(DesignPythonObjects pythonObjects) {
if (Objects.isNull(pythonObjects)) {
return;
}
pythonObjects.getObjects().forEach(
o -> {
for (DesignPythonItem item : o.getItems()) {
List<Long> list = new ArrayList<>();
list.add(1L);
list.add(1L);
item.setOffset(list);
item.setResize_scale(new Float[]{1.0f,1.0f});
String path = item.getPath();
if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path();
Long imageId = pythonTAllInfoService.getImageIdByPath(bodyPath);
item.setImage_id(imageId);
} else {
Long imageId = pythonTAllInfoService.getImageIdByPath(path);
item.setImage_id(imageId);
}
}
}
);
}
@Override @Override
public List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignDTO) { public List<CollectionSketchVO> sketchesBoundingBox(ReDesignCollectionDTO reDesignDTO) {
List<CollectionSketchDTO> sketchBoards = new ArrayList<>(); List<CollectionSketchDTO> sketchBoards = new ArrayList<>();
@@ -610,18 +456,18 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true));
}else { } else {
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true));
} }
result.add(vo); result.add(vo);
}else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) { } else if (collectionSketchDTO.getDesignType().equals(DesignTypeEnum.GENERATE.getRealName())) {
GenerateDetail generateDetail = generateDetailMapper.selectById(collectionSketchDTO.getSketchBoardId()); GenerateDetail generateDetail = generateDetailMapper.selectById(collectionSketchDTO.getSketchBoardId());
libraryService.processSketchBoards(generateDetail.getUrl(), collectionSketchDTO.getLevel2Type()); libraryService.processSketchBoards(generateDetail.getUrl(), collectionSketchDTO.getLevel2Type());
String url = generateDetail.getUrl(); String url = generateDetail.getUrl();
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true));
}else { } else {
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true));
} }
result.add(vo); result.add(vo);
@@ -639,7 +485,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (url.contains(".")) { if (url.contains(".")) {
String[] split = url.split("\\."); String[] split = url.split("\\.");
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(split[0] + "-show." + split[1], 24 * 60, true));
}else { } else {
vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true)); vo.setUrlWithWhiteSide(minioUtil.getPreSignedUrl(url + "-show", 24 * 60, true));
} }
result.add(vo); result.add(vo);
@@ -662,7 +508,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
list.add(1L); list.add(1L);
list.add(1L); list.add(1L);
item.setOffset(list); item.setOffset(list);
item.setResize_scale(new Float[]{1.0f,1.0f}); item.setResize_scale(new Float[]{1.0f, 1.0f});
String path = item.getPath(); String path = item.getPath();
if (StringUtils.isEmpty(path)) { if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path(); String bodyPath = item.getBody_path();
@@ -757,8 +603,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
LocalCacheUtils.setDesignProcessCache(userId, saveNames); LocalCacheUtils.setDesignProcessCache(userId, saveNames);
} }
@Resource
private MinioUtil minioUtil;
private DesignCollectionVO savePythonDesignItemAndDetailSingle(DesignPythonObjects pythonObjects, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject outfit, String singleOverall, Map<String, Object> context) { private DesignCollectionVO savePythonDesignItemAndDetailSingle(DesignPythonObjects pythonObjects, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject outfit, String singleOverall, Map<String, Object> context) {
Object designCollectionVO = context.get("DesignCollectionVO"); Object designCollectionVO = context.get("DesignCollectionVO");
@@ -769,7 +613,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
response.setDesignId(designId); response.setDesignId(designId);
response.setCollectionId(collectionId); response.setCollectionId(collectionId);
response.setProcessId(pythonObjects.getProcess_id()); response.setProcessId(pythonObjects.getProcess_id());
}else { } else {
response = (DesignCollectionVO) designCollectionVO; response = (DesignCollectionVO) designCollectionVO;
designCollectionItems = response.getDesignCollectionItems(); designCollectionItems = response.getDesignCollectionItems();
} }
@@ -882,7 +726,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
log.info("detail.getType():{}", detail.getType()); log.info("detail.getType():{}", detail.getType());
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
log.info("layer : {}", typeAndUndividedLayer.get(designItemDetail.getType())); log.info("layer : {}", typeAndUndividedLayer.get(designItemDetail.getType()));
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType())); designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
} }
@@ -893,7 +737,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
DesignPythonItemPrint printObject = detail.getPrint().getOverall(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0)); designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
@@ -928,6 +772,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
return response; return response;
} }
private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects private DesignCollectionVO savePythonDesignItemAndDetail(DesignPythonObjects pythonObjects
, Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject responseJSONObject, String singleOverall) { , Long designId, Long collectionId, AuthPrincipalVo userInfo, String timeZone, JSONObject responseJSONObject, String singleOverall) {
DesignCollectionVO response = new DesignCollectionVO(); DesignCollectionVO response = new DesignCollectionVO();
@@ -1005,8 +850,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
List<DesignItemDetail> designItemDetails = Lists.newArrayList(); List<DesignItemDetail> designItemDetails = Lists.newArrayList();
Map<String, Integer> typePriority = list.stream().collect(Collectors.toMap(d -> d.getImageCategory().split("_")[0], Map<String, Integer> typePriority = list.stream().collect(Collectors.toMap(d -> d.getImageCategory().split("_")[0],
d -> Math.abs(d.getPriority()), d -> Math.abs(d.getPriority()),
(existing, replacement) -> replacement)); (existing, replacement) -> replacement));
Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers); Map<String, String> typeAndUndividedLayer = designItemService.setTypeAndUndividedLayer(layers);
for (DesignPythonItem detail : item.getItems()) { for (DesignPythonItem detail : item.getItems()) {
if (null == detail) { if (null == detail) {
@@ -1018,7 +863,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType())); designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
} }
@@ -1029,7 +874,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
DesignPythonItemPrint printObject = detail.getPrint().getOverall(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0)); designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
@@ -1197,7 +1042,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public DesignLikeVO like(DesignLikeDTO designLikeDTO) { public DesignLikeVO like(DesignLikeDTO designLikeDTO) {
Long userGroupId = designLikeDTO.getUserGroupId();; Long userGroupId = designLikeDTO.getUserGroupId();
Long groupDetailId; Long groupDetailId;
AuthPrincipalVo userInfo = UserContext.getUserHolder(); AuthPrincipalVo userInfo = UserContext.getUserHolder();
DesignItem designItem = designItemService.getById(designLikeDTO.getDesignItemId()); DesignItem designItem = designItemService.getById(designLikeDTO.getDesignItemId());
@@ -1389,7 +1234,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
public String generateHighDesign(GenerateHighDesignDTO generateHighDesignDTO) { public String generateHighDesign(GenerateHighDesignDTO generateHighDesignDTO) {
DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId()); DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId());
if (Objects.isNull(designItem)){ if (Objects.isNull(designItem)) {
throw new BusinessException("design.item.does.not.exist"); throw new BusinessException("design.item.does.not.exist");
} }
String highUrl = pythonService.generateHighDesign(designItem.getDesignUrl()); String highUrl = pythonService.generateHighDesign(designItem.getDesignUrl());
@@ -1401,7 +1246,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
public Boolean deleteHighDesign(GenerateHighDesignDTO generateHighDesignDTO) { public Boolean deleteHighDesign(GenerateHighDesignDTO generateHighDesignDTO) {
DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId()); DesignItem designItem = designItemService.getById(generateHighDesignDTO.getDesignItemId());
if (Objects.isNull(designItem)){ if (Objects.isNull(designItem)) {
throw new BusinessException("design.item.does.not.exist"); throw new BusinessException("design.item.does.not.exist");
} }
if (StringUtils.isEmpty(designItem.getHighDesignUrl())) { if (StringUtils.isEmpty(designItem.getHighDesignUrl())) {
@@ -1444,7 +1289,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
// 为没有优先级的衣服添加优先级 // 为没有优先级的衣服添加优先级
if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")){ if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")) {
designItemDetailService.setDesignItemDetailPriority(designItemDetails); designItemDetailService.setDesignItemDetailPriority(designItemDetails);
} }
@@ -1456,18 +1301,19 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
response.setHighDesignUrl(designItem.getHighDesignUrl()); response.setHighDesignUrl(designItem.getHighDesignUrl());
List<DesignItemDetail> filterDetail = designItemDetails.stream() List<DesignItemDetail> filterDetail = designItemDetails.stream()
.filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType()) .filter(f -> OUTWEAR_DRESS_BLOUSE.contains(f.getType()) || SKIRT_TROUSERS.contains(f.getType())
|| TOPS.contains(f.getType()) || BOTTOMS.contains(f.getType())) || TOPS.contains(f.getType()) || BOTTOMS.contains(f.getType()) || OTHERS.contains(f.getType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> { response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
d.setId(o.getId()); d.setId(o.getId());
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60, true)); d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60, true));
d.setMinIOPath(o.getPath()); d.setMinIOPath(o.getPath());
d.setScope(o.getPath().startsWith("aida-sys-image") ? "sys" : "user");
d.setLevel1Type(converTypeToLevel1(o.getType())); d.setLevel1Type(converTypeToLevel1(o.getType()));
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class)); d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));
if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())){ if (!StringUtil.isNullOrEmpty(o.getUndividedLayer())) {
d.setUndividedLayer(minioUtil.getPreSignedUrl(o.getUndividedLayer(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); d.setUndividedLayer(minioUtil.getPreSignedUrl(o.getUndividedLayer(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
if (!StringUtil.isNullOrEmpty(o.getUndividedLayerWithSinglePrint())){ if (!StringUtil.isNullOrEmpty(o.getUndividedLayerWithSinglePrint())) {
d.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(o.getUndividedLayerWithSinglePrint(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); d.setUndividedLayerWithSinglePrint(minioUtil.getPreSignedUrl(o.getUndividedLayerWithSinglePrint(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
// 根据designItemDetailId获取印花 // 根据designItemDetailId获取印花
@@ -1488,7 +1334,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String preSigned = StringUtil.isNullOrEmpty(o.getPartialDesign()) ? null : minioUtil.getPreSignedUrl(o.getPartialDesign(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME); String preSigned = StringUtil.isNullOrEmpty(o.getPartialDesign()) ? null : minioUtil.getPreSignedUrl(o.getPartialDesign(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
d.setPartialDesign(new PartialDesignDTO(o.getPartialDesign(), preSigned)); d.setPartialDesign(new PartialDesignDTO(o.getPartialDesign(), preSigned));
DesignItemDetailCanvas designItemDetailCanvas = designItemDetailService.getDIDCByDesignItemDetailId(o.getId()); DesignItemDetailCanvas designItemDetailCanvas = designItemDetailService.getDIDCByDesignItemDetailId(o.getId());
if (Objects.nonNull(designItemDetailCanvas)){ if (Objects.nonNull(designItemDetailCanvas)) {
d.setCanvasId(designItemDetailCanvas.getExportFileId()); d.setCanvasId(designItemDetailCanvas.getExportFileId());
} }
})); }));
@@ -1626,7 +1472,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
}); });
if (!CollectionUtil.isEmpty(designItemDetailIdColor)){ if (!CollectionUtil.isEmpty(designItemDetailIdColor)) {
Map<String, PantoneVO> pantoneByRgbBatch = panToneService.getPantoneByRgbBatch(new ArrayList<>(designItemDetailIdColor.values())); Map<String, PantoneVO> pantoneByRgbBatch = panToneService.getPantoneByRgbBatch(new ArrayList<>(designItemDetailIdColor.values()));
designItemDetailVO.getClothes().forEach(c -> { designItemDetailVO.getClothes().forEach(c -> {
PantoneVO pantoneVO = pantoneByRgbBatch.get(designItemDetailIdColor.get(c.getId())); PantoneVO pantoneVO = pantoneByRgbBatch.get(designItemDetailIdColor.get(c.getId()));
@@ -1648,13 +1494,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (flag) { if (flag) {
// 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误 // 1、判断designPythonOutfitId查出的图层信息是否为空不允许为空系统内部错误
List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId()); List<TDesignPythonOutfitDetail> details = designPythonOutfitDetailService.getDetailByDesignPythonOutfitId(designPythonOutfit.getId());
if (Objects.isNull(details)){ if (Objects.isNull(details)) {
log.error("Layer information is empty! DesignPythonOutfitId is " + designPythonOutfit.getId()); log.error("Layer information is empty! DesignPythonOutfitId is " + designPythonOutfit.getId());
throw new BusinessException("layer.information.not.found"); throw new BusinessException("layer.information.not.found");
} }
// 为没有优先级的图层添加优先级 // 为没有优先级的图层添加优先级
if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")){ if (!StringUtil.isNullOrEmpty(design.getSingleOverall()) && design.getSingleOverall().equals("overall")) {
designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details); designPythonOutfitDetailService.setDesignPythonOutfitDetailPriority(details);
} }
@@ -1704,16 +1550,16 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designSinglePrint.setMinIOPath(detailPrint.getPath()); designSinglePrint.setMinIOPath(detailPrint.getPath());
designSinglePrint.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE); designSinglePrint.setIfSingle(detailPrint.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE);
List<Float> scales; List<Float> scales;
try{ try {
scales = JSONArray.parseArray(detailPrint.getScale(), Float.class); scales = JSONArray.parseArray(detailPrint.getScale(), Float.class);
}catch (JSONException e){ } catch (JSONException e) {
Float scale = Float.valueOf(detailPrint.getScale()); Float scale = Float.valueOf(detailPrint.getScale());
if (designSinglePrint.getIfSingle()){ if (designSinglePrint.getIfSingle()) {
List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(detailPrint.getPath()); List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(detailPrint.getPath());
List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath); List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath);
scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1)); scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1));
}else { } else {
scales = Arrays.asList(scale, scale); scales = Arrays.asList(scale, scale);
} }
} }
@@ -1726,15 +1572,15 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// if (print.getSingleOrOverall().equals("single")) { // if (print.getSingleOrOverall().equals("single")) {
List<Float> scales; List<Float> scales;
Boolean ifSingle = print.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE; Boolean ifSingle = print.getSingleOrOverall().equals("single") ? Boolean.TRUE : Boolean.FALSE;
try{ try {
scales = JSONArray.parseArray(print.getScale(), Float.class); scales = JSONArray.parseArray(print.getScale(), Float.class);
}catch (JSONException e){ } catch (JSONException e) {
Float scale = Float.valueOf(print.getScale()); Float scale = Float.valueOf(print.getScale());
if (ifSingle){ if (ifSingle) {
List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(print.getPath()); List<Integer> printWAndH = minioUtil.getImagesWidthAndHeight(print.getPath());
List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath); List<Integer> sketchWAndH = minioUtil.getImagesWidthAndHeight(sketchPath);
scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1)); scales = Arrays.asList(scale * printWAndH.get(0) / sketchWAndH.get(0), scale * printWAndH.get(1) / sketchWAndH.get(1));
}else { } else {
scales = Arrays.asList(scale, scale); scales = Arrays.asList(scale, scale);
} }
} }
@@ -1755,27 +1601,27 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
@Override @Override
public List<String> getModel(List<Long> designItemIdList){ public List<String> getModel(List<Long> designItemIdList) {
ArrayList<String> models = new ArrayList<>(); ArrayList<String> models = new ArrayList<>();
List<DesignItem> designIdById = designItemService.selectDesignIdById(designItemIdList); List<DesignItem> designIdById = designItemService.selectDesignIdById(designItemIdList);
if (CollectionUtil.isEmpty(designIdById)){ if (CollectionUtil.isEmpty(designIdById)) {
log.info("according to the designItemIdList cannot find the designIdList"); log.info("according to the designItemIdList cannot find the designIdList");
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
List<Long> designIdList = designIdById.stream().map(DesignItem::getDesignId).collect(Collectors.toList()); List<Long> designIdList = designIdById.stream().map(DesignItem::getDesignId).collect(Collectors.toList());
List<Design> designs = selectList(designIdList); List<Design> designs = selectList(designIdList);
if (CollectionUtil.isEmpty(designIdList)){ if (CollectionUtil.isEmpty(designIdList)) {
log.info("according to the designIdList cannot find the design"); log.info("according to the designIdList cannot find the design");
throw new BusinessException("design.not.found"); throw new BusinessException("design.not.found");
} }
List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList()); List<Long> modelFromLibIds = designs.stream().filter(design -> design.getModelType().equals("Library")).map(Design::getTemplateId).collect(Collectors.toList());
if (!CollectionUtil.isEmpty(modelFromLibIds)){ if (!CollectionUtil.isEmpty(modelFromLibIds)) {
models.addAll(libraryService.getByIds(modelFromLibIds).stream() models.addAll(libraryService.getByIds(modelFromLibIds).stream()
.map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60)) .map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList()); List<Long> modelFromSysIds = designs.stream().filter(design -> design.getModelType().equals("System")).map(Design::getTemplateId).collect(Collectors.toList());
if (!CollectionUtil.isEmpty(modelFromSysIds)){ if (!CollectionUtil.isEmpty(modelFromSysIds)) {
models.addAll(sysFileService.getByIds(modelFromSysIds).stream() models.addAll(sysFileService.getByIds(modelFromSysIds).stream()
.map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60)) .map(d -> minioUtil.getPreSignedUrl(d.getUrl(), 24 * 60))
.collect(Collectors.toList())); .collect(Collectors.toList()));
@@ -1784,21 +1630,21 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return models; return models;
} }
private List<Design> selectList(List<Long> designIdList){ private List<Design> selectList(List<Long> designIdList) {
QueryWrapper<Design> queryWrapper = new QueryWrapper<>(); QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
queryWrapper.in("id",designIdList); queryWrapper.in("id", designIdList);
return designMapper.selectList(queryWrapper); return designMapper.selectList(queryWrapper);
} }
// 查询指定用户在指定时间内使用了多少次design // 查询指定用户在指定时间内使用了多少次design
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){ public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds) {
QueryWrapper<Design> queryWrapper = new QueryWrapper<>(); QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
queryWrapper.gt("create_date", startTime) queryWrapper.gt("create_date", startTime)
.lt("create_date", endTime) .lt("create_date", endTime)
.select("count(id) as count"); .select("count(id) as count");
if (!Objects.isNull(accountIds) && !accountIds.isEmpty() ){ if (!Objects.isNull(accountIds) && !accountIds.isEmpty()) {
queryWrapper.in("account_id", accountIds); queryWrapper.in("account_id", accountIds);
} }
@@ -1806,7 +1652,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (result != null && !result.isEmpty()) { if (result != null && !result.isEmpty()) {
Object countObj = result.get(0).get("count"); Object countObj = result.get(0).get("count");
return (Long) countObj; return (Long) countObj;
}else { } else {
return 0L; return 0L;
} }
} }
@@ -1884,7 +1730,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
//design //design
String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId); String taskId = designBatch(designDTO, userInfo, null, elementVO, cloudTaskDTO, projectId);
return taskId; return taskId;
}else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) { } else if (cloudTaskDTO.getBuildType().equals(BuildType.TO_PRODUCT_IMAGE.getValue())) {
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage(); ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
// 判断用户当前积分是否够本次生成消耗 // 判断用户当前积分是否够本次生成消耗
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums()); Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums());
@@ -1973,17 +1819,17 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (design.getSingleOverall().equals("single")) { if (design.getSingleOverall().equals("single")) {
productType = "single"; productType = "single";
sb.append(collect); sb.append(collect);
}else { } else {
if (collect.contains("Tops")) { if (collect.contains("Tops")) {
sb.append("a handsome man,"); sb.append("a handsome man,");
}else { } else {
sb.append("a beautiful women,"); sb.append("a beautiful women,");
} }
sb.append("wearing ").append(collect); sb.append("wearing ").append(collect);
} }
if (StringUtils.isEmpty(prompt)) { if (StringUtils.isEmpty(prompt)) {
sb.append(",high quality clothing details,8K realistic,HDR"); sb.append(",high quality clothing details,8K realistic,HDR");
}else { } else {
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR"); sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
} }
// 走模型 // 走模型
@@ -2016,17 +1862,17 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setImageStrength(randomFromRange); toProductImageResult.setImageStrength(randomFromRange);
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
}else { } else {
if (StringUtils.isEmpty(prompt)) { if (StringUtils.isEmpty(prompt)) {
sb.append(",high quality clothing details,8K realistic,HDR"); sb.append(",high quality clothing details,8K realistic,HDR");
}else { } else {
sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR"); sb.append(",high quality clothing details,").append(prompt).append(",8K realistic,HDR");
} }
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
@@ -2060,19 +1906,19 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setImageStrength(randomFromRange); toProductImageResult.setImageStrength(randomFromRange);
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.toProductImageBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.TO_PRODUCT_IMAGE, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.TO_PRODUCT_IMAGE.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
} }
sb = new StringBuilder("The best quality, masterpiece, real image."); sb = new StringBuilder("The best quality, masterpiece, real image.");
} }
return batchTaskId; return batchTaskId;
}else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) { } else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) {
ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage(); ToProductImageDTO toProductImageDTO = cloudTaskDTO.getToProductImage();
// 判断用户当前积分是否够本次生成消耗 // 判断用户当前积分是否够本次生成消耗
Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums()); Boolean preDeduction = creditsService.creditsPreDeduction(CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums());
@@ -2139,7 +1985,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String s = ""; String s = "";
if (!StringUtil.isNullOrEmpty(prompt)) { if (!StringUtil.isNullOrEmpty(prompt)) {
s = pythonService.promptTranslate(prompt); s = pythonService.promptTranslate(prompt);
}else { } else {
s = "Snow moutain, snowy day, natural light"; s = "Snow moutain, snowy day, natural light";
} }
Map<String, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums()); Map<String, Integer> toProductImageVOIntegerMap = allocateElements(toProductImageDTO.getToProductImageVOList(), cloudTaskDTO.getNums());
@@ -2187,18 +2033,18 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setDirection(toProductImageDTO.getDirection()); toProductImageResult.setDirection(toProductImageDTO.getDirection());
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
// 走模型 // 走模型
pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
} }
}else { } else {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型 // 走模型
List<BatchParamDTO> paramList = new ArrayList<>(); List<BatchParamDTO> paramList = new ArrayList<>();
@@ -2232,14 +2078,14 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
toProductImageResult.setDirection(toProductImageDTO.getDirection()); toProductImageResult.setDirection(toProductImageDTO.getDirection());
toProductImageResultMapper.insert(toProductImageResult); toProductImageResultMapper.insert(toProductImageResult);
result.add(toProductImageResult); result.add(toProductImageResult);
i ++; i++;
} }
// 走模型 // 走模型
pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString()); pythonService.relightBatch(batchTaskId, paramList, userHolder.getId().toString());
// 添加需要扣除的积分到预扣除区 // 添加需要扣除的积分到预扣除区
creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(userHolder.getId(), batchTaskId, CreditsEventsEnum.RELIGHT, cloudTaskDTO.getNums());
// 预插入数据到积分变更表 // 预插入数据到积分变更表
creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null,cloudTaskDTO.getNums() ); creditsService.preInsert(userHolder.getId(), CreditsEventsEnum.RELIGHT.getName(), batchTaskId, true, null, cloudTaskDTO.getNums());
} }
} }
return batchTaskId; return batchTaskId;
@@ -2308,12 +2154,12 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
poseTransformationMapper.insert(poseTransformation); poseTransformationMapper.insert(poseTransformation);
Boolean b = pythonService.poseTransformationBatch(poseTransformBatchDTO.getProductImage(), poseTransformBatchDTO.getPoseId(), taskId); Boolean b = pythonService.poseTransformationBatch(poseTransformBatchDTO.getProductImage(), poseTransformBatchDTO.getPoseId(), taskId);
if (b){ if (b) {
// 6、添加预扣除积分到redis // 6、添加预扣除积分到redis
creditsService.addRecordToCreditsDeduction(accountId, taskBatchId, creditsEventsEnum, cloudTaskDTO.getNums()); creditsService.addRecordToCreditsDeduction(accountId, taskBatchId, creditsEventsEnum, cloudTaskDTO.getNums());
// 6.1 添加积分扣除记录到db // 6.1 添加积分扣除记录到db
creditsService.preInsert(accountId, creditsEventsEnum.getName(), taskBatchId, Boolean.TRUE, null, cloudTaskDTO.getNums()); creditsService.preInsert(accountId, creditsEventsEnum.getName(), taskBatchId, Boolean.TRUE, null, cloudTaskDTO.getNums());
}else { } else {
throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode()); throw new BusinessException("pose transformation error", ResultEnum.ERROR.getCode());
} }
} }
@@ -2365,7 +2211,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) { if (collectionElement.getIsCompositeImage() != null && collectionElement.getIsCompositeImage() == 1) {
designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId())); designCollectionDTO.setMoodTemplateId(String.valueOf(collectionElement.getId()));
designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId())); designCollectionDTO.setMoodboardPosition(collectionService.getMoodboardPositionString(collectionElement.getId()));
}else { } else {
DesignCollectionElementDTO dto = new DesignCollectionElementDTO(); DesignCollectionElementDTO dto = new DesignCollectionElementDTO();
dto.setId(collectionElement.getId()); dto.setId(collectionElement.getId());
dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName()); dto.setDesignType(DesignTypeEnum.COLLECTION.getRealName());
@@ -2373,7 +2219,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
} }
designCollectionDTO.setMoodBoards(moodBoards); designCollectionDTO.setMoodBoards(moodBoards);
}else { } else {
designCollectionDTO.setMoodBoards(new ArrayList<>()); designCollectionDTO.setMoodBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Printboard"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Printboard"))) {
@@ -2386,7 +2232,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
printBoards.add(dto); printBoards.add(dto);
} }
designCollectionDTO.setPrintBoards(printBoards); designCollectionDTO.setPrintBoards(printBoards);
}else { } else {
designCollectionDTO.setPrintBoards(new ArrayList<>()); designCollectionDTO.setPrintBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Colorboard"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Colorboard"))) {
@@ -2408,7 +2254,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
colorBoards.add(dto); colorBoards.add(dto);
} }
designCollectionDTO.setColorBoards(colorBoards); designCollectionDTO.setColorBoards(colorBoards);
}else { } else {
designCollectionDTO.setColorBoards(new ArrayList<>()); designCollectionDTO.setColorBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Sketchboard"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Sketchboard"))) {
@@ -2423,7 +2269,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
sketchBoards.add(dto); sketchBoards.add(dto);
} }
designCollectionDTO.setSketchBoards(sketchBoards); designCollectionDTO.setSketchBoards(sketchBoards);
}else { } else {
designCollectionDTO.setSketchBoards(new ArrayList<>()); designCollectionDTO.setSketchBoards(new ArrayList<>());
} }
if (CollectionUtil.isNotEmpty(groupedMap.get("Models"))) { if (CollectionUtil.isNotEmpty(groupedMap.get("Models"))) {
@@ -2441,10 +2287,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
} }
}else { } else {
designCollectionDTO.setMannequins(new ArrayList<>()); designCollectionDTO.setMannequins(new ArrayList<>());
} }
}else { } else {
designCollectionDTO.setMoodBoards(new ArrayList<>()); designCollectionDTO.setMoodBoards(new ArrayList<>());
designCollectionDTO.setPrintBoards(new ArrayList<>()); designCollectionDTO.setPrintBoards(new ArrayList<>());
designCollectionDTO.setColorBoards(new ArrayList<>()); designCollectionDTO.setColorBoards(new ArrayList<>());
@@ -2464,7 +2310,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
if (workspace.getPosition().equals("Overall")) { if (workspace.getPosition().equals("Overall")) {
designCollectionDTO.setSingleOverall("overall"); designCollectionDTO.setSingleOverall("overall");
}else { } else {
designCollectionDTO.setSingleOverall("single"); designCollectionDTO.setSingleOverall("single");
designCollectionDTO.setSwitchCategory(workspace.getPosition()); designCollectionDTO.setSwitchCategory(workspace.getPosition());
} }
@@ -2478,7 +2324,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
Long collectionId; Long collectionId;
if (null == collectionIdParam) { if (null == collectionIdParam) {
collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition()); collectionId = collectionService.saveCollection(userInfo.getId(), designDTO.getTimeZone(), designDTO.getMoodTemplateId(), designDTO.getMoodboardPosition());
}else { } else {
collectionId = collectionIdParam; collectionId = collectionIdParam;
} }
List<Long> elementIds = getElementId(elementVO); List<Long> elementIds = getElementId(elementVO);
@@ -2525,7 +2371,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
log.info("design python端运行时间" + totalTimeInSeconds + ""); log.info("design python端运行时间" + totalTimeInSeconds + "");
//生成library //生成library
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
String ageGroup = getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId); String ageGroup = workspaceService.getAgeGroupByProjectOrCollectionId(designDTO.getProjectId(), collectionId);
generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup); generateLibrary(elementVO, designDTO.getTimeZone(), ageGroup);
//处理关联关系,修复element覆盖得情况 //处理关联关系,修复element覆盖得情况
// List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId); // List<CollectionElement> relationElements = collectionElementService.getByOnlyCollectionId(collectionId);
@@ -2576,7 +2422,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
cloudTaskMapper.updateById(cloudTask); cloudTaskMapper.updateById(cloudTask);
} }
} }
}else { } else {
String taskId = (String) designBatchResult.get("task_id"); String taskId = (String) designBatchResult.get("task_id");
// QueryWrapper<CloudTask> qw = new QueryWrapper<>(); // QueryWrapper<CloudTask> qw = new QueryWrapper<>();
// qw.lambda().eq(CloudTask::getTaskId, taskId); // qw.lambda().eq(CloudTask::getTaskId, taskId);
@@ -2608,7 +2454,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
String timeZone = (String) context.get("timeZone"); String timeZone = (String) context.get("timeZone");
String singleOverall = (String) context.get("singleOverall"); String singleOverall = (String) context.get("singleOverall");
DesignPythonObject item = pythonObjects.getObjects().get(i-1); DesignPythonObject item = pythonObjects.getObjects().get(i - 1);
DesignItem designItem = new DesignItem(); DesignItem designItem = new DesignItem();
designItem.setAccountId(userInfo.getId()); designItem.setAccountId(userInfo.getId());
designItem.setCollectionId(collectionId); designItem.setCollectionId(collectionId);
@@ -2685,7 +2531,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
designItemDetail.setDesignItemId(designItemId); designItemDetail.setDesignItemId(designItemId);
designItemDetail.setCollectionElementId(detail.getElementId()); designItemDetail.setCollectionElementId(detail.getElementId());
designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone)); designItemDetail.setCreateDate(DateUtil.getByTimeZone(timeZone));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType())); designItemDetail.setUndividedLayer(typeAndUndividedLayer.get(designItemDetail.getType()));
} }
if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) { if (SysFileLevel2TypeEnum.BODY.getRealName().equals(detail.getType())) {
@@ -2695,7 +2541,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
designItemDetail.setIconPath(detail.getIcon()); designItemDetail.setIconPath(detail.getIcon());
designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase())); designItemDetail.setPriority(typePriority.get(detail.getType().toLowerCase()));
if (!detail.getType().equals("Body")){ if (!detail.getType().equals("Body")) {
DesignPythonItemPrint printObject = detail.getPrint().getOverall(); DesignPythonItemPrint printObject = detail.getPrint().getOverall();
// designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath()); // designItemDetail.setPrintPath(Objects.isNull(printObject) ? "" : printObject.getPath());
designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0)); designItemDetail.setPrintPath(CollectionUtils.isEmpty(printObject.getPrint_path_list()) ? "" : printObject.getPrint_path_list().get(0));
@@ -2756,7 +2602,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
CloudTaskVO cloudTaskVO = CopyUtil.copyObject(cloudTask, CloudTaskVO.class); CloudTaskVO cloudTaskVO = CopyUtil.copyObject(cloudTask, CloudTaskVO.class);
if (cloudTaskVO.getCompletedNum() == null) { if (cloudTaskVO.getCompletedNum() == null) {
cloudTaskVO.setProcess("0%"); cloudTaskVO.setProcess("0%");
}else { } else {
BigDecimal completed = BigDecimal.valueOf(cloudTaskVO.getCompletedNum()); BigDecimal completed = BigDecimal.valueOf(cloudTaskVO.getCompletedNum());
BigDecimal total = BigDecimal.valueOf(cloudTaskVO.getNums()); BigDecimal total = BigDecimal.valueOf(cloudTaskVO.getNums());
@@ -2812,7 +2658,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// }); // });
// result.setDesign(PageBaseResponse.success(convert)); // result.setDesign(PageBaseResponse.success(convert));
return result; return result;
}else { } else {
result.setDesign(new ArrayList<>()); result.setDesign(new ArrayList<>());
return result; return result;
} }
@@ -2837,7 +2683,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (toProductImageResult.getElementType().equals("ProductElement")) { if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else { } else {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId()); TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
} }
@@ -2863,7 +2709,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
if (toProductImageResult.getElementType().equals("ProductElement")) { if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId()); ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else { } else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId()); ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60)); magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductImageResult1.getUrl(), 24 * 60));
} }
@@ -2884,13 +2730,13 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
poseTransformationVO.setStatus("Success"); poseTransformationVO.setStatus("Success");
poseTransformationVO.setTaskId(poseTransformation.getUniqueId()); poseTransformationVO.setTaskId(poseTransformation.getUniqueId());
poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(poseTransformation.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(poseTransformation.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
if (null != poseTransformation.getGifUrl()){ if (null != poseTransformation.getGifUrl()) {
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformation.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
if (null != poseTransformation.getVideoUrl()){ if (null != poseTransformation.getVideoUrl()) {
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformation.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
if (null != poseTransformation.getFirstFrameUrl()){ if (null != poseTransformation.getFirstFrameUrl()) {
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformation.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
voList.add(poseTransformationVO); voList.add(poseTransformationVO);
@@ -2901,9 +2747,6 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return result; return result;
} }
@Resource
private PanToneMapper panToneMapper;
@Override @Override
public Boolean receiveDesignParams(ReceiveDesignParam receiveDesignParam) { public Boolean receiveDesignParams(ReceiveDesignParam receiveDesignParam) {
List<ReceiveCollectionElement> receiveCollectionElementList = receiveDesignParam.getReceiveCollectionElementList(); List<ReceiveCollectionElement> receiveCollectionElementList = receiveDesignParam.getReceiveCollectionElementList();
@@ -2927,7 +2770,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setUrl(url); collectionElement.setUrl(url);
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setCreateDate(date); collectionElement.setCreateDate(date);
}else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName())) { } else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.MOOD_BOARD.getRealName())) {
String url = receiveCollectionElement.getUrl(); String url = receiveCollectionElement.getUrl();
String[] split = url.split("/"); String[] split = url.split("/");
String pictureName = split[split.length - 1]; String pictureName = split[split.length - 1];
@@ -2939,7 +2782,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setUrl(url); collectionElement.setUrl(url);
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setCreateDate(date); collectionElement.setCreateDate(date);
}else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())) { } else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName())) {
String url = receiveCollectionElement.getUrl(); String url = receiveCollectionElement.getUrl();
String[] split = url.split("/"); String[] split = url.split("/");
String pictureName = split[split.length - 1]; String pictureName = split[split.length - 1];
@@ -2954,7 +2797,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
collectionElement.setHasPin((byte) 0); collectionElement.setHasPin((byte) 0);
collectionElement.setCreateDate(date); collectionElement.setCreateDate(date);
libraryService.processSketchBoards(url, collectionElement.getLevel2Type()); libraryService.processSketchBoards(url, collectionElement.getLevel2Type());
}else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.COLOR_BOARD.getRealName())) { } else if (receiveCollectionElement.getLevel1Type().equals(CollectionLevel1TypeEnum.COLOR_BOARD.getRealName())) {
/*String color = receiveCollectionElement.getHsv(); /*String color = receiveCollectionElement.getHsv();
String[] parts = color.split("\\s+"); String[] parts = color.split("\\s+");
int h = Math.round(Float.parseFloat(parts[0])); int h = Math.round(Float.parseFloat(parts[0]));

View File

@@ -586,7 +586,7 @@ public class EmailServiceImpl implements EmailService {
try { try {
String merchantEmail = "kimwong@code-create.com.hk"; String merchantEmail = "kimwong@code-create.com.hk";
String developer = "xupei3360@163.com"; String developer = "xupei3360@163.com";
List<String> merchantReceiver = Arrays.asList(merchantEmail, developer); List<String> merchantReceiver = Arrays.asList(/*merchantEmail,*/ developer);
String merchantSubject = null; String merchantSubject = null;
String merchantTemplate = null; String merchantTemplate = null;
@@ -634,7 +634,7 @@ public class EmailServiceImpl implements EmailService {
userTemplate = RENEWAL_USER_CN; userTemplate = RENEWAL_USER_CN;
} }
break; break;
case "reminder": /*case "reminder":
if (language.equals("ENGLISH")) { if (language.equals("ENGLISH")) {
userSubject = "[Code-Create] AiDA Subscription Renewal Reminder"; userSubject = "[Code-Create] AiDA Subscription Renewal Reminder";
userTemplate = RENEWAL_REMINDER_USER_EN; userTemplate = RENEWAL_REMINDER_USER_EN;
@@ -642,6 +642,30 @@ public class EmailServiceImpl implements EmailService {
userSubject = "[Code-Create] AiDA续订提醒"; userSubject = "[Code-Create] AiDA续订提醒";
userTemplate = RENEWAL_REMINDER_USER_CN; userTemplate = RENEWAL_REMINDER_USER_CN;
} }
break;*/
case "reminder_subscriber":
if (language.equals("ENGLISH")) {
userSubject = "[Code-Create] AiDA Subscription Renewal Reminder";
userTemplate = String.valueOf(156072L);
} else if (language.equals("CHINESE")){
userSubject = "[Code-Create] AiDA续订提醒";
userTemplate = String.valueOf(156073L);
} else {
userSubject = "[Code-Create] AiDA續訂提醒";
userTemplate = String.valueOf(156074L);
}
break;
case "reminder_trial":
if (language.equals("ENGLISH")) {
userSubject = "[Code-Create] AiDA — Free Trial Ending";
userTemplate = String.valueOf(156075L);
} else if (language.equals("CHINESE")){
userSubject = "[Code-Create] AiDA — 免费试用结束提醒";
userTemplate = String.valueOf(156076L);
} else {
userSubject = "[Code-Create] AiDA — 免費試用結束提醒";
userTemplate = String.valueOf(156077L);
}
break; break;
default: default:
log.error("unknown subscription email type"); log.error("unknown subscription email type");
@@ -654,7 +678,7 @@ public class EmailServiceImpl implements EmailService {
sendEmail(Collections.singletonList(receiverAddress), jsonObject, userTemplate, userSubject, null, null); sendEmail(Collections.singletonList(receiverAddress), jsonObject, userTemplate, userSubject, null, null);
} }
// 排除不向商家发送邮件的情况 // 排除不向商家发送邮件的情况
if (!type.equals("reminder")) { if (!type.startsWith("reminder")) {
sendEmail(merchantReceiver, jsonObject, merchantTemplate, merchantSubject, null, null); sendEmail(merchantReceiver, jsonObject, merchantTemplate, merchantSubject, null, null);
} }
return true; return true;
@@ -706,7 +730,7 @@ public class EmailServiceImpl implements EmailService {
jsonObject.put("quantity", quantity); jsonObject.put("quantity", quantity);
jsonObject.put("totalFee", amount); jsonObject.put("totalFee", amount);
sendEmail(Arrays.asList(merchantEmail,developerEmail), jsonObject, CREDITS_PURCHASE_MERCHANT, "New Credit Purchase Order", null, null); sendEmail(Arrays.asList(/*merchantEmail,*/developerEmail), jsonObject, CREDITS_PURCHASE_MERCHANT, "New Credit Purchase Order", null, null);
} }
private final static String COMMON_EXCEPTION_REMINDER = "135279_common-exception-reminder.html"; private final static String COMMON_EXCEPTION_REMINDER = "135279_common-exception-reminder.html";

File diff suppressed because it is too large Load Diff

View File

@@ -17,21 +17,20 @@ import com.ai.da.model.enums.Sex;
import com.ai.da.model.vo.LibraryModelPointVO; import com.ai.da.model.vo.LibraryModelPointVO;
import com.ai.da.python.PythonService; import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonObjects; import com.ai.da.python.vo.DesignPythonObjects;
import com.ai.da.service.DesignService;
import com.ai.da.service.LibraryModelPointService; import com.ai.da.service.LibraryModelPointService;
import com.ai.da.service.LibraryService; import com.ai.da.service.LibraryService;
import com.ai.da.service.PythonTAllInfoService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -45,17 +44,13 @@ import java.util.Objects;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointMapper, LibraryModelPoint> implements LibraryModelPointService { public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointMapper, LibraryModelPoint> implements LibraryModelPointService {
@Resource private final LibraryModelPointMapper libraryModelPointMapper;
private LibraryModelPointMapper libraryModelPointMapper; private final LibraryService libraryService;
@Resource private final MinioUtil minioUtil;
private LibraryService libraryService; private final PythonService pythonService;
@Resource private final PythonTAllInfoService pythonTAllInfoService;
private PythonService pythonService;
@Resource
private DesignService designService;
@Autowired
private MinioUtil minioUtil;
@Override @Override
public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) { public LibraryModelPointVO saveOrEditTemplatePoint(LibraryModelPointDTO libraryModelPointDTO) {
@@ -63,7 +58,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
// 不管是保存还是另存为都需要传模特的libraryId // 不管是保存还是另存为都需要传模特的libraryId
Library libModel = libraryService.getById(libraryModelPointDTO.getLibraryId()); Library libModel = libraryService.getById(libraryModelPointDTO.getLibraryId());
if (Objects.isNull(libModel)){ if (Objects.isNull(libModel)) {
throw new BusinessException("model.not.found"); throw new BusinessException("model.not.found");
} }
@@ -72,9 +67,9 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
// 标志是否有更改过模特比例(即更换模特图) // 标志是否有更改过模特比例(即更换模特图)
boolean flag = !url.equals(libModel.getUrl()); boolean flag = !url.equals(libModel.getUrl());
if (libraryModelPointDTO.getIsCovered()){ if (libraryModelPointDTO.getIsCovered()) {
// 更新模特图片 // 更新模特图片
if (flag){ if (flag) {
libModel.setUrl(url); libModel.setUrl(url);
libModel.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false)); libModel.setMd5(MD5Utils.encryptFile(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false));
List<Integer> imagesWidthAndHeight = minioUtil.getImagesWidthAndHeight(url); List<Integer> imagesWidthAndHeight = minioUtil.getImagesWidthAndHeight(url);
@@ -84,7 +79,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
libraryService.updateById(libModel); libraryService.updateById(libModel);
} }
if (Objects.nonNull(libraryModelPointDTO.getTemplateId())){ if (Objects.nonNull(libraryModelPointDTO.getTemplateId())) {
// 覆盖保存,即更新原有数据(点位数据和模特图片) // 覆盖保存,即更新原有数据(点位数据和模特图片)
LibraryModelPoint modelPoint = getById(libraryModelPointDTO.getTemplateId()); LibraryModelPoint modelPoint = getById(libraryModelPointDTO.getTemplateId());
if (Objects.isNull(modelPoint)) { if (Objects.isNull(modelPoint)) {
@@ -97,7 +92,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
updateById(modelPoint); updateById(modelPoint);
libraryModelPointVO.setTemplateId(modelPoint.getId()); libraryModelPointVO.setTemplateId(modelPoint.getId());
libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId()); libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId());
}else { } else {
// 新增模特点位信息 // 新增模特点位信息
LibraryModelPoint libraryModelPoint = resolvePoint(libraryModelPointDTO); LibraryModelPoint libraryModelPoint = resolvePoint(libraryModelPointDTO);
libraryModelPoint.setModelType("Library"); libraryModelPoint.setModelType("Library");
@@ -107,7 +102,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId()); libraryModelPointVO.setRelationId(libraryModelPointDTO.getLibraryId());
} }
}else { } else {
// 不覆盖,即另存为 // 不覆盖,即另存为
// 新增模特library信息 // 新增模特library信息
Library saveAsModel = new Library(); Library saveAsModel = new Library();
@@ -169,7 +164,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
if (!byId.getLevel2Type().equals(libraryModelPointDTO.getModelSex())) { if (!byId.getLevel2Type().equals(libraryModelPointDTO.getModelSex())) {
if (byId.getLevel2Type().equals(Sex.FEMALE.getValue())) { if (byId.getLevel2Type().equals(Sex.FEMALE.getValue())) {
libraryService.checkModel(Sex.FEMALE.getValue(), Collections.singletonList(byId.getId()), 1); libraryService.checkModel(Sex.FEMALE.getValue(), Collections.singletonList(byId.getId()), 1);
}else { } else {
libraryService.checkModel(Sex.MALE.getValue(), Collections.singletonList(byId.getId()), 1); libraryService.checkModel(Sex.MALE.getValue(), Collections.singletonList(byId.getId()), 1);
} }
byId.setLevel2Type(libraryModelPointDTO.getModelSex()); byId.setLevel2Type(libraryModelPointDTO.getModelSex());
@@ -226,7 +221,7 @@ public class LibraryModelPointServiceImpl extends ServiceImpl<LibraryModelPointM
public String modelsDot(ModelsDotDTO modelsDotDTO) { public String modelsDot(ModelsDotDTO modelsDotDTO) {
DesignPythonObjects objects = pythonService.covertModelsDotParam( DesignPythonObjects objects = pythonService.covertModelsDotParam(
modelsDotDTO, SingleOverallEnum.OVERALL.getRealName(), ""); modelsDotDTO, SingleOverallEnum.OVERALL.getRealName(), "");
designService.relationImageId(objects); pythonTAllInfoService.relationImageId(objects);
JSONObject jsonObject = pythonService.designNew(objects); JSONObject jsonObject = pythonService.designNew(objects);
JSONObject data = jsonObject.getJSONObject("data"); JSONObject data = jsonObject.getJSONObject("data");
if (data == null) { if (data == null) {

View File

@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
@@ -54,6 +55,8 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.ai.da.common.enums.CollectionLevel2TypeEnum.OUTWEAR;
/** /**
* 服务实现类 * 服务实现类
* *
@@ -62,39 +65,25 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> implements LibraryService { public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> implements LibraryService {
@Resource private final AccountMapper accountMapper;
private LibraryMapper libraryMapper; private final BrandRelLibraryMapper brandRelLibraryMapper;
@Resource private final ClassificationService classificationService;
private SysFileMapper sysFileMapper; private final DesignItemDetailService designItemDetailService;
@Resource private final EductionLibraryMapper eductionLibraryMapper;
private SysFileExtraMapper sysFileExtraMapper; private final EnterpriseLibraryMapper enterpriseLibraryMapper;
@Resource private final FileProperties fileProperties;
private FileProperties fileProperties; private final GenerateDetailMapper generateDetailMapper;
@Resource private final MinioUtil minioUtil;
private LibraryModelPointService libraryModelPointService; private final LibraryMapper libraryMapper;
@Resource private final LibraryCopyMapper libraryCopyMapper;
private WorkspaceService workspaceService; private final LibraryModelPointMapper libraryModelPointMapper;
@Resource private final LibraryModelPointCopyMapper libraryModelPointCopyMapper;
private ClassificationService classificationService; private final PythonTAllInfoService pythonTAllInfoService;
@Resource private final SysFileMapper sysFileMapper;
private MinioUtil minioUtil; private final SysFileExtraMapper sysFileExtraMapper;
@Resource private final WorkspaceService workspaceService;
private AccountMapper accountMapper;
@Resource
private EductionLibraryMapper eductionLibraryMapper;
@Resource
private EnterpriseLibraryMapper enterpriseLibraryMapper;
@Resource
private LibraryCopyMapper libraryCopyMapper;
@Resource
private LibraryModelPointCopyMapper libraryModelPointCopyMapper;
@Resource
private PythonTAllInfoService pythonTAllInfoService;
@Resource
private BrandRelLibraryMapper brandRelLibraryMapper;
@Resource
private GenerateDetailMapper generateDetailMapper;
@Value("${minio.bucketName.users}") @Value("${minio.bucketName.users}")
private String users; private String users;
@@ -110,7 +99,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
private String fastApiPythonAddress; private String fastApiPythonAddress;
private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(), private static List<String> top = Arrays.asList(CollectionLevel2TypeEnum.DRESS.getRealName(),
CollectionLevel2TypeEnum.OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName()); OUTWEAR.getRealName(), CollectionLevel2TypeEnum.BLOUSE.getRealName());
private static List<String> bottom = Arrays.asList(CollectionLevel2TypeEnum.SKIRT.getRealName(), private static List<String> bottom = Arrays.asList(CollectionLevel2TypeEnum.SKIRT.getRealName(),
CollectionLevel2TypeEnum.TROUSERS.getRealName()); CollectionLevel2TypeEnum.TROUSERS.getRealName());
@@ -233,7 +222,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
.filter(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName())) .filter(library -> library.getLevel1Type().equals(LibraryLevel1TypeEnum.MODELS.getRealName()))
.map(Library::getId) .map(Library::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<LibraryModelPointVO> libraryModelPointVOS = libraryModelPointService.selectByLibraryIds(libraryIds); List<LibraryModelPointVO> libraryModelPointVOS = selectByLibraryIds(libraryIds);
if (!CollectionUtils.isEmpty(libraryModelPointVOS)) { if (!CollectionUtils.isEmpty(libraryModelPointVOS)) {
map = libraryModelPointVOS.stream() map = libraryModelPointVOS.stream()
.collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v)); .collect(Collectors.toMap(LibraryModelPointVO::getRelationId, v -> v));
@@ -307,6 +296,25 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
return PageBaseResponse.success(pageResult); return PageBaseResponse.success(pageResult);
} }
public List<LibraryModelPointVO> selectByLibraryIds(List<Long> libraryIds) {
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(LibraryModelPoint::getModelType, ModelType.LIBRARY.getValue());
queryWrapper.in("relation_id", libraryIds);
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(libraryModelPoints)) {
return null;
}
return CopyUtil.copyList(libraryModelPoints, LibraryModelPointVO.class, (o, d) -> {
d.setTemplateId(o.getId());
d.setHandLeft(JSON.parseObject(o.getHandLeft(), List.class));
d.setHandRight(JSON.parseObject(o.getHandRight(), List.class));
d.setShoulderRight(JSON.parseObject(o.getShoulderRight(), List.class));
d.setShoulderLeft(JSON.parseObject(o.getShoulderLeft(), List.class));
d.setWaistbandRight(JSON.parseObject(o.getWaistbandRight(), List.class));
d.setWaistbandLeft(JSON.parseObject(o.getWaistbandLeft(), List.class));
});
}
@Override @Override
public LibraryUpdateVo upload(LibraryUploadDTO libraryUploadDTO) { public LibraryUpdateVo upload(LibraryUploadDTO libraryUploadDTO) {
//用户信息 //用户信息
@@ -659,7 +667,8 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
libraryModelPoint.setRelationId(newInsert.getId()); libraryModelPoint.setRelationId(newInsert.getId());
libraryModelPoint.setId(null); libraryModelPoint.setId(null);
libraryModelPointService.saveOrUpdate(libraryModelPoint); // libraryModelPointService.saveOrUpdate(libraryModelPoint);
libraryModelPointMapper.insert(libraryModelPoint);
continue; continue;
} }
if (libraryCopy.getLevel1Type().equals("Sketchboard")) { if (libraryCopy.getLevel1Type().equals("Sketchboard")) {
@@ -780,7 +789,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
} else { } else {
library.setLevel3Type(uploadDTO.getModelSex()); library.setLevel3Type(uploadDTO.getModelSex());
} }
library.setAgeGroup(uploadDTO.getAgeGroup()); if (uploadDTO.getLevel1Type().equals(LibraryLevel1TypeEnum.SKETCH_BOARD.getRealName())&&StringUtils.isEmpty(uploadDTO.getAgeGroup())) {
log.error("前端未传ageGroup");
library.setAgeGroup("Adult");
} else {
library.setAgeGroup(uploadDTO.getAgeGroup());
}
libraryMapper.insert(library); libraryMapper.insert(library);
return library; return library;
} else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) { } else if (uploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
@@ -913,12 +927,12 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
libraryMapper.insert(library); libraryMapper.insert(library);
// 添加点位信息到library // 添加点位信息到library
LibraryModelPoint sysModelPoint = libraryModelPointService.getByRelationId(sysModelId, "System"); LibraryModelPoint sysModelPoint = getByRelationId(sysModelId, "System");
sysModelPoint.setId(null); sysModelPoint.setId(null);
sysModelPoint.setModelType("Library"); sysModelPoint.setModelType("Library");
sysModelPoint.setRelationId(library.getId()); sysModelPoint.setRelationId(library.getId());
sysModelPoint.setCreateDate(new Date()); sysModelPoint.setCreateDate(new Date());
libraryModelPointService.save(sysModelPoint); libraryModelPointMapper.insert(sysModelPoint);
Map<String, String> resp = new HashMap<>(); Map<String, String> resp = new HashMap<>();
resp.put("id", library.getId().toString()); resp.put("id", library.getId().toString());
@@ -926,6 +940,19 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
return resp; return resp;
} }
public LibraryModelPoint getByRelationId(Long relationId, String modelType) {
QueryWrapper<LibraryModelPoint> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(LibraryModelPoint::getRelationId, relationId)
.eq(LibraryModelPoint::getModelType, modelType)
.last("limit 1");
List<LibraryModelPoint> libraryModelPoints = libraryModelPointMapper.selectList(queryWrapper);
if (CollectionUtil.isEmpty(libraryModelPoints)) {
throw new BusinessException("modelPoint.not.found");
}
return libraryModelPoints.get(0);
}
public boolean saveToOrganizationLibrary(Long libraryId){ public boolean saveToOrganizationLibrary(Long libraryId){
// 1、判断该用户是否属于某个组织 // 1、判断该用户是否属于某个组织
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
@@ -1030,4 +1057,54 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
} }
} }
/**
* 将系统sketch添加到个人library
*/
public String addSysSketchToLibrary(Long clothId, String path) {
// 1. 判断当前路径是不是系统sketch
if (!path.startsWith("aida-sys-image/images")) {
throw new BusinessException("Non-system Sketch file cannot be added to personal library.", ResultEnum.PROMPT.getCode());
}
// 2. 是。获取当前用户id,随机生成4位数
String sourceObject = path.substring(path.indexOf("/") + 1);
String subPath = sourceObject.substring(sourceObject.indexOf("images/") + "images/".length(), sourceObject.lastIndexOf("."));
String gender = subPath.substring(0, subPath.indexOf("/")).equals("female") ? "Female" : "Male";
String category = subPath.substring(subPath.indexOf("/") + 1, subPath.lastIndexOf("/"));
CollectionLevel2TypeEnum collectionLevel2TypeEnum = CollectionLevel2TypeEnum.ofWithLoweCase(category);
if (Objects.nonNull(collectionLevel2TypeEnum)){
category = collectionLevel2TypeEnum.getRealName();
} else {
category = OUTWEAR.getRealName();
}
String suffix = sourceObject.substring(sourceObject.lastIndexOf(".") + 1);
Long userId = UserContext.getUserHolder().getId();
// 由于允许将同一张系统sketch多次添加到个人library但是路径相对固定所以这里添加随机数以作区分
String name = subPath.substring(subPath.lastIndexOf("/") + 1) + "_" + RandomsUtil.generateVerifyCode(1000L, 9999L);
String targetObject = userId + "/sketchboard/" + gender.toLowerCase() + "/" + category + "/" +
name + "." + suffix;
// 3. 复制图片到用户个人图片文件夹下
minioUtil.copyObject(sysImage, sourceObject, users, targetObject);
// 4. 存储到数据库中
String targetPath = users + "/" + targetObject;
String md5 = MD5Utils.encryptFile(minioUtil.getPreSignedUrl(targetPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME), false);
Library library = new Library(userId, CollectionLevel1TypeEnum.SKETCH_BOARD.getRealName(),
category, gender, "Adult", name, targetPath, md5, new Date());
saveOne(library);
// 5. 更新designItemDetail中的图片路径
if (Objects.nonNull(clothId)) {
designItemDetailService.updateDetailPathById(clothId, targetPath);
}
return minioUtil.getPreSignedUrl(targetPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
}
/**
* todo 低分辨率下载
*/
public void downloadSysSketchWithWatermark() {
}
} }

View File

@@ -8,19 +8,15 @@ import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.MinioUtil; import com.ai.da.common.utils.MinioUtil;
import com.ai.da.common.utils.RedisUtil; import com.ai.da.common.utils.RedisUtil;
import com.ai.da.common.websocket.NotificationConnection; import com.ai.da.common.websocket.NotificationConnection;
import com.ai.da.mapper.primary.CanvasMapper; import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.NotificationMapper; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.mapper.primary.SysNotificationReadStatusMapper;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.mapper.primary.entity.Notification;
import com.ai.da.mapper.primary.entity.Portfolio;
import com.ai.da.mapper.primary.entity.SysNotificationReadStatus;
import com.ai.da.model.dto.GetNotificationDTO; import com.ai.da.model.dto.GetNotificationDTO;
import com.ai.da.model.dto.PublishSysNotificationDTO; import com.ai.da.model.dto.PublishSysNotificationDTO;
import com.ai.da.model.enums.Language;
import com.ai.da.model.vo.NotificationVO; import com.ai.da.model.vo.NotificationVO;
import com.ai.da.service.AccountService; import com.ai.da.service.AccountService;
import com.ai.da.service.MessageCenterService; import com.ai.da.service.MessageCenterService;
import com.ai.da.service.PortfolioService; import com.ai.da.service.UserFollowService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -30,12 +26,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.mysql.cj.util.StringUtils; import com.mysql.cj.util.StringUtils;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@@ -44,22 +40,18 @@ import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@RequiredArgsConstructor
public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements MessageCenterService { public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements MessageCenterService {
@Resource private final AccountService accountService;
private NotificationConnection notificationConnection; private final CanvasMapper canvasMapper;
@Resource private final MinioUtil minioUtil;
private SysNotificationReadStatusMapper sysNotificationReadStatusMapper; private final NotificationConnection notificationConnection;
@Resource private final PortfolioMapper portfolioMapper;
private AccountService accountService; private final RedisUtil redisUtil;
@Resource private final SysNotificationReadStatusMapper sysNotificationReadStatusMapper;
private MinioUtil minioUtil; private final UserFollowService userFollowService;
@Resource
private PortfolioService portfolioService;
@Resource
private CanvasMapper canvasMapper;
@Resource
private RedisUtil redisUtil;
@Value("${redis.key.newPosted}") @Value("${redis.key.newPosted}")
private String lastViewNewPostedTimeKey; private String lastViewNewPostedTimeKey;
@@ -72,7 +64,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
.collect(Collectors.toMap( .collect(Collectors.toMap(
map -> (String) map.get("type"), map -> (String) map.get("type"),
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count"))); map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
msgTypeCount.put("system", getUnreadSystemNotification()); msgTypeCount.put("system", getUnreadSystemNotification(accountId));
msgTypeCount.put("newPosted", getNewPostedCount(accountId)); msgTypeCount.put("newPosted", getNewPostedCount(accountId));
log.info(msgTypeCount.toString()); log.info(msgTypeCount.toString());
// 整理数据 加上系统消息未读数 // 整理数据 加上系统消息未读数
@@ -83,12 +75,12 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
@Override @Override
public PageBaseResponse<NotificationVO> getHistoryNotification(GetNotificationDTO getNotificationDTO) { public PageBaseResponse<NotificationVO> getHistoryNotification(GetNotificationDTO getNotificationDTO) {
log.info("获取历史消息parameter => {}", getNotificationDTO); log.info("获取历史消息parameter => {}", getNotificationDTO);
if (StringUtil.isNullOrEmpty(getNotificationDTO.getType())){ if (StringUtil.isNullOrEmpty(getNotificationDTO.getType())) {
throw new BusinessException("type.cannot.be.empty"); throw new BusinessException("type.cannot.be.empty");
} }
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
// 查动态 // 查动态
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType()) && getNotificationDTO.getType().equals("newPosted")){ if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType()) && getNotificationDTO.getType().equals("newPosted")) {
return getNewPosted(accountId, getNotificationDTO.getPage(), getNotificationDTO.getSize()); return getNewPosted(accountId, getNotificationDTO.getPage(), getNotificationDTO.getSize());
} }
@@ -97,44 +89,53 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType())) { if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType())) {
queryWrapper.eq("type", getNotificationDTO.getType()); queryWrapper.eq("type", getNotificationDTO.getType());
} }
if (!getNotificationDTO.getType().equals("system")){
queryWrapper.eq("receiver_id", accountId); if (getNotificationDTO.getType().equals("system")) {
queryWrapper.lambda().eq(Notification::getType, "system")
.and(wrapper -> wrapper
.isNull(Notification::getReceiverId)
.or()
.eq(Notification::getReceiverId, accountId)
);
} else {
queryWrapper.lambda().eq(Notification::getReceiverId, accountId);
} }
Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper); Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper);
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId); List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
IPage<NotificationVO> convert = notificationPage.convert(o -> { IPage<NotificationVO> convert = notificationPage.convert(o -> {
NotificationVO notificationVO = CopyUtil.copyObject(o, NotificationVO.class); NotificationVO notificationVO = CopyUtil.copyObject(o, NotificationVO.class);
Account senderAccount = accountService.getById(notificationVO.getSenderId()); Account senderAccount = accountService.getById(notificationVO.getSenderId());
if (Objects.nonNull(senderAccount)){ if (Objects.nonNull(senderAccount)) {
notificationVO.setUserName(senderAccount.getUserName()); notificationVO.setUserName(senderAccount.getUserName());
}else { } else {
notificationVO.setUserName("--"); notificationVO.setUserName("--");
} }
// notificationVO.setSenderUserAvatar(StringUtils.isNullOrEmpty(senderAccount.getAvatar()) ? null : minioUtil.getPreSignedUrl(senderAccount.getAvatar(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); // notificationVO.setSenderUserAvatar(StringUtils.isNullOrEmpty(senderAccount.getAvatar()) ? null : minioUtil.getPreSignedUrl(senderAccount.getAvatar(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
if (Objects.isNull(notificationVO.getPortfolioId())){ if (Objects.isNull(notificationVO.getPortfolioId())) {
notificationVO.setPortfolioId(null); notificationVO.setPortfolioId(null);
}else { } else {
Portfolio byId = portfolioService.getById(notificationVO.getPortfolioId()); Portfolio byId = portfolioMapper.selectById(notificationVO.getPortfolioId());
if (!Objects.isNull(byId)){ if (!Objects.isNull(byId)) {
if (Objects.isNull(byId.getPortfolioName())){ if (Objects.isNull(byId.getPortfolioName())) {
notificationVO.setPortfolioName(null); notificationVO.setPortfolioName(null);
}else { } else {
notificationVO.setPortfolioName(byId.getPortfolioName()); notificationVO.setPortfolioName(byId.getPortfolioName());
} }
}else { } else {
String name = UserContext.getUserHolder().getLanguage().equals("ENGLISH") ? CommonConstant.PORTFOLIO_DELETED_EN : CommonConstant.PORTFOLIO_DELETED_CN; String name = UserContext.getUserHolder().getLanguage().equals("ENGLISH") ? CommonConstant.PORTFOLIO_DELETED_EN : CommonConstant.PORTFOLIO_DELETED_CN;
notificationVO.setPortfolioName(name); notificationVO.setPortfolioName(name);
} }
} }
// 设置单个人 系统消息是否已读 // 设置单个人 系统消息是否已读
if (notificationVO.getType().equals("system")){ if (notificationVO.getType().equals("system")) {
if (unreadSysNotificationIds.contains(notificationVO.getId())){ if (unreadSysNotificationIds.contains(notificationVO.getId())) {
notificationVO.setIsRead(0); notificationVO.setIsRead(0);
}else { } else {
notificationVO.setIsRead(1); notificationVO.setIsRead(1);
} }
}else { } else {
String avatar = Objects.isNull(senderAccount) || StringUtil.isNullOrEmpty(senderAccount.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : senderAccount.getAvatar(); String avatar = Objects.isNull(senderAccount) || StringUtil.isNullOrEmpty(senderAccount.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : senderAccount.getAvatar();
notificationVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); notificationVO.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
} }
@@ -143,9 +144,9 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return PageBaseResponse.success(convert); return PageBaseResponse.success(convert);
} }
public void prePushMessage(Notification notification){ public void prePushMessage(Notification notification) {
// 先判断点赞、关注记录是不是唯一 // 先判断点赞、关注记录是不是唯一
if (!getUniqueLikeAndFollow(notification)){ if (!getUniqueLikeAndFollow(notification)) {
// 1、将数据存数据库 // 1、将数据存数据库
if (!notification.getType().equals("system")) { if (!notification.getType().equals("system")) {
notification.setIsRead(0); notification.setIsRead(0);
@@ -161,18 +162,19 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
/** /**
* 只记录唯一点赞和关注 * 只记录唯一点赞和关注
* 重复点赞、关注只会记录最新的一次操作 * 重复点赞、关注只会记录最新的一次操作
*
* @param notification * @param notification
* @return * @return
*/ */
public Boolean getUniqueLikeAndFollow(Notification notification){ public Boolean getUniqueLikeAndFollow(Notification notification) {
Notification existNotification= null; Notification existNotification = null;
// 对单个作品的点赞和对某个人的关注 具有唯一性 // 对单个作品的点赞和对某个人的关注 具有唯一性
if (notification.getType().equals("like") || notification.getType().equals("follow")){ if (notification.getType().equals("like") || notification.getType().equals("follow")) {
existNotification = baseMapper.getUniqueLikeAndFollow(notification.getType(), notification.getSenderId(), existNotification = baseMapper.getUniqueLikeAndFollow(notification.getType(), notification.getSenderId(),
notification.getReceiverId(), notification.getPortfolioId()); notification.getReceiverId(), notification.getPortfolioId());
} }
if (!Objects.isNull(existNotification)){ if (!Objects.isNull(existNotification)) {
// 有记录,则更新 1、删除状态 为0 2、已读状态 为0 3、创建时间 为最新时间 4、更新时间 为最新时间 // 有记录,则更新 1、删除状态 为0 2、已读状态 为0 3、创建时间 为最新时间 4、更新时间 为最新时间
baseMapper.updateUniqueLikeAndFollow(existNotification.getId(), LocalDateTime.now()); baseMapper.updateUniqueLikeAndFollow(existNotification.getId(), LocalDateTime.now());
return Boolean.TRUE; return Boolean.TRUE;
@@ -192,13 +194,13 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
count = getUnreadCountByType(type, receiverId); count = getUnreadCountByType(type, receiverId);
} else { } else {
// 系统未读消息 // 系统未读消息
count = getUnreadSystemNotification(); count = getUnreadSystemNotification(receiverId);
} }
if (type.equals("follow")){ if (type.equals("follow")) {
HashMap<String, Object> followee = new HashMap<>(); HashMap<String, Object> followee = new HashMap<>();
HashMap<String, Object> follower = new HashMap<>(); HashMap<String, Object> follower = new HashMap<>();
follower.put("followerCount",portfolioService.getFollowerCount(receiverId)); follower.put("followerCount", userFollowService.getFollowerCount(receiverId));
followee.put("followeeCount",portfolioService.getFolloweeCount(receiverId)); followee.put("followeeCount", userFollowService.getFolloweeCount(receiverId));
resp.add(followee); resp.add(followee);
resp.add(follower); resp.add(follower);
} }
@@ -219,7 +221,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
.eq("receiver_id", receiverId) .eq("receiver_id", receiverId)
.eq("is_deleted", 0); .eq("is_deleted", 0);
if (!type.equals("follow")){ if (!type.equals("follow")) {
queryWrapper.eq("portfolio_id", portfolioId); queryWrapper.eq("portfolio_id", portfolioId);
} }
if (type.equals("comment")) { if (type.equals("comment")) {
@@ -243,15 +245,21 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
private Long getUnreadSystemNotification() { private Long getUnreadSystemNotification(Long receiverId) {
// Long accountId = UserContext.getUserHolder().getId();
// 计算总的系统通知数量 // 计算总的系统通知数量
QueryWrapper<Notification> queryWrapper = new QueryWrapper<>(); QueryWrapper<Notification> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "system"); queryWrapper.lambda().eq(Notification::getType, "system")
.and(wrapper -> wrapper
.isNull(Notification::getReceiverId)
.or()
.eq(Notification::getReceiverId, receiverId)
);
Long totalSysCount = baseMapper.selectCount(queryWrapper); Long totalSysCount = baseMapper.selectCount(queryWrapper);
// 计算单个用户读了多少条系统数据 // 计算单个用户读了多少条系统数据
QueryWrapper<SysNotificationReadStatus> wrapper = new QueryWrapper<>(); QueryWrapper<SysNotificationReadStatus> wrapper = new QueryWrapper<>();
wrapper.eq("account_id", UserContext.getUserHolder().getId()); wrapper.eq("account_id", receiverId);
Long readCount = sysNotificationReadStatusMapper.selectCount(wrapper); Long readCount = sysNotificationReadStatusMapper.selectCount(wrapper);
// 计算差 // 计算差
@@ -279,20 +287,26 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
public void setReadStatusSystem(List<Long> notificationIdList) { public void setReadStatusSystem(List<Long> notificationIdList) {
Long id = UserContext.getUserHolder().getId(); Long id = UserContext.getUserHolder().getId();
for (Long notificationId : notificationIdList) { for (Long notificationId : notificationIdList) {
SysNotificationReadStatus sysNotificationReadStatus = new SysNotificationReadStatus(notificationId, id); Notification notification = getById(notificationId);
sysNotificationReadStatus.setCreateTime(LocalDateTime.now()); if (Objects.nonNull(notification) && notification.getType().equals("system")) {
sysNotificationReadStatusMapper.insert(sysNotificationReadStatus); // 当系统消息指定了接收人员时,不允许其他人员已读
if (Objects.isNull(notification.getReceiverId()) || notification.getReceiverId().equals(id)) {
SysNotificationReadStatus sysNotificationReadStatus = new SysNotificationReadStatus(notificationId, id);
sysNotificationReadStatus.setCreateTime(LocalDateTime.now());
sysNotificationReadStatusMapper.insert(sysNotificationReadStatus);
}
}
} }
} }
// 一键已读 // 一键已读
public void setReadAll(String type){ public void setReadAll(String type) {
Long accountId = UserContext.getUserHolder().getId(); Long accountId = UserContext.getUserHolder().getId();
// 指定某个用户的某种类型的数据,将未读数据全部已读 // 指定某个用户的某种类型的数据,将未读数据全部已读
if (!type.equals("system")){ if (!type.equals("system")) {
// 个人消息已读 // 个人消息已读
baseMapper.setPersonalNotificationAllRead(type, accountId, LocalDateTime.now()); baseMapper.setPersonalNotificationAllRead(type, accountId, LocalDateTime.now());
}else { } else {
// 系统消息已读 // 系统消息已读
// 1、先确定当前用户未读的系统消息有哪些 // 1、先确定当前用户未读的系统消息有哪些
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId); List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
@@ -312,44 +326,44 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
prePushMessage(notification); prePushMessage(notification);
} }
public Long getNewPostedCount(Long accountId){ public Long getNewPostedCount(Long accountId) {
// 1.1 获取我关注的所有用户 // 1.1 获取我关注的所有用户
List<Long> followeeList = portfolioService.getFolloweeList(accountId); List<Long> followeeList = userFollowService.getFolloweeList(accountId);
// 1.2 查询我关注的用户在我上次查看动态之后发布的作品数量 // 1.2 查询我关注的用户在我上次查看动态之后发布的作品数量
String lastViewTime = redisUtil.getFromString(lastViewNewPostedTimeKey + ":" + accountId); String lastViewTime = redisUtil.getFromString(lastViewNewPostedTimeKey + ":" + accountId);
QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>(); QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>();
if (!followeeList.isEmpty()){ if (!followeeList.isEmpty()) {
queryWrapper.in("account_id", followeeList); queryWrapper.in("account_id", followeeList);
}else { } else {
return 0L; return 0L;
} }
if (!StringUtil.isNullOrEmpty(lastViewTime)){ if (!StringUtil.isNullOrEmpty(lastViewTime)) {
queryWrapper.gt("create_date", lastViewTime); queryWrapper.gt("create_date", lastViewTime);
}else { } else {
return 0L; return 0L;
} }
return portfolioService.getBaseMapper().selectCount(queryWrapper); return portfolioMapper.selectCount(queryWrapper);
} }
/** /**
* 获取关注用户发布的新作品 分页查询 * 获取关注用户发布的新作品 分页查询
*/ */
public PageBaseResponse<NotificationVO> getNewPosted(Long accountId, Integer page, Integer size){ public PageBaseResponse<NotificationVO> getNewPosted(Long accountId, Integer page, Integer size) {
// 1、获取关注用户发布的所有作品 // 1、获取关注用户发布的所有作品
// 1.1 获取我关注的所有用户 // 1.1 获取我关注的所有用户
List<Long> followeeList = portfolioService.getFolloweeList(accountId); List<Long> followeeList = userFollowService.getFolloweeList(accountId);
// 1.2 分页查询我关注的用户发布的作品 // 1.2 分页查询我关注的用户发布的作品
QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>(); QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>();
if (!followeeList.isEmpty()){ if (!followeeList.isEmpty()) {
queryWrapper.in("account_id", followeeList); queryWrapper.in("account_id", followeeList);
}else { } else {
return new PageBaseResponse<>(new ArrayList<>(), page, size, 0, 0); return new PageBaseResponse<>(new ArrayList<>(), page, size, 0, 0);
} }
queryWrapper.orderByDesc("create_date"); queryWrapper.orderByDesc("create_date");
Page<Portfolio> portfolioPage = portfolioService.getBaseMapper().selectPage(new Page<>(page, size), queryWrapper); Page<Portfolio> portfolioPage = portfolioMapper.selectPage(new Page<>(page, size), queryWrapper);
// 2、组装返回的数据 // 2、组装返回的数据
IPage<NotificationVO> convert = portfolioPage.convert(o -> { IPage<NotificationVO> convert = portfolioPage.convert(o -> {
@@ -378,4 +392,38 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
return PageBaseResponse.success(convert); return PageBaseResponse.success(convert);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void videoFinishedMsg(Long userId, String projectName, boolean isSuccess) {
Account account = accountService.getById(userId);
String language = account.getLanguage();
PublishSysNotificationDTO sysNotificationDTO = new PublishSysNotificationDTO();
Notification notification = new Notification();
notification.setType("system");
notification.setReceiverId(userId);
if (isSuccess) {
if (language.equals(Language.ENGLISH.name())) {
sysNotificationDTO.setTitle("System Notification");
sysNotificationDTO.setContent("Your video generation task in Project " + projectName + " is ready!");
} else {
sysNotificationDTO.setTitle("系统通知");
sysNotificationDTO.setContent("您在项目 " + projectName + " 中创建的视频生成任务已完成!");
}
} else {
if (language.equals(Language.ENGLISH.name())) {
sysNotificationDTO.setTitle("System Notification");
sysNotificationDTO.setContent("Your video generation task in Project " + projectName + " has failed.");
} else {
sysNotificationDTO.setTitle("系统通知");
sysNotificationDTO.setContent("视频生成任务失败。");
}
}
notification.setContent(JSON.toJSONString(sysNotificationDTO));
notification.setIsRead(0);
notification.setCreateTime(LocalDateTime.now());
save(notification);
// 这里推送消息是在接受到视频生成结束后发生的所以UserContext中没有用户信息
pushMessage("system", userId);
}
} }

View File

@@ -0,0 +1,90 @@
package com.ai.da.service.impl;
import com.ai.da.mapper.primary.MoodboardPositionMapper;
import com.ai.da.mapper.primary.entity.MoodboardPosition;
import com.ai.da.service.MoodboardPositionService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Service
public class MoodboardPositionServiceImpl extends ServiceImpl<MoodboardPositionMapper, MoodboardPosition> implements MoodboardPositionService {
@Override
public void parseMoodboardPosition(String moodboardPosition, Long collectionIdParam) {
if (!StringUtils.isEmpty(moodboardPosition)) {
// 将 JSON 字符串解析为 JSONObject
JSONObject moodboardPositionJson = JSONObject.parseObject(moodboardPosition);
// 准备保存的 MoodboardPosition 列表
List<MoodboardPosition> moodboardPositions = new ArrayList<>();
// 遍历 JSON 对象的 key即样式类型
for (String key : moodboardPositionJson.keySet()) {
// 特殊处理 "class" 字段
if ("class".equals(key)) {
// 获取 "class" 字段的值并将其转为 List<String>
JSONArray classArray = moodboardPositionJson.getJSONArray(key);
if (classArray != null) {
for (int j = 0; j < classArray.size(); j++) {
// 将 classList 存入 MoodboardPosition或者其他结构
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(classArray.getString(j)) // 设置 class 字段
.setSequence(j) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
continue; // 跳过 "class" 字段的常规处理
}
JSONArray styleArray = moodboardPositionJson.getJSONArray(key);
if (styleArray != null) {
for (int i = 0; i < styleArray.size(); i++) {
// 获取当前样式数据
JSONObject styleData = styleArray.getJSONObject(i);
// 构建 MoodboardPosition 实例
MoodboardPosition position = new MoodboardPosition()
.setCollectionId(collectionIdParam) // 关联 Collection ID
.setType(key) // 样式类型
.setStyleData(styleData.toJSONString()) // 样式数据存为 JSON 字符串
.setSequence(i) // 根据索引值设置顺序
.setCreateTime(LocalDateTime.now()) // 创建时间
.setUpdateTime(LocalDateTime.now()); // 更新时间
// 添加到列表中
moodboardPositions.add(position);
}
}
}
// 如果解析结果非空,保存到数据库
if (!moodboardPositions.isEmpty()) {
for (MoodboardPosition position : moodboardPositions) {
baseMapper.insert(position);
}
log.info("成功解析并保存 {} 条 MoodboardPosition 数据", moodboardPositions.size());
} else {
log.warn("未找到可保存的 MoodboardPosition 数据");
}
} else {
log.warn("传入的 moodboardPosition 字段为空");
}
}
}

View File

@@ -27,6 +27,7 @@ import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -224,6 +225,7 @@ public class PaymentInfoServiceImpl extends ServiceImpl<PaymentInfoMapper, Payme
@Value("${stripe.private-key}") @Value("${stripe.private-key}")
private String privateKey; private String privateKey;
@Transactional(rollbackFor = Exception.class)
public PaymentInfo createOrUpdatePaymentInfoForStripe(Invoice invoice){ public PaymentInfo createOrUpdatePaymentInfoForStripe(Invoice invoice){
Stripe.apiKey = privateKey; Stripe.apiKey = privateKey;
// 获取transactionId,从sessionId更改为invoiceId // 获取transactionId,从sessionId更改为invoiceId

View File

@@ -30,6 +30,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Function; import com.google.common.base.Function;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -45,107 +46,41 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService { public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {
@Resource private final AccountMapper accountMapper;
private UserLikeGroupMapper userLikeGroupMapper; private final CanvasMapper canvasMapper;
private final CollectionMapper collectionMapper;
@Resource private final CollectionElementMapper collectionElementMapper;
private CollectionMapper collectionMapper; private final CollectionElementService collectionElementService;
private final CollectionSortMapper collectionSortMapper;
@Resource private final CollectionSortService collectionSortService;
private CollectionElementService collectionElementService; private final CollectionElementRelModelMapper collectionElementRelModelMapper;
private final TCollectionElementRelationMapper collectionElementRelationMapper;
@Resource private final DesignMapper designMapper;
private CollectionElementMapper collectionElementMapper; private final DesignItemMapper designItemMapper;
@Resource private final DesignItemDetailMapper designItemDetailMapper;
private CollectionSortService collectionSortService; private final DesignItemDetailPrintMapper designItemDetailPrintMapper;
@Resource private final TDesignPythonOutfitMapper designPythonOutfitMapper;
private CollectionSortMapper collectionSortMapper; private final TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper;
@Resource private final MinioUtil minioUtil;
private TCollectionElementRelationMapper collectionElementRelationMapper; private final ProjectMapper projectMapper;
private final PortfolioMapper portfolioMapper;
@Resource private final PortfolioTagsMapper portfolioTagsMapper;
private PortfolioMapper portfolioMapper; private final PoseTransformationMapper poseTransformationMapper;
private final TagsMapper tagsMapper;
@Resource private final TagsService tagsService;
private UserLikeService userLikeService; private final ToProductImageResultMapper toProductImageResultMapper;
private final ToProductImageRecordMapper toProductImageRecordMapper;
@Resource private final UserFollowMapper userFollowMapper;
private UserLikeMapper userLikeMapper; private final UserFollowService userFollowService;
private final UserLikeService userLikeService;
@Resource private final UserLikeMapper userLikeMapper;
private TDesignPythonOutfitMapper designPythonOutfitMapper; private final UserLikeGroupMapper userLikeGroupMapper;
private final UserLikeGroupService userLikeGroupService;
@Resource private final WorkspaceMapper workspaceMapper;
private TDesignPythonOutfitDetailMapper designPythonOutfitDetailMapper; private final WorkspaceService workspaceService;
@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;
@Resource
private CanvasMapper canvasMapper;
@Resource
private AccountMapper accountMapper;
@Resource
private WorkspaceMapper workspaceMapper;
@Resource
private SysFileMapper sysFileMapper;
@Resource
private LibraryMapper libraryMapper;
@Resource
private StyleMapper styleMapper;
@Resource
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
@Resource
private UserFollowMapper userFollowMapper;
@Resource
private PortfolioTagsMapper portfolioTagsMapper;
@Resource
private TagsService tagsService;
@Resource
private TagsMapper tagsMapper;
@Resource
private ProjectMapper projectMapper;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private ToProductImageRecordMapper toProductImageRecordMapper;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -585,7 +520,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
vo.setIsLike(0); vo.setIsLike(0);
} }
// 设置当前用户是否关注了所查看作品的作者 // 设置当前用户是否关注了所查看作品的作者
Integer ifFollowed = getIfFollowed(portfolio.getAccountId(), portfolioDTO.getAccountId()); Integer ifFollowed = userFollowService.getIfFollowed(portfolio.getAccountId(), portfolioDTO.getAccountId());
vo.setIsFollow(ifFollowed); vo.setIsFollow(ifFollowed);
avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar(); avatar = StringUtil.isNullOrEmpty(account.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : account.getAvatar();
} }
@@ -1157,7 +1092,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)) { if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)) {
return false; return false;
} else { } else {
UserLikeGroup userLikeGroup = userLikeGroupService.getById(userLikeGroupId); UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(userLikeGroupId);
// 不是原创的作品不能参与活动 // 不是原创的作品不能参与活动
if (userLikeGroup.getOriginal().equals(0)) { if (userLikeGroup.getOriginal().equals(0)) {
throw new BusinessException("only.original.works.can.participate.in.the.event", ResultEnum.PROMPT.getCode()); throw new BusinessException("only.original.works.can.participate.in.the.event", ResultEnum.PROMPT.getCode());
@@ -1276,86 +1211,6 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
messageCenterService.pushMessage("follow", followeeId); messageCenterService.pushMessage("follow", followeeId);
} }
public Long getFolloweeCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("follower_id", accountId).select("followee_id");
return userFollowMapper.selectCount(queryWrapper);
}
// 获取某个用户的关注列表 + 按名字查询
public List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 1、判断是否有按用户名查询
List<AccountFollowVO> followeeList;
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followeeList = userFollowMapper.getFolloweeListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followeeList = userFollowMapper.getFolloweeListByFollower(accountId, limit, offset, order);
}
if (!followeeList.isEmpty()) {
followeeList.forEach(followee -> {
String avatar = StringUtil.isNullOrEmpty(followee.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : followee.getAvatar();
followee.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
});
return followeeList;
}
return new ArrayList<>();
}
public Long getFollowerCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", accountId).select("follower_id");
return userFollowMapper.selectCount(queryWrapper);
}
// 获取某个用户的粉丝列表 + 按名字查询 需返回是否关注该粉丝
public List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 获取当前用户的所有粉丝
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id", "create_time");
List<UserFollow> userFollows = userFollowMapper.selectList(qw);
Map<Long, LocalDateTime> followeeMap = userFollows.stream().collect(Collectors.toMap(UserFollow::getFolloweeId, UserFollow::getCreateTime));
List<AccountFollowVO> followerList;
// 1、判断是否有按用户名查询粉丝
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followerList = userFollowMapper.getFollowerListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followerList = userFollowMapper.getFollowerListByFollowee(accountId, limit, offset, order);
}
if (!followerList.isEmpty()) {
// 判断当前用户是否与粉丝互关
followerList.forEach(follower -> {
String avatar = StringUtil.isNullOrEmpty(follower.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : follower.getAvatar();
follower.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
follower.setIsFollow(Objects.isNull(followeeMap.get(follower.getSenderId())) ? 0 : 1);
// follower.setFollowTime(followeeMap.get(follower.getUserId()));
});
return followerList;
}
return new ArrayList<>();
}
public Integer getIfFollowed(Long followeeId, Long followerId) {
// 设置当前用户是否关注了所查看作品的作者
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", followeeId).eq("follower_id", followerId);
UserFollow userFollow = userFollowMapper.selectOne(queryWrapper);
return Objects.isNull(userFollow) ? 0 : 1;
}
public Long getPortfolioCount(Long accountId) { public Long getPortfolioCount(Long accountId) {
QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>(); QueryWrapper<Portfolio> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", accountId); queryWrapper.eq("account_id", accountId);
@@ -1363,19 +1218,6 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
/**
* 获取关注列表
*
* @param accountId
* @return
*/
public List<Long> getFolloweeList(Long accountId) {
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id");
List<UserFollow> userFollows = userFollowMapper.selectList(qw);
return userFollows.stream().map(UserFollow::getFolloweeId).collect(Collectors.toList());
}
public void setPortfolioToPublic(Long portfolioId) { public void setPortfolioToPublic(Long portfolioId) {
// 判断当前用户与作品用户是不是一家公司的 // 判断当前用户与作品用户是不是一家公司的

View File

@@ -4,6 +4,8 @@ package com.ai.da.service.impl;
import com.ai.da.common.config.exception.BusinessException; import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.mapper.primary.PythonTAllInfoMapper; import com.ai.da.mapper.primary.PythonTAllInfoMapper;
import com.ai.da.mapper.primary.entity.PythonTAllInfo; import com.ai.da.mapper.primary.entity.PythonTAllInfo;
import com.ai.da.python.vo.DesignPythonItem;
import com.ai.da.python.vo.DesignPythonObjects;
import com.ai.da.service.PythonTAllInfoService; import com.ai.da.service.PythonTAllInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -13,7 +15,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* (PythonTAllInfo)表服务实现类 * (PythonTAllInfo)表服务实现类
@@ -48,4 +52,31 @@ public class PythonTAllInfoServiceImpl extends ServiceImpl<PythonTAllInfoMapper,
} }
return pythonTAllInfo.getId(); return pythonTAllInfo.getId();
} }
@Override
public void relationImageId(DesignPythonObjects pythonObjects) {
if (Objects.isNull(pythonObjects)) {
return;
}
pythonObjects.getObjects().forEach(
o -> {
for (DesignPythonItem item : o.getItems()) {
List<Long> list = new ArrayList<>();
list.add(1L);
list.add(1L);
item.setOffset(list);
item.setResize_scale(new Float[]{1.0f, 1.0f});
String path = item.getPath();
if (StringUtils.isEmpty(path)) {
String bodyPath = item.getBody_path();
Long imageId = getImageIdByPath(bodyPath);
item.setImage_id(imageId);
} else {
Long imageId = getImageIdByPath(path);
item.setImage_id(imageId);
}
}
}
);
}
} }

View File

@@ -16,6 +16,7 @@ import com.ai.da.model.dto.CreateCouponDTO;
import com.ai.da.model.dto.ProductPurchaseDTO; import com.ai.da.model.dto.ProductPurchaseDTO;
import com.ai.da.model.dto.QueryCouponsPageDTO; import com.ai.da.model.dto.QueryCouponsPageDTO;
import com.ai.da.model.dto.SubscriptionEmailParamsDTO; import com.ai.da.model.dto.SubscriptionEmailParamsDTO;
import com.ai.da.model.enums.Language;
import com.ai.da.model.vo.CheckCouponsVO; import com.ai.da.model.vo.CheckCouponsVO;
import com.ai.da.service.*; import com.ai.da.service.*;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@@ -351,6 +352,9 @@ public class StripeServiceImpl implements StripeService {
} }
} else if (event.getType().equals("customer.subscription.deleted")){ } else if (event.getType().equals("customer.subscription.deleted")){
SubscriptionInfo subscriptionInfo = updateSubscription(subscription); SubscriptionInfo subscriptionInfo = updateSubscription(subscription);
if (Objects.isNull(subscriptionInfo)){
return true;
}
log.info("用户 {} 取消连续订阅 {}", subscriptionInfo.getAccountId(), subscription.getId()); log.info("用户 {} 取消连续订阅 {}", subscriptionInfo.getAccountId(), subscription.getId());
if (subscriptionInfo.getCancelNotified() == (byte)0){ if (subscriptionInfo.getCancelNotified() == (byte)0){
log.info("取消订阅 邮件通知商家"); log.info("取消订阅 邮件通知商家");
@@ -571,6 +575,10 @@ public class StripeServiceImpl implements StripeService {
String description = subscription.getDescription(); String description = subscription.getDescription();
String orderNo = description.replace("AiDA - ", ""); String orderNo = description.replace("AiDA - ", "");
OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo); OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo);
if (Objects.isNull(orderInfo)){
log.warn("未知订阅:{}", subscription.getId());
return null;
}
// 从回调信息中获取recurring type // 从回调信息中获取recurring type
SubscriptionItem subscriptionItem = subscription.getItems().getData().get(0); SubscriptionItem subscriptionItem = subscription.getItems().getData().get(0);
@@ -1002,9 +1010,14 @@ public class StripeServiceImpl implements StripeService {
public boolean sendEmail(String subscriptionId, String type, String orderNo) { public boolean sendEmail(String subscriptionId, String type, String orderNo) {
SubscriptionInfo subscriptionInfo; SubscriptionInfo subscriptionInfo;
long secondsTimestamp = System.currentTimeMillis() / 1000;
log.info("当前时间戳:{}", secondsTimestamp);
QueryWrapper<SubscriptionInfo> qwSI = new QueryWrapper<>(); QueryWrapper<SubscriptionInfo> qwSI = new QueryWrapper<>();
if (!StringUtil.isNullOrEmpty(subscriptionId)) { if (!StringUtil.isNullOrEmpty(subscriptionId)) {
qwSI.eq("subscription_id", subscriptionId); // 区分当前订阅的时段,从而确定是新订单还是续订订单的记录
qwSI.lambda().eq(SubscriptionInfo::getSubscriptionId, subscriptionId)
.lt(SubscriptionInfo::getCurrentPeriodStart, secondsTimestamp)
.gt(SubscriptionInfo::getCurrentPeriodEnd, secondsTimestamp);
List<SubscriptionInfo> subscriptionInfoList = subscriptionInfoMapper.selectList(qwSI); List<SubscriptionInfo> subscriptionInfoList = subscriptionInfoMapper.selectList(qwSI);
if (subscriptionInfoList.isEmpty()){ if (subscriptionInfoList.isEmpty()){
@@ -1024,7 +1037,9 @@ public class StripeServiceImpl implements StripeService {
} }
} }
}else if (!StringUtil.isNullOrEmpty(orderNo)) { }else if (!StringUtil.isNullOrEmpty(orderNo)) {
qwSI.eq("order_no", orderNo); qwSI.lambda().eq(SubscriptionInfo::getOrderNo, orderNo)
.lt(SubscriptionInfo::getCurrentPeriodStart, secondsTimestamp)
.gt(SubscriptionInfo::getCurrentPeriodEnd, secondsTimestamp);
subscriptionInfo = subscriptionInfoMapper.selectOne(qwSI); subscriptionInfo = subscriptionInfoMapper.selectOne(qwSI);
if (Objects.isNull(subscriptionInfo)){ if (Objects.isNull(subscriptionInfo)){
log.info("不发送邮件原因【根据order_no{}查询到的subscriptionInfo为空】", orderNo); log.info("不发送邮件原因【根据order_no{}查询到的subscriptionInfo为空】", orderNo);
@@ -1036,7 +1051,12 @@ public class StripeServiceImpl implements StripeService {
} }
QueryWrapper<PaymentInfo> qwPI = new QueryWrapper<>(); QueryWrapper<PaymentInfo> qwPI = new QueryWrapper<>();
qwPI.eq("order_no", subscriptionInfo.getOrderNo()).orderByDesc("id"); String periodStart = DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodStart(), "seconds", CommonConstant.TIME_FORMAT_yyyy_MM_dd_HH_mm_ss);
String periodEnd = DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_yyyy_MM_dd_HH_mm_ss);
qwPI.lambda().eq(PaymentInfo::getOrderNo, subscriptionInfo.getOrderNo())
.between(PaymentInfo::getCreateTime, periodStart, periodEnd)
.orderByDesc(PaymentInfo::getId);
List<PaymentInfo> paymentInfos = paymentInfoMapper.selectList(qwPI); List<PaymentInfo> paymentInfos = paymentInfoMapper.selectList(qwPI);
if (paymentInfos.isEmpty()) { if (paymentInfos.isEmpty()) {
log.info("不发送邮件原因【根据order_no:{},查询到的paymentInfos为空】", orderNo); log.info("不发送邮件原因【根据order_no:{},查询到的paymentInfos为空】", orderNo);
@@ -1053,7 +1073,7 @@ public class StripeServiceImpl implements StripeService {
String key = RedisUtil.SUBSCRIPTION_SENT_EMAIL_TYPE + subscriptionInfo.getId(); String key = RedisUtil.SUBSCRIPTION_SENT_EMAIL_TYPE + subscriptionInfo.getId();
// 先判断当前订单 这个类型的邮件是否已发送过 // 先判断当前订单 这个类型的邮件是否已发送过
Boolean elementExistsInSet = redisUtil.isElementExistsInSet(key, type); Boolean elementExistsInSet = redisUtil.isElementExistsInSet(key, type);
if (!type.equals("reminder") && !type.equals("cancel") && paymentInfo.getNotified() == 1 && elementExistsInSet){ if (!type.startsWith("reminder") && !type.equals("cancel") && paymentInfo.getNotified() == 1 && elementExistsInSet){
// 已经邮件通知过,直接返回 // 已经邮件通知过,直接返回
log.info("不发送邮件原因【type为{}order_no为{},已经进行邮件通知】", type, orderNo); log.info("不发送邮件原因【type为{}order_no为{},已经进行邮件通知】", type, orderNo);
return true; return true;
@@ -1061,11 +1081,13 @@ public class StripeServiceImpl implements StripeService {
com.ai.da.mapper.primary.entity.Account account = accountMapper.selectById(subscriptionInfo.getAccountId()); com.ai.da.mapper.primary.entity.Account account = accountMapper.selectById(subscriptionInfo.getAccountId());
String userName = account.getUserName(); String userName = account.getUserName();
String language = account.getLanguage(); String language = getLanguage(account.getLanguage(), account.getCountry(), type);
OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(subscriptionInfo.getOrderNo()); OrderInfo orderByOrderNo = orderInfoService.getOrderByOrderNo(subscriptionInfo.getOrderNo());
SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO(); SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO();
emailParamsDTO.setUsername(userName); emailParamsDTO.setUsername(userName);
emailParamsDTO.setEmail(account.getUserEmail());
emailParamsDTO.setCountry(paymentInfo.getCountry());
emailParamsDTO.setOrderId(paymentInfo.getId().toString()); emailParamsDTO.setOrderId(paymentInfo.getId().toString());
emailParamsDTO.setOrderRef("\"" + orderListLink + paymentInfo.getId().toString() + "\""); emailParamsDTO.setOrderRef("\"" + orderListLink + paymentInfo.getId().toString() + "\"");
emailParamsDTO.setCreateDate(String.valueOf(paymentInfo.getCreateTime()).replace("T", " ")); emailParamsDTO.setCreateDate(String.valueOf(paymentInfo.getCreateTime()).replace("T", " "));
@@ -1080,7 +1102,7 @@ public class StripeServiceImpl implements StripeService {
if (!b) return false; if (!b) return false;
// 邮件通知成功后,更新标志 // 邮件通知成功后,更新标志
if (!type.equals("reminder") && !type.equals("cancel")){ if (!type.startsWith("reminder") && !type.equals("cancel")){
PaymentInfo payment = new PaymentInfo(); PaymentInfo payment = new PaymentInfo();
payment.setId(paymentInfo.getId()); payment.setId(paymentInfo.getId());
payment.setNotified(1); payment.setNotified(1);
@@ -1093,6 +1115,20 @@ public class StripeServiceImpl implements StripeService {
return true; return true;
} }
public String getLanguage(String language, String country, String type) {
if (StringUtil.isNullOrEmpty(language)){
return Language.ENGLISH.name();
} else {
if (!StringUtil.isNullOrEmpty(type) && type.startsWith("reminder")
&& language.equals(Language.CHINESE_SIMPLIFIED.name())
&& !StringUtil.isNullOrEmpty(country)
&& (country.equals("Hong Kong, China") || country.equals("Taiwan, China"))) {
return "zh-Hant";
}
return language;
}
}
public boolean sendEmail(String orderNo){ public boolean sendEmail(String orderNo){
SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO(); SubscriptionEmailParamsDTO emailParamsDTO = new SubscriptionEmailParamsDTO();
OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo); OrderInfo orderInfo = orderInfoService.getOrderByOrderNo(orderNo);
@@ -1236,9 +1272,10 @@ public class StripeServiceImpl implements StripeService {
emailParamsDTO.setNextPayDate(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy)); emailParamsDTO.setNextPayDate(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy));
} }
emailParamsDTO.setRenewalTime(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy)); emailParamsDTO.setRenewalTime(DateUtil.changeTimeStampFormat(subscriptionInfo.getCurrentPeriodEnd(), "seconds", CommonConstant.TIME_FORMAT_MMM_dd_yyyy));
emailParamsDTO.setDays(subscriptionInfo.getType().equals("month") ? "7" : subscriptionInfo.getType().equals("year") ? "14" : "N/A");
} }
public void subscriptionReminder(){ /*public void subscriptionReminder(){
// 提前7天的 00:00:00 和 23:59:59 // 提前7天的 00:00:00 和 23:59:59
LocalDateTime startOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atStartOfDay(); LocalDateTime startOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atStartOfDay();
LocalDateTime endOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atTime(23, 59, 59); LocalDateTime endOfDay = LocalDateTime.now().plusDays(7).toLocalDate().atTime(23, 59, 59);
@@ -1257,7 +1294,7 @@ public class StripeServiceImpl implements StripeService {
boolean b = sendEmail(subscriptionInfo.getSubscriptionId(), "reminder", null); boolean b = sendEmail(subscriptionInfo.getSubscriptionId(), "reminder", null);
if (b) log.info("提前7天向用户 {} 发送续订通知邮件", subscriptionInfo.getAccountId()); if (b) log.info("提前7天向用户 {} 发送续订通知邮件", subscriptionInfo.getAccountId());
} }
} }*/
public void checkSubscriptionExpiration(){ public void checkSubscriptionExpiration(){
long epochSecond = Instant.now().getEpochSecond(); long epochSecond = Instant.now().getEpochSecond();

View File

@@ -45,6 +45,7 @@ public class TDesignPythonOutfitDetailServiceImpl extends ServiceImpl<TDesignPyt
public List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId) { public List<TDesignPythonOutfitDetail> getDetailByDesignPythonOutfitId(Long designPythonOutfitId) {
QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>(); QueryWrapper<TDesignPythonOutfitDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("design_python_outfit_id", designPythonOutfitId); queryWrapper.eq("design_python_outfit_id", designPythonOutfitId);
queryWrapper.eq("is_deleted", 0);
return baseMapper.selectList(queryWrapper); return baseMapper.selectList(queryWrapper);
} }

View File

@@ -0,0 +1,78 @@
package com.ai.da.service.impl;
import com.ai.da.mapper.primary.ToProductImageResultMapper;
import com.ai.da.mapper.primary.entity.CollectionSort;
import com.ai.da.mapper.primary.entity.ToProductImageResult;
import com.ai.da.mapper.primary.entity.UserLike;
import com.ai.da.service.CollectionSortService;
import com.ai.da.service.ToProductImageResultService;
import com.ai.da.service.UserLikeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Slf4j
@Service
@RequiredArgsConstructor
public class ToProductImageResultServiceImpl extends ServiceImpl<ToProductImageResultMapper, ToProductImageResult> implements ToProductImageResultService {
private final CollectionSortService collectionSortService;
private final UserLikeService userLikeService;
// 获取未被like的to product\relight的parentId
public Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url) {
// 卫语句处理null情况
if (toProductImageResult == null && StringUtil.isNullOrEmpty(url)) {
return null;
}
// 如果需要查询结果对象
if (toProductImageResult == null) {
toProductImageResult = baseMapper.selectOne(
new QueryWrapper<ToProductImageResult>().eq("url", url));
}
// 卫语句处理查询结果为空的情况
if (toProductImageResult == null) {
return null;
}
// 根据不同类型处理
String elementType = toProductImageResult.getElementType();
if ("DesignOutfit".equals(elementType)) {
return handleDesignOutfitCase(toProductImageResult);
} else if ("ToProductImage".equals(elementType)) {
// 两种情况 resultType : ToProductImage | Relight
return handleToProductImageCase(toProductImageResult);
}
return null;
}
private Long handleDesignOutfitCase(ToProductImageResult result) {
UserLike userLike = userLikeService.getByDesignOutfitId(result.getElementId());
if (userLike == null) {
return null;
}
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
userLike.getId(), "Design", result.getProjectId());
return collectionSort != null ? collectionSort.getId() : null;
}
private Long handleToProductImageCase(ToProductImageResult result) {
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
result.getElementId(), result.getResultType(), result.getProjectId());
if (Objects.isNull(collectionSort) && result.getElementType().equals("ToProductImage")) {
ToProductImageResult toProductImageResult = baseMapper.selectById(result.getElementId());
return getUnlikedResultParentId(toProductImageResult, null);
}
return collectionSort != null ? collectionSort.getParentId() : null;
}
}

View File

@@ -0,0 +1,125 @@
package com.ai.da.service.impl;
import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.utils.MinioUtil;
import com.ai.da.mapper.primary.UserFollowMapper;
import com.ai.da.mapper.primary.entity.UserFollow;
import com.ai.da.model.dto.GetFollowListDTO;
import com.ai.da.model.vo.AccountFollowVO;
import com.ai.da.service.UserFollowService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFollow> implements UserFollowService {
private final MinioUtil minioUtil;
public Long getFolloweeCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("follower_id", accountId).select("followee_id");
return baseMapper.selectCount(queryWrapper);
}
// 获取某个用户的关注列表 + 按名字查询
public List<AccountFollowVO> getFolloweeList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 1、判断是否有按用户名查询
List<AccountFollowVO> followeeList;
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followeeList = baseMapper.getFolloweeListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followeeList = baseMapper.getFolloweeListByFollower(accountId, limit, offset, order);
}
if (!followeeList.isEmpty()) {
followeeList.forEach(followee -> {
String avatar = StringUtil.isNullOrEmpty(followee.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : followee.getAvatar();
followee.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
});
return followeeList;
}
return new ArrayList<>();
}
public Long getFollowerCount(Long accountId) {
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", accountId).select("follower_id");
return baseMapper.selectCount(queryWrapper);
}
// 获取某个用户的粉丝列表 + 按名字查询 需返回是否关注该粉丝
public List<AccountFollowVO> getFollowerList(GetFollowListDTO getFollowListDTO) {
Long accountId = UserContext.getUserHolder().getId();
// 获取当前用户的所有粉丝
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id", "create_time");
List<UserFollow> userFollows = baseMapper.selectList(qw);
Map<Long, LocalDateTime> followeeMap = userFollows.stream().collect(Collectors.toMap(UserFollow::getFolloweeId, UserFollow::getCreateTime));
List<AccountFollowVO> followerList;
// 1、判断是否有按用户名查询粉丝
if (!StringUtil.isNullOrEmpty(getFollowListDTO.getSearchByName())) {
followerList = baseMapper.getFollowerListByName(getFollowListDTO.getSearchByName(), accountId);
} else {
// 2、查全部 分页查询
String order = StringUtil.isNullOrEmpty(getFollowListDTO.getOrder()) ? "DESC" : getFollowListDTO.getOrder().equals("DESC") ? "DESC" : "ASC";
Integer limit = getFollowListDTO.getSize() > 0 ? getFollowListDTO.getSize() : 20;
Integer offset = getFollowListDTO.getPage() > 0 ? (getFollowListDTO.getPage() - 1) * getFollowListDTO.getSize() : 0;
followerList = baseMapper.getFollowerListByFollowee(accountId, limit, offset, order);
}
if (!followerList.isEmpty()) {
// 判断当前用户是否与粉丝互关
followerList.forEach(follower -> {
String avatar = StringUtil.isNullOrEmpty(follower.getAvatar()) ? CommonConstant.DEFAULT_AVATAR : follower.getAvatar();
follower.setAvatar(minioUtil.getPreSignedUrl(avatar, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
follower.setIsFollow(Objects.isNull(followeeMap.get(follower.getSenderId())) ? 0 : 1);
// follower.setFollowTime(followeeMap.get(follower.getUserId()));
});
return followerList;
}
return new ArrayList<>();
}
public Integer getIfFollowed(Long followeeId, Long followerId) {
// 设置当前用户是否关注了所查看作品的作者
QueryWrapper<UserFollow> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("followee_id", followeeId).eq("follower_id", followerId);
UserFollow userFollow = baseMapper.selectOne(queryWrapper);
return Objects.isNull(userFollow) ? 0 : 1;
}
/**
* 获取关注列表
*
* @param accountId
* @return
*/
public List<Long> getFolloweeList(Long accountId) {
QueryWrapper<UserFollow> qw = new QueryWrapper<>();
qw.eq("follower_id", accountId).select("followee_id");
List<UserFollow> userFollows = baseMapper.selectList(qw);
return userFollows.stream().map(UserFollow::getFolloweeId).collect(Collectors.toList());
}
}

View File

@@ -29,6 +29,9 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Comparator;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -37,6 +40,7 @@ import com.google.common.base.Function;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.minio.errors.MinioException; import io.minio.errors.MinioException;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -65,98 +69,54 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, UserLikeGroup> implements UserLikeGroupService { public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, UserLikeGroup> implements UserLikeGroupService {
@Resource private final UserLikeGroupMapper userLikeGroupMapper;
private UserLikeGroupMapper userLikeGroupMapper; private final AccountService accountService;
@Resource private final CollectionService collectionService;
private AccountService accountService; private final UserLikeService userLikeService;
@Resource private final WorkspaceService workspaceService;
private CollectionService collectionService; private final UserLikeMapper userLikeMapper;
@Resource private final MinioUtil minioUtil;
private UserLikeService userLikeService; private final TDesignPythonOutfitMapper designPythonOutfitMapper;
@Resource private final DesignMapper designMapper;
private WorkspaceService workspaceService; private final MoodboardPositionService moodboardPositionService;
@Resource private final SysFileMapper sysFileMapper;
private UserLikeMapper userLikeMapper; private final LibraryMapper libraryMapper;
@Resource private final GenerateDetailMapper generateDetailMapper;
private MinioUtil minioUtil; private final PortfolioMapper portfolioMapper;
@Resource private final TagsMapper tagsMapper;
private TDesignPythonOutfitMapper designPythonOutfitMapper; private final DesignItemDetailService designItemDetailService;
@Resource private final CollectionElementMapper collectionElementMapper;
private DesignMapper designMapper; private final AttributeRetrievalMapper attributeRetrievalMapper;
@Resource private final ProductImageAttributeMapper productImageAttributeMapper;
private DesignService designService; private final CollectionSortMapper collectionSortMapper;
@Resource private final ClassificationService classificationService;
private SysFileMapper sysFileMapper; // private ProjectMapper projectMapper;
@Resource private final ProjectService projectService;
private LibraryMapper libraryMapper; private final LibraryModelPointMapper libraryModelPointMapper;
@Resource private final LibraryService libraryService;
private GenerateDetailMapper generateDetailMapper; private final BrandDNAMapper brandDNAMapper;
@Resource private final BrandRelLibraryMapper brandRelLibraryMapper;
private PortfolioMapper portfolioMapper; private final ThreeDLayoutMapper threeDLayoutMapper;
@Resource private final ThreeDPatternLayoutMapper threeDPatternLayoutMapper;
private TagsMapper tagsMapper; private final ThreeDDetailMapper threeDDetailMapper;
@Resource private final ThreeDSimpleMapper threeDSimpleMapper;
private DesignItemDetailService designItemDetailService; private final ThreeDModuleMapper threeDModuleMapper;
@Resource private final ProductImageService productImageService;
private CollectionElementMapper collectionElementMapper; private final CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource private final CollectionSortService collectionSortService;
private AttributeRetrievalMapper attributeRetrievalMapper; private final GenerateService generateService;
@Resource private final ToProductElementMapper toProductElementMapper;
private ProductImageAttributeMapper productImageAttributeMapper; private final ToProductImageRecordMapper toProductImageRecordMapper;
@Resource private final ToProductImageResultMapper toProductImageResultMapper;
private CollectionSortMapper collectionSortMapper; private final ToProductImageResultService toProductImageResultService;
@Resource private final CloudTaskMapper cloudTaskMapper;
private ClassificationService classificationService; private final PythonService pythonService;
@Resource private final CreditsService creditsService;
// private ProjectMapper projectMapper; private final PoseTransformationMapper poseTransformationMapper;
private ProjectService projectService; private final ExportFileMapper exportFileMapper;
@Resource private final DesignItemDetailCanvasMapper designItemDetailCanvasMapper;
private PortfolioService portfolioService;
@Resource
private LibraryModelPointMapper libraryModelPointMapper;
@Resource
private LibraryService libraryService;
@Resource
private BrandDNAMapper brandDNAMapper;
@Resource
private BrandRelLibraryMapper brandRelLibraryMapper;
@Resource
private ThreeDLayoutMapper threeDLayoutMapper;
@Resource
private ThreeDPatternLayoutMapper threeDPatternLayoutMapper;
@Resource
private ThreeDDetailMapper threeDDetailMapper;
@Resource
private ThreeDSimpleMapper threeDSimpleMapper;
@Resource
private ThreeDModuleMapper threeDModuleMapper;
@Resource
private ProductImageService productImageService;
@Resource
private CollectionElementRelModelMapper collectionElementRelModelMapper;
@Resource
private CollectionSortService collectionSortService;
@Resource
private GenerateService generateService;
@Resource
private ToProductElementMapper toProductElementMapper;
@Resource
private ToProductImageRecordMapper toProductImageRecordMapper;
@Resource
private ToProductImageResultMapper toProductImageResultMapper;
@Resource
private CloudTaskMapper cloudTaskMapper;
@Resource
private PythonService pythonService;
@Resource
private CreditsService creditsService;
@Resource
private PoseTransformationMapper poseTransformationMapper;
@Resource
private ExportFileMapper exportFileMapper;
@Resource
private DesignItemDetailCanvasMapper designItemDetailCanvasMapper;
@Value("${redis.key.generateResult}") @Value("${redis.key.generateResult}")
private String generateResultKey; private String generateResultKey;
@@ -443,17 +403,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageRecord.setUserLikeGroupId(userLikeGroupId); toProductImageRecord.setUserLikeGroupId(userLikeGroupId);
} }
// 处理用户输入的提示词
String prompt = toProductImageDTO.getPrompt(); String prompt = toProductImageDTO.getPrompt();
String advancedPrompt; String advancedPrompt = buildAdvancedPrompt(projectId, prompt);
//nanobanana模型支持中文为保证语义使用这个模型的不翻译
if (StringUtil.isNullOrEmpty(prompt)) {
advancedPrompt = "Transform this image into a realistic, studio-quality photograph."
+ "Pay attention to the size of the garment, the print, and the fabric texture. the white background. 8K, HDR, DOF, soft lighting" +
", high detail, high quality,Do not return the original image";
} else {
advancedPrompt = prompt + "Pay attention to the size of the garment, the print, and the fabric texture. the white background. 8K, HDR, DOF, soft lighting, high detail, high quality,Do not return the original image";
}
// 初始化基础提示词,确保生成高质量的真实图像 // 初始化基础提示词,确保生成高质量的真实图像
StringBuilder sb = new StringBuilder("The best quality, masterpiece, real image."); StringBuilder sb = new StringBuilder("The best quality, masterpiece, real image.");
if (!StringUtil.isNullOrEmpty(prompt) && !advanced) { if (!StringUtil.isNullOrEmpty(prompt) && !advanced) {
@@ -747,7 +698,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ToProductElementVO toProductImageElementUpload(MultipartFile file, Long projectId) { public ToProductElementVO toProductImageElementUpload(MultipartFile file, Long projectId, String type) {
if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) { if (null == file || StringUtils.isEmpty(file.getOriginalFilename())) {
throw new BusinessException("file.cannot.be.empty"); throw new BusinessException("file.cannot.be.empty");
} }
@@ -762,7 +713,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// toProductElement.setUserLikeGroupId(userLikeGroupId); // toProductElement.setUserLikeGroupId(userLikeGroupId);
toProductElement.setProjectId(projectId); toProductElement.setProjectId(projectId);
toProductElement.setCreateTime(LocalDateTime.now()); toProductElement.setCreateTime(LocalDateTime.now());
// toProductElement.setType(type); toProductElement.setFrameType(type);
toProductElementMapper.insert(toProductElement); toProductElementMapper.insert(toProductElement);
ToProductElementVO toProductElementVO = CopyUtil.copyObject(toProductElement, ToProductElementVO.class); ToProductElementVO toProductElementVO = CopyUtil.copyObject(toProductElement, ToProductElementVO.class);
toProductElementVO.setMinioUrl(toProductElementVO.getUrl()); toProductElementVO.setMinioUrl(toProductElementVO.getUrl());
@@ -1909,13 +1860,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// private ProductImageAttribute toAttrDict(AttributeRecognitionJSON attrDictJSON) { // private ProductImageAttribute toAttrDict(AttributeRecognitionJSON attrDictJSON) {
// ProductImageAttribute attributeRetrieval = new ProductImageAttribute(); // ProductImageAttribute attributeRetrieval = new ProductImageAttribute();
//// attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
//// attributeRetrieval.setLength(attrDictJSON.getLength().get(0)); /// / attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
//// attributeRetrieval.setSleeveLength(attrDictJSON.getSleeveLength().get(0)); /// / attributeRetrieval.setLength(attrDictJSON.getLength().get(0));
//// attributeRetrieval.setSleeveShape(attrDictJSON.getSleeveShape().get(0)); /// / attributeRetrieval.setSleeveLength(attrDictJSON.getSleeveLength().get(0));
//// attributeRetrieval.setSleeveShoulder(attrDictJSON.getSleeveShoulder().get(0)); /// / attributeRetrieval.setSleeveShape(attrDictJSON.getSleeveShape().get(0));
//// attributeRetrieval.setNeckline(attrDictJSON.getNeckline().get(0)); /// / attributeRetrieval.setSleeveShoulder(attrDictJSON.getSleeveShoulder().get(0));
//// attributeRetrieval.setCollar(attrDictJSON.getCollar().get(0)); /// / attributeRetrieval.setNeckline(attrDictJSON.getNeckline().get(0));
/// / attributeRetrieval.setCollar(attrDictJSON.getCollar().get(0));
// if (CollectionUtil.isNotEmpty(attrDictJSON.getDesign()) && attrDictJSON.getDesign().get(0) != null) { // if (CollectionUtil.isNotEmpty(attrDictJSON.getDesign()) && attrDictJSON.getDesign().get(0) != null) {
// attributeRetrieval.setDesign(attrDictJSON.getDesign().get(0)); // attributeRetrieval.setDesign(attrDictJSON.getDesign().get(0));
// } // }
@@ -1933,7 +1885,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// } // }
// return attributeRetrieval; // return attributeRetrieval;
// } // }
@Override @Override
public IPage<ProjectVO> getPage(ProjectQueryDTO query) { public IPage<ProjectVO> getPage(ProjectQueryDTO query) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder(); AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
@@ -2041,7 +1992,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
} }
if (userLikeGroupVO.getOriginal() == 0) { if (userLikeGroupVO.getOriginal() == 0) {
userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName()); userLikeGroupVO.setOriginalAccountName(accountService.getById(userLikeGroupVO.getOriginalAccountId()).getUserName());
Portfolio byId = portfolioService.getByIdAll(userLikeGroupVO.getOriginalPortfolioId()); Portfolio byId = portfolioMapper.getByIdAll(userLikeGroupVO.getOriginalPortfolioId());
if (Objects.nonNull(byId)) { if (Objects.nonNull(byId)) {
String portfolioName = byId.getPortfolioName(); String portfolioName = byId.getPortfolioName();
userLikeGroupVO.setOriginalPortfolioName(portfolioName); userLikeGroupVO.setOriginalPortfolioName(portfolioName);
@@ -2177,6 +2128,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
vo.setSketchBoardId(collectionElement.getId()); vo.setSketchBoardId(collectionElement.getId());
voList.add(vo); voList.add(vo);
} }
voList.sort(Comparator.comparing(CollectionSketchVO::getSketchBoardId));
moduleChooseVO.setBoundingBox(voList); moduleChooseVO.setBoundingBox(voList);
moduleChooseVO.setSketchBoard(list); moduleChooseVO.setSketchBoard(list);
} else if (module.equals(Module.design.name())) { } else if (module.equals(Module.design.name())) {
@@ -2293,6 +2245,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
poseTransformationVO.setId(item.getId()); poseTransformationVO.setId(item.getId());
poseTransformationVO.setTaskId(item.getUniqueId()); poseTransformationVO.setTaskId(item.getUniqueId());
poseTransformationVO.setProductImage(getMinioUrl(item.getProductImage())); poseTransformationVO.setProductImage(getMinioUrl(item.getProductImage()));
poseTransformationVO.setLastFrameProductImage(getMinioUrl(item.getLastFrameProductImage()));
poseTransformationVO.setPrompt(item.getPrompt());
poseTransformationVO.setGifUrl(getMinioUrl(item.getGifUrl())); poseTransformationVO.setGifUrl(getMinioUrl(item.getGifUrl()));
poseTransformationVO.setVideoUrl(getMinioUrl(item.getVideoUrl())); poseTransformationVO.setVideoUrl(getMinioUrl(item.getVideoUrl()));
poseTransformationVO.setFirstFrameUrl(getMinioUrl(item.getFirstFrameUrl())); poseTransformationVO.setFirstFrameUrl(getMinioUrl(item.getFirstFrameUrl()));
@@ -2373,7 +2327,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (Objects.nonNull(toProductImageRecord)) { if (Objects.nonNull(toProductImageRecord)) {
vo.setPrompt(toProductImageRecord.getPrompt()); vo.setPrompt(toProductImageRecord.getPrompt());
} }
vo.setParentId(getUnlikedResultParentId(result, null)); vo.setParentId(toProductImageResultService.getUnlikedResultParentId(result, null));
// 按isLike分类 // 按isLike分类
if (result.getIsLike() != null && result.getIsLike() == 1) { if (result.getIsLike() != null && result.getIsLike() == 1) {
likedList.add(vo); likedList.add(vo);
@@ -2502,56 +2456,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
return duration.toHours() >= 1; return duration.toHours() >= 1;
} }
// 获取未被like的to product\relight的parentId
public Long getUnlikedResultParentId(ToProductImageResult toProductImageResult, String url) {
// 卫语句处理null情况
if (toProductImageResult == null && StringUtil.isNullOrEmpty(url)) {
return null;
}
// 如果需要查询结果对象
if (toProductImageResult == null) {
toProductImageResult = toProductImageResultMapper.selectOne(
new QueryWrapper<ToProductImageResult>().eq("url", url));
}
// 卫语句处理查询结果为空的情况
if (toProductImageResult == null) {
return null;
}
// 根据不同类型处理
String elementType = toProductImageResult.getElementType();
if ("DesignOutfit".equals(elementType)) {
return handleDesignOutfitCase(toProductImageResult);
} else if ("ToProductImage".equals(elementType)) {
// 两种情况 resultType : ToProductImage | Relight
return handleToProductImageCase(toProductImageResult);
}
return null;
}
private Long handleDesignOutfitCase(ToProductImageResult result) {
UserLike userLike = userLikeService.getByDesignOutfitId(result.getElementId());
if (userLike == null) {
return null;
}
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
userLike.getId(), "Design", result.getProjectId());
return collectionSort != null ? collectionSort.getId() : null;
}
private Long handleToProductImageCase(ToProductImageResult result) {
CollectionSort collectionSort = collectionSortService.queryCollectionSortByRelation(
result.getElementId(), result.getResultType(), result.getProjectId());
if (Objects.isNull(collectionSort) && result.getElementType().equals("ToProductImage")) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(result.getElementId());
return getUnlikedResultParentId(toProductImageResult, null);
}
return collectionSort != null ? collectionSort.getParentId() : null;
}
@Override @Override
@Transactional @Transactional
@@ -2573,7 +2477,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
collectionElementMapper.updateById(compositeImage); collectionElementMapper.updateById(compositeImage);
if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) { if (!StringUtils.isEmpty(moodBoard.getMoodboardPosition())) {
// 合成图位置信息通过collectElementId关联旧逻辑通过collectionId关联 // 合成图位置信息通过collectElementId关联旧逻辑通过collectionId关联
designService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), compositeImage.getId()); moodboardPositionService.parseMoodboardPosition(moodBoard.getMoodboardPosition(), compositeImage.getId());
} }
} }
} }
@@ -2945,6 +2849,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
vo.setSketchBoardId(collectionElement.getId()); vo.setSketchBoardId(collectionElement.getId());
voList.add(vo); voList.add(vo);
} }
voList.sort(Comparator.comparing(CollectionSketchVO::getSketchBoardId));
result.setBoundingBox(voList); result.setBoundingBox(voList);
} }
project.setUpdateTime(LocalDateTime.now()); project.setUpdateTime(LocalDateTime.now());
@@ -3362,4 +3267,49 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductElementVO.setUrl(minioUtil.getPreSignedUrl(toProductElementVO.getUrl(), 24 * 60)); toProductElementVO.setUrl(minioUtil.getPreSignedUrl(toProductElementVO.getUrl(), 24 * 60));
return toProductElementVO; return toProductElementVO;
} }
private String buildAdvancedPrompt(Long projectId, String prompt) {
String process = projectService.getById(projectId).getProcess();
String ageGroup = null;
if (!"TO_PRODUCT_IMAGE".equals(process)) {
//高级工具转产品图不需要这个字段
ageGroup = workspaceService.getWSByProjectId(projectId).getAgeGroup();
}
String suffixCommon = "Pay attention to the size of the garment, the print, and the fabric texture, real photo, 8K, HDR, DOF, soft lighting, high detail, high quality, Do not return the original image.";
String suffixModelAdult = "Transform this image into a real model standing," + suffixCommon;
String suffixModelChild = "Transform this image into a real child model standing," + suffixCommon;
if ("SINGLE_DESIGN".equals(process) && "Adult".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "Transform this image into a real garment showing in the white studio: garment on invisible mannequin" + suffixCommon;
} else {
return prompt + suffixCommon;
}
} else if ("SINGLE_DESIGN".equals(process) && "Child".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "Transform this image into a real child model stand and wear this garment, in the white studio, facing camera, standing posture." + suffixCommon;
} else {
return prompt + suffixCommon;
}
} else if ("SERIES_DESIGN".equals(process) && "Adult".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "in the white studio, facing camera, standing posture." + suffixModelAdult;
} else {
return prompt + suffixModelAdult;
}
} else if ("SERIES_DESIGN".equals(process) && "Child".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "in the white studio, facing camera, standing posture." + suffixModelChild + "\n";
} else {
return prompt + suffixModelChild;
}
} else if ("TO_PRODUCT_IMAGE".equals(process)) {
if (StringUtil.isNullOrEmpty(prompt)) {
throw new BusinessException("Please enter the prompt.");
} else {
return prompt + suffixCommon;
}
} else {
return "Transform this image into a realistic, studio-quality photograph." + "Pay attention to the size of the garment, the print, and the fabric texture. the white background. 8K, HDR, DOF, soft lighting" + ", high detail, high quality,Do not return the original image";
}
}
} }

View File

@@ -12,17 +12,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 服务实现类 * 服务实现类
@@ -32,13 +29,10 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> implements UserLikeService { public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> implements UserLikeService {
@Resource private final UserLikeMapper userLikeMapper;
private UserLikeMapper userLikeMapper; private final UserLikeGroupMapper userLikeGroupMapper;
@Resource
private UserLikeGroupMapper userLikeGroupMapper;
@Resource
private DesignItemServiceImpl designItemService;
@Override @Override
public List<UserLikeVO> getGroupDetail(Long userGroupId) { public List<UserLikeVO> getGroupDetail(Long userGroupId) {
@@ -50,12 +44,6 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
return Lists.newArrayList(); return Lists.newArrayList();
} }
return CopyUtil.copyList(userLikes, UserLikeVO.class); return CopyUtil.copyList(userLikes, UserLikeVO.class);
// List<Long> designItemIds = userLikes.stream().map(UserLike::getDesignItemId).collect(Collectors.toList());
// List<DesignItem> designItems = designItemService.listByIds(designItemIds);
// Map<Long,String> idToUrlMap = designItems.stream().collect(Collectors.toMap(DesignItem::getId,DesignItem::getDesignUrl));
// return CopyUtil.copyList(userLikes,UserLikeVO.class,(o,d) ->{
// d.setUrl(idToUrlMap.get(o.getDesignItemId()));
// });
} }
@Override @Override
@@ -72,11 +60,11 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
} }
@Override @Override
public UserLike getByDesignItemId(Long designItemId){ public UserLike getByDesignItemId(Long designItemId) {
QueryWrapper<UserLike> qw = new QueryWrapper<>(); QueryWrapper<UserLike> qw = new QueryWrapper<>();
qw.eq("design_item_id",designItemId); qw.eq("design_item_id", designItemId);
List<UserLike> userLikes = baseMapper.selectList(qw); List<UserLike> userLikes = baseMapper.selectList(qw);
if (!userLikes.isEmpty()){ if (!userLikes.isEmpty()) {
return baseMapper.selectList(qw).get(0); return baseMapper.selectList(qw).get(0);
} }
return null; return null;
@@ -84,13 +72,13 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateDate(Long designItemId,String timeZone){ public void updateDate(Long designItemId, String timeZone) {
UpdateWrapper<UserLike> uw = new UpdateWrapper<>(); UpdateWrapper<UserLike> uw = new UpdateWrapper<>();
uw.eq("design_item_id",designItemId); uw.eq("design_item_id", designItemId);
uw.set("update_date",DateUtil.getByTimeZone(timeZone)); uw.set("update_date", DateUtil.getByTimeZone(timeZone));
uw.set("converted", 1); uw.set("converted", 1);
baseMapper.update(null,uw); baseMapper.update(null, uw);
} }
@Override @Override
@@ -123,12 +111,12 @@ public class UserLikeServiceImpl extends ServiceImpl<UserLikeMapper, UserLike> i
} }
@Override @Override
public UserLike getByDesignOutfitId(Long designOutfitId){ public UserLike getByDesignOutfitId(Long designOutfitId) {
QueryWrapper<UserLike> qw = new QueryWrapper<>(); QueryWrapper<UserLike> qw = new QueryWrapper<>();
qw.lambda().eq(UserLike::getDesignOutfitId, designOutfitId); qw.lambda().eq(UserLike::getDesignOutfitId, designOutfitId);
// 有脏数据 // 有脏数据
List<UserLike> userLikes = baseMapper.selectList(qw); List<UserLike> userLikes = baseMapper.selectList(qw);
if (!userLikes.isEmpty()){ if (!userLikes.isEmpty()) {
return userLikes.get(0); return userLikes.get(0);
} }
return null; return null;

View File

@@ -10,6 +10,8 @@ import com.ai.da.common.response.ResultEnum;
import com.ai.da.common.utils.*; import com.ai.da.common.utils.*;
import com.ai.da.mapper.primary.*; import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*; import com.ai.da.mapper.primary.entity.*;
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
import com.ai.da.mapper.secondary.entity.AttributeRetrieval;
import com.ai.da.model.dto.ProjectDTO; import com.ai.da.model.dto.ProjectDTO;
import com.ai.da.model.dto.WorkspaceDTO; import com.ai.da.model.dto.WorkspaceDTO;
import com.ai.da.model.dto.WorkspaceSaveDTO; import com.ai.da.model.dto.WorkspaceSaveDTO;
@@ -26,6 +28,7 @@ import io.netty.util.internal.StringUtil;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -37,6 +40,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.*; import java.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -610,9 +614,138 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
} }
} }
@Autowired
private AttributeRetrievalMapper attributeRetrievalMapper;
@Override @Override
@Transactional
public void maleDataInsert() throws FileNotFoundException { public void maleDataInsert() throws FileNotFoundException {
String directoryPath = "C:\\workspace\\fileData\\aida_men_library"; String directoryPath = "C:\\Users\\39093\\Desktop\\generated_sketch_gemini_updated_regendered\\unisex\\Post_apocalyptic";
List<File> pngFiles = getPNGFiles(directoryPath);
for (File pngFile : pngFiles) {
String category = Paths.get(directoryPath).getFileName().toString();
String fileName = category + "_2_" + pngFile.getName();
String tableName = null;
SysFile sysFile = new SysFile();
sysFile.setName(fileName);
sysFile.setLevel1Type("Images");
AttributeRetrieval attributeRetrievalAttrDict = new AttributeRetrieval();
attributeRetrievalAttrDict.setStyle("POST_APOCALYPTIC");
String absolutePath = pngFile.getAbsolutePath();
StringBuilder sb = new StringBuilder();
sb.append("aida-sys-image/images");
if (absolutePath.contains("Coat_Jacket") || absolutePath.contains("coat_jacket")) {
if (absolutePath.contains("\\male")) {
tableName = "male_outwear";
sb.append("/male/outwear/");
sysFile.setLevel3Type("Male");
} else if (absolutePath.contains("\\female")) {
tableName = "female_outwear";
sb.append("/female/outwear/");
sysFile.setLevel3Type("Female");
} else if (absolutePath.contains("\\unisex")) {
tableName = "female_outwear";
sb.append("/female/outwear/");
sysFile.setLevel3Type("Female");
}
sysFile.setLevel2Type("Outwear");
attributeRetrievalAttrDict.setImgName("outwear/" + fileName);
}
if (absolutePath.contains("Pants") || absolutePath.contains("pants")) {
if (absolutePath.contains("\\male")) {
tableName = "male_bottoms";
sb.append("/male/bottoms/");
sysFile.setLevel3Type("Male");
} else if (absolutePath.contains("\\female")) {
tableName = "female_trousers";
sb.append("/female/trousers/");
sysFile.setLevel3Type("Female");
} else if (absolutePath.contains("\\unisex")) {
tableName = "female_trousers";
sb.append("/female/trousers/");
sysFile.setLevel3Type("Female");
}
sysFile.setLevel2Type("Trousers");
attributeRetrievalAttrDict.setImgName("trousers/" + fileName);
}
if (absolutePath.contains("Top_Shirt") || absolutePath.contains("top_shirt")) {
if (absolutePath.contains("\\male")) {
tableName = "male_tops";
sb.append("/male/tops/");
sysFile.setLevel3Type("Male");
} else if (absolutePath.contains("\\female")) {
tableName = "female_blouse";
sb.append("/female/blouse/");
sysFile.setLevel3Type("Female");
} else if (absolutePath.contains("\\unisex")) {
tableName = "female_blouse";
sb.append("/female/blouse/");
sysFile.setLevel3Type("Female");
}
sysFile.setLevel2Type("Blouse");
attributeRetrievalAttrDict.setImgName("blouse/" + fileName);
}
if (absolutePath.contains("Dress") || absolutePath.contains("dress")) {
tableName = "female_dress";
sb.append("/female/dress/");
sysFile.setLevel2Type("Dress");
sysFile.setLevel3Type("Female");
attributeRetrievalAttrDict.setImgName("dress/" + fileName);
}
if (absolutePath.contains("skirt") || absolutePath.contains("Skirt")) {
tableName = "female_skirt";
sb.append("/female/skirt/");
sysFile.setLevel2Type("Skirt");
sysFile.setLevel3Type("Female");
attributeRetrievalAttrDict.setImgName("skirt/" + fileName);
}
sb.append(fileName);
String url = sb.toString();
sysFile.setUrl(url);
sysFile.setMd5(MD5Utils.encryptFile(new FileInputStream(pngFile)));
attributeRetrievalMapper.insertSketch(attributeRetrievalAttrDict, tableName);
sysFile.setCreateDate(new Date());
sysFile.setId(null);
sysFileMapper.insert(sysFile);
FileItem a = getMultipartFile(pngFile, fileName);
MultipartFile multipartFile = new CommonsMultipartFile(a);
minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, "");
System.out.println("上传成功url:" + url);
if (absolutePath.contains("unisex")) {
if (tableName.equals("female_outwear")) {
tableName = "male_outwear";
url = url.replace("/female/outwear/", "/male/outwear/");
} else if (tableName.equals("female_blouse")) {
tableName = "male_tops";
attributeRetrievalAttrDict.setImgName("tops/" + fileName);
sysFile.setLevel2Type("Tops");
url = url.replace("/female/blouse/", "/male/tops/");
} else if (tableName.equals("female_trousers")) {
tableName = "male_bottoms";
attributeRetrievalAttrDict.setImgName("bottoms/" + fileName);
sysFile.setLevel2Type("Bottoms");
url = url.replace("/female/trousers/", "/male/bottoms/");
}
minioUtil.upload(url.substring(0, 14), url.substring(15), multipartFile, "");
sysFile.setLevel3Type("Male");
sysFile.setId(null);
sysFile.setUrl(url);
sysFileMapper.insert(sysFile);
attributeRetrievalMapper.insertSketch(attributeRetrievalAttrDict, tableName);
System.out.println("上传成功url:" + url);
}
}
System.out.println("结束");
}
//上传衣服
public void maleDataInsert1() throws FileNotFoundException {
String directoryPath = "C:\\Users\\39093\\Desktop\\generated_sketch_gemini_updated_regendered";
List<File> pngFiles = getPNGFiles(directoryPath); List<File> pngFiles = getPNGFiles(directoryPath);
for (File pngFile : pngFiles) { for (File pngFile : pngFiles) {
SysFile sysFile = new SysFile(); SysFile sysFile = new SysFile();
@@ -731,7 +864,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId) LambdaQueryWrapper<CollectionElement> queryWrapper = new LambdaQueryWrapper<CollectionElement>().eq(CollectionElement::getProjectId, projectId)
.eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName()) .eq(CollectionElement::getLevel1Type, CollectionLevel1TypeEnum.MODEL.getRealName())
.eq(CollectionElement::getLevel3Type, workspaceNew.getSex()); .eq(CollectionElement::getLevel3Type, workspaceNew.getSex());
if (collectionElementMapper.selectCount(queryWrapper) == 0){ if (collectionElementMapper.selectCount(queryWrapper) == 0) {
CollectionElement collectionElement = new CollectionElement(); CollectionElement collectionElement = new CollectionElement();
collectionElement.setAccountId(userInfo.getId()); collectionElement.setAccountId(userInfo.getId());
collectionElement.setProjectId(projectId); collectionElement.setProjectId(projectId);
@@ -792,7 +925,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
Project project = CopyUtil.copyObject(projectDTO, Project.class); Project project = CopyUtil.copyObject(projectDTO, Project.class);
project.setAccountId(userInfo.getId()); project.setAccountId(userInfo.getId());
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
if (StringUtil.isNullOrEmpty(project.getName())){ if (StringUtil.isNullOrEmpty(project.getName())) {
Long seq = redisUtil.increaseCount(UNNAMED_PROJECT_SEQ + userInfo.getId()); Long seq = redisUtil.increaseCount(UNNAMED_PROJECT_SEQ + userInfo.getId());
project.setName("Untitled_" + seq); project.setName("Untitled_" + seq);
} }
@@ -898,6 +1031,11 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return null; return null;
} }
@Override
public String getStyleByProjectId(Long projectId) {
return workspaceMapper.getStyleByProjectId(projectId);
}
// 由于在数据库中表设计问题,目前只能通过路径来判断项目中是否存在某一个模特 // 由于在数据库中表设计问题,目前只能通过路径来判断项目中是否存在某一个模特
public Boolean checkIfModelExistsInProject(String md5, Long projectId) { public Boolean checkIfModelExistsInProject(String md5, Long projectId) {
QueryWrapper<CollectionElement> qw = new QueryWrapper<>(); QueryWrapper<CollectionElement> qw = new QueryWrapper<>();
@@ -974,4 +1112,32 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
return kvs; return kvs;
} }
@Override
public String getAgeGroupByProjectOrCollectionId(Long projectId, Long collectionId) {
if (Objects.nonNull(projectId)) {
Workspace workspace = getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())) {
return workspace.getAgeGroup();
}
} else if (Objects.nonNull(collectionId) && collectionId != 0) {
List<CollectionElement> byCollectionId = getByCollectionId(collectionId);
if (byCollectionId != null && !byCollectionId.isEmpty()) {
projectId = byCollectionId.get(0).getProjectId();
if (projectId != null && projectId != 0L) {
Workspace workspace = getWSByProjectId(projectId);
if (workspace != null && !StringUtil.isNullOrEmpty(workspace.getAgeGroup())) {
return workspace.getAgeGroup();
}
}
}
}
return AgeGroup.ADULT.getValue();
}
private List<CollectionElement> getByCollectionId(Long collectionId) {
QueryWrapper<CollectionElement> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(CollectionElement::getCollectionId, collectionId);
return collectionElementMapper.selectList(queryWrapper);
}
} }

View File

@@ -8,7 +8,7 @@ spring.datasource.primary.username=aida_con
spring.datasource.primary.password=123456 spring.datasource.primary.password=123456
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_new_style?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_style?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.secondary.username=aida_con spring.datasource.secondary.username=aida_con
spring.datasource.secondary.password=123456 spring.datasource.secondary.password=123456

View File

@@ -7,7 +7,7 @@ spring.datasource.primary.username=root
spring.datasource.primary.password=QWa998345 spring.datasource.primary.password=QWa998345
spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.secondary.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_new_style?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.datasource.secondary.jdbcUrl=jdbc:mysql://18.167.251.121:33008/attribute_retrieval_style?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
spring.datasource.secondary.username=aida_con spring.datasource.secondary.username=aida_con
spring.datasource.secondary.password=123456 spring.datasource.secondary.password=123456

View File

@@ -2,7 +2,7 @@
#spring.profiles.active=test #spring.profiles.active=test
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) #<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
spring.profiles.active=prod #spring.profiles.active=prod
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) #<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
#spring.profiles.active=dev spring.profiles.active=dev

View File

@@ -27,5 +27,10 @@
<select id="selectWorkspacePage" resultMap="BaseResultMap"> <select id="selectWorkspacePage" resultMap="BaseResultMap">
select * from workspace where is_deleted = 0 select * from workspace where is_deleted = 0
</select> </select>
<select id="getStyleByProjectId" resultType="java.lang.String">
select name from style where id =
(select style_id from workspace_rel_style where workspace_id =
(select id from workspace where project_id = #{projectId}))
</select>
</mapper> </mapper>

View File

@@ -16,6 +16,10 @@
<result column="opening_type" property="openingType" /> <result column="opening_type" property="openingType" />
<result column="subtype" property="subtype" /> <result column="subtype" property="subtype" />
</resultMap> </resultMap>
<insert id="insertSketch">
INSERT INTO ${tableName} (img_name, style)
VALUES (#{attributeRetrievalAttrDict.imgName}, #{attributeRetrievalAttrDict.style})
</insert>
<select id="getSystemSketchPool" resultMap="BaseResultMap"> <select id="getSystemSketchPool" resultMap="BaseResultMap">
SELECT SELECT
@@ -110,4 +114,21 @@
${tableName} ${tableName}
WHERE img_name = #{replace} WHERE img_name = #{replace}
</select> </select>
<select id="getCountByStyle" resultType="java.lang.Integer">
SELECT
count(*)
FROM
${tableName}
WHERE style = #{style} and deprecated = 0
</select>
<select id="getOneSystemSketchRadom" resultType="java.lang.String">
SELECT
img_name
FROM
${tableName}
WHERE style = #{style}
and deprecated = 0
ORDER BY ID LIMIT #{randomNum},1
</select>
</mapper> </mapper>

View File

@@ -186,6 +186,9 @@ order.creation.failed=Order creation failed.
order.deduction.failed=Order deduction failed. order.deduction.failed=Order deduction failed.
order.query.failed=Order query failed. order.query.failed=Order query failed.
do.not.have.the.permission.to.delete.this.comment=You do not have the permission to delete this comment. do.not.have.the.permission.to.delete.this.comment=You do not have the permission to delete this comment.
unknow.affiliate=Unknown affiliate id.
unknown.operationType=Unknown operationType.
unknown.mode=unknown mode
# 可能会报异常 # 可能会报异常
# Informative: # Informative:
@@ -231,6 +234,7 @@ OVERALL=Overall
TOPS=Tops TOPS=Tops
BOTTOMS=Bottoms BOTTOMS=Bottoms
OUTWEAR=Outwear OUTWEAR=Outwear
OTHERS=Others
BLOUSE=Blouse BLOUSE=Blouse
DRESS=Dress DRESS=Dress
TROUSERS=Trousers TROUSERS=Trousers

View File

@@ -171,6 +171,7 @@ OVERALL=Général
TOPS=Hauts TOPS=Hauts
BOTTOMS=Bas BOTTOMS=Bas
OUTWEAR=Manteau OUTWEAR=Manteau
OTHERS=Autres
BLOUSE=Chemisier BLOUSE=Chemisier
DRESS=Robe DRESS=Robe
TROUSERS=Pantalons TROUSERS=Pantalons

View File

@@ -171,6 +171,7 @@ OVERALL=Complessivo
TOPS=Parte superiore TOPS=Parte superiore
BOTTOMS=Parte inferiore BOTTOMS=Parte inferiore
OUTWEAR=Capo esterno OUTWEAR=Capo esterno
OTHERS=Altri
BLOUSE=Camicetta BLOUSE=Camicetta
DRESS=Vestito DRESS=Vestito
TROUSERS=Pantaloni TROUSERS=Pantaloni

View File

@@ -171,6 +171,7 @@ OVERALL=全体
TOPS=トップス TOPS=トップス
BOTTOMS=ボトムス BOTTOMS=ボトムス
OUTWEAR=アウターウェア OUTWEAR=アウターウェア
OTHERS=その他
BLOUSE=ブラウス BLOUSE=ブラウス
DRESS=ドレス DRESS=ドレス
TROUSERS=ズボン TROUSERS=ズボン

View File

@@ -171,6 +171,7 @@ OVERALL=전체
TOPS=상의 TOPS=상의
BOTTOMS=하의 BOTTOMS=하의
OUTWEAR=외투 OUTWEAR=외투
OTHERS=기타
BLOUSE=블라우스 BLOUSE=블라우스
DRESS=드레스 DRESS=드레스
TROUSERS=바지 TROUSERS=바지

View File

@@ -171,6 +171,7 @@ OVERALL=Общий
TOPS=Топы TOPS=Топы
BOTTOMS=Штаны BOTTOMS=Штаны
OUTWEAR=Верхняя одежда OUTWEAR=Верхняя одежда
OTHERS=ДРУГИЕ
BLOUSE=Блуза BLOUSE=Блуза
DRESS=Платье DRESS=Платье
TROUSERS=Брюки TROUSERS=Брюки

View File

@@ -171,6 +171,7 @@ OVERALL=โดยรวม
TOPS=เสื้อ TOPS=เสื้อ
BOTTOMS=กางเกง BOTTOMS=กางเกง
OUTWEAR=เสื้อผ้านอก OUTWEAR=เสื้อผ้านอก
OTHERS=อื่นๆ
BLOUSE=เสื้อผ้าผู้หญิง BLOUSE=เสื้อผ้าผู้หญิง
DRESS=ชุดเดรส DRESS=ชุดเดรส
TROUSERS=กางเกงขายาว TROUSERS=กางเกงขายาว

View File

@@ -171,6 +171,7 @@ OVERALL=Tổng thể
TOPS=Áo đầu TOPS=Áo đầu
BOTTOMS=Quần BOTTOMS=Quần
OUTWEAR=Áo ngoại cỡ OUTWEAR=Áo ngoại cỡ
OTHERS=KHÁC
BLOUSE=Áo sơ mi nữ BLOUSE=Áo sơ mi nữ
DRESS=Váy DRESS=Váy
TROUSERS=Quần dài TROUSERS=Quần dài

View File

@@ -182,6 +182,9 @@ order.creation.failed=订单创建失败
order.deduction.failed=订单金额扣除失败。 order.deduction.failed=订单金额扣除失败。
order.query.failed=订单查询失败 order.query.failed=订单查询失败
do.not.have.the.permission.to.delete.this.comment=您没有权限删除此评论 do.not.have.the.permission.to.delete.this.comment=您没有权限删除此评论
unknow.affiliate=未知推广者id
unknown.operationType=未知操作类型
unknown.mode=未知模式
# 可能会报异常 # 可能会报异常
# Informative: # Informative:
@@ -225,6 +228,7 @@ OVERALL=整体
TOPS=上装 TOPS=上装
BOTTOMS=下装 BOTTOMS=下装
OUTWEAR=外套 OUTWEAR=外套
OTHERS=其他
BLOUSE=上衣 BLOUSE=上衣
DRESS=连衣裙 DRESS=连衣裙
TROUSERS=裤子 TROUSERS=裤子

View File

@@ -27,9 +27,9 @@ paypal.webhook_id=1D107312EX592781K
##### Stripe ##### Stripe
# developer # developer
#stripe.private-key=sk_test_51P4ZZL02n1TEydyN8qQHjOA9imsFU7Oxs2HMHGy2urHnnQgSHnZuu5vVP6pKhEACwUpsKNyrbZpdcg5TJWJLRHcY008dEO1fn2 stripe.private-key=sk_test_51P4ZZL02n1TEydyN8qQHjOA9imsFU7Oxs2HMHGy2urHnnQgSHnZuu5vVP6pKhEACwUpsKNyrbZpdcg5TJWJLRHcY008dEO1fn2
# dev 端点 # dev 端点
#stripe.webhook-sign-secret=whsec_e0dBiJngx6qqgJj6yPyJ2A9ouh1Cjv5w stripe.webhook-sign-secret=whsec_e0dBiJngx6qqgJj6yPyJ2A9ouh1Cjv5w
# local 端点 # local 端点
#stripe.webhook-sign-secret=whsec_TJcMSnAkh4uktrNY1M6Iy8XaVze4Rzqm #stripe.webhook-sign-secret=whsec_TJcMSnAkh4uktrNY1M6Iy8XaVze4Rzqm
@@ -43,8 +43,8 @@ paypal.webhook_id=1D107312EX592781K
#stripe.webhook-sign-secret=whsec_pX0pPMQm85PaUSWnFMEzoccb3MGNkjoL #stripe.webhook-sign-secret=whsec_pX0pPMQm85PaUSWnFMEzoccb3MGNkjoL
# kim - live # kim - live
stripe.private-key=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 #stripe.private-key=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
# prod 端点 # prod 端点
stripe.webhook-sign-secret=whsec_hhGDgdelQRHSg4LmChtQe41crj41eb11 #stripe.webhook-sign-secret=whsec_hhGDgdelQRHSg4LmChtQe41crj41eb11
# dev 端点 # dev 端点
#stripe.webhook-sign-secret=whsec_cFUtjUOo8wnrIKZmt4GNvt7ZY1bOfrYr #stripe.webhook-sign-secret=whsec_cFUtjUOo8wnrIKZmt4GNvt7ZY1bOfrYr