TASK:collection sort;

This commit is contained in:
shahaibo
2025-06-03 13:41:45 +08:00
parent 32c8aaec9b
commit 442e87267a
2 changed files with 8 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ import lombok.Data;
@Data
public class CollectionLikeUpdateDTO {
private Long userLikeSortId;
private Long oldRelationId;
private Long relationId;
private String relationType;
}

View File

@@ -2470,22 +2470,25 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
@Override
@Transactional
public Boolean collectionLikeUpdate(CollectionLikeUpdateDTO collectionLikeUpdateDTO) {
CollectionSort collectionSort = collectionSortMapper.selectById(collectionLikeUpdateDTO.getUserLikeSortId());
Long relationIdOld = collectionSort.getRelationId();
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getRelationId, collectionLikeUpdateDTO.getOldRelationId());
qw.lambda().eq(CollectionSort::getRelationType, collectionLikeUpdateDTO.getRelationType());
CollectionSort collectionSort = collectionSortMapper.selectOne(qw);
// Long relationIdOld = collectionSort.getRelationId();
collectionSort.setRelationId(collectionLikeUpdateDTO.getRelationId());
collectionSortMapper.updateById(collectionSort);
if (collectionLikeUpdateDTO.getRelationType().equals(CollectionType.TO_PRODUCT_IMAGE.getValue()) || collectionLikeUpdateDTO.getRelationType().equals(CollectionType.RELIGHT.getValue())) {
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(collectionLikeUpdateDTO.getRelationId());
toProductImageResult.setIsLike(1);
toProductImageResultMapper.updateById(toProductImageResult);
ToProductImageResult toProductImageResultOld = toProductImageResultMapper.selectById(relationIdOld);
ToProductImageResult toProductImageResultOld = toProductImageResultMapper.selectById(collectionLikeUpdateDTO.getOldRelationId());
toProductImageResultOld.setIsLike(0);
toProductImageResultMapper.updateById(toProductImageResultOld);
}else if (collectionLikeUpdateDTO.getRelationType().equals(CollectionType.POSE_TRANSFORM.getValue())) {
PoseTransformation poseTransformation = poseTransformationMapper.selectById(collectionLikeUpdateDTO.getRelationId());
poseTransformation.setIsLiked((byte) 1);
poseTransformationMapper.updateById(poseTransformation);
PoseTransformation poseTransformationOld = poseTransformationMapper.selectById(relationIdOld);
PoseTransformation poseTransformationOld = poseTransformationMapper.selectById(collectionLikeUpdateDTO.getOldRelationId());
poseTransformationOld.setIsLiked((byte) 0);
poseTransformationMapper.updateById(poseTransformationOld);
}