コード例 #1
0
 @Override
 public List<ProductCategoryDTO> getRecentlyUsedProductCategoryDTOList(Long shopId, Long userId) {
   List<ProductCategoryDTO> productCategoryDTOList = new ArrayList<ProductCategoryDTO>();
   if (shopId == null) return productCategoryDTOList;
   IRecentlyUsedDataService recentlyUsedDataService =
       ServiceManager.getService(IRecentlyUsedDataService.class);
   int maxSize = ConfigUtils.getRecentlyUsedProductCategoryNum();
   List<RecentlyUsedDataDTO> recentlyUsedDataDTOList =
       recentlyUsedDataService.getRecentlyUsedDataDTOList(
           shopId, userId, RecentlyUsedDataType.USED_PRODUCT_CATEGORY, maxSize);
   if (CollectionUtils.isNotEmpty(recentlyUsedDataDTOList)) {
     Set<Long> prouctCategoryIdSet = new HashSet<Long>();
     for (RecentlyUsedDataDTO recentlyUsedDataDTO : recentlyUsedDataDTOList) {
       prouctCategoryIdSet.add(recentlyUsedDataDTO.getDataId());
     }
     List<ProductCategoryDTO> productCategoryDTOs =
         getProductCategoryDTOByIds(prouctCategoryIdSet);
     fillProductCategoryDTOListInfo(productCategoryDTOs);
     Map<Long, ProductCategoryDTO> productCategoryDTOMap = new HashMap<Long, ProductCategoryDTO>();
     for (ProductCategoryDTO productCategoryDTO : productCategoryDTOs) {
       productCategoryDTOMap.put(productCategoryDTO.getId(), productCategoryDTO);
     }
     ProductCategoryDTO productCategoryDTO = null;
     for (RecentlyUsedDataDTO recentlyUsedDataDTO : recentlyUsedDataDTOList) {
       productCategoryDTO = productCategoryDTOMap.get(recentlyUsedDataDTO.getDataId());
       if (productCategoryDTO != null) {
         productCategoryDTOList.add(productCategoryDTO);
       }
     }
   }
   return productCategoryDTOList;
 }
コード例 #2
0
ファイル: MenuService.java プロジェクト: ndong211/bo
 @Override
 public String buildMenu(long shopVersionId, long shopId, long userId, long userGroupId)
     throws Exception {
   Set<Long> resourceIds = new HashSet<Long>();
   List<Resource> resourceList =
       ServiceManager.getService(IResourceService.class)
           .getAllResourcesByUserGroupId(shopVersionId, userGroupId);
   for (Resource r : resourceList) {
     if (ResourceType.menu == r.getType()) {
       resourceIds.add(r.getId());
     }
   }
   Map<String, MenuRootResponse> menuRootResponseMap = new HashMap<String, MenuRootResponse>();
   List<MenuDTO> parents = new ArrayList<MenuDTO>();
   if (CollectionUtil.isNotEmpty(resourceIds)) {
     List<MenuDTO> menuDTOList =
         ServiceManager.getService(IResourceService.class).getMenuByResourceIds(resourceIds);
     //      List<UserSwitch> userSwitches =
     // ServiceManager.getService(IUserService.class).getUserSwitch(shopId);
     boolean isRepairPickingSwitchOn =
         ServiceManager.getService(IUserService.class).isRepairPickingSwitchOn(shopId);
     Iterator iterator = menuDTOList.iterator();
     MenuDTO menuDTO;
     while (iterator.hasNext()) {
       menuDTO = (MenuDTO) iterator.next();
       // 特殊过滤
       if (MenuType.TXN_INVENTORY_MANAGE_REPAIR_PICKING.name().equals(menuDTO.getMenuName())
           && !isRepairPickingSwitchOn) {
         iterator.remove();
       }
       // 页面配置开关
       if (MenuType.WEB_SYSTEM_SETTINGS_CUSTOM_CONFIG_PAGE_CONFIG
               .name()
               .equals(menuDTO.getMenuName())
           && !ConfigUtils.isCustomizerConfigOpen()) {
         iterator.remove();
       }
       if (menuDTO.getParentId() == null) {
         parents.add(menuDTO);
         iterator.remove();
       }
     }
     List<MenuItemResponse> menuItemResponseList;
     MenuItemResponse response;
     MenuRootResponse rootResponse;
     for (MenuDTO root : parents) {
       root.buildTree(root, menuDTOList);
       // 根据logic 做具体处理
       //        sort(shopVersionId, root);
       root.reBuildTreeForSort();
       menuItemResponseList = new ArrayList<MenuItemResponse>();
       for (MenuDTO menu : root.getChildren()) {
         //          if (menu.getChildren().size() > 1) {
         //            String href = "";
         //            //特殊root menu 需要连接
         //            if
         // (MenuType.AUTO_ACCESSORY_ONLINE_ORDER_CENTER.name().equals(menu.getMenuName())
         //                || MenuType.VEHICLE_CONSTRUCTION.name().equals(menu.getMenuName())) {
         //              href = root.getHref();
         //            }
         response = new MenuItemResponse(menu.getLabel(), menu.getHref(), menu.getMenuName());
         for (MenuDTO m : menu.getChildren()) {
           response
               .getItem()
               .add(new MenuItemResponse(m.getLabel(), m.getHref(), m.getMenuName()));
         }
         //          } else {
         //            response = new MenuItemResponse(menu.getLabel(), menu.getHref(),
         // menu.getMenuName());
         //          }
         menuItemResponseList.add(response);
       }
       rootResponse = new MenuRootResponse(root.getLabel(), root.getHref(), root.getMenuName());
       rootResponse.setItem(menuItemResponseList);
       menuRootResponseMap.put(root.getMenuName(), rootResponse);
     }
   }
   return JsonUtil.mapToJson(menuRootResponseMap);
 }