这是我的代码,不论 ids 列表为不为空,都会报错
@Query("""
SELECT SUM(age) FROM user
where (:ids IS NULL OR id in (:ids))
""")
Mono<Long> sumAges(List<Long> ids);
下面这个当 ids 列表不为空时不报错
@Query("""
SELECT SUM(age) FROM user
where (concat(', :ids,') = '()' OR id in (:ids))
""")
Mono<Long> sumAges(List<Long> ids);
我该怎么改呀,我知道可以在 service 层判断列表空直接返回 Mono.just(0L),但是还有其他许多参数需要判断时呢,总不能疯狂定制方法