常用代码收集

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12

<select id="pageUserInfoByAccount" resultType="com.sdstc.authcenter.pojo.UserAndCompany">
    SELECT tu.id as id, tu.name as name , tu.company_id as companyId, tu.mobile as mobile, tc.name as companyName
    FROM t_user tu
    JOIN t_company tc on tc.id = tu.company_id
    AND tu.is_delete = '0'
    <if test="@org.apache.commons.lang3.StringUtils@isNotBlank(account)">
        <bind name="account" value="'%' + account"/>
        AND tu.account LIKE #{account}
    </if>
</select>

收集点:

  1. bind标签放在了if标签的内部
  2. if标签中使用了lang3的StringUtils.isNotBlank()

参考资料

  1. Mybatis中xml判断字符串不为空和null简单方法