Skip to content

Commit ad9fa37

Browse files
committed
Fixed issue with findWeaponByWeaponClass bug spring-projects/spring-data-jpa#2472
1 parent b2ffe61 commit ad9fa37

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

db/dark_heresy.mv.db

20 KB
Binary file not shown.

src/main/java/com/bnta/dark_heresy_character_sheet/controllers/WeaponController.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ public ResponseEntity<List<Weapon>> getAllWeaponsAndFilters(
2525
@RequestParam(name = "weaponClass",required = false) String weaponClass,
2626
@RequestParam(name = "cost",required = false) Integer cost){
2727
if(weaponClass != null && cost != null){
28-
return new ResponseEntity(weaponRepository.findWeaponByWeaponClassLike(weaponClass).addAll(weaponRepository.findWeaponByCostGreaterThanEqual(cost)),HttpStatus.OK);
28+
return new ResponseEntity(weaponRepository.findWeaponByWeaponClass(weaponClass).addAll(weaponRepository.findWeaponByCostGreaterThanEqual(cost)),HttpStatus.OK);
29+
}
30+
if(weaponClass == null && cost != null){
31+
return new ResponseEntity(weaponRepository.findWeaponByCostGreaterThanEqual(cost),HttpStatus.OK);
32+
}
33+
if(weaponClass != null && cost == null){
34+
return new ResponseEntity<>(weaponRepository.findWeaponByWeaponClass(weaponClass),HttpStatus.OK);
2935
}
3036
return new ResponseEntity<>(weaponRepository.findAll(), HttpStatus.OK);
3137
}

src/main/java/com/bnta/dark_heresy_character_sheet/repositories/WeaponRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
public interface WeaponRepository extends JpaRepository<Weapon, Long> {
99

10-
List<Weapon> findWeaponByWeaponClassLike(String weaponClass);
10+
List<Weapon> findWeaponByWeaponClass(String weaponClass);
1111
List<Weapon> findWeaponByCostGreaterThanEqual(Integer cost);
1212
}

0 commit comments

Comments
 (0)