poprawki graficzne, zdjęcia, panel administarcyjny oraz układ stron
This commit is contained in:
@@ -74,7 +74,7 @@ public class DataSeeder implements CommandLineRunner {
|
||||
OfferType.SALE, PropertyType.HOUSE, "Kraków", "ul. Podgórska 8",
|
||||
new BigDecimal("1290000"), 145.0, 5, ListingStatus.PENDING));
|
||||
listingRepository.save(demoListing(
|
||||
"Kawalerka do wynajęcia — Wrocław", "Umeblowana kawalerka w centrum, dostępna od zaraz.",
|
||||
"Kawalerka do wynajęcia - Wrocław", "Umeblowana kawalerka w centrum, dostępna od zaraz.",
|
||||
OfferType.RENT, PropertyType.APARTMENT, "Wrocław", "ul. Krupnicza 3",
|
||||
new BigDecimal("2600"), 30.0, 1, ListingStatus.PENDING));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -58,6 +59,16 @@ public class ListingController {
|
||||
.body(response);
|
||||
}
|
||||
|
||||
// Edycja wlasnego ogloszenia (pelna aktualizacja pol; status bez zmian).
|
||||
@PutMapping("/{id}")
|
||||
public ListingDetailResponse update(
|
||||
@PathVariable Long id,
|
||||
@Valid @RequestBody ListingCreateRequest request,
|
||||
Authentication authentication
|
||||
) {
|
||||
return listingService.updateOwn(id, authentication.getName(), request);
|
||||
}
|
||||
|
||||
// Wstrzymanie/wznowienie wlasnego ogloszenia (status=PAUSED lub APPROVED).
|
||||
@PatchMapping("/{id}/status")
|
||||
public ListingResponse updateStatus(
|
||||
|
||||
@@ -100,6 +100,33 @@ public class ListingService {
|
||||
request.district(), request.street(), request.contactName());
|
||||
|
||||
PropertyListing listing = new PropertyListing();
|
||||
applyRequest(listing, request);
|
||||
listing.setOwnerEmail(ownerEmail);
|
||||
listing.setStatus(ListingStatus.PENDING);
|
||||
|
||||
return ListingDetailResponse.from(listingRepository.save(listing));
|
||||
}
|
||||
|
||||
// Edycja wlasnego ogloszenia. Waliduje tresc filtrem, ale NIE zmienia statusu -
|
||||
// zatwierdzone ogloszenie pozostaje widoczne od razu po zapisie zmian.
|
||||
@Transactional
|
||||
public ListingDetailResponse updateOwn(Long id, String ownerEmail, ListingCreateRequest request) {
|
||||
PropertyListing listing = listingRepository.findById(id)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Listing not found"));
|
||||
requireOwner(listing, ownerEmail);
|
||||
|
||||
textModerationService.validateOrThrow(
|
||||
request.title(), request.description(), request.city(), request.address(),
|
||||
request.district(), request.street(), request.contactName());
|
||||
|
||||
applyRequest(listing, request);
|
||||
// ownerEmail i status pozostaja bez zmian.
|
||||
|
||||
return ListingDetailResponse.from(listingRepository.save(listing));
|
||||
}
|
||||
|
||||
// Wspolne mapowanie pol requestu na encje (uzywane przez create i updateOwn).
|
||||
private void applyRequest(PropertyListing listing, ListingCreateRequest request) {
|
||||
listing.setTitle(request.title().trim());
|
||||
listing.setDescription(request.description().trim());
|
||||
listing.setOfferType(request.offerType());
|
||||
@@ -140,11 +167,6 @@ public class ListingService {
|
||||
listing.setPhotos(photos);
|
||||
listing.setCoverPhoto(photos.isEmpty() ? null : photos.get(0));
|
||||
listing.setVirtualTourUrl(normalizeVirtualTourUrl(request.virtualTourUrl()));
|
||||
|
||||
listing.setOwnerEmail(ownerEmail);
|
||||
listing.setStatus(ListingStatus.PENDING);
|
||||
|
||||
return ListingDetailResponse.from(listingRepository.save(listing));
|
||||
}
|
||||
|
||||
// --- Moderacja (admin) ---
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PropertyListing {
|
||||
@Column(nullable = false, length = 160)
|
||||
private String title;
|
||||
|
||||
@Column(nullable = false, length = 3000)
|
||||
@Column(nullable = false, columnDefinition = "text")
|
||||
private String description;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MailConfigController {
|
||||
SendResult result = emailSender.send(
|
||||
mailConfigService.getSmtp(),
|
||||
request.recipient().trim(),
|
||||
"Test konfiguracji SMTP – Polska Lokalnie",
|
||||
"Test konfiguracji SMTP - Polska Lokalnie",
|
||||
"<p>To jest wiadomość testowa potwierdzająca poprawną konfigurację poczty SMTP.</p>");
|
||||
return TestResultResponse.from(result);
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class MailConfigController {
|
||||
SendResult result = smsSender.send(
|
||||
mailConfigService.getSms(),
|
||||
request.recipient().trim(),
|
||||
"Test konfiguracji bramki SMS – Polska Lokalnie");
|
||||
"Test konfiguracji bramki SMS - Polska Lokalnie");
|
||||
return TestResultResponse.from(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user