edit 产品图失败会导致sort不对试验4
This commit is contained in:
@@ -1522,27 +1522,23 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
return results;
|
||||
}
|
||||
|
||||
/*
|
||||
重排Relight失败sort
|
||||
*/
|
||||
private void sortRank(ToProductImageResult toProductImageResult) {
|
||||
LambdaQueryWrapper<CollectionSort> collectionSortLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
collectionSortLambdaQueryWrapper.eq(CollectionSort::getRelationId, toProductImageResult.getId());
|
||||
collectionSortLambdaQueryWrapper.eq(CollectionSort::getRelationId, toProductImageResult.getId()).orderByDesc(CollectionSort::getCreateTime).last("LIMIT 1");
|
||||
|
||||
// 查询符合条件的CollectionSort集合
|
||||
List<CollectionSort> collectionSorts = collectionSortMapper.selectList(collectionSortLambdaQueryWrapper);
|
||||
|
||||
if (!collectionSorts.isEmpty()) {
|
||||
// 按照创建时间排序,找到最新的一条记录
|
||||
collectionSorts.sort((a, b) -> b.getCreateTime().compareTo(a.getCreateTime()));
|
||||
|
||||
// 删除最新的一条记录
|
||||
CollectionSort latestSort = collectionSorts.remove(0);
|
||||
collectionSortMapper.deleteById(latestSort.getId());
|
||||
collectionSortMapper.deleteById(collectionSorts.get(0));
|
||||
List<CollectionSort> collectionSorts1 = collectionSortMapper.selectList(new LambdaQueryWrapper<CollectionSort>().eq(CollectionSort::getParentId, collectionSorts.get(0).getParentId()).orderByDesc(CollectionSort::getSort).last("LIMIT 1"));
|
||||
|
||||
// 将其他记录的sort值减一并更新回数据库
|
||||
for (CollectionSort sort : collectionSorts) {
|
||||
if (sort.getSort() != null && sort.getSort() > 0) {
|
||||
sort.setSort(sort.getSort() - 1);
|
||||
collectionSortMapper.updateById(sort);
|
||||
}
|
||||
if (!collectionSorts1.isEmpty()) {
|
||||
collectionSorts1.get(0).setSort(collectionSorts1.get(0).getSort() - 1);
|
||||
collectionSortMapper.updateById(collectionSorts1.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user