我需要在SpringBoot中搜索所有使用这个名称“type”的对象,怎么做?
我的代码:
//Find by type
@GetMapping("/type")
public ResponseEntity<List<Address>> listAddressByType(@RequestParam("type") descriptiontype type){
return ResponseEntity.ok(repository.findByTypeContains(type));
}
我的枚举:
public enum descriptiontype {
HOME,
APARTMENT,
COMPANY,
GOVERNMENT;
}
我的存储库:
public interface Repository extends JpaRepository<Address, Long> {
List<Address> findByCepContains(String cep);
List<Address> findByTypeContains(descriptiontype type);
}
我的型号:
@Enumerated(value = EnumType.STRING)
@Column(nullable = false)
private descriptiontype type;
暂无答案!
目前还没有任何答案,快来回答吧!