From e4451cbe7eea81c397353e8d5649e52dcbd3b7d1 Mon Sep 17 00:00:00 2001 From: guyue <1721849008@qq.com> Date: 星期五, 05 九月 2025 13:14:00 +0800 Subject: [PATCH] 平台筛选 --- src/main/java/com/linghu/service/impl/PlatformServiceImpl.java | 35 ++++++++++++++--------------------- 1 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/linghu/service/impl/PlatformServiceImpl.java b/src/main/java/com/linghu/service/impl/PlatformServiceImpl.java index 13af561..141b850 100644 --- a/src/main/java/com/linghu/service/impl/PlatformServiceImpl.java +++ b/src/main/java/com/linghu/service/impl/PlatformServiceImpl.java @@ -124,37 +124,30 @@ // 构建查询条件并添加排序(按创建时间倒序) LambdaQueryWrapper<Platform> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByDesc(Platform::getCreate_time); // 新增的排序条件 if (!platForm.isEmpty()){ queryWrapper.in(Platform::getPlatform_id, platForm); - }else { - if (page != null && pageSize != null){ - Page<Platform> pageInfo = new Page<>(page, pageSize); - Page<Platform> result = this.page(pageInfo, queryWrapper); - return ResponseResult.success(new CustomPage<>(result)); - }else { - CustomPage<Platform> customPage = new CustomPage<>(new Page<>()); - customPage.setRecords(new ArrayList<>()); - customPage.setTotal(0); - return ResponseResult.success(customPage); - } - } - - if (type_id != null) { - queryWrapper.eq(Platform::getType_id, type_id); - } - queryWrapper.orderByDesc(Platform::getCreate_time); // 新增的排序条件 - if (page != null && pageSize != null) { + if (page != null && pageSize != null && type_id == null){ Page<Platform> pageInfo = new Page<>(page, pageSize); Page<Platform> result = this.page(pageInfo, queryWrapper); return ResponseResult.success(new CustomPage<>(result)); + } else if (page != null && pageSize != null && type_id != null) { + Page<Platform> pageInfo = new Page<>(page, pageSize); + queryWrapper.eq(Platform::getType_id, type_id); + Page<Platform> result = this.page(pageInfo, queryWrapper); + return ResponseResult.success(new CustomPage<>(result)); + } else { - List<Platform> list = this.list(queryWrapper); CustomPage<Platform> customPage = new CustomPage<>(new Page<>()); - customPage.setRecords(list); - customPage.setTotal(list.size()); + customPage.setRecords(new ArrayList<>()); + customPage.setTotal(0); return ResponseResult.success(customPage); } + + + + } @Override -- Gitblit v1.7.1