TASK: 默认不like的元素,如有parentId,需要添加到CollectionSort表中

This commit is contained in:
2025-07-08 14:29:54 +08:00
parent ec44c2a6b5
commit d379f778dc
3 changed files with 25 additions and 1 deletions

View File

@@ -63,6 +63,8 @@ public interface DesignService extends IService<Design> {
CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long parentId);
CollectionSort queryCollectionSortByRelation(Long relationId, String relationType, Long projectId);
int getNextSort(Long projectId, Long parentId);
/**

View File

@@ -1262,6 +1262,10 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
@Override
public CollectionSort addCollectionSort(Long relationId, String relationType, Long projectId, Long collectionSortParentId) {
CollectionSort collectionSort = queryCollectionSortByRelation(relationId, relationType, projectId);
if (Objects.nonNull(collectionSort)){
return collectionSort;
}
int sort = getNextSort(projectId, collectionSortParentId);
CollectionSort userLikeSort = new CollectionSort();
// userLikeSort.setUserLikeGroupId(userGroupId);
@@ -1278,6 +1282,14 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
return userLikeSort;
}
public CollectionSort queryCollectionSortByRelation(Long relationId, String relationType, Long projectId){
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();
qw.lambda().eq(CollectionSort::getProjectId, projectId).
eq(CollectionSort::getRelationId, relationId).
eq(CollectionSort::getRelationType, relationType);
return collectionSortMapper.selectOne(qw);
}
@Override
public int getNextSort(Long projectId, Long parentId) {
QueryWrapper<CollectionSort> qw = new QueryWrapper<>();

View File

@@ -500,6 +500,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
toProductImageResult.setParentId(toProductImageVO.getParentId());
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
designService.addCollectionSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), toProductImageDTO.getProjectId(), toProductImageVO.getParentId());
}
result.add(toProductImageResult);
}else {
@@ -552,6 +554,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
toProductImageResult.setParentId(toProductImageVO.getParentId());
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
designService.addCollectionSort(toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), toProductImageDTO.getProjectId(), toProductImageVO.getParentId());
}
result.add(toProductImageResult);
}
@@ -1151,6 +1155,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
toProductImageResult.setParentId(toProductImageVO.getParentId());
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
designService.addCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageDTO.getProjectId(), toProductImageVO.getParentId());
}
result.add(toProductImageResult);
}else {
@@ -1193,6 +1199,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageResult.setSort(Objects.isNull(reSort) ? sort : reSort);
}else if (Objects.nonNull(toProductImageDTO.getIsDefaultLike()) && Objects.nonNull(toProductImageVO.getParentId())){
toProductImageResult.setParentId(toProductImageVO.getParentId());
// 默认不添加到like,但是需要有parentId,所以这里添加到collectionSort表中
designService.addCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageDTO.getProjectId(), toProductImageVO.getParentId());
}
result.add(toProductImageResult);
}
@@ -1594,7 +1602,9 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("account_id", authPrincipalVo.getId());
if (Objects.nonNull(query.getId())){
queryWrapper.eq("id", query.getId());
}
// queryWrapper.isNull("parent_id");
if (!StringUtils.isEmpty(query.getProjectName())) {
queryWrapper.like("name", query.getProjectName());