讨厌JAVA分页插件弱智和缓慢,DBA随手写个分页代码

2023年 10月 13日 59.4k 0

package com.example.demo.Service.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.example.demo.Domain.JavaObject.Page;
import com.example.demo.Domain.ViewObject.PersonalVO;
import com.example.demo.Domain.ParamterObject.PersonalCondition;
import com.example.demo.Domain.ReturnObject.TotalAmount;
import com.example.demo.Service.PersonalService;
import com.example.demo.MapperInterface.PersonalMapper;

@Service
  public class PersonalServiceImpl implements PersonalService
{
   @Autowired
   private PersonalMapper PersonalMapperI; /** 定义私有映射对象 才能使用上该方法*/

   @Override
   public PersonalVO GetPageByCondition(Page PagePo, PersonalCondition Po, TotalAmount TotalAmountPo)
   {
        PersonalVO Personal_Vo = new PersonalVO();

       if (TotalAmountPo.Total == 0)                    /** 首次 或条件重新刷新过*/
       {
           Personal_Vo.TotalAmountVo = PersonalMapperI.selectTotalByCondition(Po);
           if (Personal_Vo.TotalAmountVo.Total == 0)
               return null;
       } else                                             /**下一页 **/
       {
           if (PagePo.Is_RealTime)                     /** 实时统计**/
           {
               Personal_Vo.TotalAmountVo = PersonalMapperI.selectTotalByCondition(Po);
           } else
           {
               Personal_Vo.TotalAmountVo = new TotalAmount();
               Personal_Vo.TotalAmountVo.Total = TotalAmountPo.Total;
               Personal_Vo.TotalAmountVo.Amount = TotalAmountPo.Amount;
           }
       }

       Personal_Vo.PersonalListVo = PersonalMapperI.selectPageByCondition(PagePo.PageRows, PagePo.StartRows, Po);
       return Personal_Vo;
   }
}

package com.example.demo.Service.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.example.demo.Domain.JavaObject.Page;
import com.example.demo.Domain.ViewObject.PersonalVO;
import com.example.demo.Domain.ParamterObject.PersonalCondition;
import com.example.demo.Domain.ReturnObject.TotalAmount;
import com.example.demo.Service.PersonalService;
import com.example.demo.MapperInterface.PersonalMapper;

@Service
  public class PersonalServiceImpl implements PersonalService
{
   @Autowired
   private PersonalMapper PersonalMapperI; /** 定义私有映射对象 才能使用上该方法*/

   @Override
   public PersonalVO GetPageByCondition(Page PagePo, PersonalCondition Po, TotalAmount TotalAmountPo)
   {
        PersonalVO Personal_Vo = new PersonalVO();

       if (TotalAmountPo.Total == 0)                    /** 首次 或条件重新刷新过*/
       {
           Personal_Vo.TotalAmountVo = PersonalMapperI.selectTotalByCondition(Po);
           if (Personal_Vo.TotalAmountVo.Total == 0)
               return null;
       } else                                             /**下一页 **/
       {
           if (PagePo.Is_RealTime)                     /** 实时统计**/
           {
               Personal_Vo.TotalAmountVo = PersonalMapperI.selectTotalByCondition(Po);
           } else
           {
               Personal_Vo.TotalAmountVo = new TotalAmount();
               Personal_Vo.TotalAmountVo.Total = TotalAmountPo.Total;
               Personal_Vo.TotalAmountVo.Amount = TotalAmountPo.Amount;
           }
       }

       Personal_Vo.PersonalListVo = PersonalMapperI.selectPageByCondition(PagePo.PageRows, PagePo.StartRows, Po);
       return Personal_Vo;
   }
}

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论