mybatis 嵌套 if 判断

<select id="queryAdminLicenseDtoList" parameterType="map" resultType="com.zxwa.ntmss.dto.creditmanage.credictremark.AdminLicenseDto">
    SELECT
        b.*,s.orgName
    FROM
        base_credit_company_admin_license b
    LEFT JOIN sys_org s ON b.licOrgCode = s.orgCode
    <where>
        <if test="companyName != null and companyName != ''">
            and companyName like concat('%', #{companyName}, '%')
        </if>
        <if test="creditCode != null and creditCode != ''">
            and creditCode like concat('%', #{creditCode}, '%')
        </if>
        <if test="registrationCode != null and registrationCode != ''">
            and registrationCode like concat('%', #{registrationCode}, '%')
        </if>
        <if test="legalPerson != null and legalPerson != ''">
            and legalPerson like concat('%', #{legalPerson}, '%')
        </if>
        <if test="licNo != null and licNo != ''">
            and licNo like concat('%', #{licNo}, '%')
        </if>
        <if test="licName != null and licName != ''">
            and licName like concat('%', #{licName}, '%')
        </if>
        <if test="licId != null and licId != ''">
            and licId like concat('%', #{licId}, '%')
        </if>
        <if test="orgCode !=null and orgCode !=''">
            <if test="containSub == '1'.toString()">
                and b.licOrgCode like concat(#{orgCode},'%')
            </if>
            <if test="containSub == '0'.toString()">
                and b.licOrgCode = #{orgCode}
            </if>
        </if>
        <if test="validStart !=null and validStart !='' ">
            AND b.validFrom &gt;= #{validStart}
        </if>
        <if test="validEnd !=null and validEnd !='' ">
            AND b.validTo &lt; #{validEnd}
        </if>
    </where>
    ORDER BY b.validFrom DESC
    limit #{start}, #{pageNo}
</select>

 

posted @ 2022-11-30 19:06  Bonnie_ξ  阅读(196)  评论(0编辑  收藏  举报