我有一个过滤器要搜索 - 用户名以及两个开始和结束日期。如何使用存储库选择这些字段?
@Service
public class ResolutionServiceDefault implements ResolutionService {
@Autowired
private ResolutionRepository resolutionRepository;
@Override
public List<Resolution> findAllFilter(String user, Date start, Date end) {
if(user!=null)...
if(start!=null)...
if(end!=null)...
//perform a query on the fields that are not null
return .....;
}
}
@Repository
public interface ResolutionRepository extends JpaRepository<Resolution, Long> {
List<Resolution> findAllByStatus(int status);
List<Resolution> findAll();//String user, Date start, Date end
}