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);

  

posted @ 2018-06-10 11:17  个子  阅读(4569)  评论(0编辑  收藏  举报