From 6e31bb6251abcd79dca77d2b204e8f9d7ad21d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 2 Sep 2024 16:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=9A=E5=91=98=E6=B5=81?= =?UTF-8?q?=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/AppRun.java | 1 - .../service/TbShopUserFlowService.java | 3 +- .../impl/TbShopUserFlowServiceImpl.java | 32 +++++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/AppRun.java b/eladmin-system/src/main/java/cn/ysk/cashier/AppRun.java index d13e8412..a395fb8c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/AppRun.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/AppRun.java @@ -38,7 +38,6 @@ import org.springframework.web.bind.annotation.RestController; @Api(hidden = true) @EnableTransactionManagement @SpringBootApplication - @EnableJpaAuditing(auditorAwareRef = "auditorAware") public class AppRun { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopUserFlowService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopUserFlowService.java index aa9ab95a..c315c4a1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopUserFlowService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopUserFlowService.java @@ -1,6 +1,7 @@ package cn.ysk.cashier.mybatis.service; import cn.ysk.cashier.mybatis.entity.TbShopUserFlow; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import java.math.BigDecimal; @@ -15,7 +16,7 @@ public interface TbShopUserFlowService extends IService { BigDecimal sumUserFlowAmountByConditions(Long shopId, String startTime, String endTime); - Map selectByUserId(Integer userId, Integer page, Integer pageSize); + IPage> selectByUserId(Integer userId, Integer page, Integer pageSize); Integer selectCountByUserId(Integer userId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopUserFlowServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopUserFlowServiceImpl.java index 5d813b93..4442afac 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopUserFlowServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopUserFlowServiceImpl.java @@ -3,11 +3,19 @@ package cn.ysk.cashier.mybatis.service.impl; import cn.ysk.cashier.mybatis.entity.TbShopUserFlow; import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper; import cn.ysk.cashier.mybatis.service.TbShopUserFlowService; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.ibatis.annotations.Param; import org.springframework.data.domain.*; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,21 +31,19 @@ public class TbShopUserFlowServiceImpl extends ServiceImpl> selectByUserId(Integer userId, Integer page, Integer pageSize) { - Map map=new HashMap(); - int count= baseMapper.selectCountByUserId(userId); - if(count>0){ - Pageable pageable = PageRequest.of(page, pageSize, Sort.by("id").descending()); - List userFlows=baseMapper.selectByUserId(userId,pageable.getPageNumber(),pageable.getPageSize()); - map.put("totalElements",count); - map.put("content",userFlows); - }else { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("shop_user_id",userId); - map.put("totalElements",0); - map.put("content",null); - } - return map; + List orders=new ArrayList<>(); + OrderItem orderItem=new OrderItem(); + orderItem.setColumn("id"); + orderItem.setAsc(false); + orders.add(orderItem); + Page page1=new Page<>(page,pageSize); + page1.setOrders(orders); + return baseMapper.selectMapsPage(page1,queryWrapper); } @Override