edit 产品图失败会导致sort不对试验3
This commit is contained in:
@@ -1461,18 +1461,18 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
if (StringUtil.isNullOrEmpty(fluxResult)) {
|
||||
toProductImageResult.setStatus("Fail");
|
||||
toProductImageResultMapper.updateById(toProductImageResult);
|
||||
collectionSortMapper.delete(new QueryWrapper<CollectionSort>().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<CollectionSort>().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<CollectionSort>().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<UserLikeGroupMapper, U
|
||||
return results;
|
||||
}
|
||||
|
||||
private void sortRank(ToProductImageResult toProductImageResult) {
|
||||
LambdaQueryWrapper<CollectionSort> collectionSortLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
collectionSortLambdaQueryWrapper.eq(CollectionSort::getRelationId, toProductImageResult.getId());
|
||||
|
||||
// 查询符合条件的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());
|
||||
|
||||
// 将其他记录的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"));
|
||||
|
||||
Reference in New Issue
Block a user