Update /staff for Ariel (new schhema)
This commit is contained in:
parent
7f10888151
commit
23a6739eb1
@ -12,38 +12,38 @@ import java.util.*;
|
||||
|
||||
public final class GETStaff implements Handler<RoutingContext> {
|
||||
|
||||
public void handle(RoutingContext ctx) {
|
||||
Map<String, Rank> staffRanks = new HashMap<>();
|
||||
public void handle(RoutingContext ctx) {
|
||||
Map<String, Rank> staffRanks = new HashMap<>();
|
||||
|
||||
Rank.findAll().forEach(rank -> {
|
||||
if (rank.isStaffRank()) {
|
||||
staffRanks.put(rank.getId(), rank);
|
||||
}
|
||||
});
|
||||
Rank.findAll().forEach(rank -> {
|
||||
if (rank.isStaffRank()) {
|
||||
staffRanks.put(rank.getId(), rank);
|
||||
}
|
||||
});
|
||||
|
||||
Map<String, Set<User>> result = new TreeMap<>((first, second) -> {
|
||||
Rank firstRank = staffRanks.get(first);
|
||||
Rank secondRank = staffRanks.get(second);
|
||||
Map<String, Set<User>> result = new TreeMap<>((a, b) -> {
|
||||
Rank aRank = staffRanks.get(a);
|
||||
Rank bRank = staffRanks.get(b);
|
||||
|
||||
return Integer.compare(firstRank.getGeneralWeight(), secondRank.getGeneralWeight());
|
||||
});
|
||||
return Integer.compare(bRank.getGeneralWeight(), aRank.getGeneralWeight());
|
||||
});
|
||||
|
||||
List<Grant> staffGrants = SyncUtils.runBlocking(v -> Grant.findByRank(staffRanks.values(), v));
|
||||
List<Grant> staffGrants = SyncUtils.runBlocking(v -> Grant.findByRank(staffRanks.values(), v));
|
||||
|
||||
for (Grant staffGrant : staffGrants) {
|
||||
if (staffGrant.isActive()) {
|
||||
User user = SyncUtils.runBlocking(v -> User.findById(staffGrant.getId(), v));
|
||||
Rank rank = staffRanks.get(staffGrant.getRank());
|
||||
for (Grant staffGrant : staffGrants) {
|
||||
if (staffGrant.isActive()) {
|
||||
User user = SyncUtils.runBlocking(v -> User.findById(staffGrant.getUser(), v));
|
||||
Rank rank = staffRanks.get(staffGrant.getRank());
|
||||
|
||||
if (!result.containsKey(rank.getId())) {
|
||||
result.put(rank.getId(), new HashSet<>());
|
||||
}
|
||||
if (!result.containsKey(rank.getId())) {
|
||||
result.put(rank.getId(), new HashSet<>());
|
||||
}
|
||||
|
||||
result.get(rank.getId()).add(user);
|
||||
}
|
||||
}
|
||||
result.get(rank.getId()).add(user);
|
||||
}
|
||||
}
|
||||
|
||||
APIv3.respondJson(ctx, 200, result);
|
||||
}
|
||||
APIv3.respondJson(ctx, 200, result);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user