diff --git a/angular/src/app/app.component.html b/angular/src/app/app.component.html
index ab45df1..3476291 100644
--- a/angular/src/app/app.component.html
+++ b/angular/src/app/app.component.html
@@ -5,7 +5,7 @@
-
+
diff --git a/angular/src/app/app.module.ts b/angular/src/app/app.module.ts
index 9a7da97..d02aa24 100644
--- a/angular/src/app/app.module.ts
+++ b/angular/src/app/app.module.ts
@@ -1,7 +1,7 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
-import { ReactiveFormsModule } from '@angular/forms';
-import {HttpClient, HttpClientModule} from '@angular/common/http';
+import { ReactiveFormsModule} from '@angular/forms';
+import { HttpClient, HttpClientModule} from '@angular/common/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { FormComponent } from './form/form.component';
@@ -28,7 +28,6 @@ import { FindAdvertisementComponent } from './find-advertisement/find-advertisem
ContactformComponent,
FindAdvertisementComponent
// PropertyDetailsComponent
-
],
imports: [
BrowserModule,
diff --git a/angular/src/app/contactform/contactform.component.ts b/angular/src/app/contactform/contactform.component.ts
index fed8704..98e8813 100644
--- a/angular/src/app/contactform/contactform.component.ts
+++ b/angular/src/app/contactform/contactform.component.ts
@@ -1,53 +1,57 @@
import { Component } from '@angular/core';
+import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import { HttpClient } from '@angular/common/http';
-
@Component({
selector: 'app-contactform',
template: `
`
})
export class ContactformComponent {
- name: string = '';
- email: string = '';
- message: string = '';
+ contactForm: FormGroup;
+
+
+ constructor(private fb: FormBuilder, private http: HttpClient) {
+ this.contactForm = new FormGroup({
+ name: new FormControl('', Validators.required),
+ email: new FormControl('', Validators.required),
+ message: new FormControl('', Validators.required)
+ });
+ }
+
+
- constructor(private http: HttpClient) {}
submitForm() {
- const contactForm = {
- name: this.name,
- email: this.email,
- message: this.message
- };
+ if (this.contactForm.invalid) {
+ return;
+ }
+
+ const contactForm = this.contactForm.value;
this.http.post('/property/contact', contactForm).subscribe(
() => {
alert('Contact form submitted successfully!');
- // Reset the form fields
- this.name = '';
- this.email = '';
- this.message = '';
+ this.contactForm.reset();
},
-
(error) => {
console.error('Failed to submit contact form:', error);
alert('Failed to submit contact form. Please try again later.');
diff --git a/angular/src/app/property-list/property-list.component.html b/angular/src/app/property-list/property-list.component.html
index fece73a..09fb0fa 100644
--- a/angular/src/app/property-list/property-list.component.html
+++ b/angular/src/app/property-list/property-list.component.html
@@ -23,6 +23,7 @@ Properties
+
diff --git a/angular/src/app/property-list/property-list.component.ts b/angular/src/app/property-list/property-list.component.ts
index fd9d968..4cb775e 100644
--- a/angular/src/app/property-list/property-list.component.ts
+++ b/angular/src/app/property-list/property-list.component.ts
@@ -43,23 +43,23 @@ export class PropertyListComponent implements OnInit {
fallbackImageUrl = 'assets/No-image-available.jpg';
selectedProperty: Property | null = null;
showContactForm: boolean = false; // Define the showContactForm property
- selectedCity: string = '';
- maxRent: number = 0;
+ selectedCity: string = 'All Cities';
+ maxRent: number = 10000;
+ minRent: number = 0;
selectedGender: string = '';
id: number = 2;
distinctCities: string[] = [];
showFilterButtons: boolean = false;
topN: number = 10;
-
currentPage = 1;
- minRent: number = 0;
- constructor(
+ sortBy: String = "rent";
+ sortDirection: String = "asc";
+ constructor(
private http: HttpClient,
private router: Router,
private activatedRoute: ActivatedRoute,
private propertyService: PropertyService
-
-) {
+ ) {
}
ngOnInit(): void {
@@ -85,6 +85,31 @@ export class PropertyListComponent implements OnInit {
this.showContactForm = true;
}
+ nextPage(): void {
+ if (this.properties.last) {
+ // If it's the last page, do nothing
+ return;
+ }
+
+
+
+ // Increment the current page number
+ this.currentPage++;
+
+
+ this.getProperties().subscribe(
+ (data: Page
) => {
+ console.log(data); // Log the API response
+ this.properties = data;
+ this.properties.content = this.properties.content.slice(0, 1000);
+ },
+ (error) => {
+ console.error('Error retrieving properties:', error);
+ }
+ );
+ }
+
+
getDistinctCities(): void {
this.propertyService.findAllDistinctCities().subscribe(
(data: { cities: string[] }) => {
@@ -99,77 +124,23 @@ export class PropertyListComponent implements OnInit {
);
}
- applyInit(): void {
- console.log('Apply Filters clicked');
- const apiUrl = 'http://localhost:8080/property';
- const params: any = {};
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- params.city = this.selectedCity;
- }
- // Make the API call with the updated URL and query parameters
- this.http.get>(apiUrl, { params }).subscribe(
- (data: Page) => {
- console.log(data); // Log the API response
- this.properties = data;
- this.properties.content = this.properties.content.slice(0, 1000);
- },
- (error) => {
- console.error('Error retrieving properties:', error);
- }
- );
- }
+ applyInit(): void {
- applyFilters(): void {
- console.log('Apply Filters clicked');
- const apiUrl = 'http://localhost:8080/property';
- const params: any = {};
-
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- params.city = this.selectedCity;
- }
-
- if (this.maxRent) {
- params.maxRent = this.maxRent;
- }
- if (this.minRent) {
- params.minRent = this.minRent;
- }
- if (this.selectedGender) {
- params.gender = this.selectedGender;
- }
+ // Reset the filter values
+ this.selectedCity = '';
+ this.minRent = 0;
+ this.maxRent = 10000;
+ this.selectedGender = '';
+ this.currentPage = 1;
+ this.sortBy = 'rent';
+ this.sortDirection = 'asc';
// Make the API call with the updated URL and query parameters
- this.http.get>(apiUrl, { params }).subscribe(
+ this.getProperties().subscribe(
(data: Page) => {
console.log(data); // Log the API response
this.properties = data;
-
- // Filter the properties based on the selected criteria
- this.properties.content = this.properties.content.filter(property => {
- let meetsCriteria = true;
-
- if (this.selectedCity && this.selectedCity !== 'All Cities' && property.city !== this.selectedCity) {
- meetsCriteria = false;
- }
- if (this.minRent && property.rent < this.minRent) {
- meetsCriteria = false;
- }
- if (this.maxRent && property.rent > this.maxRent) {
- meetsCriteria = false;
- }
-
- if (this.selectedGender && property.gender !== this.selectedGender) {
- meetsCriteria = false;
- }
-
- return meetsCriteria;
- });
-
- this.properties.content = this.properties.content.slice(0, 1000);
-
- // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
- this.showFilterButtons = true;
},
(error) => {
console.error('Error retrieving properties:', error);
@@ -178,44 +149,61 @@ export class PropertyListComponent implements OnInit {
}
- filterRentDown(): void {
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- const apiUrl = 'http://localhost:8080/property';
- const params: any = {};
-
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- params.city = this.selectedCity;
- }
-
- if (this.maxRent) {
- params.maxRent = this.maxRent;
- }
- if (this.minRent) {
- params.minRent = this.minRent;
- }
- if (this.selectedGender) {
- params.gender = this.selectedGender;
- }
+ applyFilters(): void {
+ if (this.selectedCity === 'All Cities') {
+ // Retrieve all properties without filtering by city
+ this.getProperties().subscribe(
+ (data: Page) => {
+ console.log(data); // Log the API response
+ this.properties = data;
+ // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
+ this.showFilterButtons = true;
+ // Display only the top N properties
+ this.properties.content = this.properties.content.slice(0, this.topN);
+ },
+ (error) => {
+ console.error('Error retrieving properties:', error);
+ }
+ );
+ } else {
+ // Apply the regular filtering logic
+ this.currentPage = 0;
- // Make the API call with the updated URL and query parameters
- this.http.get>(apiUrl, { params }).pipe(
+ this.getProperties().pipe(
map((data: Page) => {
- // Filter the properties based on rent within the specified range
- data.content = data.content.filter(property => property.rent >= this.minRent && property.rent <= this.maxRent);
- return data;
- }),
- tap((data: Page) => {
- // Sort the properties based on rent in descending order
- data.content.sort((a, b) => b.rent - a.rent);
- return data;
+ // Filter the properties based on the selected criteria
+ return data.content.filter(property => {
+ let meetsCriteria = true;
+
+ if (property.city !== this.selectedCity) {
+ meetsCriteria = false;
+ }
+ if (this.minRent && property.rent < this.minRent) {
+ meetsCriteria = false;
+ }
+ if (this.maxRent && property.rent > this.maxRent) {
+ meetsCriteria = false;
+ }
+ if (this.selectedGender && property.gender !== this.selectedGender) {
+ meetsCriteria = false;
+ }
+
+ return meetsCriteria;
+ });
}),
- tap((data: Page) => {
- // Get the top N properties
- this.properties.content = data.content.slice(0, this.topN);
+ tap((filteredProperties: Property[]) => {
+ console.log(filteredProperties); // Log the filtered properties
+
+ // Set the filtered properties to the component's properties
+ this.properties.content = filteredProperties;
+ // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
+ this.showFilterButtons = true;
+ // Display only the top N properties
+ this.properties.content = this.properties.content.slice(0, this.topN);
}),
catchError((error) => {
console.error('Error retrieving properties:', error);
- return of(null);
+ return [];
})
).subscribe();
}
@@ -223,133 +211,118 @@ export class PropertyListComponent implements OnInit {
filterRentUp(): void {
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- const apiUrl = 'http://localhost:8080/property';
- const params: any = {};
-
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- params.city = this.selectedCity;
- }
-
- if (this.maxRent) {
- params.maxRent = this.maxRent;
- }
- if (this.minRent) {
- params.minRent = this.minRent;
- }
- if (this.selectedGender) {
- params.gender = this.selectedGender;
- }
+ this.sortBy = "rent";
+ this.sortDirection = "asc";
+ this.getProperties().pipe(
+ map((data: Page) => {
+ // Get all properties within the rent range
+ this.properties.content = data.content;
- // Make the API call with the updated URL and query parameters
- this.http.get>(apiUrl, { params }).pipe(
- map((data: Page) => {
- // Filter the properties based on rent within the specified range
- data.content = data.content.filter(property => property.rent >= this.minRent && property.rent <= this.maxRent);
- return data;
- }),
- tap((data: Page) => {
- // Sort the properties based on rent in ascending order
- data.content.sort((a, b) => a.rent - b.rent);
- return data;
- }),
- tap((data: Page) => {
- // Get the top N properties
- this.properties.content = data.content.slice(0, this.topN);
- }),
- catchError((error) => {
- console.error('Error retrieving properties:', error);
- return of(null);
- })
- ).subscribe();
- }
+ // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
+ this.showFilterButtons = true;
+ }),
+ catchError((error) => {
+ console.error('Error retrieving properties:', error);
+ return [];
+ })
+ ).subscribe();
}
- filterSqmUp(): void {
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- const apiUrl = 'http://localhost:8080/property';
- const params: any = {};
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- params.city = this.selectedCity;
- }
+ filterRentDown(): void {
- if (this.maxRent) {
- params.maxRent = this.maxRent;
- }
- if (this.minRent) {
- params.minRent = this.minRent;
- }
- if (this.selectedGender) {
- params.gender = this.selectedGender;
- }
+ this.sortBy = "rent";
+ this.sortDirection = "desc";
- // Make the API call with the updated URL and query parameters
- this.http.get>(apiUrl, { params }).pipe(
- map((data: Page) => {
- // Calculate rent per sqm for each property
- data.content.forEach(property => {
- property.rentPerSqm = property.rent / property.areaSqm;
- });
+ this.getProperties().pipe(
- // Sort the properties based on rent per sqm in ascending order
- data.content.sort((a, b) => a.rentPerSqm - b.rentPerSqm);
+ map((data: Page) => {
+ // Get all properties within the rent range
+ this.properties.content = data.content;
- return data;
- }),
- tap((data: Page) => {
- // Get the top N properties
- this.properties.content = data.content.slice(0, this.topN);
- }),
- catchError((error) => {
- console.error('Error retrieving properties:', error);
- return of(null);
- })
- ).subscribe();
- }
+ // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
+ this.showFilterButtons = true;
+ }),
+ catchError((error) => {
+ console.error('Error retrieving properties:', error);
+ return [];
+ })
+ ).subscribe();
}
+ filterSqmUp(): void {
+ this.sortBy = "rentSqm";
+ this.sortDirection = "asc";
+
+ this.getProperties().pipe(
+
+ map((data: Page) => {
+ // Get all properties within the rent range
+ this.properties.content = data.content;
+
+ // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
+ this.showFilterButtons = true;
+ }),
+ catchError((error) => {
+ console.error('Error retrieving properties:', error);
+ return [];
+ })
+ ).subscribe();
+ }
filterSqmDown(): void {
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- const apiUrl = 'http://localhost:8080/property';
- const params: any = {};
+ this.sortBy = "rentSqm";
+ this.sortDirection = "desc";
- if (this.selectedCity && this.selectedCity !== 'All Cities') {
- params.city = this.selectedCity;
- }
- if (this.maxRent) {
- params.maxRent = this.maxRent;
- }
- if (this.minRent) {
- params.minRent = this.minRent;
- }
- if (this.selectedGender) {
- params.gender = this.selectedGender;
- }
+ this.getProperties().pipe(
- // Make the API call with the updated URL and query parameters
- this.http.get>(apiUrl, { params }).pipe(
- map((data: Page) => {
- // Calculate rent per sqm for each property
- data.content.forEach(property => {
- property.rentPerSqm = property.rent / property.areaSqm;
- });
+ map((data: Page) => {
+ // Get all properties within the rent range
+ this.properties.content = data.content;
- // Sort the properties based on rent per sqm in descending order
- data.content.sort((a, b) => b.rentPerSqm - a.rentPerSqm);
+ // Set the flag to show the filter buttons only after the "Apply Filters" button is clicked
+ this.showFilterButtons = true;
+ }),
+ catchError((error) => {
+ console.error('Error retrieving properties:', error);
+ return [];
+ })
+ ).subscribe();
+ }
+ private getProperties(): Observable> {
+ let params: any = {
+ sortBy: this.sortBy,
+ sortDirection: this.sortDirection,
+ page: this.currentPage,
+ gender: this.selectedGender,
+ minRent: this.minRent,
+ maxRent: this.maxRent
+ };
- return data;
- }),
- tap((data: Page) => {
- // Get the top N properties
- this.properties.content = data.content.slice(0, this.topN);
- }),
- catchError((error) => {
- console.error('Error retrieving properties:', error);
- return of(null);
- })
- ).subscribe();
+ if (this.selectedCity && this.selectedCity !== 'All Cities') {
+ params.city = this.selectedCity;
}
+
+ return this.http.get>(this.apiUrl, { params }).pipe(
+ tap((data: Page) => {
+ console.log(data); // Log the API response
+ this.properties = data;
+ }),
+ catchError((error) => {
+ console.error('Error retrieving properties:', error);
+ return of({
+ content: [],
+ totalPages: 0,
+ totalElements: 0,
+ number: 0,
+ size: 0,
+ first: false,
+ last: false,
+ numberOfElements: 0,
+ empty: false,
+ properties: []
+ });
+ })
+ );
}
}
diff --git a/src/main/java/com/example/studenthousing/controller/PropertyController.java b/src/main/java/com/example/studenthousing/controller/PropertyController.java
index db81467..45c3ead 100644
--- a/src/main/java/com/example/studenthousing/controller/PropertyController.java
+++ b/src/main/java/com/example/studenthousing/controller/PropertyController.java
@@ -4,7 +4,7 @@
import com.example.studenthousing.repository.PropertyRepository;
import com.example.studenthousing.services.PropertyService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
+import org.springframework.data.domain.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@@ -29,28 +29,47 @@ public class PropertyController {
public PropertyController(PropertyService propertyService) {
this.propertyService = propertyService;
}
- @GetMapping(value = "/property", produces = {MediaType.APPLICATION_JSON_VALUE, "text/csv"})
+ @GetMapping(value = "/property", produces = { MediaType.APPLICATION_JSON_VALUE, "text/csv" })
public ResponseEntity> getPropertyList(
@RequestParam(required = false) String city,
- @RequestParam(defaultValue = "json") String format) {
+ @RequestParam(defaultValue = "json") String format,
+ @RequestParam(defaultValue = "0") int page,
+ @RequestParam(defaultValue = "10") int size,
+ @RequestParam(defaultValue = "rent") String sortBy,
+ @RequestParam(defaultValue = "asc") String sortDirection,
+ @RequestParam(required = false) Integer minRent,
+ @RequestParam(required = false) Integer maxRent) {
+
+ Sort.Direction direction = sortDirection.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC;
+
+ Pageable pageable = PageRequest.of(page, size, Sort.by(direction, sortBy));
+
Page properties;
- if (city != null) {
- properties = propertyService.getPropertiesByCity(city);
+ if (minRent != null && maxRent != null) {
+ if (city != null) {
+ properties = propertyService.getPropertiesByCityAndRentRange(city, minRent, maxRent, pageable);
+ } else {
+ properties = propertyService.getPropertiesByRentRange(minRent, maxRent, pageable);
+ }
+ } else if (city != null) {
+ properties = propertyService.getPropertiesByCity(city, pageable);
} else {
- properties = propertyService.getProperties();
+ properties = propertyService.getAllProperties(pageable);
}
- HttpHeaders headers = new HttpHeaders();
+
if (format.equalsIgnoreCase("csv")) {
- headers.setContentType(MediaType.parseMediaType("text/csv"));
String csvData = convertPropertiesToCSV(properties.getContent());
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.TEXT_PLAIN);
+ headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=properties.csv");
return new ResponseEntity<>(csvData, headers, HttpStatus.OK);
} else {
- headers.setContentType(MediaType.APPLICATION_JSON);
- return new ResponseEntity<>(properties, headers, HttpStatus.OK);
+ return new ResponseEntity<>(properties, HttpStatus.OK);
}
}
+
private String convertPropertiesToCSV(List properties) {
StringBuilder csvBuilder = new StringBuilder();
csvBuilder.append("id,external_id,area_sqm,city,cover_image_url,furnish,latitude,longitude,postal_code,property_type,raw_availability,rent,rent_detail,title,additional_costs,deposit,description_non_translated,description_translated,energy_label,gender,internet,is_room_active,kitchen,living,match_age,match_capacity,match_gender,match_languages,match_status,page_description,page_title,pets,registration_costs,roommates,shower,smoking_inside,toilet\n");
diff --git a/src/main/java/com/example/studenthousing/model/Property.java b/src/main/java/com/example/studenthousing/model/Property.java
index 8da7def..49535b5 100644
--- a/src/main/java/com/example/studenthousing/model/Property.java
+++ b/src/main/java/com/example/studenthousing/model/Property.java
@@ -1,5 +1,7 @@
package com.example.studenthousing.model;
+import org.hibernate.annotations.Formula;
+
import javax.persistence.*;
@Entity
@@ -84,6 +86,17 @@ public class Property {
private String smokingInside;
@Column(name="toilet")
private String toilet;
+ @Formula("rent/area_sqm")
+ private Float rentSqm;
+ public float getRentSqm() {
+ return rentSqm;
+ }
+
+ public void setRentSqm(Float rentSqm) {
+ this.rentSqm = rentSqm;
+ }
+
+
public Property() {
}
public int getId() {
diff --git a/src/main/java/com/example/studenthousing/repository/PropertyRepository.java b/src/main/java/com/example/studenthousing/repository/PropertyRepository.java
index 3f8ac69..8dfc902 100644
--- a/src/main/java/com/example/studenthousing/repository/PropertyRepository.java
+++ b/src/main/java/com/example/studenthousing/repository/PropertyRepository.java
@@ -18,9 +18,13 @@ public interface PropertyRepository extends JpaRepository {
@Query("SELECT DISTINCT p.city FROM Property p WHERE p.isRoomActive = 'true' ORDER BY p.city ASC ")
List findAllDistinctCities();
- @Query("SELECT p FROM Property p WHERE p.city = :city AND p.isRoomActive = 'true' ORDER BY p.rent ASC ")
+// @Query("SELECT p FROM Property p WHERE p.city = :city AND p.isRoomActive = 'true' ORDER BY p.rent ASC ")
Page findByCity(@Param("city") String city, Pageable pageable);
@Query("SELECT p FROM Property p WHERE p.id = :id AND p.isRoomActive = 'true' ")
Page findById(@Param("id") Integer id, Pageable pageable);
+
+ Page findByRentBetween(int minRent, int maxRent, Pageable pageable);
+ Page findByCityAndRentBetween(String city, int minRent, int maxRent, Pageable pageable);
+
}
diff --git a/src/main/java/com/example/studenthousing/services/PropertyService.java b/src/main/java/com/example/studenthousing/services/PropertyService.java
index ca13a07..c55e8aa 100644
--- a/src/main/java/com/example/studenthousing/services/PropertyService.java
+++ b/src/main/java/com/example/studenthousing/services/PropertyService.java
@@ -6,6 +6,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
@@ -24,6 +25,20 @@ public PropertyService() {
// Create the EntityManagerFactory
entityManagerFactory = Persistence.createEntityManagerFactory("StudentHousing");
}
+ public Page getProperties(Pageable pageable) {
+ return propertyRepository.findAll(pageable);
+ }
+
+ public Page getPropertiesByRentRange(Integer minRent, Integer maxRent, Pageable pageable) {
+ return propertyRepository.findByRentBetween(minRent, maxRent, pageable);
+ }
+ public Page getPropertiesByCityAndRentRange(String city, Integer minRent, Integer maxRent, Pageable pageable) {
+ return propertyRepository.findByCityAndRentBetween(city, minRent, maxRent, pageable);
+ }
+
+
+
+
public Property newProperty(int id, String externalId, int areaSqm, String city, String coverImageUrl, String furnish, String latitude, String longitude, String postalCode, String propertyType, String rawAvailability, int rent, String rentDetail, String title, int additionalCosts, int deposit, String descriptionNonTranslated, String descriptionTranslated, String energyLabel, String gender, String internet, String isRoomActive, String kitchen, String living, String matchAge, String matchCapacity, String matchGender, String matchLanguages, String matchStatus, String pageDescription, String pageTitle, String pets, int registrationCost, String roommates, String shower, String smokingInside, String toilet) {
Property p = new Property();
@@ -67,21 +82,25 @@ public Property newProperty(int id, String externalId, int areaSqm, String city,
return propertyRepository.save(p);
}
- public Page getProperties() {
- Pageable pageable = PageRequest.of(0, 1000);
+ public Page getAllProperties(int page, int pageSize) {
+ Pageable pageable = PageRequest.of(page, pageSize);
+ return propertyRepository.findAll(pageable);
+ }
+ public Page getAllProperties(Pageable pageable) {
return propertyRepository.findAll(pageable);
}
+
public Optional getPropertyById(int propertyId) {
return propertyRepository.findById(propertyId);
}
public List getDistinctCities() {
return propertyRepository.findAllDistinctCities();
}
- public Page getPropertiesByCity(String city) {
- Pageable pageable = PageRequest.of(0, 1000);
- return propertyRepository.findByCity(city,pageable);
+ public Page getPropertiesByCity(String city, Pageable pageable) {
+ return propertyRepository.findByCity(city, pageable);
}
+
public Page getPropertiesById(int id) {
Pageable pageable = PageRequest.of(0, 1000);
return propertyRepository.findById(id,pageable);