Subversion Repositories SmartDukaan

Rev

Rev 34082 | Rev 34158 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34082 Rev 34084
Line 703... Line 703...
703
 
703
 
704
    @Override
704
    @Override
705
    public Map<Integer, List<Integer>> authUserpartnerIdMap(int authId, int categoryId) {
705
    public Map<Integer, List<Integer>> authUserpartnerIdMap(int authId, int categoryId) {
706
        Session session = sessionFactory.getCurrentSession();
706
        Session session = sessionFactory.getCurrentSession();
707
 
707
 
708
        final TypedQuery<AuthUserPartnerMapModel> typedQuerySimilar = session
708
        Map<Integer, List<Integer>> authUserpartnerIdMap = new HashMap<>();
709
                .createNamedQuery("Position.Auth_User_Partner_Maping", AuthUserPartnerMapModel.class);
-
 
710
 
709
 
711
        typedQuerySimilar.setParameter("authId", authId);
-
 
712
        typedQuerySimilar.setParameter("categoryId", categoryId);
710
        List<Position> authPositions = positionRepository.selectPositionbyCategoryIdAndAuthId(categoryId,authId);
713
 
711
 
714
        List<AuthUserPartnerMapModel> authUserPartnerMapModels = typedQuerySimilar.getResultList();
712
        List<PartnerPosition> partnerPositions = authPositions.stream()
715
        LOGGER.info("authUserPartnerMapModels {}", authUserPartnerMapModels);
713
                .flatMap(authPosition -> partnerPositionRepository.selectByPositionId(authPosition.getId()).stream())
-
 
714
                .collect(Collectors.toList());
716
 
715
 
-
 
716
        if (partnerPositions.stream().anyMatch(partnerPosition -> partnerPosition.getFofoId() == 0)) {
-
 
717
            List<FofoStore> activeFofoStores = fofoStoreRepository.selectActiveStores();
-
 
718
 
717
        Map<Integer, List<Integer>> authUserpartnerIdMap = authUserPartnerMapModels.stream()
719
            List<Integer> fofoStoreIds = activeFofoStores.stream()
718
                .collect(Collectors.groupingBy(
720
                    .map(FofoStore::getId) // Extract the IDs of FofoStores
719
                        AuthUserPartnerMapModel::getAuthId,
721
                    .collect(Collectors.toList());
-
 
722
 
720
                        Collectors.mapping(AuthUserPartnerMapModel::getFofoId, Collectors.toList())
723
            authUserpartnerIdMap.put(authId, fofoStoreIds);
-
 
724
 
721
                ));
725
         } else {
-
 
726
            final TypedQuery<AuthUserPartnerMapModel> typedQuerySimilar = session
-
 
727
                    .createNamedQuery("Position.Auth_User_Partner_Maping", AuthUserPartnerMapModel.class);
-
 
728
 
722
        LOGGER.info("partnerusermap {}", authUserpartnerIdMap);
729
            typedQuerySimilar.setParameter("authId", authId);
-
 
730
            typedQuerySimilar.setParameter("categoryId", categoryId);
723
 
731
 
-
 
732
            List<AuthUserPartnerMapModel> authUserPartnerMapModels = typedQuerySimilar.getResultList();
-
 
733
 
-
 
734
            authUserpartnerIdMap = authUserPartnerMapModels.stream()
-
 
735
                    .collect(Collectors.groupingBy(
-
 
736
                            AuthUserPartnerMapModel::getAuthId,
-
 
737
                            Collectors.mapping(AuthUserPartnerMapModel::getFofoId, Collectors.toList())
-
 
738
                    ));
-
 
739
 
-
 
740
        }
-
 
741
 
-
 
742
        LOGGER.info("partnerusermap {}", authUserpartnerIdMap);
724
        return authUserpartnerIdMap;
743
        return authUserpartnerIdMap;
725
    }
744
    }
726
 
745
 
727
    @Override
746
    @Override
728
    public List<String> getAuthUserByPartnerId(int fofoId) throws ProfitMandiBusinessException {
747
    public List<String> getAuthUserByPartnerId(int fofoId) throws ProfitMandiBusinessException {