mybatis 判斷參數有沒有傳入


 <!--審核展示列表-->
    <select id="auditResList" resultType="java.util.HashMap">
        <include refid="auditRes"/>
    </select>
    <!--審核展示 一條-->
    <select id="auditResInfo" resultType="java.util.HashMap">
        <include refid="auditRes"/>
    </select>
    <sql id="auditRes">
        SELECT
        r.id AS resId,
        r.res_desc,
        r.res_type,
        r.res_state,
        r.expires_date,
        r.res_pic_path,
        ra.id as applyId,
        ra.reason,
        ra.apply_note,
        ra.company_id,
        ra.state,
        r.res_name,
        c.companyName,
        c.shopName
        FROM resource r
        inner JOIN resource_apply ra
        ON r.id = ra.res_id
        left JOIN company c
        on ra.company_id = c.companyId
        <where>
            r.res_state = 1
            <if test="resType != null">
                and r.res_type = #{resType}
            </if>
            <if test="_parameter.containsKey('applyId') and applyId != null">
                and ra.id = #{applyId}
            </if>
            <if test=" _parameter.containsKey('state') and state != null">
                and ra.state = #{state}
            </if>
            <if test=" _parameter.containsKey('resName') and resName != null and resName != ''">
                and r.res_name like CONCAT('%', #{resName}, '%')
            </if>
            <if test=" _parameter.containsKey('companyName') and companyName != null and companyName != ''">
                and c.companyName like CONCAT('%', #{companyName}, '%')
            </if>
            <if test=" _parameter.containsKey('shopName') and shopName != null and shopName != ''">
                and c.shopName like CONCAT('%', #{shopName}, '%')
            </if>
        </where>
    </sql>


    /**
     * 審核展示列表
     *
     * @param resType
     * @return
     */
    List<HashMap> auditResList(@Param("resType") Integer resType,
                               @Param("companyName") String companyName,
                               @Param("shopName") String shopName,
                               @Param("state") Integer state,
                               @Param("resName") String resName);

    /**
     * 審核展示 一條
     *
     * @param resType
     * @param applyId
     * @return
     */
    HashMap auditResInfo(@Param("resType") Integer resType, @Param("applyId") Integer applyId);

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM