diff --git a/src/main/java/ru/job4j/cars/repository/HibernatePriceHistoryRepository.java b/src/main/java/ru/job4j/cars/repository/HibernatePriceHistoryRepository.java new file mode 100644 index 0000000..bf66fa3 --- /dev/null +++ b/src/main/java/ru/job4j/cars/repository/HibernatePriceHistoryRepository.java @@ -0,0 +1,28 @@ +package ru.job4j.cars.repository; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Repository; +import ru.job4j.cars.model.PriceHistory; + +@Repository +@AllArgsConstructor +public class HibernatePriceHistoryRepository implements PriceHistoryRepository { + + private final CrudRepository crudRepository; + + /** + * Получить из БД всю историю цен по id объявления. + * @param id ID объявления. + * @return множество историй цен. + */ + @Override + public Set getPriceHistoriesByPostId(int id) { + return new HashSet<>(crudRepository.query("FROM PriceHistory WHERE post_id = :pId", + PriceHistory.class, + Map.of("pId", id))); + } + +} \ No newline at end of file diff --git a/src/main/java/ru/job4j/cars/repository/PriceHistoryRepository.java b/src/main/java/ru/job4j/cars/repository/PriceHistoryRepository.java new file mode 100644 index 0000000..7d9ac45 --- /dev/null +++ b/src/main/java/ru/job4j/cars/repository/PriceHistoryRepository.java @@ -0,0 +1,10 @@ +package ru.job4j.cars.repository; + +import java.util.Set; +import ru.job4j.cars.model.PriceHistory; + +public interface PriceHistoryRepository { + + Set getPriceHistoriesByPostId(int id); + +} \ No newline at end of file diff --git a/src/main/java/ru/job4j/cars/service/PriceHistoryService.java b/src/main/java/ru/job4j/cars/service/PriceHistoryService.java new file mode 100644 index 0000000..e1b6cd6 --- /dev/null +++ b/src/main/java/ru/job4j/cars/service/PriceHistoryService.java @@ -0,0 +1,10 @@ +package ru.job4j.cars.service; + +import java.util.Set; +import ru.job4j.cars.model.PriceHistory; + +public interface PriceHistoryService { + + Set getPriceHistoriesByPostId(int id); + +} \ No newline at end of file diff --git a/src/main/java/ru/job4j/cars/service/SimplePriceHistoryService.java b/src/main/java/ru/job4j/cars/service/SimplePriceHistoryService.java new file mode 100644 index 0000000..9b929ac --- /dev/null +++ b/src/main/java/ru/job4j/cars/service/SimplePriceHistoryService.java @@ -0,0 +1,20 @@ +package ru.job4j.cars.service; + +import java.util.Set; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import ru.job4j.cars.model.PriceHistory; +import ru.job4j.cars.repository.PriceHistoryRepository; + +@Service +@AllArgsConstructor +public class SimplePriceHistoryService implements PriceHistoryService { + + private final PriceHistoryRepository priceHistoryRepository; + + @Override + public Set getPriceHistoriesByPostId(int id) { + return priceHistoryRepository.getPriceHistoriesByPostId(id); + } + +} \ No newline at end of file diff --git a/src/main/resources/templates/posts/edit.html b/src/main/resources/templates/posts/edit.html new file mode 100644 index 0000000..30eb2d1 --- /dev/null +++ b/src/main/resources/templates/posts/edit.html @@ -0,0 +1,149 @@ + + + + + + + + + + + + Редактирование объявления + + + +
+
+
+
+
+ Редактирование объявления +
+
+
+ + + + + +
+ Параметры автомобиля +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+ + \ No newline at end of file