TASK: cloud、posetransfer、sort;

This commit is contained in:
shahaibo
2025-06-16 16:53:50 +08:00
parent 76219aa4fe
commit 8b0f9cfd11
8 changed files with 55 additions and 32 deletions

View File

@@ -114,8 +114,8 @@ public class GenerateController {
@ApiOperation("喜欢或取消喜欢姿势变换生成的图片") @ApiOperation("喜欢或取消喜欢姿势变换生成的图片")
@PostMapping("/likeOrDislike") @PostMapping("/likeOrDislike")
public Response<Object> likeOrDislike(@ApiParam("id") @RequestParam Long transformedId, @ApiParam("like || dislike") @RequestParam String likeOrDislike, @RequestParam("projectId") Long projectId) { public Response<Object> 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)); return Response.success(generateService.disOrLikePose(transformedId, likeOrDislike, projectId, sortLikeParentId));
} }
@ApiOperation(value = "修改模特比例") @ApiOperation(value = "修改模特比例")

View File

@@ -25,5 +25,5 @@ public class CollectionSort implements Serializable {
private Long relationId; private Long relationId;
private String relationType; private String relationType;
// private Long parentId; private Long parentId;
} }

View File

@@ -8,4 +8,6 @@ import java.util.List;
public class ProductImageLikeDTO { public class ProductImageLikeDTO {
private List<Long> toProductImageResultId; private List<Long> toProductImageResultId;
private Long projectId; private Long projectId;
private Long sortLikeParentId;
} }

View File

