From e10feb602f4db80cc726bd1750ee2c2a66464f3c Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Sat, 29 Mar 2025 01:59:04 +0800 Subject: [PATCH] this is 3.24 update --- .../good/AppointmentDateController.java | 12 ++++++++++ .../order/PendingServiceGoodController.java | 4 ++-- .../cultural/heritage/utils/Pagination.java | 24 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/cultural/heritage/utils/Pagination.java diff --git a/src/main/java/com/cultural/heritage/controller/good/AppointmentDateController.java b/src/main/java/com/cultural/heritage/controller/good/AppointmentDateController.java index 91759a6..93bddb6 100644 --- a/src/main/java/com/cultural/heritage/controller/good/AppointmentDateController.java +++ b/src/main/java/com/cultural/heritage/controller/good/AppointmentDateController.java @@ -25,6 +25,7 @@ import com.cultural.heritage.service.good.AppointmentDateService; import com.cultural.heritage.service.good.GoodService; import com.cultural.heritage.service.good.TimePeriodService; import com.cultural.heritage.service.order.PendingServiceGoodService; +import com.cultural.heritage.service.order.PendingServiceOrderService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -73,6 +74,11 @@ public class AppointmentDateController { + @Resource + private PendingServiceOrderService pendingServiceOrderService; + + + /** * Web端管理员根据id删除预约日期 * @param commonRequest 预约日期id @@ -130,6 +136,12 @@ public class AppointmentDateController { // 删除服务类商品待处理记录 QueryWrapper goodQueryWrapper = new QueryWrapper<>(); goodQueryWrapper.eq("timePeriodId", id); +// List pendingServiceGoodList = pendingServiceGoodService.list(goodQueryWrapper); +// PendingServiceGood pendingServiceGood = pendingServiceGoodList.get(0); +// Long pendingId = pendingServiceGood.getId(); +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("pendingId", pendingId); + boolean result = pendingServiceGoodService.remove(goodQueryWrapper); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "服务类商品待处理记录删除失败"); diff --git a/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java b/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java index 355b09b..2eb323e 100644 --- a/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java +++ b/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java @@ -20,6 +20,7 @@ import com.cultural.heritage.service.common.CommonService; import com.cultural.heritage.service.order.PendingServiceGoodService; import com.cultural.heritage.service.order.PendingServiceOrderService; import com.cultural.heritage.service.user.UserService; +import com.cultural.heritage.utils.Pagination; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -94,8 +95,6 @@ public class PendingServiceGoodController { List pendingServiceGoodVOList = new ArrayList<>(); for (PendingServiceGood pendingServiceGood : pendingServiceGoodList) { - // TODO -// pendingServiceGood.setGoodImg(FileConstant.SERVER_HOST + pendingServiceGood.getGoodImg()); PendingServiceGoodVO pendingServiceGoodVO = new PendingServiceGoodVO(); BeanUtils.copyProperties(pendingServiceGood, pendingServiceGoodVO); Long goodId = pendingServiceGood.getId(); @@ -111,6 +110,7 @@ public class PendingServiceGoodController { long pages = (total + pageSize - 1) / pageSize; Page voPage = new Page<>(); + pendingServiceGoodVOList = Pagination.paginate(pendingServiceGoodVOList, current, pageSize); voPage.setRecords(pendingServiceGoodVOList); voPage.setTotal(total); voPage.setSize(pageSize); diff --git a/src/main/java/com/cultural/heritage/utils/Pagination.java b/src/main/java/com/cultural/heritage/utils/Pagination.java new file mode 100644 index 0000000..2a4929e --- /dev/null +++ b/src/main/java/com/cultural/heritage/utils/Pagination.java @@ -0,0 +1,24 @@ +package com.cultural.heritage.utils; + +import java.util.List; +import java.util.ArrayList; + +public class Pagination { + + public static List paginate(List sourceList, long currentPage, long pageSize) { + // 计算起始索引 + long startIndex = (currentPage - 1) * pageSize; + + // 如果起始索引超出集合大小,返回空列表 + if (startIndex >= sourceList.size()) { + return new ArrayList<>(); + } + + // 计算结束索引 + long endIndex = Math.min(startIndex + pageSize, sourceList.size()); + + // 返回分页后的子集 + return sourceList.subList((int) startIndex, (int) endIndex); + } + +}