<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.hikcreate.demo.infra.data.mapper.TestMapper"> <!--综合性查询 --> <select id="getList" parameterType="com.hikcreate.demo.infra.model.query.TestQuery" resultType="com.hikcreate.demo.infra.model.Test"> select * from Test where 1=1 <if test="id !=null "> and id =#{id} </if> <if test="idNotEqual !=null "> and id !=#{idNotEqual} </if> <if test="name !=null and name!=''"> and name=#{name} </if> <if test="nameLike !=null and nameLike!=''"> and name like CONCAT('%',#{nameLike},'%') </if> </select> </mapper>