-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support generate mybatis plus query condition
- Loading branch information
Showing
8 changed files
with
77 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...nsion/tang-mybatis-plus/src/main/kotlin/com/tang/extension/mybatisplus/utils/PageUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.tang.extension.mybatisplus.utils | ||
|
||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper | ||
import com.baomidou.mybatisplus.core.mapper.BaseMapper | ||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page | ||
import com.tang.commons.utils.page.PageResult | ||
import com.tang.commons.utils.page.PageSupport | ||
|
||
/** | ||
* MyBatis Plus 分页工具类 | ||
* | ||
* @author Tang | ||
*/ | ||
object PageUtils { | ||
|
||
/** | ||
* 分页查询 | ||
* | ||
* @param baseMapper 通用 Mapper 接口 | ||
* @param queryWrapper 查询条件 | ||
* @param <T> 实体类 | ||
* @return 分页结果 | ||
*/ | ||
@JvmStatic | ||
fun <T> page(baseMapper: BaseMapper<T>, queryWrapper: QueryWrapper<T>): PageResult { | ||
val pageDomain = PageSupport.buildPageRequest() | ||
queryWrapper.orderBy(pageDomain.orderBy.isNotBlank(), pageDomain.isAscBoolean, pageDomain.orderByColumn) | ||
val page = Page<T>(pageDomain.pageNum.toLong(), pageDomain.pageSize.toLong()) | ||
val selectPage = baseMapper.selectPage(page, queryWrapper) | ||
return PageResult(selectPage.records, selectPage.total) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.