fix(chore):
Some checks failed
Build, Test, Deploy and Analysis / qodana (push) Failing after 13s
Build, Test, Deploy and Analysis / test-backend (push) Successful in 38s
Build, Test, Deploy and Analysis / build-and-push (push) Successful in 34s
Build, Test, Deploy and Analysis / deploy (push) Successful in 9s
Some checks failed
Build, Test, Deploy and Analysis / qodana (push) Failing after 13s
Build, Test, Deploy and Analysis / test-backend (push) Successful in 38s
Build, Test, Deploy and Analysis / build-and-push (push) Successful in 34s
Build, Test, Deploy and Analysis / deploy (push) Successful in 9s
This commit is contained in:
@@ -16,6 +16,7 @@ import com.printcalculator.repository.NozzleOptionRepository;
|
||||
import com.printcalculator.repository.PrinterMachineRepository;
|
||||
import com.printcalculator.service.OrcaProfileResolver;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -54,13 +55,13 @@ public class OptionsController {
|
||||
}
|
||||
|
||||
@GetMapping("/api/calculator/options")
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<OptionsResponse> getOptions(
|
||||
@RequestParam(value = "printerMachineId", required = false) Long printerMachineId,
|
||||
@RequestParam(value = "nozzleDiameter", required = false) Double nozzleDiameter
|
||||
) {
|
||||
List<FilamentMaterialType> types = materialRepo.findAll();
|
||||
List<FilamentVariant> allVariants = variantRepo.findAll().stream()
|
||||
.filter(v -> Boolean.TRUE.equals(v.getIsActive()))
|
||||
List<FilamentVariant> allVariants = variantRepo.findByIsActiveTrue().stream()
|
||||
.sorted(Comparator
|
||||
.comparing((FilamentVariant v) -> safeMaterialCode(v.getFilamentMaterialType()), String.CASE_INSENSITIVE_ORDER)
|
||||
.thenComparing(v -> safeString(v.getVariantDisplayName()), String.CASE_INSENSITIVE_ORDER))
|
||||
|
||||
@@ -2,11 +2,16 @@ package com.printcalculator.repository;
|
||||
|
||||
import com.printcalculator.entity.FilamentVariant;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
|
||||
import com.printcalculator.entity.FilamentMaterialType;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface FilamentVariantRepository extends JpaRepository<FilamentVariant, Long> {
|
||||
@EntityGraph(attributePaths = {"filamentMaterialType"})
|
||||
List<FilamentVariant> findByIsActiveTrue();
|
||||
|
||||
// We try to match by color name if possible, or get first active
|
||||
Optional<FilamentVariant> findByFilamentMaterialTypeAndColorName(FilamentMaterialType type, String colorName);
|
||||
Optional<FilamentVariant> findByFilamentMaterialTypeAndVariantDisplayName(FilamentMaterialType type, String variantDisplayName);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.printcalculator.repository;
|
||||
import com.printcalculator.entity.FilamentMaterialType;
|
||||
import com.printcalculator.entity.MaterialOrcaProfileMap;
|
||||
import com.printcalculator.entity.PrinterMachineProfile;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,5 +15,6 @@ public interface MaterialOrcaProfileMapRepository extends JpaRepository<Material
|
||||
FilamentMaterialType filamentMaterialType
|
||||
);
|
||||
|
||||
@EntityGraph(attributePaths = {"filamentMaterialType"})
|
||||
List<MaterialOrcaProfileMap> findByPrinterMachineProfileAndIsActiveTrue(PrinterMachineProfile printerMachineProfile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user