优化分页查询,增加页码返回前端
This commit is contained in:
parent
2d48d4bb63
commit
00a2026daf
@ -6,13 +6,13 @@ import com.qiuguo.iot.data.entity.device.DeviceInfoEntity;
|
||||
import com.qiuguo.iot.data.request.device.DeviceInfoRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hswebframework.ezorm.core.param.QueryParam;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
|
||||
import org.hswebframework.ezorm.rdb.operator.dml.query.SortOrder;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||
import org.hswebframework.web.crud.service.GenericReactiveCrudService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Date;
|
||||
@ -113,7 +113,9 @@ public class DeviceInfoService extends GenericReactiveCrudService<DeviceInfoEnti
|
||||
|
||||
|
||||
|
||||
public Flux<DeviceInfoEntity> selectDeviceInfosByRequest(DeviceInfoRequest request){
|
||||
public Mono<PagerResult<DeviceInfoEntity>> selectDeviceInfosByRequest(DeviceInfoRequest request){
|
||||
|
||||
|
||||
ReactiveQuery<DeviceInfoEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
@ -212,14 +214,13 @@ public class DeviceInfoService extends GenericReactiveCrudService<DeviceInfoEnti
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
/*QueryParam param = new QueryParam();
|
||||
param.setPageIndex(request.getCurrPage());
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
param.setPageIndex(request.getCurrPage() - 1);
|
||||
param.setPageSize(request.getPageSize());
|
||||
param.setPaging(true);
|
||||
param.setFirstPageIndex(0);
|
||||
|
||||
reactiveQuery.setParam(param);*/
|
||||
return reactiveQuery.paging(request.getCurrPage(), request.getPageSize()).fetch();
|
||||
return queryPager(param);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,9 +10,10 @@ import java.util.Date;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveQuery;
|
||||
import org.hswebframework.ezorm.rdb.mapping.ReactiveUpdate;
|
||||
import org.hswebframework.ezorm.rdb.operator.dml.query.SortOrder;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||
import org.hswebframework.web.crud.service.GenericReactiveCrudService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
@ -64,7 +65,7 @@ public class UserHomeService extends GenericReactiveCrudService<UserHomeEntity,
|
||||
|
||||
|
||||
|
||||
public Flux<UserHomeEntity> selectUserHomesByRequest(UserHomeRequest request){
|
||||
public Mono<PagerResult<UserHomeEntity>> selectUserHomesByRequest(UserHomeRequest request){
|
||||
ReactiveQuery<UserHomeEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
@ -100,7 +101,14 @@ public class UserHomeService extends GenericReactiveCrudService<UserHomeEntity,
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
return reactiveQuery.paging(request.getCurrPage(), request.getPageSize()).fetch();
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
param.setPageIndex(request.getCurrPage() - 1);
|
||||
param.setPageSize(request.getPageSize());
|
||||
param.setPaging(true);
|
||||
param.setFirstPageIndex(0);
|
||||
|
||||
return queryPager(param);
|
||||
//return reactiveQuery.paging(request.getCurrPage(), request.getPageSize()).fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -13,10 +13,7 @@ import org.hswebframework.ezorm.rdb.operator.dml.query.SortOrder;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.api.crud.entity.QueryParamEntity;
|
||||
import org.hswebframework.web.crud.service.GenericReactiveCrudService;
|
||||
import org.hswebframework.web.crud.service.ReactiveCrudService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
@ -73,7 +70,7 @@ public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity,
|
||||
|
||||
|
||||
|
||||
public Flux<UserRoomEntity> selectUserRoomsByRequest(UserRoomRequest request){
|
||||
public Mono<PagerResult<UserRoomEntity>> selectUserRoomsByRequest(UserRoomRequest request){
|
||||
ReactiveQuery<UserRoomEntity> reactiveQuery = createQuery();
|
||||
reactiveQuery = reactiveQuery.and("is_delete", 0);
|
||||
if(request.getId() != null){
|
||||
@ -112,12 +109,19 @@ public class UserRoomService extends GenericReactiveCrudService<UserRoomEntity,
|
||||
}
|
||||
reactiveQuery = reactiveQuery.orderBy(sortOrder);
|
||||
}
|
||||
QueryParamEntity param = new QueryParamEntity();
|
||||
QueryParamEntity param = QueryParamEntity.of(reactiveQuery.getParam());
|
||||
param.setPageIndex(request.getCurrPage() - 1);
|
||||
param.setPageSize(request.getPageSize());
|
||||
param.setPageIndex(request.getCurrPage());
|
||||
// reactiveQuery.
|
||||
// return queryPager(param);
|
||||
return reactiveQuery.paging(request.getCurrPage(),request.getPageSize()).fetch();
|
||||
param.setPaging(true);
|
||||
param.setFirstPageIndex(0);
|
||||
|
||||
return queryPager(param);
|
||||
// QueryParamEntity param = new QueryParamEntity();
|
||||
// param.setPageSize(request.getPageSize());
|
||||
// param.setPageIndex(request.getCurrPage());
|
||||
//// reactiveQuery.
|
||||
//// return queryPager(param);
|
||||
// return reactiveQuery.paging(request.getCurrPage(),request.getPageSize()).fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,21 +4,17 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.qiuguo.iot.data.entity.user.UserRoomEntity;
|
||||
import com.qiuguo.iot.data.request.user.UserRoomRequest;
|
||||
import com.qiuguo.iot.data.service.device.DeviceBatchService;
|
||||
import com.qiuguo.iot.data.service.user.UserRoomService;
|
||||
import com.qiuguo.iot.user.api.rest.RoomInitResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@ -75,7 +71,7 @@ public class RoomAdminController {
|
||||
|
||||
//查询
|
||||
@PostMapping("/get/room")
|
||||
public Flux<UserRoomEntity> getFamily(@RequestBody RoomInitResp resp) {
|
||||
public Mono<PagerResult<UserRoomEntity>> getFamily(@RequestBody RoomInitResp resp) {
|
||||
List<UserRoomEntity> aa = new ArrayList<>();
|
||||
|
||||
UserRoomRequest room = new UserRoomRequest();
|
||||
|
||||
@ -11,6 +11,7 @@ import com.qiuguo.iot.data.service.device.DeviceBatchService;
|
||||
import com.qiuguo.iot.data.service.device.DeviceInfoService;
|
||||
import com.qiuguo.iot.user.api.resp.device.DeviceInitResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hswebframework.web.api.crud.entity.PagerResult;
|
||||
import org.hswebframework.web.exception.BusinessException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -108,9 +109,10 @@ public class DeviceController {
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Flux<DeviceInfoEntity> getList(){
|
||||
public Mono<PagerResult<DeviceInfoEntity>> getList(@RequestParam Integer pageIndex, @RequestParam Integer pageSize){
|
||||
DeviceInfoRequest request = new DeviceInfoRequest();
|
||||
|
||||
request.setCurrPage(pageIndex);
|
||||
request.setPageSize(pageSize);
|
||||
return deviceInfoService.selectDeviceInfosByRequest(request);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2
pom.xml
2
pom.xml
@ -24,7 +24,7 @@
|
||||
<spring-cloud.version>2021.0.8</spring-cloud.version>
|
||||
<alibaba.nacos.version>2.1.1</alibaba.nacos.version>
|
||||
<hswebframework.version>4.0.16</hswebframework.version>
|
||||
<hsweb.orm.version>4.1.1.qg</hsweb.orm.version>
|
||||
<hsweb.orm.version>4.1.1</hsweb.orm.version>
|
||||
<spring.cloud.version>3.1.7</spring.cloud.version>
|
||||
<spring.boot.version>2.7.15</spring.boot.version>
|
||||
<spring.boot.maven.plugin.version>2.7.14</spring.boot.maven.plugin.version>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user