фильтр по числу не робит

This commit is contained in:
VictoriaPresnyakova 2023-05-10 16:58:54 +04:00
parent 61bc65a4ea
commit e111e75e54
4 changed files with 8 additions and 9 deletions

View File

@ -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 => {

View File

@ -51,9 +51,9 @@ public class ComponentController {
@GetMapping("/filter")
public List<ComponentDTO> 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();
}

View File

@ -8,10 +8,8 @@ import ru.ulstu.is.sbapp.repair.model.Component;
import java.util.List;
public interface ComponentRepository extends JpaRepository<Component, Long> {
@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<Component> findFilteredComponents(@Param("id") Long id,
@Param("componentName") String componentName,
@Param("amount") int amount );
@Param("amount") String amount );
}

View File

@ -34,7 +34,8 @@ public class ComponentService {
}
@Transactional(readOnly = true)
public List<Component> findFilteredComponents(Long id, String componentName, int amount) {
public List<Component> findFilteredComponents(Long id, String componentName, String amount) {
return componentRepository.findFilteredComponents(id, componentName, amount);
}