@@ -115,7 +115,17 @@ public class UserInfoHandler implements RequestHandler {
|
||||
Sort.Direction.fromString(req.getSortDirection() != null ? req.getSortDirection() : "desc");
|
||||
String sortBy = req.getSortBy() != null ? req.getSortBy() : "createdAt";
|
||||
|
||||
Pageable pageable = PageRequest.of(req.getPage(), req.getSize(), Sort.by(direction, sortBy));
|
||||
String sortField = switch (sortBy) {
|
||||
case "fullName" -> "fullName";
|
||||
case "email" -> "email";
|
||||
case "createdAt" -> "createdAt";
|
||||
case "verificationStatus" -> "verificationStatus";
|
||||
case "tariff" -> "personalTariffInfo.status";
|
||||
case "tokens" -> "personalTariffInfo.tokens";
|
||||
default -> "createdAt";
|
||||
};
|
||||
|
||||
Pageable pageable = PageRequest.of(req.getPage(), req.getSize(), Sort.by(direction, sortField));
|
||||
|
||||
Specification<User> spec = (root, query, cb) -> cb.conjunction();
|
||||
|
||||
@@ -145,23 +155,16 @@ public class UserInfoHandler implements RequestHandler {
|
||||
map.put("id", user.getId());
|
||||
map.put("fullName", user.getFullName());
|
||||
map.put("email", user.getEmail());
|
||||
map.put("phone", user.getPhone());
|
||||
map.put("emailVerified", user.isEmailVerified());
|
||||
map.put("subscriptionType", user.getSubscriptionType().name());
|
||||
map.put("genderType", user.getGenderType().name());
|
||||
map.put("isActive", user.isActive());
|
||||
map.put("birthday", user.getBirthday() != null ? user.getBirthday().toString() : null);
|
||||
map.put("createdAt", user.getCreatedAt() != null ? user.getCreatedAt().toString() : null);
|
||||
map.put("lastLoginAt", user.getLastLoginAt() != null ? user.getLastLoginAt().toString() : null);
|
||||
map.put("companyName", user.getCompanyName());
|
||||
map.put("verificationStatus", user.getVerificationStatus().name());
|
||||
map.put("createdAt", user.getCreatedAt() != null ? user.getCreatedAt().toString() : null);
|
||||
|
||||
TariffInfo tariff = user.getActiveTariffInfo();
|
||||
if (tariff != null) {
|
||||
map.put("tariff", tariff.getStatus().name());
|
||||
map.put("tokens", tariff.getTokens());
|
||||
map.put("boughtTokens", tariff.getBoughtTokens());
|
||||
map.put("tariffStatus", tariff.getStatus().name());
|
||||
map.put("tariffEndDate", tariff.getEndTariff() != null ? tariff.getEndTariff().toString() : null);
|
||||
} else {
|
||||
map.put("tariff", null);
|
||||
map.put("tokens", 0);
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
Reference in New Issue
Block a user