MyBatisPlus 传入数组条件查询
public class TxQueryDto{
...
private int[] txType;
...
1
2
3
4
5
6
2
3
4
5
6
IPage<TxClearing> selectRecordByCondition(Page page, @Param("tableName") String tableName, @Param("condition") TxQueryDto condition);
1
public List<TxClearing> queryRecordByCondition(TxQueryDto txQueryDto) {
Page page = new Page(txQueryDto.getPidx(), DEFAULT_PAGE_SIZE);
IPage<TxClearing> txClearings = managementMapper.selectRecordByCondition(
page, DbTableNameUtils.retTableNameByMonth(txQueryDto.getMonth()) + "_002", txQueryDto);
return txClearings.getRecords();
}
1
2
3
4
5
6
2
3
4
5
6
<select id="selectRecordByCondition" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from ${tableName}
where cid=#{condition.cid,jdbcType=BIGINT}
<if test="condition.txType != null">
AND tx_type IN
<foreach collection="condition.txType" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Last Updated: 2023/01/30, 11:01:00