From 7720c8c77119195bb20c44a1aae8f30b7fc97226 Mon Sep 17 00:00:00 2001 From: litianxiang Date: Wed, 17 Dec 2025 14:12:20 +0800 Subject: [PATCH] =?UTF-8?q?edit=20=E4=BA=A7=E5=93=81=E5=9B=BE=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=BC=9A=E5=AF=BC=E8=87=B4sort=E4=B8=8D=E5=AF=B9?= =?UTF-8?q?=E8=AF=95=E9=AA=8C3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/UserLikeGroupServiceImpl.java | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index a481a9d8..80084555 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -1461,18 +1461,18 @@ public class UserLikeGroupServiceImpl extends ServiceImpl().lambda().eq(CollectionSort::getRelationId, toProductImageResult.getId()).orderByDesc(BaseEntity::getCreateTime).last("limit 1")); + sortRank(toProductImageResult); results.add(new MagicToolResultVO(taskId, "Fail")); } else if (fluxResult.equals("Fail") || fluxResult.equals("Pending")) { toProductImageResult.setStatus(fluxResult); toProductImageResultMapper.updateById(toProductImageResult); - collectionSortMapper.delete(new QueryWrapper().lambda().eq(CollectionSort::getRelationId, toProductImageResult.getId()).orderByDesc(BaseEntity::getCreateTime).last("limit 1")); + sortRank(toProductImageResult); results.add(new MagicToolResultVO(taskId, fluxResult)); } else { fluxResult="Fail"; toProductImageResult.setStatus(fluxResult); toProductImageResultMapper.updateById(toProductImageResult); - collectionSortMapper.delete(new QueryWrapper().lambda().eq(CollectionSort::getRelationId, toProductImageResult.getId()).orderByDesc(BaseEntity::getCreateTime).last("limit 1")); + sortRank(toProductImageResult); results.add(new MagicToolResultVO(taskId, fluxResult)); // results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt())); // // 扣积分 @@ -1522,6 +1522,31 @@ public class UserLikeGroupServiceImpl extends ServiceImpl collectionSortLambdaQueryWrapper = new LambdaQueryWrapper<>(); + collectionSortLambdaQueryWrapper.eq(CollectionSort::getRelationId, toProductImageResult.getId()); + + // 查询符合条件的CollectionSort集合 + List 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()); + + // 将其他记录的sort值减一并更新回数据库 + for (CollectionSort sort : collectionSorts) { + if (sort.getSort() != null && sort.getSort() > 0) { + sort.setSort(sort.getSort() - 1); + collectionSortMapper.updateById(sort); + } + } + } + } + public static String convert(InputStream inputStream) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { return reader.lines().collect(Collectors.joining("\n"));