Browse Source

更改分页校验

tags/v2.4.1
xiaoying 1 year ago
parent
commit
e0105221ac
2 changed files with 16 additions and 6 deletions
  1. +12
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/common/BaseQuery.java
  2. +4
    -6
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java

+ 12
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/common/BaseQuery.java View File

@@ -16,4 +16,16 @@ public class BaseQuery {
* 每页数
*/
private Integer limit;

/**
* 不传参的时候默认1,10
*/
public void checkParam() {
if (this.page == null || this.page < 0) {
setPage(1);
}
if (this.limit == null || this.limit < 0 || this.limit > 100) {
setLimit(10);
}
}
}

+ 4
- 6
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java View File

@@ -249,9 +249,8 @@ public class ClientUserServiceImpl implements ClientUserSevice {
@Override
public JsonResult findUserList(UserQuery query) {

if (ObjectUtil.isNull(query.getPage()) || ObjectUtil.isNull(query.getLimit())) {
return JsonResult.error("分页参数不能为空");
}
//分页参数校验
query.checkParam();
//开启分页
IPage<UserPo> page = new Page<>(query.getPage(), query.getLimit());
IPage<UserVo> pageData = clientUserMapper.selectByTenantIdAndPage(query, page);
@@ -357,9 +356,8 @@ public class ClientUserServiceImpl implements ClientUserSevice {
*/
@Override
public JsonResult findTenants(TenantQuery query) {
if (ObjectUtil.isNull(query.getPage()) || ObjectUtil.isNull(query.getLimit())) {
return JsonResult.error("分页参数不能为空");
}
//分页参数校验
query.checkParam();
//开启分页
IPage<TenantVo> page = new Page<>(query.getPage(), query.getLimit());
IPage<TenantPo> pageData = tenantMapper.findList(page, query);

Loading…
Cancel
Save