BUGFIX: 1、相同的relation_id,relation_type重复排序,针对脏数据做处理 2、传入数据库中没有的userLikeSortId
This commit is contained in:
@@ -592,11 +592,21 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (Objects.isNull(userLikeSortId)) {
|
||||
return null;
|
||||
}
|
||||
CollectionSort child = collectionSortMapper.selectOne(new QueryWrapper<CollectionSort>().eq("relation_id", childId));
|
||||
if (!child.getRelationType().equals(relationType)) {
|
||||
|
||||
// 相同的relation_id,relation_type重复排序,有脏数据
|
||||
List<CollectionSort> childList = collectionSortMapper.selectList(
|
||||
new QueryWrapper<CollectionSort>().eq("relation_id", childId)
|
||||
.eq("relation_type", relationType).orderByDesc("id"));
|
||||
if (childList.isEmpty()) {
|
||||
return null;
|
||||
}else if (childList.size() > 1){
|
||||
log.error("CollectionSort表中,relation_id为{},relation_type为{}的记录有 {} 条,", childId, relationType, childList.size());
|
||||
}
|
||||
CollectionSort child = childList.get(0);
|
||||
CollectionSort collectionSort = collectionSortMapper.selectById(userLikeSortId);
|
||||
if (Objects.isNull(collectionSort)){
|
||||
return null;
|
||||
}
|
||||
CollectionSort collectionSort = collectionSortMapper.selectById(userLikeSortId);
|
||||
child.setSort(collectionSort.getSort());
|
||||
// 原来排序的大于等于userLikeSortId的排序的,都要+1
|
||||
collectionSortMapper.increaseGenerateSortAbove(parentId, relationType, collectionSort.getSort() - 1);
|
||||
|
||||
Reference in New Issue
Block a user