public Pager queryForPager(ProductCondition condition) { Region region = condition.getRegion(); Admin admin = condition.getAdmin(); Set<Region> regions = new HashSet<Region>(); // 如果是管理员,则需要根据管理员所管辖的地区进行过滤 if (admin != null) { if (region != null) { List<Region> list = regionService.getAllChildRegionByRegionId(region.getId()); for (Region region2 : list) { if (admin.getRegionSet().contains(region2)) regions.add(region2); } } else regions.addAll(admin.getRegionSet()); // 为空则搜索该管理员所管理的所有区域中的数据 } else { if (region != null) { regions.addAll(regionService.getAllChildRegionByRegionId(region.getId())); } } condition.setRegions(regions); return productDao.queryForPager(condition); }
public Pager getProductPager(ProductCategory productCategory, Pager pager, Region region) { return productDao.getProductPager( productCategory, pager, regionService.getAllChildRegionByRegionId(region == null ? null : region.getId())); }