Commit 055497a7 by 丁伟峰

配件仓不需要翻页,查询一次性返回

1 parent 0e1263d8
......@@ -29,9 +29,7 @@ public interface OrgWarehouseInfoDao extends JpaRepository<OrgWarehouseInfoEntit
@Query("select a from OrgWarehouseInfoEntity a join OrgBranchEntity o on a.branchId=o.branchId where o.clusterId=:clusterId")
Page<OrgWarehouseInfoEntity> findByClusterId(String clusterId, Pageable pageable);
List<OrgWarehouseInfoEntity> findByClusterId(String clusterId);
Page<OrgWarehouseInfoEntity> findByBranchId(String branchId, Pageable pageable);
Page<OrgWarehouseInfoEntity> findByGroupId(String groupId, Pageable pageable);
List<OrgWarehouseInfoEntity> findByGroupId(String groupId);
}
......@@ -12,17 +12,11 @@ public class BusinessOrgWarehousesDTO {
public static class Request {
private String levelType;
private String levelValue;
private Integer size = DEFAULT_PAGE_SIZE;
private Integer page = 1;
}
@lombok.Data
@Accessors(chain = true)
public static class Result {
private long pageCurrent;
private long pages;
private long pageSize;
private long total;
private List<Content> content;
}
......
......@@ -67,17 +67,16 @@ public class BusinessBaseServiceImpl implements BusinessBaseService {
@Override
public Result<?> getOrgWarehouses(BusinessOrgWarehousesDTO.Request req) {
Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize());
Page<OrgWarehouseInfoEntity> page = null;
List<OrgWarehouseInfoEntity> entities = null;
if (req.getLevelType().equals("cluster")) {
page = orgWarehouseInfoDao.findByClusterId(req.getLevelValue(), pageable);
entities = orgWarehouseInfoDao.findByClusterId(req.getLevelValue());
} else if (req.getLevelType().equals("branch")) {
page = orgWarehouseInfoDao.findByBranchId(req.getLevelValue(), pageable);
entities = orgWarehouseInfoDao.findByBranchId(req.getLevelValue());
} else {
page = orgWarehouseInfoDao.findByGroupId(req.getLevelValue(), pageable);
entities = orgWarehouseInfoDao.findByGroupId(req.getLevelValue());
}
List<BusinessOrgWarehousesDTO.Content> contents = page.getContent().stream().map(e -> {
List<BusinessOrgWarehousesDTO.Content> contents = entities.stream().map(e -> {
BusinessOrgWarehousesDTO.Content content = new BusinessOrgWarehousesDTO.Content();
content.setWarehouseId(e.getWarehouseId());
content.setWarehouseName(e.getWarehouseName());
......@@ -95,10 +94,6 @@ public class BusinessBaseServiceImpl implements BusinessBaseService {
return content;
}).collect(Collectors.toList());
BusinessOrgWarehousesDTO.Result rs = new BusinessOrgWarehousesDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setPageCurrent(page.getNumber());
rs.setContent(contents);
return Result.success(rs);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!