mybatis中的<if test=“”>test中多条件
代码展示:
其中
accountCode和apiName
都是ApiAllRespBean的属性
<select id="getAllApiByApiName" parameterType="pisen.cloud.luna.ms.account.api.beans.ApiAllRespBean" resultType="pisen.cloud.luna.ms.account.api.beans.ApiAllRespBean"> SELECT ad.name apiName, ad.uid apiUid, aa.account_code accountCode, aa.expire_date expireDate, aa.expire_time expireTime, aa.freeze_time freezeTime FROM account_api aa INNER JOIN api_detail ad on aa.api_uid = ad.uid WHERE account_code = #{accountCode} <if test="apiName != null and apiName != ''"> AND ad.name like '%' #{apiName} '%' </if> </select>