poprawki
Deploy Polska Lokalnie / deploy (push) Successful in 12s

This commit is contained in:
2026-09-03 16:49:33 +02:00
parent 52e1f2cb96
commit d973b44e47
8 changed files with 531 additions and 119 deletions
@@ -332,6 +332,10 @@ public class AuthService {
}
user.setPhone(phone);
user.setAddress(request.address() != null && !request.address().isBlank() ? request.address().trim() : null);
// NIP: null = nie zmieniaj (zapis czesciowy nie moze skasowac NIP-u firmy), pusty = wyczysc.
if (request.nip() != null) {
user.setNip(request.nip().isBlank() ? null : request.nip().trim());
}
user.setContactPreference(request.contactPreference() != null ? request.contactPreference() : ContactPreference.EMAIL_AND_PHONE);
user.setPreferredLanguage(request.preferredLanguage() != null ? request.preferredLanguage() : PreferredLanguage.PL);
if (request.birthDate() != null && !request.birthDate().isBlank()) {
@@ -11,6 +11,9 @@ public record UpdateProfileRequest(
String phone,
String birthDate,
String address,
// NIP firmy. null = nie zmieniaj (zapisy czesciowe, np. jezyka, nie kasuja NIP-u);
// pusty ciag = wyczysc. Dotyczy kont firmowych.
String nip,
ContactPreference contactPreference,
PreferredLanguage preferredLanguage
) {
@@ -94,7 +94,72 @@ public class GusService {
throw new ResponseStatusException(HttpStatus.NOT_FOUND,
"Nie znaleziono firmy o podanym numerze NIP w rejestrze REGON.");
}
return new GusCompanyResponse(dane.get("Nazwa"), nip, dane.get("Regon"), buildAddress(dane));
String name = dane.get("Nazwa");
String regon = dane.get("Regon");
String address = buildAddress(dane);
// Wyszukiwanie (DaneSzukajPodmioty) zwraca skrocony rekord - dla czesci podmiotow (czesto
// jednoosobowych dzialalnosci) nazwa lub adres sa puste i sa dostepne dopiero w pelnym
// raporcie. Dociagamy go tylko wtedy, gdy czegos brakuje. Blad raportu nie moze zepsuc
// dzialajacych przypadkow, wiec zostajemy przy danych z wyszukiwania.
if ((isBlank(name) || isBlank(address)) && !isBlank(regon)) {
try {
Map<String, String> full = fullReport(endpoint, key, regon, dane.get("Typ"));
if (isBlank(name)) {
name = full.get("Nazwa");
}
if (isBlank(address)) {
String fullAddress = buildAddress(full);
if (!isBlank(fullAddress)) {
address = fullAddress;
}
}
} catch (ResponseStatusException ignored) {
// Pelny raport jest tylko uzupelnieniem - brak odpowiedzi nie przerywa rejestracji.
}
}
return new GusCompanyResponse(name, nip, regon, address);
}
/**
* Pelny raport podmiotu (DanePobierzPelnyRaport) - uzupelnia nazwe i adres, gdy nie ma ich w
* wyniku wyszukiwania. Nazwa raportu i nazwy pol zaleza od typu podmiotu (osoba prawna vs fizyczna).
* Zwrocone pola mapujemy na te same klucze co wyszukiwanie, zeby uzyc wspolnego buildAddress.
*/
private Map<String, String> fullReport(String endpoint, String key, String regon, String typ) {
boolean legal = typ != null && typ.trim().toUpperCase().startsWith("P");
String report = legal ? "BIR11OsPrawna" : "BIR11OsFizycznaDaneOgolne";
String prefix = legal ? "praw_" : "fiz_";
String body = """
<ns:DanePobierzPelnyRaport>
<ns:pRegon>%s</ns:pRegon>
<ns:pNazwaRaportu>%s</ns:pNazwaRaportu>
</ns:DanePobierzPelnyRaport>""".formatted(regon, report);
String response = call(endpoint, "DanePobierzPelnyRaport", body, session(endpoint, key));
Map<String, String> raw = firstDane(resultOf(response, "DanePobierzPelnyRaportResult"));
if (raw == null) {
return Map.of();
}
Map<String, String> mapped = new HashMap<>();
putIfPresent(mapped, "Nazwa", raw.get(prefix + "nazwa"));
putIfPresent(mapped, "Ulica", raw.get(prefix + "adSiedzUlica_Nazwa"));
putIfPresent(mapped, "NrNieruchomosci", raw.get(prefix + "adSiedzNumerNieruchomosci"));
putIfPresent(mapped, "NrLokalu", raw.get(prefix + "adSiedzNumerLokalu"));
putIfPresent(mapped, "KodPocztowy", raw.get(prefix + "adSiedzKodPocztowy"));
putIfPresent(mapped, "Miejscowosc", raw.get(prefix + "adSiedzMiejscowosc_Nazwa"));
return mapped;
}
private static void putIfPresent(Map<String, String> target, String key, String value) {
if (!isBlank(value)) {
target.put(key, value);
}
}
private static boolean isBlank(String value) {
return value == null || value.isBlank();
}
// Pusty wynik oznacza wygasla sesje - wtedy logujemy sie ponownie i probujemy raz jeszcze.
@@ -51,6 +51,11 @@ public record ListingDetailResponse(
Long ownerId,
// Zdjecie profilowe wlasciciela (data URL) albo null - wtedy karta sprzedajacego rysuje inicjaly.
String ownerAvatar,
// Typ konta wlasciciela ("PERSONAL"/"COMPANY") albo null, gdy ogloszenie nie ma konta w serwisie.
// Po tym front rozroznia oferte prywatna od firmowej (etykieta na karcie, jak na Otodom).
String ownerAccountType,
// Nazwa wlasciciela do etykiety oferty firmowej (dla konta firmowego). Dla oferty prywatnej pomijana.
String ownerName,
ListingStatus status,
Instant createdAt,
Long viewsCount,
@@ -63,7 +68,7 @@ public record ListingDetailResponse(
private static final double METERS_PER_DEGREE = 111_320d;
public static ListingDetailResponse from(PropertyListing listing, Long ownerId, String ownerAvatar) {
return from(listing, ownerId, ownerAvatar, false);
return from(listing, ownerId, ownerAvatar, null, null, false);
}
/**
@@ -72,7 +77,8 @@ public record ListingDetailResponse(
* przesuwane w obrebie obszaru. Przesuniecie liczymy z identyfikatora ogloszenia, wiec dla danej
* oferty jest zawsze takie samo - inaczej kolo skakaloby po mapie przy kazdym odswiezeniu.
*/
public static ListingDetailResponse from(PropertyListing listing, Long ownerId, String ownerAvatar, boolean masked) {
public static ListingDetailResponse from(PropertyListing listing, Long ownerId, String ownerAvatar,
String ownerAccountType, String ownerName, boolean masked) {
String street = masked ? null : listing.getStreet();
String building = masked ? null : listing.getBuilding();
String address = masked ? approximateAddress(listing) : listing.getAddress();
@@ -118,6 +124,8 @@ public record ListingDetailResponse(
listing.getOwnerEmail(),
ownerId,
ownerAvatar,
ownerAccountType,
ownerName,
listing.getStatus(),
listing.getCreatedAt(),
listing.getViewsCount(),
@@ -62,9 +62,11 @@ public class ListingService {
private ListingDetailResponse detailOf(PropertyListing listing, boolean masked) {
AppUser owner = ownerOf(listing);
if (owner == null) {
return ListingDetailResponse.from(listing, null, null, masked);
return ListingDetailResponse.from(listing, null, null, null, null, masked);
}
return ListingDetailResponse.from(listing, owner.getId(), userSettingsService.avatarFor(owner.getId()), masked);
String ownerAccountType = owner.getAccountType() == null ? null : owner.getAccountType().name();
return ListingDetailResponse.from(listing, owner.getId(), userSettingsService.avatarFor(owner.getId()),
ownerAccountType, owner.getFullName(), masked);
}
/**