Subversion Repositories SmartDukaan

Rev

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

Rev 34815 Rev 35026
Line 17... Line 17...
17
import org.springframework.mail.javamail.JavaMailSender;
17
import org.springframework.mail.javamail.JavaMailSender;
18
import org.springframework.stereotype.Component;
18
import org.springframework.stereotype.Component;
19
 
19
 
20
import java.nio.charset.StandardCharsets;
20
import java.nio.charset.StandardCharsets;
21
import java.util.ArrayList;
21
import java.util.ArrayList;
-
 
22
import java.util.HashSet;
22
import java.util.List;
23
import java.util.List;
-
 
24
import java.util.Set;
23
import java.util.stream.Collectors;
25
import java.util.stream.Collectors;
24
 
26
 
25
@Component
27
@Component
26
public class AuthServiceImpl implements AuthService {
28
public class AuthServiceImpl implements AuthService {
27
 
29
 
Line 71... Line 73...
71
        }
73
        }
72
        return managersHierarchy;
74
        return managersHierarchy;
73
    }
75
    }
74
 
76
 
75
    public List<Integer> getAllReportees(int authId) {
77
    public List<Integer> getAllReportees(int authId) {
-
 
78
        return getAllReportees(authId, new HashSet<>());  // call helper with visited set
-
 
79
    }
76
 
80
 
-
 
81
    private List<Integer> getAllReportees(int authId, Set<Integer> visited) {
77
        List<Integer> allReportees = new ArrayList<>();
82
        List<Integer> allReportees = new ArrayList<>();
78
 
83
 
79
        List<Integer> directReporteeIds = this.getDirectReportees(authId);
84
        List<Integer> directReporteeIds = this.getDirectReportees(authId);
80
        allReportees.addAll(directReporteeIds);
-
 
-
 
85
 
81
        for (int directReporteeId : directReporteeIds) {
86
        for (int directReporteeId : directReporteeIds) {
-
 
87
            if (!visited.contains(directReporteeId)) {
-
 
88
                visited.add(directReporteeId); // mark visited
-
 
89
                allReportees.add(directReporteeId);
-
 
90
 
-
 
91
                // recursively get sub-reportees
82
            allReportees.addAll(this.getAllReportees(directReporteeId));
92
                allReportees.addAll(getAllReportees(directReporteeId, visited));
-
 
93
            }
83
        }
94
        }
84
        return allReportees;
95
        return allReportees;
85
    }
96
    }
86
 
97
 
87
    @Override
98
    @Override