class AssetCountController {

    @GetMapping(value = "/v1/count")
    public ResponseEntity<Object> geAssetCount(@RequestParam(name = "ag", required = true) String assetGroup,
            @RequestParam(name = "type", required = false) String type,
            @RequestParam(name = "domain", required = false) String domain,
            @RequestParam(name = "application", required = false) String application,
            @RequestParam(name = "provider", required = false) String provider) {
        if (type == null) {
            type = "all";
        }
        List<Map<String, Object>> countMap = assetService.getAssetCountAndEnvDistributionByAssetGroup(assetGroup, type, domain, application, provider);
        LongSummaryStatistics totalCount = countMap.stream().collect(Collectors.summarizingLong(map -> (Long) map.get(Constants.COUNT)));
        Map<String, Object> response = new HashMap<>();
        response.put("ag", assetGroup);
        response.put(AssetConstants.ASSET_COUNT, countMap);
        response.put(AssetConstants.ASSET_TYPE, totalCount.getCount());
        response.put(AssetConstants.TOTAL_ASSETS, totalCount.getSum());
        return ResponseUtils.buildSucessResponse(response);
    }

}