Solon v3.0.3

mybatis-pagehelper-solon-plugin

</> markdown
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>mybatis-pagehelper-solon-plugin</artifactId>
</dependency>

1、描述

数据扩展插件,为 mybatis-solon-plguin 插件提供分页支持。

2、配置示例

#数据源配置块(名字按业务需要取,与 @Db 那边对起来就好)
solon.dataSources:
  db1!:
    class: "com.zaxxer.hikari.HikariDataSource"
    jdbcUrl: jdbc:mysql://localhost:3306/rock?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true
    driverClassName: com.mysql.cj.jdbc.Driver
    username: root
    password: 123456

#映射配置
mybatis.db1:
    typeAliases:    #支持包名 或 类名(.class 结尾)
        - "demo.model"
    mappers:        #支持包名 或 类名(.class 结尾)或 xml(.xml结尾)
        - "demo.dso.mapper"


#分页组件的配置
pagehelper:
    offsetAsPageNum: true
    rowBoundsWithCount: true
    pageSizeZero: true
    reasonable: false
    params: pageNum=pageHelperStart;pageSize=pageHelperRows;
    supportMethodsArguments: false

3、应用示例

//应用
@Component
public class AppService{
    @Db
    AppMapper appMapper; 
    
    public List<AppxModel> test(){
        //分页查询
        PageHelper.offsetPage(2, 2);
        return appxMapper.appx_get_page();
    }
    
    public Page<AppxModel> test2(){
        //分页查询(带总数)
        return PageHelper.startPage(2, 2).doSelectPage(()-> appxMapper.appx_get_page());
    }
}

具体可参考:

https://gitee.com/noear/solon-examples/tree/main/4.Solon-Data/demo4023-mybatis_pagehelper

https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md