Skip to content

Commit 1053e35

Browse files
committed
(TP-107) feat: add findAllByFilter method
1 parent 3ba77be commit 1053e35

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

rentplace/src/main/java/kattsyn/dev/rentplace/controllers/PropertyController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import kattsyn.dev.rentplace.dtos.ImageDTO;
1313
import kattsyn.dev.rentplace.dtos.PropertyCreateEditDTO;
1414
import kattsyn.dev.rentplace.dtos.PropertyDTO;
15+
import kattsyn.dev.rentplace.dtos.filters.PropertyFilterDTO;
1516
import kattsyn.dev.rentplace.services.PropertyService;
1617
import lombok.RequiredArgsConstructor;
1718
import org.springframework.http.HttpStatus;
@@ -76,6 +77,20 @@ public ResponseEntity<List<PropertyDTO>> getProperties() {
7677
return ResponseEntity.ok(properties);
7778
}
7879

80+
@Operation(
81+
summary = "Получение всех объявлений, с фильтрацией",
82+
description = "Позволяет получить все объявления, с фильтрацией"
83+
)
84+
@ApiResponses(value = {
85+
@ApiResponse(responseCode = "200", description = "Успешно", content = @Content(mediaType = "application/json", schema = @Schema(implementation = PropertyDTO[].class))),
86+
@ApiResponse(responseCode = "500", description = "Непредвиденная ошибка со стороны сервера", content = @Content)
87+
})
88+
@PostMapping(path = "/filtered/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
89+
public ResponseEntity<List<PropertyDTO>> getPropertiesByFilter(@Valid @ModelAttribute PropertyFilterDTO propertyFilter) {
90+
List<PropertyDTO> properties = propertyService.findAllByFilter(propertyFilter);
91+
return ResponseEntity.ok(properties);
92+
}
93+
7994
@Operation(
8095
summary = "Получение объявлений пользователя",
8196
description = "Позволяет получить все объявления пользователя по его токену. Только для авторизованных пользователей."

0 commit comments

Comments
 (0)