diff --git a/src/main/java/com/ai/da/controller/GenerateController.java b/src/main/java/com/ai/da/controller/GenerateController.java index e48a39b5..13b61bd3 100644 --- a/src/main/java/com/ai/da/controller/GenerateController.java +++ b/src/main/java/com/ai/da/controller/GenerateController.java @@ -114,8 +114,8 @@ public class GenerateController { @ApiOperation("喜欢或取消喜欢姿势变换生成的图片") @PostMapping("/likeOrDislike") - public Response likeOrDislike(@ApiParam("id") @RequestParam Long transformedId, @ApiParam("like || dislike") @RequestParam String likeOrDislike, @RequestParam("projectId") Long projectId) { - return Response.success(generateService.disOrLikePose(transformedId, likeOrDislike, projectId)); + public Response likeOrDislike(@ApiParam("id") @RequestParam Long transformedId, @ApiParam("like || dislike") @RequestParam String likeOrDislike, @RequestParam("projectId") Long projectId, @RequestParam("sortLikeParentId") Long sortLikeParentId) { + return Response.success(generateService.disOrLikePose(transformedId, likeOrDislike, projectId, sortLikeParentId)); } @ApiOperation(value = "修改模特比例") diff --git a/src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java b/src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java index fa55bcab..37f7eac9 100644 --- a/src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java +++ b/src/main/java/com/ai/da/mapper/primary/entity/CollectionSort.java @@ -25,5 +25,5 @@ public class CollectionSort implements Serializable { private Long relationId; private String relationType; -// private Long parentId; + private Long parentId; } \ No newline at end of file diff --git a/src/main/java/com/ai/da/model/dto/ProductImageLikeDTO.java b/src/main/java/com/ai/da/model/dto/ProductImageLikeDTO.java index eb6768b6..0cd96fd1 100644 --- a/src/main/java/com/ai/da/model/dto/ProductImageLikeDTO.java +++ b/src/main/java/com/ai/da/model/dto/ProductImageLikeDTO.java @@ -8,4 +8,6 @@ import java.util.List; public class ProductImageLikeDTO { private List toProductImageResultId; private Long projectId; + + private Long sortLikeParentId; } diff --git a/src/main/java/com/ai/da/service/DesignService.java b/src/main/java/com/ai/da/service/DesignService.java index c6a9a892..0c9c3957 100644 --- a/src/main/java/com/ai/da/service/DesignService.java +++ b/src/main/java/com/ai/da/service/DesignService.java @@ -61,9 +61,9 @@ public interface DesignService extends IService { */ DesignLikeVO like(DesignLikeDTO designLikeDTO); - CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId); + CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long parentId); - int getNextSort(Long projectId); + int getNextSort(Long projectId, Long parentId); /** * dislike @@ -73,7 +73,7 @@ public interface DesignService extends IService { */ Boolean dislike(DisDesignLikeDTO disDesignLikeDTO); - void deleteCollectionSort(Long relationId, String relationType, Long projectId); + void deleteCollectionSort(Long relationId, String relationType, Long projectId, Long parentId); CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId); diff --git a/src/main/java/com/ai/da/service/GenerateService.java b/src/main/java/com/ai/da/service/GenerateService.java index 77217507..f95dd2a5 100644 --- a/src/main/java/com/ai/da/service/GenerateService.java +++ b/src/main/java/com/ai/da/service/GenerateService.java @@ -57,7 +57,7 @@ public interface GenerateService extends IService { List getPoseTransformationResultList(Long projectId, boolean like); - Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId); + Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId, Long sortLikeParentId); String modifyModelProportion(ModifyModelProportionDTO proportionDTO); diff --git a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java index bd74a207..789ec55c 100644 --- a/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/DesignServiceImpl.java @@ -35,6 +35,7 @@ import com.google.common.collect.Lists; import io.netty.util.internal.StringUtil; import lombok.extern.slf4j.Slf4j; import okhttp3.*; +import org.apache.catalina.User; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -1209,7 +1210,7 @@ public class DesignServiceImpl extends ServiceImpl impleme } userLikeService.save(userLike); Long userLikeSortId; - CollectionSort userLikeSort = addCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), designLikeDTO.getProjectId()); + CollectionSort userLikeSort = addCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), designLikeDTO.getProjectId(), null); userLikeSortId = userLikeSort.getId(); groupDetailId = userLike.getId(); String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl(); @@ -1246,8 +1247,8 @@ public class DesignServiceImpl extends ServiceImpl impleme } @Override - public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId) { - int sort = getNextSort(projectId); + public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long sortParentId) { + int sort = getNextSort(projectId, sortParentId); CollectionSort userLikeSort = new CollectionSort(); // userLikeSort.setUserLikeGroupId(userGroupId); // userLikeSort.setUserLikeId(relationId); @@ -1255,14 +1256,20 @@ public class DesignServiceImpl extends ServiceImpl impleme userLikeSort.setRelationId(relationId); userLikeSort.setRelationType(relationType); userLikeSort.setSort(sort); + if (null != sortParentId) { + userLikeSort.setParentId(sortParentId); + } collectionSortMapper.insert(userLikeSort); return userLikeSort; } @Override - public int getNextSort(Long projectId) { + public int getNextSort(Long projectId, Long parentId) { QueryWrapper qw = new QueryWrapper<>(); qw.lambda().eq(CollectionSort::getProjectId, projectId); + if (null != parentId) { + qw.lambda().eq(CollectionSort::getParentId, parentId); + } List userLikeSorts = collectionSortMapper.selectList(qw); if (CollectionUtils.isEmpty(userLikeSorts)) { return 1; @@ -1348,16 +1355,19 @@ public class DesignServiceImpl extends ServiceImpl impleme // userLikeGroupService.removeById(userLike.getUserLikeGroupId()); } - deleteCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), disDesignLikeDTO.getProjectId()); + deleteCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), disDesignLikeDTO.getProjectId(), null); //删除对应的history userLikeService.removeById(disDesignLikeDTO.getGroupDetailId()); return Boolean.TRUE; } @Override - public void deleteCollectionSort(Long relationId, String relationType, Long projectId) { + public void deleteCollectionSort(Long relationId, String relationType, Long projectId, Long parentId) { QueryWrapper qw = new QueryWrapper<>(); qw.lambda().eq(CollectionSort::getProjectId, projectId); + if (null != parentId) { + qw.lambda().eq(CollectionSort::getParentId, parentId); + } qw.lambda().orderByDesc(CollectionSort::getSort); List userLikeSorts = collectionSortMapper.selectList(qw); CollectionSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId); @@ -1858,11 +1868,11 @@ public class DesignServiceImpl extends ServiceImpl impleme @Override public String designCloud(CloudTaskDTO cloudTaskDTO) { + AuthPrincipalVo userInfo = UserContext.getUserHolder(); if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) { Long projectId = cloudTaskDTO.getProjectId(); DesignCollectionDTO designDTO = transDesignParam(projectId); designDTO.setDesignNum(cloudTaskDTO.getNums()); - AuthPrincipalVo userInfo = UserContext.getUserHolder(); //校验collection element ValidateElementVO elementVO = collectionElementService.validateElement(designDTO); @@ -2046,6 +2056,7 @@ public class DesignServiceImpl extends ServiceImpl impleme cloudTask.setCreateTime(now); cloudTask.setUpdateTime(now); cloudTask.setStatus(0); + cloudTask.setAccountId(userInfo.getId()); cloudTaskMapper.insert(cloudTask); return batchTaskId; }else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) { diff --git a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java index 5c56cf91..1b87d0ad 100644 --- a/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/GenerateServiceImpl.java @@ -1225,36 +1225,46 @@ public class GenerateServiceImpl extends ServiceImpl i List vos = new ArrayList<>(); if (poseTransformations != null && poseTransformations.size() > 1){ poseTransformations.forEach(item -> { - PoseTransformationVO poseTransformationVO = new PoseTransformationVO(); - if (StringUtils.isNotBlank(item.getVideoUrl())) { + String taskId = item.getUniqueId(); + String key = generateResultKey + ":" + taskId; + String resultJson = redisUtil.getFromString(key); + + if (!StringUtil.isNullOrEmpty(resultJson)) { + PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class); poseTransformationVO.setId(item.getId()); - poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); - poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(item.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); - poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(item.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); - poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(item.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); poseTransformationVO.setIsLiked(item.getIsLiked()); - poseTransformationVO.setStatus("Success"); - }else { - poseTransformationVO.setTaskId(item.getUniqueId()); - poseTransformationVO.setStatus("Invalid"); + if (poseTransformationVO.getStatus().equals("Success")) { + poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); + if (!poseTransformationVO.getGifUrl().equals("None")) { + poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getGifUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); + } + if (!poseTransformationVO.getVideoUrl().equals("None")) { + poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getVideoUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); + } + if (!poseTransformationVO.getFirstFrameUrl().equals("None")) { + poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(poseTransformationVO.getFirstFrameUrl(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME)); + } + } + if (!poseTransformationVO.getStatus().equals("Invalid") && !poseTransformationVO.getStatus().equals("Failed")) { + vos.add(poseTransformationVO); + } } - vos.add(poseTransformationVO); }); } return vos; } - public Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId){ + public Object disOrLikePose(Long transformedId, String likeOrDislike, Long projectId, Long sortLikeParentId){ PoseTransformation poseTransformation = poseTransformationMapper.selectById(transformedId); Long collectionSortId = null; if (Objects.nonNull(poseTransformation)){ if (likeOrDislike.equals("like")){ poseTransformation.setIsLiked((byte)1); - CollectionSort collectionSort = designService.addCollectionSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), projectId); + CollectionSort collectionSort = designService.addCollectionSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), projectId, sortLikeParentId); collectionSortId = collectionSort.getId(); }else if (likeOrDislike.equals("dislike")){ poseTransformation.setIsLiked((byte)0); - designService.deleteCollectionSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), projectId); + designService.deleteCollectionSort(poseTransformation.getId(), CollectionType.POSE_TRANSFORM.getValue(), projectId, sortLikeParentId); } poseTransformation.setUpdateTime(LocalDateTime.now()); poseTransformationMapper.updateById(poseTransformation); diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index bc038416..664ecd44 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -611,10 +611,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl