xml
<select id="selectListByWhere" resultMap="BaseResultMap" >
select OBJECT_CODE,
OBJECT_NAME, OBJECT_DESCRIBE, OBJECT_PARENT_CODE,
OBJECT_TYPE_CODE,
USE_FLAG, DISPLAY_SN,URL
from SYS_RIGHT_OBJECT
where 1=1
<if test="objectCode != null and objectCode != ''">
AND OBJECT_CODE LIKE CONCAT(CONCAT('%',#{objectCode}),'%')
</if>
<if test="objectName != null and objectName != ''">
AND OBJECT_NAME LIKE CONCAT(CONCAT('%',#{objectName}),'%')
</if>
<if test="objectParentCode != null and objectParentCode != ''">
AND OBJECT_PARENT_CODE LIKE CONCAT(CONCAT('%',#{objectParentCode}),'%')
</if>
<if test="objectTypeCode != null and objectTypeCode != ''">
AND OBJECT_TYPE_CODE LIKE CONCAT(CONCAT('%',#{objectTypeCode}),'%')
</if>
order by DISPLAY_SN
</select>
对应DAO
List<SysRightObject> selectListByWhere(@Param("objectCode")String objectCode,@Param("objectName")String objectName
,@Param("objectParentCode")String objectParentCode,@Param("objectTypeCode")String objectTypeCode);
参考博客:MyBatis传入多个参数的问题
参考博客:Mybatis中的模糊查询