再做查询的时候有这几个字段要进行模糊查询 在使用MyBatis 时动态拼接sql可以这样来写 设计的是一个字段接收搜索的值 一个字段接收类型 list 这样动态构建的sql
<if test="dto.searchValue != null and dto.searchValue != '' and dto.globalSearch != null and dto.globalSearch.size() > 0">
AND (
<foreach collection="dto.globalSearch" item="item" index="index" separator="OR">
<if test="item == 1">
book_name like concat('%', #{dto.searchValue}, '%')
</if>
<if test="item == 2">
standard_code like concat('%', #{dto.searchValue}, '%')
</if>
<if test="item == 3">
release_institution like concat('%', #{dto.searchValue}, '%')
</if>
</foreach>
)
</if>