From 6565c18958cc10af0126683aa502fe77ee949841 Mon Sep 17 00:00:00 2001 From: backdev-1 Date: Fri, 8 May 2026 15:19:17 +0700 Subject: [PATCH] dev add method link --- .../soune/nocopy/handler/UserInfoHandler.java | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/ru/soune/nocopy/handler/UserInfoHandler.java b/src/main/java/ru/soune/nocopy/handler/UserInfoHandler.java index 30b8a80..e106344 100644 --- a/src/main/java/ru/soune/nocopy/handler/UserInfoHandler.java +++ b/src/main/java/ru/soune/nocopy/handler/UserInfoHandler.java @@ -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 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;