@@ -61,9 +61,9 @@ public interface DesignService extends IService<Design> {
*/ */
DesignLikeVO like(DesignLikeDTO designLikeDTO); 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 * dislike
@@ -73,7 +73,7 @@ public interface DesignService extends IService<Design> {
*/ */
Boolean dislike(DisDesignLikeDTO disDesignLikeDTO); 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); CollectionSort getUserLikeSortByUserLikeId(Long userLikeId, String relationType, Long projectId);

View File

@@ -57,7 +57,7 @@ public interface GenerateService extends IService<Generate> {
List<PoseTransformationVO> getPoseTransformationResultList(Long projectId, boolean like); List<PoseTransformationVO> 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); String modifyModelProportion(ModifyModelProportionDTO proportionDTO);

View File

@@ -35,6 +35,7 @@ import com.google.common.collect.Lists;
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.catalina.User;
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;
@@ -1209,7 +1210,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
userLikeService.save(userLike); userLikeService.save(userLike);
Long userLikeSortId; 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(); userLikeSortId = userLikeSort.getId();
groupDetailId = userLike.getId(); groupDetailId = userLike.getId();
String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl(); String designUrl = designPythonOutfitMapper.selectById(userLike.getDesignOutfitId()).getDesignUrl();
@@ -1246,8 +1247,8 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
} }
@Override @Override
public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId) { public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long sortParentId) {
int sort = getNextSort(projectId); int sort = getNextSort(projectId, sortParentId);
CollectionSort userLikeSort = new CollectionSort(); CollectionSort userLikeSort = new CollectionSort();
// userLikeSort.setUserLikeGroupId(userGroupId); // userLikeSort.setUserLikeGroupId(userGroupId);
// userLikeSort.setUserLikeId(relationId); // userLikeSort.setUserLikeId(relationId);
@@ -1255,14 +1256,20 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
userLikeSort.setRelationId(relationId); userLikeSort.setRelationId(relationId);
userLikeSort.setRelationType(relationType); userLikeSort.setRelationType(relationType);
userLikeSort.setSort(sort); userLikeSort.setSort(sort);
if (null != sortParentId) {
userLikeSort.setParentId(sortParentId);
}
collectionSortMapper.insert(userLikeSort); collectionSortMapper.insert(userLikeSort);
return userLikeSort; return userLikeSort;
} }
@Override @Override
public int getNextSort(Long projectId) { public int getNextSort(Long projectId, Long parentId) {
QueryWrapper<CollectionSort> qw = new QueryWrapper<>(); QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getProjectId, projectId); qw.lambda().eq(CollectionSort::getProjectId, projectId);
if (null != parentId) {
qw.lambda().eq(CollectionSort::getParentId, parentId);
}
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw); List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
if (CollectionUtils.isEmpty(userLikeSorts)) { if (CollectionUtils.isEmpty(userLikeSorts)) {
return 1; return 1;
@@ -1348,16 +1355,19 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
// userLikeGroupService.removeById(userLike.getUserLikeGroupId()); // userLikeGroupService.removeById(userLike.getUserLikeGroupId());
} }
deleteCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), disDesignLikeDTO.getProjectId()); deleteCollectionSort(userLike.getId(), CollectionType.DESIGN.getValue(), disDesignLikeDTO.getProjectId(), null);
//删除对应的history //删除对应的history
userLikeService.removeById(disDesignLikeDTO.getGroupDetailId()); userLikeService.removeById(disDesignLikeDTO.getGroupDetailId());
return Boolean.TRUE; return Boolean.TRUE;
} }
@Override @Override
public void deleteCollectionSort(Long relationId, String relationType, Long projectId) { public void deleteCollectionSort(Long relationId, String relationType, Long projectId, Long parentId) {
QueryWrapper<CollectionSort> qw = new QueryWrapper<>(); QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getProjectId, projectId); qw.lambda().eq(CollectionSort::getProjectId, projectId);
if (null != parentId) {
qw.lambda().eq(CollectionSort::getParentId, parentId);
}
qw.lambda().orderByDesc(CollectionSort::getSort); qw.lambda().orderByDesc(CollectionSort::getSort);
List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw); List<CollectionSort> userLikeSorts = collectionSortMapper.selectList(qw);
CollectionSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId); CollectionSort userLikeSort = getUserLikeSortByUserLikeId(relationId, relationType, projectId);
@@ -1858,11 +1868,11 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override @Override
public String designCloud(CloudTaskDTO cloudTaskDTO) { public String designCloud(CloudTaskDTO cloudTaskDTO) {
AuthPrincipalVo userInfo = UserContext.getUserHolder();
if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) { if (cloudTaskDTO.getBuildType().equals(BuildType.DESIGN.getValue())) {
Long projectId = cloudTaskDTO.getProjectId(); Long projectId = cloudTaskDTO.getProjectId();
DesignCollectionDTO designDTO = transDesignParam(projectId); DesignCollectionDTO designDTO = transDesignParam(projectId);
designDTO.setDesignNum(cloudTaskDTO.getNums()); designDTO.setDesignNum(cloudTaskDTO.getNums());
AuthPrincipalVo userInfo = UserContext.getUserHolder();
//校验collection element //校验collection element
ValidateElementVO elementVO = collectionElementService.validateElement(designDTO); ValidateElementVO elementVO = collectionElementService.validateElement(designDTO);
@@ -2046,6 +2056,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
cloudTask.setCreateTime(now); cloudTask.setCreateTime(now);
cloudTask.setUpdateTime(now); cloudTask.setUpdateTime(now);
cloudTask.setStatus(0); cloudTask.setStatus(0);
cloudTask.setAccountId(userInfo.getId());
cloudTaskMapper.insert(cloudTask); cloudTaskMapper.insert(cloudTask);
return batchTaskId; return batchTaskId;
}else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) { }else if (cloudTaskDTO.getBuildType().equals(BuildType.RELIGHT.getValue())) {

View File

@@ -1225,36 +1225,46 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
List<PoseTransformationVO> vos = new ArrayList<>(); List<PoseTransformationVO> vos = new ArrayList<>();
if (poseTransformations != null && poseTransformations.size() > 1){ if (poseTransformations != null && poseTransformations.size() > 1){
poseTransformations.forEach(item -> { poseTransformations.forEach(item -> {
PoseTransformationVO poseTransformationVO = new PoseTransformationVO(); String taskId = item.getUniqueId();
if (StringUtils.isNotBlank(item.getVideoUrl())) { 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.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.setIsLiked(item.getIsLiked());
poseTransformationVO.setStatus("Success"); if (poseTransformationVO.getStatus().equals("Success")) {
}else { poseTransformationVO.setProductImage(minioUtil.getPreSignedUrl(item.getProductImage(), CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
poseTransformationVO.setTaskId(item.getUniqueId()); if (!poseTransformationVO.getGifUrl().equals("None")) {
poseTransformationVO.setStatus("Invalid"); 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; 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); PoseTransformation poseTransformation = poseTransformationMapper.selectById(transformedId);
Long collectionSortId = null; Long collectionSortId = null;
if (Objects.nonNull(poseTransformation)){ if (Objects.nonNull(poseTransformation)){
if (likeOrDislike.equals("like")){ if (likeOrDislike.equals("like")){
poseTransformation.setIsLiked((byte)1); 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(); collectionSortId = collectionSort.getId();
}else if (likeOrDislike.equals("dislike")){ }else if (likeOrDislike.equals("dislike")){
poseTransformation.setIsLiked((byte)0); 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()); poseTransformation.setUpdateTime(LocalDateTime.now());
poseTransformationMapper.updateById(poseTransformation); poseTransformationMapper.updateById(poseTransformation);

View File

@@ -611,10 +611,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultId.get(0)); ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultId.get(0));
Long collectionSortId = null; Long collectionSortId = null;
if (toProductImageResult1.getResultType().equals("Relight")) { if (toProductImageResult1.getResultType().equals("Relight")) {
CollectionSort collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId()); CollectionSort collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getSortLikeParentId());
collectionSortId = collectionSort.getId(); collectionSortId = collectionSort.getId();
}else { }else {
CollectionSort collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), productImageLikeDTO.getProjectId()); CollectionSort collectionSort = designService.addCollectionSort(toProductImageResult1.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getSortLikeParentId());
collectionSortId = collectionSort.getId(); collectionSortId = collectionSort.getId();
} }
return collectionSortId; return collectionSortId;
@@ -853,9 +853,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setIsLike(0); toProductImageResult.setIsLike(0);
toProductImageResultMapper.updateById(toProductImageResult); toProductImageResultMapper.updateById(toProductImageResult);
if (toProductImageResult.getResultType().equals("Relight")) { if (toProductImageResult.getResultType().equals("Relight")) {
designService.deleteCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId()); designService.deleteCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getSortLikeParentId());
}else { }else {
designService.deleteCollectionSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), productImageLikeDTO.getProjectId()); designService.deleteCollectionSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getSortLikeParentId());
} }
} }
return Boolean.TRUE; return Boolean.TRUE;