diff --git a/front/vue-project/src/components/Components.vue b/front/vue-project/src/components/Components.vue index 9e31d65..ba6ff26 100644 --- a/front/vue-project/src/components/Components.vue +++ b/front/vue-project/src/components/Components.vue @@ -33,7 +33,7 @@ export default { if (urlParams != "") { urlParams += "&"; } - urlParams += "amount=" + this.serialNumber; + urlParams += "amount=" + this.amount; } DataService.readAll(this.dataFilterUrl + urlParams, (data) => new Component(data)) .then(data => { diff --git a/src/main/java/ru/ulstu/is/sbapp/repair/controller/ComponentController.java b/src/main/java/ru/ulstu/is/sbapp/repair/controller/ComponentController.java index 58252e3..5a83230 100644 --- a/src/main/java/ru/ulstu/is/sbapp/repair/controller/ComponentController.java +++ b/src/main/java/ru/ulstu/is/sbapp/repair/controller/ComponentController.java @@ -51,9 +51,9 @@ public class ComponentController { @GetMapping("/filter") public List getFilteredComponents(@RequestParam(value = "id", required = false) Long id, - @RequestParam(value = "componentName", required = false) String modelName, - @RequestParam(value = "amount", required = false) int amount ) { - return componentService.findFilteredComponents(id, modelName, amount).stream() + @RequestParam(value = "componentName", required = false) String componentName, + @RequestParam(value = "amount", required = false) String amount ) { + return componentService.findFilteredComponents(id, componentName, amount).stream() .map(ComponentDTO::new) .toList(); } diff --git a/src/main/java/ru/ulstu/is/sbapp/repair/repository/ComponentRepository.java b/src/main/java/ru/ulstu/is/sbapp/repair/repository/ComponentRepository.java index bfd7e28..e69eac8 100644 --- a/src/main/java/ru/ulstu/is/sbapp/repair/repository/ComponentRepository.java +++ b/src/main/java/ru/ulstu/is/sbapp/repair/repository/ComponentRepository.java @@ -8,10 +8,8 @@ import ru.ulstu.is.sbapp.repair.model.Component; import java.util.List; public interface ComponentRepository extends JpaRepository { - @Query(value = "select * from Component where (\"ID\" = :id or :id is Null) and " + - "(\"NAME\" = :componentName or :componentName is Null) and " + - "(\"AMOUNT\" = :amount or :amount is Null)", nativeQuery = true) + @Query(value = "select s from Component s where (s.id = :id or :id is Null) and (s.amount = :amount or :amount is Null) and (s.componentName = :componentName or :componentName is Null)") public List findFilteredComponents(@Param("id") Long id, @Param("componentName") String componentName, - @Param("amount") int amount ); + @Param("amount") String amount ); } diff --git a/src/main/java/ru/ulstu/is/sbapp/repair/service/ComponentService.java b/src/main/java/ru/ulstu/is/sbapp/repair/service/ComponentService.java index cb643fa..70a6625 100644 --- a/src/main/java/ru/ulstu/is/sbapp/repair/service/ComponentService.java +++ b/src/main/java/ru/ulstu/is/sbapp/repair/service/ComponentService.java @@ -34,7 +34,8 @@ public class ComponentService { } @Transactional(readOnly = true) - public List findFilteredComponents(Long id, String componentName, int amount) { + public List findFilteredComponents(Long id, String componentName, String amount) { + return componentRepository.findFilteredComponents(id, componentName, amount); }