Commit 544e650e1573bf565292fadb550536d2de34dc5b
Committed by
GitHub
Merge pull request #326 from Lemon-cc-hang/base
fix: 在调用 selectList() 的时候 如果 Collection 参数为空会报错 sql 异常
Showing
1 changed file
with
8 additions
and
1 deletions
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
| 1 | package cn.iocoder.yudao.framework.mybatis.core.mapper; | 1 | package cn.iocoder.yudao.framework.mybatis.core.mapper; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; | 6 | import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; |
| @@ -69,10 +70,16 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | @@ -69,10 +70,16 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | ||
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | default List<T> selectList(String field, Collection<?> values) { | 72 | default List<T> selectList(String field, Collection<?> values) { |
| 73 | + if (CollUtil.isEmpty(values)) { | ||
| 74 | + return CollUtil.newArrayList(); | ||
| 75 | + } | ||
| 72 | return selectList(new QueryWrapper<T>().in(field, values)); | 76 | return selectList(new QueryWrapper<T>().in(field, values)); |
| 73 | } | 77 | } |
| 74 | 78 | ||
| 75 | default List<T> selectList(SFunction<T, ?> field, Collection<?> values) { | 79 | default List<T> selectList(SFunction<T, ?> field, Collection<?> values) { |
| 80 | + if (CollUtil.isEmpty(values)) { | ||
| 81 | + return CollUtil.newArrayList(); | ||
| 82 | + } | ||
| 76 | return selectList(new LambdaQueryWrapper<T>().in(field, values)); | 83 | return selectList(new LambdaQueryWrapper<T>().in(field, values)); |
| 77 | } | 84 | } |
| 78 | 85 | ||
| @@ -115,4 +122,4 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | @@ -115,4 +122,4 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | ||
| 115 | Db.saveOrUpdateBatch(collection); | 122 | Db.saveOrUpdateBatch(collection); |
| 116 | } | 123 | } |
| 117 | 124 | ||
| 118 | -} | 125 | -} |
| 126 | +} | ||
| 119 | \ No newline at end of file | 127 | \ No newline at end of file |